diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 680f08792e5..c7ca2175dbb 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -39804,7 +39804,9 @@ components: nullable: true type: string has_submitted: - description: Whether the current user has already submitted this form. Only present for forms with `single_response` set to `true`. + description: |- + Whether the current user has already submitted this form. Only present for forms with + `single_response` set to `true`. nullable: true type: boolean idp_survey: @@ -40119,6 +40121,10 @@ components: example: b51f08b698d88d8027a935d9db649774949f5fb41a0c559bfee6a9a13225c72d nullable: true type: string + has_ever_been_published: + description: Whether this version number has ever appeared in the form's publication history. + example: true + type: boolean id: description: The ID of the form version. example: "126" @@ -40175,6 +40181,15 @@ components: - type - attributes type: object + FormVersionListType: + default: form_version_lists + description: The resource type for a list of form versions. + enum: + - form_version_lists + example: form_version_lists + type: string + x-enum-varnames: + - FORM_VERSION_LISTS FormVersionResponse: description: A response containing a single form version. properties: @@ -58917,6 +58932,41 @@ components: - data - meta type: object + ListFormVersionsData: + description: A list-of-form-versions resource object. + properties: + attributes: + $ref: "#/components/schemas/ListFormVersionsDataAttributes" + id: + description: The ID of the form. + example: 22f6006a-2302-4926-9396-d2dfcf7b0b34 + type: string + type: + $ref: "#/components/schemas/FormVersionListType" + required: + - id + - type + - attributes + type: object + ListFormVersionsDataAttributes: + description: The attributes for a list of form versions. + properties: + versions: + description: The list of versions for the form. + items: + $ref: "#/components/schemas/FormVersionAttributes" + type: array + required: + - versions + type: object + ListFormVersionsResponse: + description: A response containing the list of versions for a form. + properties: + data: + $ref: "#/components/schemas/ListFormVersionsData" + required: + - data + type: object ListHistoricalJobsResponse: description: List of historical jobs. properties: @@ -139326,7 +139376,9 @@ paths: **Note**: This endpoint is in preview and is subject to change. If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). post: - description: Create a new form. The form is created in draft mode and must be published before it can be used. This also creates a new datastore for form responses and links it to the form. + description: |- + Create a new form. The form is created in draft mode and must be published before it can be used. This + also creates a new datastore for form responses and links it to the form. operationId: CreateForm requestBody: content: @@ -139400,7 +139452,9 @@ paths: If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). /api/v2/forms/create_and_publish: post: - description: Creates a new form and immediately publishes its initial version. This also creates a new datastore for form responses and links it to the form. + description: |- + Creates a new form and immediately publishes its initial version. This also creates a new datastore for + form responses and links it to the form. operationId: CreateAndPublishForm requestBody: content: @@ -139530,7 +139584,9 @@ paths: schema: format: uuid type: string - - description: The version of the form to retrieve. Use 'latest' for the most recent draft, 'published' for the last published version, or a specific version number. + - description: |- + The version of the form to retrieve. Use 'latest' for the most recent draft, 'published' for the + last published version, or a specific version number. in: query name: version required: false @@ -139837,6 +139893,72 @@ paths: **Note**: This endpoint is in preview and is subject to change. If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). /api/v2/forms/{form_id}/versions: + get: + description: List all versions of a form. + operationId: ListFormVersions + parameters: + - description: The ID of the form. + example: 22f6006a-2302-4926-9396-d2dfcf7b0b34 + in: path + name: form_id + required: true + schema: + format: uuid + type: string + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + attributes: + versions: + - created_at: "2026-05-29T20:06:14.895921Z" + data_definition: {} + definition_signature: >- + {"signature":"b7f312957a80cea2c8c9950532b205a90a3f8a7ebb7e52fc25437a25d903d545", "version":1} + etag: b51f08b698d88d8027a935d9db649774949f5fb41a0c559bfee6a9a13225c72d + has_ever_been_published: true + id: "126" + modified_at: "2026-05-29T20:06:14.949163Z" + state: draft + ui_definition: {} + user_id: 10001 + user_uuid: 1fc709aa-be19-4539-a47d-52a30d78a978 + version: 2 + id: 22f6006a-2302-4926-9396-d2dfcf7b0b34 + type: form_version_lists + schema: + $ref: "#/components/schemas/ListFormVersionsResponse" + description: OK + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Bad Request + "401": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Unauthorized + "404": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Not Found + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + summary: List form versions + tags: + - Forms + x-unstable: |- + **Note**: This endpoint is in preview and is subject to change. + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). post: description: |- Create or update the latest draft version of a form. The `upsert_params` field controls @@ -139880,7 +140002,8 @@ paths: created_at: "2026-05-29T20:06:14.895921Z" data_definition: $ref: "#/components/schemas/FormDataDefinition" - definition_signature: '{"signature":"b7f312957a80cea2c8c9950532b205a90a3f8a7ebb7e52fc25437a25d903d545","version":1}' + definition_signature: >- + {"signature":"b7f312957a80cea2c8c9950532b205a90a3f8a7ebb7e52fc25437a25d903d545", "version":1} etag: b51f08b698d88d8027a935d9db649774949f5fb41a0c559bfee6a9a13225c72d modified_at: "2026-05-29T20:06:14.949163Z" state: draft @@ -139919,6 +140042,85 @@ paths: x-unstable: |- **Note**: This endpoint is in preview and is subject to change. If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). + /api/v2/forms/{form_id}/versions/revert: + post: + description: Revert a form to a prior version by creating a new draft version copied from it. + operationId: RevertFormVersion + parameters: + - description: The ID of the form. + example: 22f6006a-2302-4926-9396-d2dfcf7b0b34 + in: path + name: form_id + required: true + schema: + format: uuid + type: string + - description: The version number to revert to. + example: 1 + in: query + name: version + required: true + schema: + format: int64 + type: integer + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + attributes: + created_at: "2026-05-29T20:10:14.895921Z" + data_definition: + $ref: "#/components/schemas/FormDataDefinition" + definition_signature: >- + {"signature":"c8f312957a80cea2c8c9950532b205a90a3f8a7ebb7e52fc25437a25d903d545", "version":1} + etag: c61f08b698d88d8027a935d9db649774949f5fb41a0c559bfee6a9a13225c72d + modified_at: "2026-05-29T20:10:14.949163Z" + state: draft + ui_definition: {} + user_id: 10001 + user_uuid: 1fc709aa-be19-4539-a47d-52a30d78a978 + version: 3 + id: "127" + type: form_versions + schema: + $ref: "#/components/schemas/FormVersionResponse" + description: OK + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Bad Request + "401": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Unauthorized + "404": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Not Found + "409": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Conflict + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + summary: Revert a form to a prior version + tags: + - Forms + x-unstable: |- + **Note**: This endpoint is in preview and is subject to change. + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). /api/v2/forms/{form_id}/versions/upsert_and_publish: post: description: Upsert the latest form version and publish it in a single atomic transaction. diff --git a/examples/v2/forms/ListFormVersions.java b/examples/v2/forms/ListFormVersions.java new file mode 100644 index 00000000000..1dc8bacb346 --- /dev/null +++ b/examples/v2/forms/ListFormVersions.java @@ -0,0 +1,27 @@ +// List form versions returns "OK" response + +import com.datadog.api.client.ApiClient; +import com.datadog.api.client.ApiException; +import com.datadog.api.client.v2.api.FormsApi; +import com.datadog.api.client.v2.model.ListFormVersionsResponse; +import java.util.UUID; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + defaultClient.setUnstableOperationEnabled("v2.listFormVersions", true); + FormsApi apiInstance = new FormsApi(defaultClient); + + try { + ListFormVersionsResponse result = + apiInstance.listFormVersions(UUID.fromString("22f6006a-2302-4926-9396-d2dfcf7b0b34")); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling FormsApi#listFormVersions"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} diff --git a/examples/v2/forms/RevertFormVersion.java b/examples/v2/forms/RevertFormVersion.java new file mode 100644 index 00000000000..84c90aeb4a7 --- /dev/null +++ b/examples/v2/forms/RevertFormVersion.java @@ -0,0 +1,28 @@ +// Revert a form to a prior version returns "OK" response + +import com.datadog.api.client.ApiClient; +import com.datadog.api.client.ApiException; +import com.datadog.api.client.v2.api.FormsApi; +import com.datadog.api.client.v2.model.FormVersionResponse; +import java.util.UUID; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + defaultClient.setUnstableOperationEnabled("v2.revertFormVersion", true); + FormsApi apiInstance = new FormsApi(defaultClient); + + try { + FormVersionResponse result = + apiInstance.revertFormVersion( + UUID.fromString("22f6006a-2302-4926-9396-d2dfcf7b0b34"), 1L); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling FormsApi#revertFormVersion"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} diff --git a/src/main/java/com/datadog/api/client/ApiClient.java b/src/main/java/com/datadog/api/client/ApiClient.java index e7ab0a985b6..88f8cbef387 100644 --- a/src/main/java/com/datadog/api/client/ApiClient.java +++ b/src/main/java/com/datadog/api/client/ApiClient.java @@ -1068,7 +1068,9 @@ public class ApiClient { put("v2.deleteForm", false); put("v2.getForm", false); put("v2.listForms", false); + put("v2.listFormVersions", false); put("v2.publishForm", false); + put("v2.revertFormVersion", false); put("v2.updateForm", false); put("v2.upsertAndPublishFormVersion", false); put("v2.upsertFormVersion", false); diff --git a/src/main/java/com/datadog/api/client/v2/api/FormsApi.java b/src/main/java/com/datadog/api/client/v2/api/FormsApi.java index 9aef24710cc..a9f42f5969c 100644 --- a/src/main/java/com/datadog/api/client/v2/api/FormsApi.java +++ b/src/main/java/com/datadog/api/client/v2/api/FormsApi.java @@ -11,6 +11,7 @@ import com.datadog.api.client.v2.model.FormResponse; import com.datadog.api.client.v2.model.FormVersionResponse; import com.datadog.api.client.v2.model.FormsResponse; +import com.datadog.api.client.v2.model.ListFormVersionsResponse; import com.datadog.api.client.v2.model.PublishFormRequest; import com.datadog.api.client.v2.model.UpdateFormRequest; import com.datadog.api.client.v2.model.UpsertAndPublishFormVersionRequest; @@ -1009,6 +1010,159 @@ public CompletableFuture> listFormsWithHttpInfoAsync( new GenericType() {}); } + /** + * List form versions. + * + *

See {@link #listFormVersionsWithHttpInfo}. + * + * @param formId The ID of the form. (required) + * @return ListFormVersionsResponse + * @throws ApiException if fails to make API call + */ + public ListFormVersionsResponse listFormVersions(UUID formId) throws ApiException { + return listFormVersionsWithHttpInfo(formId).getData(); + } + + /** + * List form versions. + * + *

See {@link #listFormVersionsWithHttpInfoAsync}. + * + * @param formId The ID of the form. (required) + * @return CompletableFuture<ListFormVersionsResponse> + */ + public CompletableFuture listFormVersionsAsync(UUID formId) { + return listFormVersionsWithHttpInfoAsync(formId) + .thenApply( + response -> { + return response.getData(); + }); + } + + /** + * List all versions of a form. + * + * @param formId The ID of the form. (required) + * @return ApiResponse<ListFormVersionsResponse> + * @throws ApiException if fails to make API call + * @http.response.details + * + * + * + * + * + * + * + * + *
Response details
Status Code Description Response Headers
200 OK -
400 Bad Request -
401 Unauthorized -
404 Not Found -
429 Too many requests -
+ */ + public ApiResponse listFormVersionsWithHttpInfo(UUID formId) + throws ApiException { + // Check if unstable operation is enabled + String operationId = "listFormVersions"; + if (apiClient.isUnstableOperationEnabled("v2." + operationId)) { + apiClient.getLogger().warning(String.format("Using unstable operation '%s'", operationId)); + } else { + throw new ApiException(0, String.format("Unstable operation '%s' is disabled", operationId)); + } + Object localVarPostBody = null; + + // verify the required parameter 'formId' is set + if (formId == null) { + throw new ApiException( + 400, "Missing the required parameter 'formId' when calling listFormVersions"); + } + // create path and map variables + String localVarPath = + "/api/v2/forms/{form_id}/versions" + .replaceAll("\\{" + "form_id" + "\\}", apiClient.escapeString(formId.toString())); + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder = + apiClient.createBuilder( + "v2.FormsApi.listFormVersions", + localVarPath, + new ArrayList(), + localVarHeaderParams, + new HashMap(), + new String[] {"application/json"}, + new String[] {"apiKeyAuth", "appKeyAuth"}); + return apiClient.invokeAPI( + "GET", + builder, + localVarHeaderParams, + new String[] {}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } + + /** + * List form versions. + * + *

See {@link #listFormVersionsWithHttpInfo}. + * + * @param formId The ID of the form. (required) + * @return CompletableFuture<ApiResponse<ListFormVersionsResponse>> + */ + public CompletableFuture> listFormVersionsWithHttpInfoAsync( + UUID formId) { + // Check if unstable operation is enabled + String operationId = "listFormVersions"; + if (apiClient.isUnstableOperationEnabled("v2." + operationId)) { + apiClient.getLogger().warning(String.format("Using unstable operation '%s'", operationId)); + } else { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally( + new ApiException(0, String.format("Unstable operation '%s' is disabled", operationId))); + return result; + } + Object localVarPostBody = null; + + // verify the required parameter 'formId' is set + if (formId == null) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally( + new ApiException( + 400, "Missing the required parameter 'formId' when calling listFormVersions")); + return result; + } + // create path and map variables + String localVarPath = + "/api/v2/forms/{form_id}/versions" + .replaceAll("\\{" + "form_id" + "\\}", apiClient.escapeString(formId.toString())); + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder; + try { + builder = + apiClient.createBuilder( + "v2.FormsApi.listFormVersions", + localVarPath, + new ArrayList(), + localVarHeaderParams, + new HashMap(), + new String[] {"application/json"}, + new String[] {"apiKeyAuth", "appKeyAuth"}); + } catch (ApiException ex) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally(ex); + return result; + } + return apiClient.invokeAPIAsync( + "GET", + builder, + localVarHeaderParams, + new String[] {}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } + /** * Publish a form version. * @@ -1181,6 +1335,185 @@ public CompletableFuture> publishFormWithHt new GenericType() {}); } + /** + * Revert a form to a prior version. + * + *

See {@link #revertFormVersionWithHttpInfo}. + * + * @param formId The ID of the form. (required) + * @param version The version number to revert to. (required) + * @return FormVersionResponse + * @throws ApiException if fails to make API call + */ + public FormVersionResponse revertFormVersion(UUID formId, Long version) throws ApiException { + return revertFormVersionWithHttpInfo(formId, version).getData(); + } + + /** + * Revert a form to a prior version. + * + *

See {@link #revertFormVersionWithHttpInfoAsync}. + * + * @param formId The ID of the form. (required) + * @param version The version number to revert to. (required) + * @return CompletableFuture<FormVersionResponse> + */ + public CompletableFuture revertFormVersionAsync(UUID formId, Long version) { + return revertFormVersionWithHttpInfoAsync(formId, version) + .thenApply( + response -> { + return response.getData(); + }); + } + + /** + * Revert a form to a prior version by creating a new draft version copied from it. + * + * @param formId The ID of the form. (required) + * @param version The version number to revert to. (required) + * @return ApiResponse<FormVersionResponse> + * @throws ApiException if fails to make API call + * @http.response.details + * + * + * + * + * + * + * + * + * + *
Response details
Status Code Description Response Headers
200 OK -
400 Bad Request -
401 Unauthorized -
404 Not Found -
409 Conflict -
429 Too many requests -
+ */ + public ApiResponse revertFormVersionWithHttpInfo(UUID formId, Long version) + throws ApiException { + // Check if unstable operation is enabled + String operationId = "revertFormVersion"; + if (apiClient.isUnstableOperationEnabled("v2." + operationId)) { + apiClient.getLogger().warning(String.format("Using unstable operation '%s'", operationId)); + } else { + throw new ApiException(0, String.format("Unstable operation '%s' is disabled", operationId)); + } + Object localVarPostBody = null; + + // verify the required parameter 'formId' is set + if (formId == null) { + throw new ApiException( + 400, "Missing the required parameter 'formId' when calling revertFormVersion"); + } + + // verify the required parameter 'version' is set + if (version == null) { + throw new ApiException( + 400, "Missing the required parameter 'version' when calling revertFormVersion"); + } + // create path and map variables + String localVarPath = + "/api/v2/forms/{form_id}/versions/revert" + .replaceAll("\\{" + "form_id" + "\\}", apiClient.escapeString(formId.toString())); + + List localVarQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + + localVarQueryParams.addAll(apiClient.parameterToPairs("", "version", version)); + + Invocation.Builder builder = + apiClient.createBuilder( + "v2.FormsApi.revertFormVersion", + localVarPath, + localVarQueryParams, + localVarHeaderParams, + new HashMap(), + new String[] {"application/json"}, + new String[] {"apiKeyAuth", "appKeyAuth"}); + return apiClient.invokeAPI( + "POST", + builder, + localVarHeaderParams, + new String[] {}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } + + /** + * Revert a form to a prior version. + * + *

See {@link #revertFormVersionWithHttpInfo}. + * + * @param formId The ID of the form. (required) + * @param version The version number to revert to. (required) + * @return CompletableFuture<ApiResponse<FormVersionResponse>> + */ + public CompletableFuture> revertFormVersionWithHttpInfoAsync( + UUID formId, Long version) { + // Check if unstable operation is enabled + String operationId = "revertFormVersion"; + if (apiClient.isUnstableOperationEnabled("v2." + operationId)) { + apiClient.getLogger().warning(String.format("Using unstable operation '%s'", operationId)); + } else { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally( + new ApiException(0, String.format("Unstable operation '%s' is disabled", operationId))); + return result; + } + Object localVarPostBody = null; + + // verify the required parameter 'formId' is set + if (formId == null) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally( + new ApiException( + 400, "Missing the required parameter 'formId' when calling revertFormVersion")); + return result; + } + + // verify the required parameter 'version' is set + if (version == null) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally( + new ApiException( + 400, "Missing the required parameter 'version' when calling revertFormVersion")); + return result; + } + // create path and map variables + String localVarPath = + "/api/v2/forms/{form_id}/versions/revert" + .replaceAll("\\{" + "form_id" + "\\}", apiClient.escapeString(formId.toString())); + + List localVarQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + + localVarQueryParams.addAll(apiClient.parameterToPairs("", "version", version)); + + Invocation.Builder builder; + try { + builder = + apiClient.createBuilder( + "v2.FormsApi.revertFormVersion", + localVarPath, + localVarQueryParams, + localVarHeaderParams, + new HashMap(), + new String[] {"application/json"}, + new String[] {"apiKeyAuth", "appKeyAuth"}); + } catch (ApiException ex) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally(ex); + return result; + } + return apiClient.invokeAPIAsync( + "POST", + builder, + localVarHeaderParams, + new String[] {}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } + /** * Update a form. * diff --git a/src/main/java/com/datadog/api/client/v2/model/FormVersionAttributes.java b/src/main/java/com/datadog/api/client/v2/model/FormVersionAttributes.java index ad7cdeb43f0..b01e2edbc96 100644 --- a/src/main/java/com/datadog/api/client/v2/model/FormVersionAttributes.java +++ b/src/main/java/com/datadog/api/client/v2/model/FormVersionAttributes.java @@ -25,6 +25,7 @@ FormVersionAttributes.JSON_PROPERTY_DATA_DEFINITION, FormVersionAttributes.JSON_PROPERTY_DEFINITION_SIGNATURE, FormVersionAttributes.JSON_PROPERTY_ETAG, + FormVersionAttributes.JSON_PROPERTY_HAS_EVER_BEEN_PUBLISHED, FormVersionAttributes.JSON_PROPERTY_ID, FormVersionAttributes.JSON_PROPERTY_MODIFIED_AT, FormVersionAttributes.JSON_PROPERTY_STATE, @@ -49,6 +50,9 @@ public class FormVersionAttributes { public static final String JSON_PROPERTY_ETAG = "etag"; private String etag; + public static final String JSON_PROPERTY_HAS_EVER_BEEN_PUBLISHED = "has_ever_been_published"; + private Boolean hasEverBeenPublished; + public static final String JSON_PROPERTY_ID = "id"; private String id; @@ -189,6 +193,27 @@ public void setEtag(String etag) { this.etag = etag; } + public FormVersionAttributes hasEverBeenPublished(Boolean hasEverBeenPublished) { + this.hasEverBeenPublished = hasEverBeenPublished; + return this; + } + + /** + * Whether this version number has ever appeared in the form's publication history. + * + * @return hasEverBeenPublished + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_HAS_EVER_BEEN_PUBLISHED) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Boolean getHasEverBeenPublished() { + return hasEverBeenPublished; + } + + public void setHasEverBeenPublished(Boolean hasEverBeenPublished) { + this.hasEverBeenPublished = hasEverBeenPublished; + } + public FormVersionAttributes id(String id) { this.id = id; return this; @@ -399,6 +424,7 @@ public boolean equals(Object o) { && Objects.equals(this.dataDefinition, formVersionAttributes.dataDefinition) && Objects.equals(this.definitionSignature, formVersionAttributes.definitionSignature) && Objects.equals(this.etag, formVersionAttributes.etag) + && Objects.equals(this.hasEverBeenPublished, formVersionAttributes.hasEverBeenPublished) && Objects.equals(this.id, formVersionAttributes.id) && Objects.equals(this.modifiedAt, formVersionAttributes.modifiedAt) && Objects.equals(this.state, formVersionAttributes.state) @@ -416,6 +442,7 @@ public int hashCode() { dataDefinition, definitionSignature, etag, + hasEverBeenPublished, id, modifiedAt, state, @@ -436,6 +463,9 @@ public String toString() { .append(toIndentedString(definitionSignature)) .append("\n"); sb.append(" etag: ").append(toIndentedString(etag)).append("\n"); + sb.append(" hasEverBeenPublished: ") + .append(toIndentedString(hasEverBeenPublished)) + .append("\n"); sb.append(" id: ").append(toIndentedString(id)).append("\n"); sb.append(" modifiedAt: ").append(toIndentedString(modifiedAt)).append("\n"); sb.append(" state: ").append(toIndentedString(state)).append("\n"); diff --git a/src/main/java/com/datadog/api/client/v2/model/FormVersionListType.java b/src/main/java/com/datadog/api/client/v2/model/FormVersionListType.java new file mode 100644 index 00000000000..bf85b481413 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/FormVersionListType.java @@ -0,0 +1,56 @@ +/* + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.datadog.api.client.ModelEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; +import java.io.IOException; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; + +/** The resource type for a list of form versions. */ +@JsonSerialize(using = FormVersionListType.FormVersionListTypeSerializer.class) +public class FormVersionListType extends ModelEnum { + + private static final Set allowedValues = + new HashSet(Arrays.asList("form_version_lists")); + + public static final FormVersionListType FORM_VERSION_LISTS = + new FormVersionListType("form_version_lists"); + + FormVersionListType(String value) { + super(value, allowedValues); + } + + public static class FormVersionListTypeSerializer extends StdSerializer { + public FormVersionListTypeSerializer(Class t) { + super(t); + } + + public FormVersionListTypeSerializer() { + this(null); + } + + @Override + public void serialize( + FormVersionListType value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.value); + } + } + + @JsonCreator + public static FormVersionListType fromValue(String value) { + return new FormVersionListType(value); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/ListFormVersionsData.java b/src/main/java/com/datadog/api/client/v2/model/ListFormVersionsData.java new file mode 100644 index 00000000000..59b544697d4 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ListFormVersionsData.java @@ -0,0 +1,212 @@ +/* + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** A list-of-form-versions resource object. */ +@JsonPropertyOrder({ + ListFormVersionsData.JSON_PROPERTY_ATTRIBUTES, + ListFormVersionsData.JSON_PROPERTY_ID, + ListFormVersionsData.JSON_PROPERTY_TYPE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class ListFormVersionsData { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_ATTRIBUTES = "attributes"; + private ListFormVersionsDataAttributes attributes; + + public static final String JSON_PROPERTY_ID = "id"; + private String id; + + public static final String JSON_PROPERTY_TYPE = "type"; + private FormVersionListType type = FormVersionListType.FORM_VERSION_LISTS; + + public ListFormVersionsData() {} + + @JsonCreator + public ListFormVersionsData( + @JsonProperty(required = true, value = JSON_PROPERTY_ATTRIBUTES) + ListFormVersionsDataAttributes attributes, + @JsonProperty(required = true, value = JSON_PROPERTY_ID) String id, + @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) FormVersionListType type) { + this.attributes = attributes; + this.unparsed |= attributes.unparsed; + this.id = id; + this.type = type; + this.unparsed |= !type.isValid(); + } + + public ListFormVersionsData attributes(ListFormVersionsDataAttributes attributes) { + this.attributes = attributes; + this.unparsed |= attributes.unparsed; + return this; + } + + /** + * The attributes for a list of form versions. + * + * @return attributes + */ + @JsonProperty(JSON_PROPERTY_ATTRIBUTES) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public ListFormVersionsDataAttributes getAttributes() { + return attributes; + } + + public void setAttributes(ListFormVersionsDataAttributes attributes) { + this.attributes = attributes; + if (attributes != null) { + this.unparsed |= attributes.unparsed; + } + } + + public ListFormVersionsData id(String id) { + this.id = id; + return this; + } + + /** + * The ID of the form. + * + * @return id + */ + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public ListFormVersionsData type(FormVersionListType type) { + this.type = type; + this.unparsed |= !type.isValid(); + return this; + } + + /** + * The resource type for a list of form versions. + * + * @return type + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public FormVersionListType getType() { + return type; + } + + public void setType(FormVersionListType type) { + if (!type.isValid()) { + this.unparsed = true; + } + this.type = type; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return ListFormVersionsData + */ + @JsonAnySetter + public ListFormVersionsData putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this ListFormVersionsData object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ListFormVersionsData listFormVersionsData = (ListFormVersionsData) o; + return Objects.equals(this.attributes, listFormVersionsData.attributes) + && Objects.equals(this.id, listFormVersionsData.id) + && Objects.equals(this.type, listFormVersionsData.type) + && Objects.equals(this.additionalProperties, listFormVersionsData.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(attributes, id, type, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ListFormVersionsData {\n"); + sb.append(" attributes: ").append(toIndentedString(attributes)).append("\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/ListFormVersionsDataAttributes.java b/src/main/java/com/datadog/api/client/v2/model/ListFormVersionsDataAttributes.java new file mode 100644 index 00000000000..f739d184dae --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ListFormVersionsDataAttributes.java @@ -0,0 +1,165 @@ +/* + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** The attributes for a list of form versions. */ +@JsonPropertyOrder({ListFormVersionsDataAttributes.JSON_PROPERTY_VERSIONS}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class ListFormVersionsDataAttributes { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_VERSIONS = "versions"; + private List versions = new ArrayList<>(); + + public ListFormVersionsDataAttributes() {} + + @JsonCreator + public ListFormVersionsDataAttributes( + @JsonProperty(required = true, value = JSON_PROPERTY_VERSIONS) + List versions) { + this.versions = versions; + for (FormVersionAttributes item : versions) { + this.unparsed |= item.unparsed; + } + } + + public ListFormVersionsDataAttributes versions(List versions) { + this.versions = versions; + for (FormVersionAttributes item : versions) { + this.unparsed |= item.unparsed; + } + return this; + } + + public ListFormVersionsDataAttributes addVersionsItem(FormVersionAttributes versionsItem) { + this.versions.add(versionsItem); + this.unparsed |= versionsItem.unparsed; + return this; + } + + /** + * The list of versions for the form. + * + * @return versions + */ + @JsonProperty(JSON_PROPERTY_VERSIONS) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public List getVersions() { + return versions; + } + + public void setVersions(List versions) { + this.versions = versions; + if (versions != null) { + for (FormVersionAttributes item : versions) { + this.unparsed |= item.unparsed; + } + } + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return ListFormVersionsDataAttributes + */ + @JsonAnySetter + public ListFormVersionsDataAttributes putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this ListFormVersionsDataAttributes object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ListFormVersionsDataAttributes listFormVersionsDataAttributes = + (ListFormVersionsDataAttributes) o; + return Objects.equals(this.versions, listFormVersionsDataAttributes.versions) + && Objects.equals( + this.additionalProperties, listFormVersionsDataAttributes.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(versions, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ListFormVersionsDataAttributes {\n"); + sb.append(" versions: ").append(toIndentedString(versions)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/ListFormVersionsResponse.java b/src/main/java/com/datadog/api/client/v2/model/ListFormVersionsResponse.java new file mode 100644 index 00000000000..26be91f0658 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ListFormVersionsResponse.java @@ -0,0 +1,148 @@ +/* + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** A response containing the list of versions for a form. */ +@JsonPropertyOrder({ListFormVersionsResponse.JSON_PROPERTY_DATA}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class ListFormVersionsResponse { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_DATA = "data"; + private ListFormVersionsData data; + + public ListFormVersionsResponse() {} + + @JsonCreator + public ListFormVersionsResponse( + @JsonProperty(required = true, value = JSON_PROPERTY_DATA) ListFormVersionsData data) { + this.data = data; + this.unparsed |= data.unparsed; + } + + public ListFormVersionsResponse data(ListFormVersionsData data) { + this.data = data; + this.unparsed |= data.unparsed; + return this; + } + + /** + * A list-of-form-versions resource object. + * + * @return data + */ + @JsonProperty(JSON_PROPERTY_DATA) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public ListFormVersionsData getData() { + return data; + } + + public void setData(ListFormVersionsData data) { + this.data = data; + if (data != null) { + this.unparsed |= data.unparsed; + } + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return ListFormVersionsResponse + */ + @JsonAnySetter + public ListFormVersionsResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this ListFormVersionsResponse object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ListFormVersionsResponse listFormVersionsResponse = (ListFormVersionsResponse) o; + return Objects.equals(this.data, listFormVersionsResponse.data) + && Objects.equals(this.additionalProperties, listFormVersionsResponse.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(data, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ListFormVersionsResponse {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/test/resources/com/datadog/api/client/v2/api/forms.feature b/src/test/resources/com/datadog/api/client/v2/api/forms.feature index eb380d0f845..26c3af40da8 100644 --- a/src/test/resources/com/datadog/api/client/v2/api/forms.feature +++ b/src/test/resources/com/datadog/api/client/v2/api/forms.feature @@ -143,6 +143,30 @@ Feature: Forms And the response "data.type" is equal to "forms" And the response "data.attributes.name" is equal to "{{ unique }}" + @generated @skip @team:DataDog/app-builder-backend + Scenario: List form versions returns "Bad Request" response + Given operation "ListFormVersions" enabled + And new "ListFormVersions" request + And request contains "form_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/app-builder-backend + Scenario: List form versions returns "Not Found" response + Given operation "ListFormVersions" enabled + And new "ListFormVersions" request + And request contains "form_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/app-builder-backend + Scenario: List form versions returns "OK" response + Given operation "ListFormVersions" enabled + And new "ListFormVersions" request + And request contains "form_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK + @generated @skip @team:DataDog/app-builder-backend Scenario: List forms returns "Bad Request" response Given operation "ListForms" enabled @@ -189,6 +213,42 @@ Feature: Forms When the request is sent Then the response status is 200 OK + @generated @skip @team:DataDog/app-builder-backend + Scenario: Revert a form to a prior version returns "Bad Request" response + Given operation "RevertFormVersion" enabled + And new "RevertFormVersion" request + And request contains "form_id" parameter from "REPLACE.ME" + And request contains "version" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/app-builder-backend + Scenario: Revert a form to a prior version returns "Conflict" response + Given operation "RevertFormVersion" enabled + And new "RevertFormVersion" request + And request contains "form_id" parameter from "REPLACE.ME" + And request contains "version" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 409 Conflict + + @generated @skip @team:DataDog/app-builder-backend + Scenario: Revert a form to a prior version returns "Not Found" response + Given operation "RevertFormVersion" enabled + And new "RevertFormVersion" request + And request contains "form_id" parameter from "REPLACE.ME" + And request contains "version" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/app-builder-backend + Scenario: Revert a form to a prior version returns "OK" response + Given operation "RevertFormVersion" enabled + And new "RevertFormVersion" request + And request contains "form_id" parameter from "REPLACE.ME" + And request contains "version" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK + @generated @skip @team:DataDog/app-builder-backend Scenario: Update a form returns "Bad Request" response Given operation "UpdateForm" enabled diff --git a/src/test/resources/com/datadog/api/client/v2/api/undo.json b/src/test/resources/com/datadog/api/client/v2/api/undo.json index e72767d8e0d..437f8944b51 100644 --- a/src/test/resources/com/datadog/api/client/v2/api/undo.json +++ b/src/test/resources/com/datadog/api/client/v2/api/undo.json @@ -2792,12 +2792,24 @@ "type": "idempotent" } }, + "ListFormVersions": { + "tag": "Forms", + "undo": { + "type": "safe" + } + }, "UpsertFormVersion": { "tag": "Forms", "undo": { "type": "idempotent" } }, + "RevertFormVersion": { + "tag": "Forms", + "undo": { + "type": "unsafe" + } + }, "UpsertAndPublishFormVersion": { "tag": "Forms", "undo": {