From f1c99fb08a7ca0aa52241c71115c8c0d79d14a5a Mon Sep 17 00:00:00 2001 From: "ci.datadog-api-spec" Date: Wed, 4 Feb 2026 13:43:32 +0000 Subject: [PATCH] Regenerate client from commit e8821c1 of spec repo --- .generator/schemas/v2/openapi.yaml | 1044 ++++++++++ examples/v2_forms_CreateAndPublishForm.rs | 34 + examples/v2_forms_CreateForm.rs | 34 + examples/v2_forms_DeleteForm.rs | 19 + examples/v2_forms_GetForm.rs | 23 + examples/v2_forms_ListForms.rs | 17 + examples/v2_forms_PublishForm.rs | 30 + examples/v2_forms_SubmitForm.rs | 31 + examples/v2_forms_UpdateForm.rs | 38 + .../v2_forms_UpsertAndPublishFormVersion.rs | 42 + examples/v2_forms_UpsertFormVersion.rs | 42 + src/datadog/configuration.rs | 10 + src/datadogV2/api/api_forms.rs | 1673 +++++++++++++++++ src/datadogV2/api/mod.rs | 1 + src/datadogV2/mod.rs | 1 + src/datadogV2/model/mod.rs | 72 + .../model/model_form_create_request.rs | 91 + .../model_form_data_attributes_request.rs | 137 ++ .../model_form_data_attributes_response.rs | 213 +++ .../model/model_form_data_request.rs | 130 ++ .../model/model_form_data_response.rs | 124 ++ .../model/model_form_datastore_config.rs | 122 ++ src/datadogV2/model/model_form_publication.rs | 198 ++ .../model_form_publication_attributes.rs | 91 + .../model_form_publication_data_request.rs | 112 ++ .../model_form_publication_data_response.rs | 123 ++ .../model/model_form_publication_request.rs | 93 + .../model/model_form_publication_response.rs | 93 + .../model/model_form_publication_type.rs | 48 + src/datadogV2/model/model_form_response.rs | 91 + .../model/model_form_submission_attributes.rs | 97 + .../model_form_submission_data_request.rs | 114 ++ .../model_form_submission_data_response.rs | 114 ++ .../model/model_form_submission_request.rs | 91 + .../model/model_form_submission_response.rs | 93 + .../model/model_form_submission_type.rs | 48 + src/datadogV2/model/model_form_type.rs | 48 + .../model/model_form_update_attributes.rs | 111 ++ ...odel_form_update_attributes_form_update.rs | 123 ++ .../model/model_form_update_data_request.rs | 129 ++ .../model/model_form_update_request.rs | 91 + src/datadogV2/model/model_form_version.rs | 243 +++ .../model/model_form_version_attributes.rs | 153 ++ ...l_form_version_data_attributes_response.rs | 215 +++ .../model/model_form_version_data_request.rs | 113 ++ .../model/model_form_version_data_response.rs | 127 ++ .../model/model_form_version_request.rs | 91 + .../model/model_form_version_response.rs | 91 + .../model/model_form_version_state.rs | 51 + .../model/model_form_version_type.rs | 48 + .../model/model_form_version_upsert_params.rs | 123 ++ .../model/model_forms_list_response.rs | 92 + tests/scenarios/features/v2/forms.feature | 229 +++ tests/scenarios/features/v2/undo.json | 74 + tests/scenarios/function_mappings.rs | 312 +++ 55 files changed, 7798 insertions(+) create mode 100644 examples/v2_forms_CreateAndPublishForm.rs create mode 100644 examples/v2_forms_CreateForm.rs create mode 100644 examples/v2_forms_DeleteForm.rs create mode 100644 examples/v2_forms_GetForm.rs create mode 100644 examples/v2_forms_ListForms.rs create mode 100644 examples/v2_forms_PublishForm.rs create mode 100644 examples/v2_forms_SubmitForm.rs create mode 100644 examples/v2_forms_UpdateForm.rs create mode 100644 examples/v2_forms_UpsertAndPublishFormVersion.rs create mode 100644 examples/v2_forms_UpsertFormVersion.rs create mode 100644 src/datadogV2/api/api_forms.rs create mode 100644 src/datadogV2/model/model_form_create_request.rs create mode 100644 src/datadogV2/model/model_form_data_attributes_request.rs create mode 100644 src/datadogV2/model/model_form_data_attributes_response.rs create mode 100644 src/datadogV2/model/model_form_data_request.rs create mode 100644 src/datadogV2/model/model_form_data_response.rs create mode 100644 src/datadogV2/model/model_form_datastore_config.rs create mode 100644 src/datadogV2/model/model_form_publication.rs create mode 100644 src/datadogV2/model/model_form_publication_attributes.rs create mode 100644 src/datadogV2/model/model_form_publication_data_request.rs create mode 100644 src/datadogV2/model/model_form_publication_data_response.rs create mode 100644 src/datadogV2/model/model_form_publication_request.rs create mode 100644 src/datadogV2/model/model_form_publication_response.rs create mode 100644 src/datadogV2/model/model_form_publication_type.rs create mode 100644 src/datadogV2/model/model_form_response.rs create mode 100644 src/datadogV2/model/model_form_submission_attributes.rs create mode 100644 src/datadogV2/model/model_form_submission_data_request.rs create mode 100644 src/datadogV2/model/model_form_submission_data_response.rs create mode 100644 src/datadogV2/model/model_form_submission_request.rs create mode 100644 src/datadogV2/model/model_form_submission_response.rs create mode 100644 src/datadogV2/model/model_form_submission_type.rs create mode 100644 src/datadogV2/model/model_form_type.rs create mode 100644 src/datadogV2/model/model_form_update_attributes.rs create mode 100644 src/datadogV2/model/model_form_update_attributes_form_update.rs create mode 100644 src/datadogV2/model/model_form_update_data_request.rs create mode 100644 src/datadogV2/model/model_form_update_request.rs create mode 100644 src/datadogV2/model/model_form_version.rs create mode 100644 src/datadogV2/model/model_form_version_attributes.rs create mode 100644 src/datadogV2/model/model_form_version_data_attributes_response.rs create mode 100644 src/datadogV2/model/model_form_version_data_request.rs create mode 100644 src/datadogV2/model/model_form_version_data_response.rs create mode 100644 src/datadogV2/model/model_form_version_request.rs create mode 100644 src/datadogV2/model/model_form_version_response.rs create mode 100644 src/datadogV2/model/model_form_version_state.rs create mode 100644 src/datadogV2/model/model_form_version_type.rs create mode 100644 src/datadogV2/model/model_form_version_upsert_params.rs create mode 100644 src/datadogV2/model/model_forms_list_response.rs create mode 100644 tests/scenarios/features/v2/forms.feature diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index a8908359f..f39a404ba 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -25383,6 +25383,592 @@ components: required: - data type: object + FormCreateRequest: + description: Request for creating a form. + properties: + data: + $ref: '#/components/schemas/FormDataRequest' + required: + - data + type: object + FormDataAttributesRequest: + description: Attributes for creating a form. + properties: + data_definition: + description: The data definition for the form. + example: {} + type: object + description: + description: The description of the form. + example: test description + type: string + name: + description: The name of the form. + example: test form happy path + type: string + ui_definition: + description: The UI definition for the form. + example: {} + type: object + required: + - name + - description + - data_definition + - ui_definition + type: object + FormDataAttributesResponse: + description: Attributes of a form. + properties: + created_at: + description: Creation timestamp. + example: '2026-01-13T17:14:57.877323Z' + format: date-time + type: string + datastore_config: + $ref: '#/components/schemas/FormDatastoreConfig' + description: + description: The description of the form. + example: test description + type: string + modified_at: + description: Last modification timestamp. + example: '2026-01-13T17:14:57.877323Z' + format: date-time + type: string + name: + description: The name of the form. + example: test form happy path + type: string + org_id: + description: The organization ID. + example: 2 + format: int64 + type: integer + publication: + $ref: '#/components/schemas/FormPublication' + user_id: + description: The ID of the user who created the form. + example: 1 + format: int64 + type: integer + user_uuid: + description: The UUID of the user who created the form. + example: 7a35d794-2294-44f7-97e4-689e593cedbe + format: uuid + type: string + version: + $ref: '#/components/schemas/FormVersion' + required: + - org_id + - name + - description + - datastore_config + - created_at + - modified_at + - user_id + - user_uuid + type: object + FormDataRequest: + properties: + attributes: + $ref: '#/components/schemas/FormDataAttributesRequest' + id: + description: The form identifier. + example: 00000000-0000-0000-0000-000000000000 + format: uuid + type: string + type: + $ref: '#/components/schemas/FormType' + required: + - type + - attributes + type: object + FormDataResponse: + properties: + attributes: + $ref: '#/components/schemas/FormDataAttributesResponse' + id: + description: The form identifier. + example: 62172096-f84c-453f-a8ee-5d768fef1b19 + format: uuid + type: string + type: + $ref: '#/components/schemas/FormType' + required: + - id + - type + - attributes + type: object + FormDatastoreConfig: + description: Configuration for the form's associated datastore. + properties: + datastore_id: + description: The unique identifier of the datastore. + example: 6883d0d5-edf6-49b1-8848-47427d3fb84b + format: uuid + type: string + primary_column_name: + description: The name of the primary key column. + example: id + type: string + primary_key_generation_strategy: + description: The strategy used for generating primary keys. + example: uuid + type: string + required: + - datastore_id + - primary_column_name + - primary_key_generation_strategy + type: object + FormPublication: + description: Publication information for the form. + properties: + created_at: + description: Creation timestamp. + example: '2026-01-13T17:14:55.62611Z' + format: date-time + type: string + form_id: + description: The form identifier. + example: 10084e11-8789-4363-b0c8-4e8275a7e1cf + format: uuid + type: string + form_version: + description: The version of the form that was published. + example: 1 + format: int64 + type: integer + id: + description: The unique identifier of the publication. + example: '2' + type: string + modified_at: + description: Last modification timestamp. + example: '2026-01-13T17:14:55.62611Z' + format: date-time + type: string + org_id: + description: The organization ID. + example: 2 + format: int64 + type: integer + publish_seq: + description: The publication sequence number. + example: 1 + format: int64 + type: integer + user_id: + description: The ID of the user who published. + example: 10001 + format: int64 + type: integer + user_uuid: + description: The UUID of the user who published. + example: 78533ca4-048c-4f4a-b6dd-964669a84436 + format: uuid + type: string + required: + - id + - org_id + - form_id + - created_at + - modified_at + - user_id + - user_uuid + type: object + FormPublicationAttributes: + properties: + version: + description: The version number to publish. + example: 1 + format: int64 + type: integer + required: + - version + type: object + FormPublicationDataRequest: + properties: + attributes: + $ref: '#/components/schemas/FormPublicationAttributes' + type: + $ref: '#/components/schemas/FormPublicationType' + required: + - type + - attributes + type: object + FormPublicationDataResponse: + properties: + attributes: + $ref: '#/components/schemas/FormPublication' + id: + description: The publication identifier. + example: '21' + type: string + type: + $ref: '#/components/schemas/FormPublicationType' + required: + - id + - type + - attributes + type: object + FormPublicationRequest: + description: Request for publishing a form. + properties: + data: + $ref: '#/components/schemas/FormPublicationDataRequest' + required: + - data + type: object + FormPublicationResponse: + description: Response for a form publication. + properties: + data: + $ref: '#/components/schemas/FormPublicationDataResponse' + required: + - data + type: object + FormPublicationType: + description: Type for form publications. + enum: + - form_publications + example: form_publications + type: string + x-enum-varnames: + - FORM_PUBLICATIONS + FormResponse: + description: Response containing a single form. + properties: + data: + $ref: '#/components/schemas/FormDataResponse' + required: + - data + type: object + FormSubmissionAttributes: + properties: + submission_data: + description: The data submitted with the form. + example: {} + type: object + required: + - submission_data + type: object + FormSubmissionDataRequest: + properties: + attributes: + $ref: '#/components/schemas/FormSubmissionAttributes' + type: + $ref: '#/components/schemas/FormSubmissionType' + required: + - type + - attributes + type: object + FormSubmissionDataResponse: + properties: + id: + description: The submission identifier. + example: edb9a20e-34d4-48d7-9bbd-bb6beaf01729 + format: uuid + type: string + type: + $ref: '#/components/schemas/FormSubmissionType' + required: + - id + - type + type: object + FormSubmissionRequest: + description: Request for submitting a form. + properties: + data: + $ref: '#/components/schemas/FormSubmissionDataRequest' + required: + - data + type: object + FormSubmissionResponse: + description: Response for a form submission. + properties: + data: + $ref: '#/components/schemas/FormSubmissionDataResponse' + required: + - data + type: object + FormSubmissionType: + description: Type for form submissions. + enum: + - form_submissions + example: form_submissions + type: string + x-enum-varnames: + - FORM_SUBMISSIONS + FormType: + description: Type for forms. + enum: + - forms + example: forms + type: string + x-enum-varnames: + - FORMS + FormUpdateAttributes: + description: Attributes for updating a form. + properties: + form_update: + $ref: '#/components/schemas/FormUpdateAttributesFormUpdate' + type: object + FormUpdateAttributesFormUpdate: + description: Update parameters for the form. + properties: + description: + description: The updated description of the form. + example: Updated description + type: string + name: + description: The updated name of the form. + example: New Form Name + type: string + type: object + FormUpdateDataRequest: + properties: + attributes: + $ref: '#/components/schemas/FormUpdateAttributes' + id: + description: The form identifier. + example: 00000000-0000-0000-0000-000000000000 + format: uuid + type: string + type: + $ref: '#/components/schemas/FormType' + required: + - type + - attributes + type: object + FormUpdateRequest: + description: Request for updating a form. + properties: + data: + $ref: '#/components/schemas/FormUpdateDataRequest' + required: + - data + type: object + FormVersion: + description: Version information for the form. + properties: + created_at: + description: Creation timestamp. + example: '2026-01-13T17:14:57.877323Z' + format: date-time + type: string + data_definition: + description: The data definition for the form. + example: {} + type: object + definition_signature: + description: Signature of the form definition. + example: '{"signature":"555f403cfc78022f3a8dfeee0d00bcda1aaa64a7e63bb605f01d4b39d3634214","version":1}' + type: string + etag: + description: The entity tag for the version. + example: b51f08b698d88d8027a935d9db649774949f5fb41a0c559bfee6a9a13225c72d + type: string + id: + description: The unique identifier of the form version. + example: '6' + type: string + modified_at: + description: Last modification timestamp. + example: '2026-01-13T17:14:57.877323Z' + format: date-time + type: string + state: + $ref: '#/components/schemas/FormVersionState' + ui_definition: + description: The UI definition for the form. + example: {} + type: object + user_id: + description: The ID of the user who created the version. + example: 1 + format: int64 + type: integer + user_uuid: + description: The UUID of the user who created the version. + example: 7a35d794-2294-44f7-97e4-689e593cedbe + format: uuid + type: string + version: + description: The version number. + example: 1 + format: int64 + type: integer + required: + - id + - state + - data_definition + - ui_definition + - created_at + - modified_at + - user_id + - user_uuid + type: object + FormVersionAttributes: + properties: + data_definition: + description: The data definition for the form. + example: + updated: 'true' + type: object + state: + $ref: '#/components/schemas/FormVersionState' + ui_definition: + description: The UI definition for the form. + example: {} + type: object + upsert_params: + $ref: '#/components/schemas/FormVersionUpsertParams' + required: + - data_definition + - ui_definition + - upsert_params + type: object + FormVersionDataAttributesResponse: + description: Attributes of a form version. + properties: + created_at: + description: Creation timestamp. + example: '2026-01-13T17:14:58.915007Z' + format: date-time + type: string + data_definition: + description: The data definition for the form. + example: + updated: 'true' + type: object + definition_signature: + description: Signature of the form definition. + example: '{"signature":"c5f07b59cd4b5e431264d68a7e2e2d804c4eb515c006ab87e9bb7a04f1e711b6","version":1}' + type: string + etag: + description: The entity tag for the version. + example: d601c99730cb76542157e9e9eb3f1b41890f6af333d7d018baf56cfbbc1e2acc + type: string + modified_at: + description: Last modification timestamp. + example: '2026-01-13T17:14:58.923633Z' + format: date-time + type: string + state: + $ref: '#/components/schemas/FormVersionState' + ui_definition: + description: The UI definition for the form. + example: {} + type: object + user_id: + description: The ID of the user who created the version. + example: 1 + format: int64 + type: integer + user_uuid: + description: The UUID of the user who created the version. + example: 7a35d794-2294-44f7-97e4-689e593cedbe + format: uuid + type: string + version: + description: The version number. + example: 2 + format: int64 + type: integer + required: + - created_at + - data_definition + - definition_signature + - etag + - modified_at + - state + - ui_definition + - user_id + - user_uuid + - version + type: object + FormVersionDataRequest: + properties: + attributes: + $ref: '#/components/schemas/FormVersionAttributes' + type: + $ref: '#/components/schemas/FormVersionType' + required: + - type + - attributes + type: object + FormVersionDataResponse: + properties: + attributes: + $ref: '#/components/schemas/FormVersionDataAttributesResponse' + id: + description: The version identifier. + example: '46' + type: string + type: + $ref: '#/components/schemas/FormVersionType' + required: + - id + - type + - attributes + type: object + FormVersionRequest: + description: Request for creating or updating a form version. + properties: + data: + $ref: '#/components/schemas/FormVersionDataRequest' + required: + - data + type: object + FormVersionResponse: + description: Response for a form version. + properties: + data: + $ref: '#/components/schemas/FormVersionDataResponse' + required: + - data + type: object + FormVersionState: + description: The state of the form version. + enum: + - draft + - frozen + example: draft + type: string + x-enum-varnames: + - DRAFT + - FROZEN + FormVersionType: + description: Type for form versions. + enum: + - form_versions + example: form_versions + type: string + x-enum-varnames: + - FORM_VERSIONS + FormVersionUpsertParams: + description: Parameters for upserting a form version. + properties: + etag: + description: The entity tag for conflict detection. + example: b51f08b698d88d8027a935d9db649774949f5fb41a0c559bfee6a9a13225c72d + type: string + match_policy: + description: The match policy for upserting. + example: none + type: string + type: object + FormsListResponse: + description: Response containing a list of forms. + properties: + data: + description: An array of forms. + items: + $ref: '#/components/schemas/FormDataResponse' + type: array + required: + - data + type: object FormulaLimit: description: 'Message for specifying limits to the number of values returned by a query. @@ -77367,6 +77953,462 @@ paths: operator: OR permissions: - events_read + /api/v2/forms: + get: + description: Get a list of all forms. + operationId: ListForms + parameters: + - description: Filter forms by name. + in: query + name: name + required: false + schema: + type: string + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/FormsListResponse' + 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 + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: List all forms + 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 a new form with the specified configuration. + operationId: CreateForm + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/FormCreateRequest' + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/FormResponse' + 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 + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: Create a new form + 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/create_and_publish: + post: + description: Create a new form and publish it immediately. + operationId: CreateAndPublishForm + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/FormCreateRequest' + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/FormResponse' + 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 + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: Create and publish a form + 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}: + delete: + description: Delete a form by ID. + operationId: DeleteForm + parameters: + - description: The ID of the form. + in: path + name: form_id + required: true + schema: + format: uuid + type: string + responses: + '200': + 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 + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: Delete a form + 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/).' + get: + description: Get a form by ID. + operationId: GetForm + parameters: + - description: The ID of the form. + in: path + name: form_id + required: true + schema: + format: uuid + type: string + - description: The version number of the form. + in: query + name: version + required: false + schema: + type: integer + - description: Whether to get the published version. + in: query + name: published_version + required: false + schema: + type: boolean + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/FormResponse' + 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: Get a form + 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/).' + patch: + description: Update a form by ID. + operationId: UpdateForm + parameters: + - description: The ID of the form. + in: path + name: form_id + required: true + schema: + format: uuid + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/FormUpdateRequest' + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/FormResponse' + 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: Update a form + 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}/publish: + post: + description: Publish a specific version of a form. + operationId: PublishForm + parameters: + - description: The ID of the form. + in: path + name: form_id + required: true + schema: + format: uuid + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/FormPublicationRequest' + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/FormPublicationResponse' + 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: Publish a form + 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}/submit: + post: + description: Submit data to a form. + operationId: SubmitForm + parameters: + - description: The ID of the form. + in: path + name: form_id + required: true + schema: + format: uuid + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/FormSubmissionRequest' + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/FormSubmissionResponse' + 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: Submit a form + 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: + post: + description: Create or update a form version. + operationId: UpsertFormVersion + parameters: + - description: The ID of the form. + in: path + name: form_id + required: true + schema: + format: uuid + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/FormVersionRequest' + required: true + responses: + '200': + content: + application/json: + 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 + '409': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Conflict + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: Create a form 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: Create or update a form version and publish it immediately. + operationId: UpsertAndPublishFormVersion + parameters: + - description: The ID of the form. + in: path + name: form_id + required: true + schema: + format: uuid + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/FormVersionRequest' + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/FormResponse' + 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 + '409': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Conflict + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: Upsert and publish a form 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/hamr: get: description: 'Retrieve the High Availability Multi-Region (HAMR) organization @@ -102521,6 +103563,8 @@ tags: - Upgrade the Datadog Agent to specific versions' name: Fleet Automation +- description: Create and manage forms for collecting data from users. + name: Forms - description: 'Configure your Datadog-Google Cloud Platform (GCP) integration directly through the Datadog API. Read more about the [Datadog-Google Cloud Platform integration](https://docs.datadoghq.com/integrations/google_cloud_platform).' diff --git a/examples/v2_forms_CreateAndPublishForm.rs b/examples/v2_forms_CreateAndPublishForm.rs new file mode 100644 index 000000000..46a4ff996 --- /dev/null +++ b/examples/v2_forms_CreateAndPublishForm.rs @@ -0,0 +1,34 @@ +// Create and publish a form returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_forms::FormsAPI; +use datadog_api_client::datadogV2::model::FormCreateRequest; +use datadog_api_client::datadogV2::model::FormDataAttributesRequest; +use datadog_api_client::datadogV2::model::FormDataRequest; +use datadog_api_client::datadogV2::model::FormType; +use std::collections::BTreeMap; +use uuid::Uuid; + +#[tokio::main] +async fn main() { + let body = FormCreateRequest::new( + FormDataRequest::new( + FormDataAttributesRequest::new( + BTreeMap::new(), + "test description".to_string(), + "test form happy path".to_string(), + BTreeMap::new(), + ), + FormType::FORMS, + ) + .id(Uuid::parse_str("00000000-0000-0000-0000-000000000000").expect("invalid UUID")), + ); + let mut configuration = datadog::Configuration::new(); + configuration.set_unstable_operation_enabled("v2.CreateAndPublishForm", true); + let api = FormsAPI::with_config(configuration); + let resp = api.create_and_publish_form(body).await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_forms_CreateForm.rs b/examples/v2_forms_CreateForm.rs new file mode 100644 index 000000000..c097c7316 --- /dev/null +++ b/examples/v2_forms_CreateForm.rs @@ -0,0 +1,34 @@ +// Create a new form returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_forms::FormsAPI; +use datadog_api_client::datadogV2::model::FormCreateRequest; +use datadog_api_client::datadogV2::model::FormDataAttributesRequest; +use datadog_api_client::datadogV2::model::FormDataRequest; +use datadog_api_client::datadogV2::model::FormType; +use std::collections::BTreeMap; +use uuid::Uuid; + +#[tokio::main] +async fn main() { + let body = FormCreateRequest::new( + FormDataRequest::new( + FormDataAttributesRequest::new( + BTreeMap::new(), + "test description".to_string(), + "test form happy path".to_string(), + BTreeMap::new(), + ), + FormType::FORMS, + ) + .id(Uuid::parse_str("00000000-0000-0000-0000-000000000000").expect("invalid UUID")), + ); + let mut configuration = datadog::Configuration::new(); + configuration.set_unstable_operation_enabled("v2.CreateForm", true); + let api = FormsAPI::with_config(configuration); + let resp = api.create_form(body).await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_forms_DeleteForm.rs b/examples/v2_forms_DeleteForm.rs new file mode 100644 index 000000000..f861475c0 --- /dev/null +++ b/examples/v2_forms_DeleteForm.rs @@ -0,0 +1,19 @@ +// Delete a form returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_forms::FormsAPI; +use uuid::Uuid; + +#[tokio::main] +async fn main() { + let mut configuration = datadog::Configuration::new(); + configuration.set_unstable_operation_enabled("v2.DeleteForm", true); + let api = FormsAPI::with_config(configuration); + let resp = api + .delete_form(Uuid::parse_str("00000000-0000-0000-0000-000000000000").expect("invalid UUID")) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_forms_GetForm.rs b/examples/v2_forms_GetForm.rs new file mode 100644 index 000000000..d6d877299 --- /dev/null +++ b/examples/v2_forms_GetForm.rs @@ -0,0 +1,23 @@ +// Get a form returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_forms::FormsAPI; +use datadog_api_client::datadogV2::api_forms::GetFormOptionalParams; +use uuid::Uuid; + +#[tokio::main] +async fn main() { + let mut configuration = datadog::Configuration::new(); + configuration.set_unstable_operation_enabled("v2.GetForm", true); + let api = FormsAPI::with_config(configuration); + let resp = api + .get_form( + Uuid::parse_str("00000000-0000-0000-0000-000000000000").expect("invalid UUID"), + GetFormOptionalParams::default(), + ) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_forms_ListForms.rs b/examples/v2_forms_ListForms.rs new file mode 100644 index 000000000..f9987c3e3 --- /dev/null +++ b/examples/v2_forms_ListForms.rs @@ -0,0 +1,17 @@ +// List all forms returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_forms::FormsAPI; +use datadog_api_client::datadogV2::api_forms::ListFormsOptionalParams; + +#[tokio::main] +async fn main() { + let mut configuration = datadog::Configuration::new(); + configuration.set_unstable_operation_enabled("v2.ListForms", true); + let api = FormsAPI::with_config(configuration); + let resp = api.list_forms(ListFormsOptionalParams::default()).await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_forms_PublishForm.rs b/examples/v2_forms_PublishForm.rs new file mode 100644 index 000000000..761d88c3c --- /dev/null +++ b/examples/v2_forms_PublishForm.rs @@ -0,0 +1,30 @@ +// Publish a form returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_forms::FormsAPI; +use datadog_api_client::datadogV2::model::FormPublicationAttributes; +use datadog_api_client::datadogV2::model::FormPublicationDataRequest; +use datadog_api_client::datadogV2::model::FormPublicationRequest; +use datadog_api_client::datadogV2::model::FormPublicationType; +use uuid::Uuid; + +#[tokio::main] +async fn main() { + let body = FormPublicationRequest::new(FormPublicationDataRequest::new( + FormPublicationAttributes::new(1), + FormPublicationType::FORM_PUBLICATIONS, + )); + let mut configuration = datadog::Configuration::new(); + configuration.set_unstable_operation_enabled("v2.PublishForm", true); + let api = FormsAPI::with_config(configuration); + let resp = api + .publish_form( + Uuid::parse_str("00000000-0000-0000-0000-000000000000").expect("invalid UUID"), + body, + ) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_forms_SubmitForm.rs b/examples/v2_forms_SubmitForm.rs new file mode 100644 index 000000000..bfd3f8e3f --- /dev/null +++ b/examples/v2_forms_SubmitForm.rs @@ -0,0 +1,31 @@ +// Submit a form returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_forms::FormsAPI; +use datadog_api_client::datadogV2::model::FormSubmissionAttributes; +use datadog_api_client::datadogV2::model::FormSubmissionDataRequest; +use datadog_api_client::datadogV2::model::FormSubmissionRequest; +use datadog_api_client::datadogV2::model::FormSubmissionType; +use std::collections::BTreeMap; +use uuid::Uuid; + +#[tokio::main] +async fn main() { + let body = FormSubmissionRequest::new(FormSubmissionDataRequest::new( + FormSubmissionAttributes::new(BTreeMap::new()), + FormSubmissionType::FORM_SUBMISSIONS, + )); + let mut configuration = datadog::Configuration::new(); + configuration.set_unstable_operation_enabled("v2.SubmitForm", true); + let api = FormsAPI::with_config(configuration); + let resp = api + .submit_form( + Uuid::parse_str("00000000-0000-0000-0000-000000000000").expect("invalid UUID"), + body, + ) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_forms_UpdateForm.rs b/examples/v2_forms_UpdateForm.rs new file mode 100644 index 000000000..bd15dd696 --- /dev/null +++ b/examples/v2_forms_UpdateForm.rs @@ -0,0 +1,38 @@ +// Update a form returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_forms::FormsAPI; +use datadog_api_client::datadogV2::model::FormType; +use datadog_api_client::datadogV2::model::FormUpdateAttributes; +use datadog_api_client::datadogV2::model::FormUpdateAttributesFormUpdate; +use datadog_api_client::datadogV2::model::FormUpdateDataRequest; +use datadog_api_client::datadogV2::model::FormUpdateRequest; +use uuid::Uuid; + +#[tokio::main] +async fn main() { + let body = FormUpdateRequest::new( + FormUpdateDataRequest::new( + FormUpdateAttributes::new().form_update( + FormUpdateAttributesFormUpdate::new() + .description("Updated description".to_string()) + .name("New Form Name".to_string()), + ), + FormType::FORMS, + ) + .id(Uuid::parse_str("00000000-0000-0000-0000-000000000000").expect("invalid UUID")), + ); + let mut configuration = datadog::Configuration::new(); + configuration.set_unstable_operation_enabled("v2.UpdateForm", true); + let api = FormsAPI::with_config(configuration); + let resp = api + .update_form( + Uuid::parse_str("00000000-0000-0000-0000-000000000000").expect("invalid UUID"), + body, + ) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_forms_UpsertAndPublishFormVersion.rs b/examples/v2_forms_UpsertAndPublishFormVersion.rs new file mode 100644 index 000000000..e198950e4 --- /dev/null +++ b/examples/v2_forms_UpsertAndPublishFormVersion.rs @@ -0,0 +1,42 @@ +// Upsert and publish a form version returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_forms::FormsAPI; +use datadog_api_client::datadogV2::model::FormVersionAttributes; +use datadog_api_client::datadogV2::model::FormVersionDataRequest; +use datadog_api_client::datadogV2::model::FormVersionRequest; +use datadog_api_client::datadogV2::model::FormVersionState; +use datadog_api_client::datadogV2::model::FormVersionType; +use datadog_api_client::datadogV2::model::FormVersionUpsertParams; +use std::collections::BTreeMap; +use uuid::Uuid; + +#[tokio::main] +async fn main() { + let body = FormVersionRequest::new(FormVersionDataRequest::new( + FormVersionAttributes::new( + BTreeMap::new(), + BTreeMap::new(), + FormVersionUpsertParams::new() + .etag( + "b51f08b698d88d8027a935d9db649774949f5fb41a0c559bfee6a9a13225c72d".to_string(), + ) + .match_policy("none".to_string()), + ) + .state(FormVersionState::DRAFT), + FormVersionType::FORM_VERSIONS, + )); + let mut configuration = datadog::Configuration::new(); + configuration.set_unstable_operation_enabled("v2.UpsertAndPublishFormVersion", true); + let api = FormsAPI::with_config(configuration); + let resp = api + .upsert_and_publish_form_version( + Uuid::parse_str("00000000-0000-0000-0000-000000000000").expect("invalid UUID"), + body, + ) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_forms_UpsertFormVersion.rs b/examples/v2_forms_UpsertFormVersion.rs new file mode 100644 index 000000000..6a400a158 --- /dev/null +++ b/examples/v2_forms_UpsertFormVersion.rs @@ -0,0 +1,42 @@ +// Create a form version returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_forms::FormsAPI; +use datadog_api_client::datadogV2::model::FormVersionAttributes; +use datadog_api_client::datadogV2::model::FormVersionDataRequest; +use datadog_api_client::datadogV2::model::FormVersionRequest; +use datadog_api_client::datadogV2::model::FormVersionState; +use datadog_api_client::datadogV2::model::FormVersionType; +use datadog_api_client::datadogV2::model::FormVersionUpsertParams; +use std::collections::BTreeMap; +use uuid::Uuid; + +#[tokio::main] +async fn main() { + let body = FormVersionRequest::new(FormVersionDataRequest::new( + FormVersionAttributes::new( + BTreeMap::new(), + BTreeMap::new(), + FormVersionUpsertParams::new() + .etag( + "b51f08b698d88d8027a935d9db649774949f5fb41a0c559bfee6a9a13225c72d".to_string(), + ) + .match_policy("none".to_string()), + ) + .state(FormVersionState::DRAFT), + FormVersionType::FORM_VERSIONS, + )); + let mut configuration = datadog::Configuration::new(); + configuration.set_unstable_operation_enabled("v2.UpsertFormVersion", true); + let api = FormsAPI::with_config(configuration); + let resp = api + .upsert_form_version( + Uuid::parse_str("00000000-0000-0000-0000-000000000000").expect("invalid UUID"), + body, + ) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/src/datadog/configuration.rs b/src/datadog/configuration.rs index 54ca27878..7e4371df1 100644 --- a/src/datadog/configuration.rs +++ b/src/datadog/configuration.rs @@ -186,6 +186,16 @@ impl Default for Configuration { ("v2.get_deployment_rule".to_owned(), false), ("v2.update_deployment_gate".to_owned(), false), ("v2.update_deployment_rule".to_owned(), false), + ("v2.create_and_publish_form".to_owned(), false), + ("v2.create_form".to_owned(), false), + ("v2.delete_form".to_owned(), false), + ("v2.get_form".to_owned(), false), + ("v2.list_forms".to_owned(), false), + ("v2.publish_form".to_owned(), false), + ("v2.submit_form".to_owned(), false), + ("v2.update_form".to_owned(), false), + ("v2.upsert_and_publish_form_version".to_owned(), false), + ("v2.upsert_form_version".to_owned(), false), ("v2.create_hamr_org_connection".to_owned(), false), ("v2.get_hamr_org_connection".to_owned(), false), ("v2.create_global_incident_handle".to_owned(), false), diff --git a/src/datadogV2/api/api_forms.rs b/src/datadogV2/api/api_forms.rs new file mode 100644 index 000000000..8b0e6d0ba --- /dev/null +++ b/src/datadogV2/api/api_forms.rs @@ -0,0 +1,1673 @@ +// 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. +use crate::datadog; +use flate2::{ + write::{GzEncoder, ZlibEncoder}, + Compression, +}; +use log::warn; +use reqwest::header::{HeaderMap, HeaderValue}; +use serde::{Deserialize, Serialize}; +use std::io::Write; + +/// GetFormOptionalParams is a struct for passing parameters to the method [`FormsAPI::get_form`] +#[non_exhaustive] +#[derive(Clone, Default, Debug)] +pub struct GetFormOptionalParams { + /// The version number of the form. + pub version: Option, + /// Whether to get the published version. + pub published_version: Option, +} + +impl GetFormOptionalParams { + /// The version number of the form. + pub fn version(mut self, value: i32) -> Self { + self.version = Some(value); + self + } + /// Whether to get the published version. + pub fn published_version(mut self, value: bool) -> Self { + self.published_version = Some(value); + self + } +} + +/// ListFormsOptionalParams is a struct for passing parameters to the method [`FormsAPI::list_forms`] +#[non_exhaustive] +#[derive(Clone, Default, Debug)] +pub struct ListFormsOptionalParams { + /// Filter forms by name. + pub name: Option, +} + +impl ListFormsOptionalParams { + /// Filter forms by name. + pub fn name(mut self, value: String) -> Self { + self.name = Some(value); + self + } +} + +/// CreateAndPublishFormError is a struct for typed errors of method [`FormsAPI::create_and_publish_form`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CreateAndPublishFormError { + JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse), + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// CreateFormError is a struct for typed errors of method [`FormsAPI::create_form`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CreateFormError { + JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse), + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// DeleteFormError is a struct for typed errors of method [`FormsAPI::delete_form`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum DeleteFormError { + JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse), + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// GetFormError is a struct for typed errors of method [`FormsAPI::get_form`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetFormError { + JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse), + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// ListFormsError is a struct for typed errors of method [`FormsAPI::list_forms`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ListFormsError { + JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse), + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// PublishFormError is a struct for typed errors of method [`FormsAPI::publish_form`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum PublishFormError { + JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse), + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// SubmitFormError is a struct for typed errors of method [`FormsAPI::submit_form`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum SubmitFormError { + JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse), + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// UpdateFormError is a struct for typed errors of method [`FormsAPI::update_form`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum UpdateFormError { + JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse), + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// UpsertAndPublishFormVersionError is a struct for typed errors of method [`FormsAPI::upsert_and_publish_form_version`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum UpsertAndPublishFormVersionError { + JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse), + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// UpsertFormVersionError is a struct for typed errors of method [`FormsAPI::upsert_form_version`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum UpsertFormVersionError { + JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse), + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// Create and manage forms for collecting data from users. +#[derive(Debug, Clone)] +pub struct FormsAPI { + config: datadog::Configuration, + client: reqwest_middleware::ClientWithMiddleware, +} + +impl Default for FormsAPI { + fn default() -> Self { + Self::with_config(datadog::Configuration::default()) + } +} + +impl FormsAPI { + pub fn new() -> Self { + Self::default() + } + pub fn with_config(config: datadog::Configuration) -> Self { + let mut reqwest_client_builder = reqwest::Client::builder(); + + if let Some(proxy_url) = &config.proxy_url { + let proxy = reqwest::Proxy::all(proxy_url).expect("Failed to parse proxy URL"); + reqwest_client_builder = reqwest_client_builder.proxy(proxy); + } + + let mut middleware_client_builder = + reqwest_middleware::ClientBuilder::new(reqwest_client_builder.build().unwrap()); + + if config.enable_retry { + struct RetryableStatus; + impl reqwest_retry::RetryableStrategy for RetryableStatus { + fn handle( + &self, + res: &Result, + ) -> Option { + match res { + Ok(success) => reqwest_retry::default_on_request_success(success), + Err(_) => None, + } + } + } + let backoff_policy = reqwest_retry::policies::ExponentialBackoff::builder() + .build_with_max_retries(config.max_retries); + + let retry_middleware = + reqwest_retry::RetryTransientMiddleware::new_with_policy_and_strategy( + backoff_policy, + RetryableStatus, + ); + + middleware_client_builder = middleware_client_builder.with(retry_middleware); + } + + let client = middleware_client_builder.build(); + + Self { config, client } + } + + pub fn with_client_and_config( + config: datadog::Configuration, + client: reqwest_middleware::ClientWithMiddleware, + ) -> Self { + Self { config, client } + } + + /// Create a new form and publish it immediately. + pub async fn create_and_publish_form( + &self, + body: crate::datadogV2::model::FormCreateRequest, + ) -> Result> + { + match self.create_and_publish_form_with_http_info(body).await { + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(datadog::Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } + Err(err) => Err(err), + } + } + + /// Create a new form and publish it immediately. + pub async fn create_and_publish_form_with_http_info( + &self, + body: crate::datadogV2::model::FormCreateRequest, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.create_and_publish_form"; + if local_configuration.is_unstable_operation_enabled(operation_id) { + warn!("Using unstable operation {operation_id}"); + } else { + let local_error = datadog::UnstableOperationDisabledError { + msg: "Operation 'v2.create_and_publish_form' is not enabled".to_string(), + }; + return Err(datadog::Error::UnstableOperationDisabledError(local_error)); + } + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/forms/create_and_publish", + local_configuration.get_operation_host(operation_id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::POST, local_uri_str.as_str()); + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Content-Type", HeaderValue::from_static("application/json")); + headers.insert("Accept", HeaderValue::from_static("application/json")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + // build body parameters + let output = Vec::new(); + let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter); + if body.serialize(&mut ser).is_ok() { + if let Some(content_encoding) = headers.get("Content-Encoding") { + match content_encoding.to_str().unwrap_or_default() { + "gzip" => { + let mut enc = GzEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + "deflate" => { + let mut enc = ZlibEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + "zstd1" => { + let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap(); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + _ => { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + } else { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + match serde_json::from_str::(&local_content) { + Ok(e) => { + return Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: Some(e), + }) + } + Err(e) => return Err(datadog::Error::Serde(e)), + }; + } else { + let local_entity: Option = + serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } + + /// Create a new form with the specified configuration. + pub async fn create_form( + &self, + body: crate::datadogV2::model::FormCreateRequest, + ) -> Result> { + match self.create_form_with_http_info(body).await { + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(datadog::Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } + Err(err) => Err(err), + } + } + + /// Create a new form with the specified configuration. + pub async fn create_form_with_http_info( + &self, + body: crate::datadogV2::model::FormCreateRequest, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.create_form"; + if local_configuration.is_unstable_operation_enabled(operation_id) { + warn!("Using unstable operation {operation_id}"); + } else { + let local_error = datadog::UnstableOperationDisabledError { + msg: "Operation 'v2.create_form' is not enabled".to_string(), + }; + return Err(datadog::Error::UnstableOperationDisabledError(local_error)); + } + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/forms", + local_configuration.get_operation_host(operation_id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::POST, local_uri_str.as_str()); + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Content-Type", HeaderValue::from_static("application/json")); + headers.insert("Accept", HeaderValue::from_static("application/json")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + // build body parameters + let output = Vec::new(); + let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter); + if body.serialize(&mut ser).is_ok() { + if let Some(content_encoding) = headers.get("Content-Encoding") { + match content_encoding.to_str().unwrap_or_default() { + "gzip" => { + let mut enc = GzEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + "deflate" => { + let mut enc = ZlibEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + "zstd1" => { + let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap(); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + _ => { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + } else { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + match serde_json::from_str::(&local_content) { + Ok(e) => { + return Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: Some(e), + }) + } + Err(e) => return Err(datadog::Error::Serde(e)), + }; + } else { + let local_entity: Option = serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } + + /// Delete a form by ID. + pub async fn delete_form( + &self, + form_id: uuid::Uuid, + ) -> Result<(), datadog::Error> { + match self.delete_form_with_http_info(form_id).await { + Ok(_) => Ok(()), + Err(err) => Err(err), + } + } + + /// Delete a form by ID. + pub async fn delete_form_with_http_info( + &self, + form_id: uuid::Uuid, + ) -> Result, datadog::Error> { + let local_configuration = &self.config; + let operation_id = "v2.delete_form"; + if local_configuration.is_unstable_operation_enabled(operation_id) { + warn!("Using unstable operation {operation_id}"); + } else { + let local_error = datadog::UnstableOperationDisabledError { + msg: "Operation 'v2.delete_form' is not enabled".to_string(), + }; + return Err(datadog::Error::UnstableOperationDisabledError(local_error)); + } + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/forms/{form_id}", + local_configuration.get_operation_host(operation_id), + form_id = datadog::urlencode(form_id.to_string()) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::DELETE, local_uri_str.as_str()); + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Accept", HeaderValue::from_static("*/*")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: None, + }) + } else { + let local_entity: Option = serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } + + /// Get a form by ID. + pub async fn get_form( + &self, + form_id: uuid::Uuid, + params: GetFormOptionalParams, + ) -> Result> { + match self.get_form_with_http_info(form_id, params).await { + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(datadog::Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } + Err(err) => Err(err), + } + } + + /// Get a form by ID. + pub async fn get_form_with_http_info( + &self, + form_id: uuid::Uuid, + params: GetFormOptionalParams, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.get_form"; + if local_configuration.is_unstable_operation_enabled(operation_id) { + warn!("Using unstable operation {operation_id}"); + } else { + let local_error = datadog::UnstableOperationDisabledError { + msg: "Operation 'v2.get_form' is not enabled".to_string(), + }; + return Err(datadog::Error::UnstableOperationDisabledError(local_error)); + } + + // unbox and build optional parameters + let version = params.version; + let published_version = params.published_version; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/forms/{form_id}", + local_configuration.get_operation_host(operation_id), + form_id = datadog::urlencode(form_id.to_string()) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::GET, local_uri_str.as_str()); + + if let Some(ref local_query_param) = version { + local_req_builder = + local_req_builder.query(&[("version", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = published_version { + local_req_builder = + local_req_builder.query(&[("published_version", &local_query_param.to_string())]); + }; + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Accept", HeaderValue::from_static("application/json")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + match serde_json::from_str::(&local_content) { + Ok(e) => { + return Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: Some(e), + }) + } + Err(e) => return Err(datadog::Error::Serde(e)), + }; + } else { + let local_entity: Option = serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } + + /// Get a list of all forms. + pub async fn list_forms( + &self, + params: ListFormsOptionalParams, + ) -> Result> { + match self.list_forms_with_http_info(params).await { + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(datadog::Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } + Err(err) => Err(err), + } + } + + /// Get a list of all forms. + pub async fn list_forms_with_http_info( + &self, + params: ListFormsOptionalParams, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.list_forms"; + if local_configuration.is_unstable_operation_enabled(operation_id) { + warn!("Using unstable operation {operation_id}"); + } else { + let local_error = datadog::UnstableOperationDisabledError { + msg: "Operation 'v2.list_forms' is not enabled".to_string(), + }; + return Err(datadog::Error::UnstableOperationDisabledError(local_error)); + } + + // unbox and build optional parameters + let name = params.name; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/forms", + local_configuration.get_operation_host(operation_id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::GET, local_uri_str.as_str()); + + if let Some(ref local_query_param) = name { + local_req_builder = + local_req_builder.query(&[("name", &local_query_param.to_string())]); + }; + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Accept", HeaderValue::from_static("application/json")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + match serde_json::from_str::(&local_content) + { + Ok(e) => { + return Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: Some(e), + }) + } + Err(e) => return Err(datadog::Error::Serde(e)), + }; + } else { + let local_entity: Option = serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } + + /// Publish a specific version of a form. + pub async fn publish_form( + &self, + form_id: uuid::Uuid, + body: crate::datadogV2::model::FormPublicationRequest, + ) -> Result> + { + match self.publish_form_with_http_info(form_id, body).await { + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(datadog::Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } + Err(err) => Err(err), + } + } + + /// Publish a specific version of a form. + pub async fn publish_form_with_http_info( + &self, + form_id: uuid::Uuid, + body: crate::datadogV2::model::FormPublicationRequest, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.publish_form"; + if local_configuration.is_unstable_operation_enabled(operation_id) { + warn!("Using unstable operation {operation_id}"); + } else { + let local_error = datadog::UnstableOperationDisabledError { + msg: "Operation 'v2.publish_form' is not enabled".to_string(), + }; + return Err(datadog::Error::UnstableOperationDisabledError(local_error)); + } + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/forms/{form_id}/publish", + local_configuration.get_operation_host(operation_id), + form_id = datadog::urlencode(form_id.to_string()) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::POST, local_uri_str.as_str()); + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Content-Type", HeaderValue::from_static("application/json")); + headers.insert("Accept", HeaderValue::from_static("application/json")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + // build body parameters + let output = Vec::new(); + let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter); + if body.serialize(&mut ser).is_ok() { + if let Some(content_encoding) = headers.get("Content-Encoding") { + match content_encoding.to_str().unwrap_or_default() { + "gzip" => { + let mut enc = GzEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + "deflate" => { + let mut enc = ZlibEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + "zstd1" => { + let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap(); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + _ => { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + } else { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + match serde_json::from_str::( + &local_content, + ) { + Ok(e) => { + return Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: Some(e), + }) + } + Err(e) => return Err(datadog::Error::Serde(e)), + }; + } else { + let local_entity: Option = serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } + + /// Submit data to a form. + pub async fn submit_form( + &self, + form_id: uuid::Uuid, + body: crate::datadogV2::model::FormSubmissionRequest, + ) -> Result> + { + match self.submit_form_with_http_info(form_id, body).await { + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(datadog::Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } + Err(err) => Err(err), + } + } + + /// Submit data to a form. + pub async fn submit_form_with_http_info( + &self, + form_id: uuid::Uuid, + body: crate::datadogV2::model::FormSubmissionRequest, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.submit_form"; + if local_configuration.is_unstable_operation_enabled(operation_id) { + warn!("Using unstable operation {operation_id}"); + } else { + let local_error = datadog::UnstableOperationDisabledError { + msg: "Operation 'v2.submit_form' is not enabled".to_string(), + }; + return Err(datadog::Error::UnstableOperationDisabledError(local_error)); + } + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/forms/{form_id}/submit", + local_configuration.get_operation_host(operation_id), + form_id = datadog::urlencode(form_id.to_string()) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::POST, local_uri_str.as_str()); + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Content-Type", HeaderValue::from_static("application/json")); + headers.insert("Accept", HeaderValue::from_static("application/json")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + // build body parameters + let output = Vec::new(); + let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter); + if body.serialize(&mut ser).is_ok() { + if let Some(content_encoding) = headers.get("Content-Encoding") { + match content_encoding.to_str().unwrap_or_default() { + "gzip" => { + let mut enc = GzEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + "deflate" => { + let mut enc = ZlibEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + "zstd1" => { + let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap(); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + _ => { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + } else { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + match serde_json::from_str::( + &local_content, + ) { + Ok(e) => { + return Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: Some(e), + }) + } + Err(e) => return Err(datadog::Error::Serde(e)), + }; + } else { + let local_entity: Option = serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } + + /// Update a form by ID. + pub async fn update_form( + &self, + form_id: uuid::Uuid, + body: crate::datadogV2::model::FormUpdateRequest, + ) -> Result> { + match self.update_form_with_http_info(form_id, body).await { + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(datadog::Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } + Err(err) => Err(err), + } + } + + /// Update a form by ID. + pub async fn update_form_with_http_info( + &self, + form_id: uuid::Uuid, + body: crate::datadogV2::model::FormUpdateRequest, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.update_form"; + if local_configuration.is_unstable_operation_enabled(operation_id) { + warn!("Using unstable operation {operation_id}"); + } else { + let local_error = datadog::UnstableOperationDisabledError { + msg: "Operation 'v2.update_form' is not enabled".to_string(), + }; + return Err(datadog::Error::UnstableOperationDisabledError(local_error)); + } + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/forms/{form_id}", + local_configuration.get_operation_host(operation_id), + form_id = datadog::urlencode(form_id.to_string()) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::PATCH, local_uri_str.as_str()); + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Content-Type", HeaderValue::from_static("application/json")); + headers.insert("Accept", HeaderValue::from_static("application/json")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + // build body parameters + let output = Vec::new(); + let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter); + if body.serialize(&mut ser).is_ok() { + if let Some(content_encoding) = headers.get("Content-Encoding") { + match content_encoding.to_str().unwrap_or_default() { + "gzip" => { + let mut enc = GzEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + "deflate" => { + let mut enc = ZlibEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + "zstd1" => { + let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap(); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + _ => { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + } else { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + match serde_json::from_str::(&local_content) { + Ok(e) => { + return Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: Some(e), + }) + } + Err(e) => return Err(datadog::Error::Serde(e)), + }; + } else { + let local_entity: Option = serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } + + /// Create or update a form version and publish it immediately. + pub async fn upsert_and_publish_form_version( + &self, + form_id: uuid::Uuid, + body: crate::datadogV2::model::FormVersionRequest, + ) -> Result< + crate::datadogV2::model::FormResponse, + datadog::Error, + > { + match self + .upsert_and_publish_form_version_with_http_info(form_id, body) + .await + { + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(datadog::Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } + Err(err) => Err(err), + } + } + + /// Create or update a form version and publish it immediately. + pub async fn upsert_and_publish_form_version_with_http_info( + &self, + form_id: uuid::Uuid, + body: crate::datadogV2::model::FormVersionRequest, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.upsert_and_publish_form_version"; + if local_configuration.is_unstable_operation_enabled(operation_id) { + warn!("Using unstable operation {operation_id}"); + } else { + let local_error = datadog::UnstableOperationDisabledError { + msg: "Operation 'v2.upsert_and_publish_form_version' is not enabled".to_string(), + }; + return Err(datadog::Error::UnstableOperationDisabledError(local_error)); + } + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/forms/{form_id}/versions/upsert_and_publish", + local_configuration.get_operation_host(operation_id), + form_id = datadog::urlencode(form_id.to_string()) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::POST, local_uri_str.as_str()); + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Content-Type", HeaderValue::from_static("application/json")); + headers.insert("Accept", HeaderValue::from_static("application/json")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + // build body parameters + let output = Vec::new(); + let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter); + if body.serialize(&mut ser).is_ok() { + if let Some(content_encoding) = headers.get("Content-Encoding") { + match content_encoding.to_str().unwrap_or_default() { + "gzip" => { + let mut enc = GzEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + "deflate" => { + let mut enc = ZlibEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + "zstd1" => { + let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap(); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + _ => { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + } else { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + match serde_json::from_str::(&local_content) { + Ok(e) => { + return Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: Some(e), + }) + } + Err(e) => return Err(datadog::Error::Serde(e)), + }; + } else { + let local_entity: Option = + serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } + + /// Create or update a form version. + pub async fn upsert_form_version( + &self, + form_id: uuid::Uuid, + body: crate::datadogV2::model::FormVersionRequest, + ) -> Result> + { + match self.upsert_form_version_with_http_info(form_id, body).await { + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(datadog::Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } + Err(err) => Err(err), + } + } + + /// Create or update a form version. + pub async fn upsert_form_version_with_http_info( + &self, + form_id: uuid::Uuid, + body: crate::datadogV2::model::FormVersionRequest, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.upsert_form_version"; + if local_configuration.is_unstable_operation_enabled(operation_id) { + warn!("Using unstable operation {operation_id}"); + } else { + let local_error = datadog::UnstableOperationDisabledError { + msg: "Operation 'v2.upsert_form_version' is not enabled".to_string(), + }; + return Err(datadog::Error::UnstableOperationDisabledError(local_error)); + } + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/forms/{form_id}/versions", + local_configuration.get_operation_host(operation_id), + form_id = datadog::urlencode(form_id.to_string()) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::POST, local_uri_str.as_str()); + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Content-Type", HeaderValue::from_static("application/json")); + headers.insert("Accept", HeaderValue::from_static("application/json")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + // build body parameters + let output = Vec::new(); + let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter); + if body.serialize(&mut ser).is_ok() { + if let Some(content_encoding) = headers.get("Content-Encoding") { + match content_encoding.to_str().unwrap_or_default() { + "gzip" => { + let mut enc = GzEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + "deflate" => { + let mut enc = ZlibEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + "zstd1" => { + let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap(); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + _ => { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + } else { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + match serde_json::from_str::( + &local_content, + ) { + Ok(e) => { + return Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: Some(e), + }) + } + Err(e) => return Err(datadog::Error::Serde(e)), + }; + } else { + let local_entity: Option = + serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } +} diff --git a/src/datadogV2/api/mod.rs b/src/datadogV2/api/mod.rs index f8867efe4..909257297 100644 --- a/src/datadogV2/api/mod.rs +++ b/src/datadogV2/api/mod.rs @@ -40,6 +40,7 @@ pub mod api_error_tracking; pub mod api_events; pub mod api_fastly_integration; pub mod api_fleet_automation; +pub mod api_forms; pub mod api_gcp_integration; pub mod api_high_availability_multi_region; pub mod api_incident_services; diff --git a/src/datadogV2/mod.rs b/src/datadogV2/mod.rs index e48711eba..47e6f0c58 100644 --- a/src/datadogV2/mod.rs +++ b/src/datadogV2/mod.rs @@ -41,6 +41,7 @@ pub use self::api::api_error_tracking; pub use self::api::api_events; pub use self::api::api_fastly_integration; pub use self::api::api_fleet_automation; +pub use self::api::api_forms; pub use self::api::api_gcp_integration; pub use self::api::api_high_availability_multi_region; pub use self::api::api_incident_services; diff --git a/src/datadogV2/model/mod.rs b/src/datadogV2/model/mod.rs index fe22fa38b..5cb61e63d 100644 --- a/src/datadogV2/model/mod.rs +++ b/src/datadogV2/model/mod.rs @@ -2778,6 +2778,78 @@ pub mod model_alert_event_attributes_status; pub use self::model_alert_event_attributes_status::AlertEventAttributesStatus; pub mod model_v2_event_attributes_attributes; pub use self::model_v2_event_attributes_attributes::V2EventAttributesAttributes; +pub mod model_forms_list_response; +pub use self::model_forms_list_response::FormsListResponse; +pub mod model_form_data_response; +pub use self::model_form_data_response::FormDataResponse; +pub mod model_form_data_attributes_response; +pub use self::model_form_data_attributes_response::FormDataAttributesResponse; +pub mod model_form_datastore_config; +pub use self::model_form_datastore_config::FormDatastoreConfig; +pub mod model_form_publication; +pub use self::model_form_publication::FormPublication; +pub mod model_form_version; +pub use self::model_form_version::FormVersion; +pub mod model_form_version_state; +pub use self::model_form_version_state::FormVersionState; +pub mod model_form_type; +pub use self::model_form_type::FormType; +pub mod model_form_create_request; +pub use self::model_form_create_request::FormCreateRequest; +pub mod model_form_data_request; +pub use self::model_form_data_request::FormDataRequest; +pub mod model_form_data_attributes_request; +pub use self::model_form_data_attributes_request::FormDataAttributesRequest; +pub mod model_form_response; +pub use self::model_form_response::FormResponse; +pub mod model_form_update_request; +pub use self::model_form_update_request::FormUpdateRequest; +pub mod model_form_update_data_request; +pub use self::model_form_update_data_request::FormUpdateDataRequest; +pub mod model_form_update_attributes; +pub use self::model_form_update_attributes::FormUpdateAttributes; +pub mod model_form_update_attributes_form_update; +pub use self::model_form_update_attributes_form_update::FormUpdateAttributesFormUpdate; +pub mod model_form_publication_request; +pub use self::model_form_publication_request::FormPublicationRequest; +pub mod model_form_publication_data_request; +pub use self::model_form_publication_data_request::FormPublicationDataRequest; +pub mod model_form_publication_attributes; +pub use self::model_form_publication_attributes::FormPublicationAttributes; +pub mod model_form_publication_type; +pub use self::model_form_publication_type::FormPublicationType; +pub mod model_form_publication_response; +pub use self::model_form_publication_response::FormPublicationResponse; +pub mod model_form_publication_data_response; +pub use self::model_form_publication_data_response::FormPublicationDataResponse; +pub mod model_form_submission_request; +pub use self::model_form_submission_request::FormSubmissionRequest; +pub mod model_form_submission_data_request; +pub use self::model_form_submission_data_request::FormSubmissionDataRequest; +pub mod model_form_submission_attributes; +pub use self::model_form_submission_attributes::FormSubmissionAttributes; +pub mod model_form_submission_type; +pub use self::model_form_submission_type::FormSubmissionType; +pub mod model_form_submission_response; +pub use self::model_form_submission_response::FormSubmissionResponse; +pub mod model_form_submission_data_response; +pub use self::model_form_submission_data_response::FormSubmissionDataResponse; +pub mod model_form_version_request; +pub use self::model_form_version_request::FormVersionRequest; +pub mod model_form_version_data_request; +pub use self::model_form_version_data_request::FormVersionDataRequest; +pub mod model_form_version_attributes; +pub use self::model_form_version_attributes::FormVersionAttributes; +pub mod model_form_version_upsert_params; +pub use self::model_form_version_upsert_params::FormVersionUpsertParams; +pub mod model_form_version_type; +pub use self::model_form_version_type::FormVersionType; +pub mod model_form_version_response; +pub use self::model_form_version_response::FormVersionResponse; +pub mod model_form_version_data_response; +pub use self::model_form_version_data_response::FormVersionDataResponse; +pub mod model_form_version_data_attributes_response; +pub use self::model_form_version_data_attributes_response::FormVersionDataAttributesResponse; pub mod model_hamr_org_connection_response; pub use self::model_hamr_org_connection_response::HamrOrgConnectionResponse; pub mod model_hamr_org_connection_data_response; diff --git a/src/datadogV2/model/model_form_create_request.rs b/src/datadogV2/model/model_form_create_request.rs new file mode 100644 index 000000000..c25ec2380 --- /dev/null +++ b/src/datadogV2/model/model_form_create_request.rs @@ -0,0 +1,91 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Request for creating a form. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct FormCreateRequest { + #[serde(rename = "data")] + pub data: crate::datadogV2::model::FormDataRequest, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl FormCreateRequest { + pub fn new(data: crate::datadogV2::model::FormDataRequest) -> FormCreateRequest { + FormCreateRequest { + data, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for FormCreateRequest { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct FormCreateRequestVisitor; + impl<'a> Visitor<'a> for FormCreateRequestVisitor { + type Value = FormCreateRequest; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "data" => { + data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let data = data.ok_or_else(|| M::Error::missing_field("data"))?; + + let content = FormCreateRequest { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(FormCreateRequestVisitor) + } +} diff --git a/src/datadogV2/model/model_form_data_attributes_request.rs b/src/datadogV2/model/model_form_data_attributes_request.rs new file mode 100644 index 000000000..2bf477a56 --- /dev/null +++ b/src/datadogV2/model/model_form_data_attributes_request.rs @@ -0,0 +1,137 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Attributes for creating a form. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct FormDataAttributesRequest { + /// The data definition for the form. + #[serde(rename = "data_definition")] + pub data_definition: std::collections::BTreeMap, + /// The description of the form. + #[serde(rename = "description")] + pub description: String, + /// The name of the form. + #[serde(rename = "name")] + pub name: String, + /// The UI definition for the form. + #[serde(rename = "ui_definition")] + pub ui_definition: std::collections::BTreeMap, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl FormDataAttributesRequest { + pub fn new( + data_definition: std::collections::BTreeMap, + description: String, + name: String, + ui_definition: std::collections::BTreeMap, + ) -> FormDataAttributesRequest { + FormDataAttributesRequest { + data_definition, + description, + name, + ui_definition, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for FormDataAttributesRequest { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct FormDataAttributesRequestVisitor; + impl<'a> Visitor<'a> for FormDataAttributesRequestVisitor { + type Value = FormDataAttributesRequest; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data_definition: Option< + std::collections::BTreeMap, + > = None; + let mut description: Option = None; + let mut name: Option = None; + let mut ui_definition: Option< + std::collections::BTreeMap, + > = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "data_definition" => { + data_definition = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "description" => { + description = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "name" => { + name = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "ui_definition" => { + ui_definition = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let data_definition = + data_definition.ok_or_else(|| M::Error::missing_field("data_definition"))?; + let description = + description.ok_or_else(|| M::Error::missing_field("description"))?; + let name = name.ok_or_else(|| M::Error::missing_field("name"))?; + let ui_definition = + ui_definition.ok_or_else(|| M::Error::missing_field("ui_definition"))?; + + let content = FormDataAttributesRequest { + data_definition, + description, + name, + ui_definition, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(FormDataAttributesRequestVisitor) + } +} diff --git a/src/datadogV2/model/model_form_data_attributes_response.rs b/src/datadogV2/model/model_form_data_attributes_response.rs new file mode 100644 index 000000000..9b8430702 --- /dev/null +++ b/src/datadogV2/model/model_form_data_attributes_response.rs @@ -0,0 +1,213 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Attributes of a form. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct FormDataAttributesResponse { + /// Creation timestamp. + #[serde(rename = "created_at")] + pub created_at: chrono::DateTime, + /// Configuration for the form's associated datastore. + #[serde(rename = "datastore_config")] + pub datastore_config: crate::datadogV2::model::FormDatastoreConfig, + /// The description of the form. + #[serde(rename = "description")] + pub description: String, + /// Last modification timestamp. + #[serde(rename = "modified_at")] + pub modified_at: chrono::DateTime, + /// The name of the form. + #[serde(rename = "name")] + pub name: String, + /// The organization ID. + #[serde(rename = "org_id")] + pub org_id: i64, + /// Publication information for the form. + #[serde(rename = "publication")] + pub publication: Option, + /// The ID of the user who created the form. + #[serde(rename = "user_id")] + pub user_id: i64, + /// The UUID of the user who created the form. + #[serde(rename = "user_uuid")] + pub user_uuid: uuid::Uuid, + /// Version information for the form. + #[serde(rename = "version")] + pub version: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl FormDataAttributesResponse { + pub fn new( + created_at: chrono::DateTime, + datastore_config: crate::datadogV2::model::FormDatastoreConfig, + description: String, + modified_at: chrono::DateTime, + name: String, + org_id: i64, + user_id: i64, + user_uuid: uuid::Uuid, + ) -> FormDataAttributesResponse { + FormDataAttributesResponse { + created_at, + datastore_config, + description, + modified_at, + name, + org_id, + publication: None, + user_id, + user_uuid, + version: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn publication(mut self, value: crate::datadogV2::model::FormPublication) -> Self { + self.publication = Some(value); + self + } + + pub fn version(mut self, value: crate::datadogV2::model::FormVersion) -> Self { + self.version = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for FormDataAttributesResponse { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct FormDataAttributesResponseVisitor; + impl<'a> Visitor<'a> for FormDataAttributesResponseVisitor { + type Value = FormDataAttributesResponse; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut created_at: Option> = None; + let mut datastore_config: Option = + None; + let mut description: Option = None; + let mut modified_at: Option> = None; + let mut name: Option = None; + let mut org_id: Option = None; + let mut publication: Option = None; + let mut user_id: Option = None; + let mut user_uuid: Option = None; + let mut version: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "created_at" => { + created_at = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "datastore_config" => { + datastore_config = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "description" => { + description = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "modified_at" => { + modified_at = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "name" => { + name = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "org_id" => { + org_id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "publication" => { + if v.is_null() { + continue; + } + publication = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "user_id" => { + user_id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "user_uuid" => { + user_uuid = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "version" => { + if v.is_null() { + continue; + } + version = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let created_at = created_at.ok_or_else(|| M::Error::missing_field("created_at"))?; + let datastore_config = + datastore_config.ok_or_else(|| M::Error::missing_field("datastore_config"))?; + let description = + description.ok_or_else(|| M::Error::missing_field("description"))?; + let modified_at = + modified_at.ok_or_else(|| M::Error::missing_field("modified_at"))?; + let name = name.ok_or_else(|| M::Error::missing_field("name"))?; + let org_id = org_id.ok_or_else(|| M::Error::missing_field("org_id"))?; + let user_id = user_id.ok_or_else(|| M::Error::missing_field("user_id"))?; + let user_uuid = user_uuid.ok_or_else(|| M::Error::missing_field("user_uuid"))?; + + let content = FormDataAttributesResponse { + created_at, + datastore_config, + description, + modified_at, + name, + org_id, + publication, + user_id, + user_uuid, + version, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(FormDataAttributesResponseVisitor) + } +} diff --git a/src/datadogV2/model/model_form_data_request.rs b/src/datadogV2/model/model_form_data_request.rs new file mode 100644 index 000000000..360d05c25 --- /dev/null +++ b/src/datadogV2/model/model_form_data_request.rs @@ -0,0 +1,130 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct FormDataRequest { + /// Attributes for creating a form. + #[serde(rename = "attributes")] + pub attributes: crate::datadogV2::model::FormDataAttributesRequest, + /// The form identifier. + #[serde(rename = "id")] + pub id: Option, + /// Type for forms. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::FormType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl FormDataRequest { + pub fn new( + attributes: crate::datadogV2::model::FormDataAttributesRequest, + type_: crate::datadogV2::model::FormType, + ) -> FormDataRequest { + FormDataRequest { + attributes, + id: None, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn id(mut self, value: uuid::Uuid) -> Self { + self.id = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for FormDataRequest { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct FormDataRequestVisitor; + impl<'a> Visitor<'a> for FormDataRequestVisitor { + type Value = FormDataRequest; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut attributes: Option = + None; + let mut id: Option = None; + let mut type_: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "attributes" => { + attributes = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "id" => { + if v.is_null() { + continue; + } + id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::FormType::UnparsedObject(_type_) => { + _unparsed = true; + } + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let attributes = attributes.ok_or_else(|| M::Error::missing_field("attributes"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = FormDataRequest { + attributes, + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(FormDataRequestVisitor) + } +} diff --git a/src/datadogV2/model/model_form_data_response.rs b/src/datadogV2/model/model_form_data_response.rs new file mode 100644 index 000000000..3cb3ec06b --- /dev/null +++ b/src/datadogV2/model/model_form_data_response.rs @@ -0,0 +1,124 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct FormDataResponse { + /// Attributes of a form. + #[serde(rename = "attributes")] + pub attributes: crate::datadogV2::model::FormDataAttributesResponse, + /// The form identifier. + #[serde(rename = "id")] + pub id: uuid::Uuid, + /// Type for forms. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::FormType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl FormDataResponse { + pub fn new( + attributes: crate::datadogV2::model::FormDataAttributesResponse, + id: uuid::Uuid, + type_: crate::datadogV2::model::FormType, + ) -> FormDataResponse { + FormDataResponse { + attributes, + id, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for FormDataResponse { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct FormDataResponseVisitor; + impl<'a> Visitor<'a> for FormDataResponseVisitor { + type Value = FormDataResponse; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut attributes: Option = + None; + let mut id: Option = None; + let mut type_: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "attributes" => { + attributes = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "id" => { + id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::FormType::UnparsedObject(_type_) => { + _unparsed = true; + } + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let attributes = attributes.ok_or_else(|| M::Error::missing_field("attributes"))?; + let id = id.ok_or_else(|| M::Error::missing_field("id"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = FormDataResponse { + attributes, + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(FormDataResponseVisitor) + } +} diff --git a/src/datadogV2/model/model_form_datastore_config.rs b/src/datadogV2/model/model_form_datastore_config.rs new file mode 100644 index 000000000..1f94f2fb2 --- /dev/null +++ b/src/datadogV2/model/model_form_datastore_config.rs @@ -0,0 +1,122 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Configuration for the form's associated datastore. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct FormDatastoreConfig { + /// The unique identifier of the datastore. + #[serde(rename = "datastore_id")] + pub datastore_id: uuid::Uuid, + /// The name of the primary key column. + #[serde(rename = "primary_column_name")] + pub primary_column_name: String, + /// The strategy used for generating primary keys. + #[serde(rename = "primary_key_generation_strategy")] + pub primary_key_generation_strategy: String, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl FormDatastoreConfig { + pub fn new( + datastore_id: uuid::Uuid, + primary_column_name: String, + primary_key_generation_strategy: String, + ) -> FormDatastoreConfig { + FormDatastoreConfig { + datastore_id, + primary_column_name, + primary_key_generation_strategy, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for FormDatastoreConfig { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct FormDatastoreConfigVisitor; + impl<'a> Visitor<'a> for FormDatastoreConfigVisitor { + type Value = FormDatastoreConfig; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut datastore_id: Option = None; + let mut primary_column_name: Option = None; + let mut primary_key_generation_strategy: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "datastore_id" => { + datastore_id = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "primary_column_name" => { + primary_column_name = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "primary_key_generation_strategy" => { + primary_key_generation_strategy = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let datastore_id = + datastore_id.ok_or_else(|| M::Error::missing_field("datastore_id"))?; + let primary_column_name = primary_column_name + .ok_or_else(|| M::Error::missing_field("primary_column_name"))?; + let primary_key_generation_strategy = primary_key_generation_strategy + .ok_or_else(|| M::Error::missing_field("primary_key_generation_strategy"))?; + + let content = FormDatastoreConfig { + datastore_id, + primary_column_name, + primary_key_generation_strategy, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(FormDatastoreConfigVisitor) + } +} diff --git a/src/datadogV2/model/model_form_publication.rs b/src/datadogV2/model/model_form_publication.rs new file mode 100644 index 000000000..534d30bd5 --- /dev/null +++ b/src/datadogV2/model/model_form_publication.rs @@ -0,0 +1,198 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Publication information for the form. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct FormPublication { + /// Creation timestamp. + #[serde(rename = "created_at")] + pub created_at: chrono::DateTime, + /// The form identifier. + #[serde(rename = "form_id")] + pub form_id: uuid::Uuid, + /// The version of the form that was published. + #[serde(rename = "form_version")] + pub form_version: Option, + /// The unique identifier of the publication. + #[serde(rename = "id")] + pub id: String, + /// Last modification timestamp. + #[serde(rename = "modified_at")] + pub modified_at: chrono::DateTime, + /// The organization ID. + #[serde(rename = "org_id")] + pub org_id: i64, + /// The publication sequence number. + #[serde(rename = "publish_seq")] + pub publish_seq: Option, + /// The ID of the user who published. + #[serde(rename = "user_id")] + pub user_id: i64, + /// The UUID of the user who published. + #[serde(rename = "user_uuid")] + pub user_uuid: uuid::Uuid, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl FormPublication { + pub fn new( + created_at: chrono::DateTime, + form_id: uuid::Uuid, + id: String, + modified_at: chrono::DateTime, + org_id: i64, + user_id: i64, + user_uuid: uuid::Uuid, + ) -> FormPublication { + FormPublication { + created_at, + form_id, + form_version: None, + id, + modified_at, + org_id, + publish_seq: None, + user_id, + user_uuid, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn form_version(mut self, value: i64) -> Self { + self.form_version = Some(value); + self + } + + pub fn publish_seq(mut self, value: i64) -> Self { + self.publish_seq = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for FormPublication { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct FormPublicationVisitor; + impl<'a> Visitor<'a> for FormPublicationVisitor { + type Value = FormPublication; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut created_at: Option> = None; + let mut form_id: Option = None; + let mut form_version: Option = None; + let mut id: Option = None; + let mut modified_at: Option> = None; + let mut org_id: Option = None; + let mut publish_seq: Option = None; + let mut user_id: Option = None; + let mut user_uuid: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "created_at" => { + created_at = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "form_id" => { + form_id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "form_version" => { + if v.is_null() { + continue; + } + form_version = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "id" => { + id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "modified_at" => { + modified_at = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "org_id" => { + org_id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "publish_seq" => { + if v.is_null() { + continue; + } + publish_seq = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "user_id" => { + user_id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "user_uuid" => { + user_uuid = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let created_at = created_at.ok_or_else(|| M::Error::missing_field("created_at"))?; + let form_id = form_id.ok_or_else(|| M::Error::missing_field("form_id"))?; + let id = id.ok_or_else(|| M::Error::missing_field("id"))?; + let modified_at = + modified_at.ok_or_else(|| M::Error::missing_field("modified_at"))?; + let org_id = org_id.ok_or_else(|| M::Error::missing_field("org_id"))?; + let user_id = user_id.ok_or_else(|| M::Error::missing_field("user_id"))?; + let user_uuid = user_uuid.ok_or_else(|| M::Error::missing_field("user_uuid"))?; + + let content = FormPublication { + created_at, + form_id, + form_version, + id, + modified_at, + org_id, + publish_seq, + user_id, + user_uuid, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(FormPublicationVisitor) + } +} diff --git a/src/datadogV2/model/model_form_publication_attributes.rs b/src/datadogV2/model/model_form_publication_attributes.rs new file mode 100644 index 000000000..241d73d34 --- /dev/null +++ b/src/datadogV2/model/model_form_publication_attributes.rs @@ -0,0 +1,91 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct FormPublicationAttributes { + /// The version number to publish. + #[serde(rename = "version")] + pub version: i64, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl FormPublicationAttributes { + pub fn new(version: i64) -> FormPublicationAttributes { + FormPublicationAttributes { + version, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for FormPublicationAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct FormPublicationAttributesVisitor; + impl<'a> Visitor<'a> for FormPublicationAttributesVisitor { + type Value = FormPublicationAttributes; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut version: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "version" => { + version = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let version = version.ok_or_else(|| M::Error::missing_field("version"))?; + + let content = FormPublicationAttributes { + version, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(FormPublicationAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_form_publication_data_request.rs b/src/datadogV2/model/model_form_publication_data_request.rs new file mode 100644 index 000000000..7eba1378d --- /dev/null +++ b/src/datadogV2/model/model_form_publication_data_request.rs @@ -0,0 +1,112 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct FormPublicationDataRequest { + #[serde(rename = "attributes")] + pub attributes: crate::datadogV2::model::FormPublicationAttributes, + /// Type for form publications. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::FormPublicationType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl FormPublicationDataRequest { + pub fn new( + attributes: crate::datadogV2::model::FormPublicationAttributes, + type_: crate::datadogV2::model::FormPublicationType, + ) -> FormPublicationDataRequest { + FormPublicationDataRequest { + attributes, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for FormPublicationDataRequest { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct FormPublicationDataRequestVisitor; + impl<'a> Visitor<'a> for FormPublicationDataRequestVisitor { + type Value = FormPublicationDataRequest; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut attributes: Option = + None; + let mut type_: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "attributes" => { + attributes = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::FormPublicationType::UnparsedObject(_type_) => { + _unparsed = true; + }, + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let attributes = attributes.ok_or_else(|| M::Error::missing_field("attributes"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = FormPublicationDataRequest { + attributes, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(FormPublicationDataRequestVisitor) + } +} diff --git a/src/datadogV2/model/model_form_publication_data_response.rs b/src/datadogV2/model/model_form_publication_data_response.rs new file mode 100644 index 000000000..05c5146d0 --- /dev/null +++ b/src/datadogV2/model/model_form_publication_data_response.rs @@ -0,0 +1,123 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct FormPublicationDataResponse { + /// Publication information for the form. + #[serde(rename = "attributes")] + pub attributes: crate::datadogV2::model::FormPublication, + /// The publication identifier. + #[serde(rename = "id")] + pub id: String, + /// Type for form publications. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::FormPublicationType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl FormPublicationDataResponse { + pub fn new( + attributes: crate::datadogV2::model::FormPublication, + id: String, + type_: crate::datadogV2::model::FormPublicationType, + ) -> FormPublicationDataResponse { + FormPublicationDataResponse { + attributes, + id, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for FormPublicationDataResponse { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct FormPublicationDataResponseVisitor; + impl<'a> Visitor<'a> for FormPublicationDataResponseVisitor { + type Value = FormPublicationDataResponse; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut attributes: Option = None; + let mut id: Option = None; + let mut type_: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "attributes" => { + attributes = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "id" => { + id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::FormPublicationType::UnparsedObject(_type_) => { + _unparsed = true; + }, + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let attributes = attributes.ok_or_else(|| M::Error::missing_field("attributes"))?; + let id = id.ok_or_else(|| M::Error::missing_field("id"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = FormPublicationDataResponse { + attributes, + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(FormPublicationDataResponseVisitor) + } +} diff --git a/src/datadogV2/model/model_form_publication_request.rs b/src/datadogV2/model/model_form_publication_request.rs new file mode 100644 index 000000000..7cdc7177e --- /dev/null +++ b/src/datadogV2/model/model_form_publication_request.rs @@ -0,0 +1,93 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Request for publishing a form. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct FormPublicationRequest { + #[serde(rename = "data")] + pub data: crate::datadogV2::model::FormPublicationDataRequest, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl FormPublicationRequest { + pub fn new( + data: crate::datadogV2::model::FormPublicationDataRequest, + ) -> FormPublicationRequest { + FormPublicationRequest { + data, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for FormPublicationRequest { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct FormPublicationRequestVisitor; + impl<'a> Visitor<'a> for FormPublicationRequestVisitor { + type Value = FormPublicationRequest; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "data" => { + data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let data = data.ok_or_else(|| M::Error::missing_field("data"))?; + + let content = FormPublicationRequest { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(FormPublicationRequestVisitor) + } +} diff --git a/src/datadogV2/model/model_form_publication_response.rs b/src/datadogV2/model/model_form_publication_response.rs new file mode 100644 index 000000000..3831d0243 --- /dev/null +++ b/src/datadogV2/model/model_form_publication_response.rs @@ -0,0 +1,93 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Response for a form publication. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct FormPublicationResponse { + #[serde(rename = "data")] + pub data: crate::datadogV2::model::FormPublicationDataResponse, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl FormPublicationResponse { + pub fn new( + data: crate::datadogV2::model::FormPublicationDataResponse, + ) -> FormPublicationResponse { + FormPublicationResponse { + data, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for FormPublicationResponse { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct FormPublicationResponseVisitor; + impl<'a> Visitor<'a> for FormPublicationResponseVisitor { + type Value = FormPublicationResponse; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "data" => { + data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let data = data.ok_or_else(|| M::Error::missing_field("data"))?; + + let content = FormPublicationResponse { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(FormPublicationResponseVisitor) + } +} diff --git a/src/datadogV2/model/model_form_publication_type.rs b/src/datadogV2/model/model_form_publication_type.rs new file mode 100644 index 000000000..a3a80779a --- /dev/null +++ b/src/datadogV2/model/model_form_publication_type.rs @@ -0,0 +1,48 @@ +// 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. + +use serde::{Deserialize, Deserializer, Serialize, Serializer}; + +#[non_exhaustive] +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum FormPublicationType { + FORM_PUBLICATIONS, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for FormPublicationType { + fn to_string(&self) -> String { + match self { + Self::FORM_PUBLICATIONS => String::from("form_publications"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for FormPublicationType { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match self { + Self::UnparsedObject(v) => v.serialize(serializer), + _ => serializer.serialize_str(self.to_string().as_str()), + } + } +} + +impl<'de> Deserialize<'de> for FormPublicationType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "form_publications" => Self::FORM_PUBLICATIONS, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_form_response.rs b/src/datadogV2/model/model_form_response.rs new file mode 100644 index 000000000..f8f465750 --- /dev/null +++ b/src/datadogV2/model/model_form_response.rs @@ -0,0 +1,91 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Response containing a single form. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct FormResponse { + #[serde(rename = "data")] + pub data: crate::datadogV2::model::FormDataResponse, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl FormResponse { + pub fn new(data: crate::datadogV2::model::FormDataResponse) -> FormResponse { + FormResponse { + data, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for FormResponse { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct FormResponseVisitor; + impl<'a> Visitor<'a> for FormResponseVisitor { + type Value = FormResponse; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "data" => { + data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let data = data.ok_or_else(|| M::Error::missing_field("data"))?; + + let content = FormResponse { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(FormResponseVisitor) + } +} diff --git a/src/datadogV2/model/model_form_submission_attributes.rs b/src/datadogV2/model/model_form_submission_attributes.rs new file mode 100644 index 000000000..d3bda3bc7 --- /dev/null +++ b/src/datadogV2/model/model_form_submission_attributes.rs @@ -0,0 +1,97 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct FormSubmissionAttributes { + /// The data submitted with the form. + #[serde(rename = "submission_data")] + pub submission_data: std::collections::BTreeMap, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl FormSubmissionAttributes { + pub fn new( + submission_data: std::collections::BTreeMap, + ) -> FormSubmissionAttributes { + FormSubmissionAttributes { + submission_data, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for FormSubmissionAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct FormSubmissionAttributesVisitor; + impl<'a> Visitor<'a> for FormSubmissionAttributesVisitor { + type Value = FormSubmissionAttributes; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut submission_data: Option< + std::collections::BTreeMap, + > = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "submission_data" => { + submission_data = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let submission_data = + submission_data.ok_or_else(|| M::Error::missing_field("submission_data"))?; + + let content = FormSubmissionAttributes { + submission_data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(FormSubmissionAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_form_submission_data_request.rs b/src/datadogV2/model/model_form_submission_data_request.rs new file mode 100644 index 000000000..2ba3ffd72 --- /dev/null +++ b/src/datadogV2/model/model_form_submission_data_request.rs @@ -0,0 +1,114 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct FormSubmissionDataRequest { + #[serde(rename = "attributes")] + pub attributes: crate::datadogV2::model::FormSubmissionAttributes, + /// Type for form submissions. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::FormSubmissionType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl FormSubmissionDataRequest { + pub fn new( + attributes: crate::datadogV2::model::FormSubmissionAttributes, + type_: crate::datadogV2::model::FormSubmissionType, + ) -> FormSubmissionDataRequest { + FormSubmissionDataRequest { + attributes, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for FormSubmissionDataRequest { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct FormSubmissionDataRequestVisitor; + impl<'a> Visitor<'a> for FormSubmissionDataRequestVisitor { + type Value = FormSubmissionDataRequest; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut attributes: Option = + None; + let mut type_: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "attributes" => { + attributes = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::FormSubmissionType::UnparsedObject( + _type_, + ) => { + _unparsed = true; + } + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let attributes = attributes.ok_or_else(|| M::Error::missing_field("attributes"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = FormSubmissionDataRequest { + attributes, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(FormSubmissionDataRequestVisitor) + } +} diff --git a/src/datadogV2/model/model_form_submission_data_response.rs b/src/datadogV2/model/model_form_submission_data_response.rs new file mode 100644 index 000000000..e99e8c4c4 --- /dev/null +++ b/src/datadogV2/model/model_form_submission_data_response.rs @@ -0,0 +1,114 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct FormSubmissionDataResponse { + /// The submission identifier. + #[serde(rename = "id")] + pub id: uuid::Uuid, + /// Type for form submissions. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::FormSubmissionType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl FormSubmissionDataResponse { + pub fn new( + id: uuid::Uuid, + type_: crate::datadogV2::model::FormSubmissionType, + ) -> FormSubmissionDataResponse { + FormSubmissionDataResponse { + id, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for FormSubmissionDataResponse { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct FormSubmissionDataResponseVisitor; + impl<'a> Visitor<'a> for FormSubmissionDataResponseVisitor { + type Value = FormSubmissionDataResponse; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut id: Option = None; + let mut type_: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "id" => { + id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::FormSubmissionType::UnparsedObject( + _type_, + ) => { + _unparsed = true; + } + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let id = id.ok_or_else(|| M::Error::missing_field("id"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = FormSubmissionDataResponse { + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(FormSubmissionDataResponseVisitor) + } +} diff --git a/src/datadogV2/model/model_form_submission_request.rs b/src/datadogV2/model/model_form_submission_request.rs new file mode 100644 index 000000000..d80decc79 --- /dev/null +++ b/src/datadogV2/model/model_form_submission_request.rs @@ -0,0 +1,91 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Request for submitting a form. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct FormSubmissionRequest { + #[serde(rename = "data")] + pub data: crate::datadogV2::model::FormSubmissionDataRequest, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl FormSubmissionRequest { + pub fn new(data: crate::datadogV2::model::FormSubmissionDataRequest) -> FormSubmissionRequest { + FormSubmissionRequest { + data, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for FormSubmissionRequest { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct FormSubmissionRequestVisitor; + impl<'a> Visitor<'a> for FormSubmissionRequestVisitor { + type Value = FormSubmissionRequest; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "data" => { + data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let data = data.ok_or_else(|| M::Error::missing_field("data"))?; + + let content = FormSubmissionRequest { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(FormSubmissionRequestVisitor) + } +} diff --git a/src/datadogV2/model/model_form_submission_response.rs b/src/datadogV2/model/model_form_submission_response.rs new file mode 100644 index 000000000..70cb12586 --- /dev/null +++ b/src/datadogV2/model/model_form_submission_response.rs @@ -0,0 +1,93 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Response for a form submission. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct FormSubmissionResponse { + #[serde(rename = "data")] + pub data: crate::datadogV2::model::FormSubmissionDataResponse, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl FormSubmissionResponse { + pub fn new( + data: crate::datadogV2::model::FormSubmissionDataResponse, + ) -> FormSubmissionResponse { + FormSubmissionResponse { + data, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for FormSubmissionResponse { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct FormSubmissionResponseVisitor; + impl<'a> Visitor<'a> for FormSubmissionResponseVisitor { + type Value = FormSubmissionResponse; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "data" => { + data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let data = data.ok_or_else(|| M::Error::missing_field("data"))?; + + let content = FormSubmissionResponse { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(FormSubmissionResponseVisitor) + } +} diff --git a/src/datadogV2/model/model_form_submission_type.rs b/src/datadogV2/model/model_form_submission_type.rs new file mode 100644 index 000000000..e7692e242 --- /dev/null +++ b/src/datadogV2/model/model_form_submission_type.rs @@ -0,0 +1,48 @@ +// 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. + +use serde::{Deserialize, Deserializer, Serialize, Serializer}; + +#[non_exhaustive] +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum FormSubmissionType { + FORM_SUBMISSIONS, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for FormSubmissionType { + fn to_string(&self) -> String { + match self { + Self::FORM_SUBMISSIONS => String::from("form_submissions"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for FormSubmissionType { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match self { + Self::UnparsedObject(v) => v.serialize(serializer), + _ => serializer.serialize_str(self.to_string().as_str()), + } + } +} + +impl<'de> Deserialize<'de> for FormSubmissionType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "form_submissions" => Self::FORM_SUBMISSIONS, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_form_type.rs b/src/datadogV2/model/model_form_type.rs new file mode 100644 index 000000000..138565212 --- /dev/null +++ b/src/datadogV2/model/model_form_type.rs @@ -0,0 +1,48 @@ +// 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. + +use serde::{Deserialize, Deserializer, Serialize, Serializer}; + +#[non_exhaustive] +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum FormType { + FORMS, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for FormType { + fn to_string(&self) -> String { + match self { + Self::FORMS => String::from("forms"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for FormType { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match self { + Self::UnparsedObject(v) => v.serialize(serializer), + _ => serializer.serialize_str(self.to_string().as_str()), + } + } +} + +impl<'de> Deserialize<'de> for FormType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "forms" => Self::FORMS, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_form_update_attributes.rs b/src/datadogV2/model/model_form_update_attributes.rs new file mode 100644 index 000000000..5f27cc6e2 --- /dev/null +++ b/src/datadogV2/model/model_form_update_attributes.rs @@ -0,0 +1,111 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Attributes for updating a form. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct FormUpdateAttributes { + /// Update parameters for the form. + #[serde(rename = "form_update")] + pub form_update: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl FormUpdateAttributes { + pub fn new() -> FormUpdateAttributes { + FormUpdateAttributes { + form_update: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn form_update( + mut self, + value: crate::datadogV2::model::FormUpdateAttributesFormUpdate, + ) -> Self { + self.form_update = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for FormUpdateAttributes { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for FormUpdateAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct FormUpdateAttributesVisitor; + impl<'a> Visitor<'a> for FormUpdateAttributesVisitor { + type Value = FormUpdateAttributes; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut form_update: Option< + crate::datadogV2::model::FormUpdateAttributesFormUpdate, + > = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "form_update" => { + if v.is_null() { + continue; + } + form_update = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = FormUpdateAttributes { + form_update, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(FormUpdateAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_form_update_attributes_form_update.rs b/src/datadogV2/model/model_form_update_attributes_form_update.rs new file mode 100644 index 000000000..c8eb2cdee --- /dev/null +++ b/src/datadogV2/model/model_form_update_attributes_form_update.rs @@ -0,0 +1,123 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Update parameters for the form. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct FormUpdateAttributesFormUpdate { + /// The updated description of the form. + #[serde(rename = "description")] + pub description: Option, + /// The updated name of the form. + #[serde(rename = "name")] + pub name: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl FormUpdateAttributesFormUpdate { + pub fn new() -> FormUpdateAttributesFormUpdate { + FormUpdateAttributesFormUpdate { + description: None, + name: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn description(mut self, value: String) -> Self { + self.description = Some(value); + self + } + + pub fn name(mut self, value: String) -> Self { + self.name = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for FormUpdateAttributesFormUpdate { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for FormUpdateAttributesFormUpdate { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct FormUpdateAttributesFormUpdateVisitor; + impl<'a> Visitor<'a> for FormUpdateAttributesFormUpdateVisitor { + type Value = FormUpdateAttributesFormUpdate; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut description: Option = None; + let mut name: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "description" => { + if v.is_null() { + continue; + } + description = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "name" => { + if v.is_null() { + continue; + } + name = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = FormUpdateAttributesFormUpdate { + description, + name, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(FormUpdateAttributesFormUpdateVisitor) + } +} diff --git a/src/datadogV2/model/model_form_update_data_request.rs b/src/datadogV2/model/model_form_update_data_request.rs new file mode 100644 index 000000000..8ccf9fd28 --- /dev/null +++ b/src/datadogV2/model/model_form_update_data_request.rs @@ -0,0 +1,129 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct FormUpdateDataRequest { + /// Attributes for updating a form. + #[serde(rename = "attributes")] + pub attributes: crate::datadogV2::model::FormUpdateAttributes, + /// The form identifier. + #[serde(rename = "id")] + pub id: Option, + /// Type for forms. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::FormType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl FormUpdateDataRequest { + pub fn new( + attributes: crate::datadogV2::model::FormUpdateAttributes, + type_: crate::datadogV2::model::FormType, + ) -> FormUpdateDataRequest { + FormUpdateDataRequest { + attributes, + id: None, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn id(mut self, value: uuid::Uuid) -> Self { + self.id = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for FormUpdateDataRequest { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct FormUpdateDataRequestVisitor; + impl<'a> Visitor<'a> for FormUpdateDataRequestVisitor { + type Value = FormUpdateDataRequest; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut attributes: Option = None; + let mut id: Option = None; + let mut type_: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "attributes" => { + attributes = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "id" => { + if v.is_null() { + continue; + } + id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::FormType::UnparsedObject(_type_) => { + _unparsed = true; + } + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let attributes = attributes.ok_or_else(|| M::Error::missing_field("attributes"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = FormUpdateDataRequest { + attributes, + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(FormUpdateDataRequestVisitor) + } +} diff --git a/src/datadogV2/model/model_form_update_request.rs b/src/datadogV2/model/model_form_update_request.rs new file mode 100644 index 000000000..620021b3f --- /dev/null +++ b/src/datadogV2/model/model_form_update_request.rs @@ -0,0 +1,91 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Request for updating a form. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct FormUpdateRequest { + #[serde(rename = "data")] + pub data: crate::datadogV2::model::FormUpdateDataRequest, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl FormUpdateRequest { + pub fn new(data: crate::datadogV2::model::FormUpdateDataRequest) -> FormUpdateRequest { + FormUpdateRequest { + data, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for FormUpdateRequest { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct FormUpdateRequestVisitor; + impl<'a> Visitor<'a> for FormUpdateRequestVisitor { + type Value = FormUpdateRequest; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "data" => { + data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let data = data.ok_or_else(|| M::Error::missing_field("data"))?; + + let content = FormUpdateRequest { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(FormUpdateRequestVisitor) + } +} diff --git a/src/datadogV2/model/model_form_version.rs b/src/datadogV2/model/model_form_version.rs new file mode 100644 index 000000000..604fdbb8d --- /dev/null +++ b/src/datadogV2/model/model_form_version.rs @@ -0,0 +1,243 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Version information for the form. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct FormVersion { + /// Creation timestamp. + #[serde(rename = "created_at")] + pub created_at: chrono::DateTime, + /// The data definition for the form. + #[serde(rename = "data_definition")] + pub data_definition: std::collections::BTreeMap, + /// Signature of the form definition. + #[serde(rename = "definition_signature")] + pub definition_signature: Option, + /// The entity tag for the version. + #[serde(rename = "etag")] + pub etag: Option, + /// The unique identifier of the form version. + #[serde(rename = "id")] + pub id: String, + /// Last modification timestamp. + #[serde(rename = "modified_at")] + pub modified_at: chrono::DateTime, + /// The state of the form version. + #[serde(rename = "state")] + pub state: crate::datadogV2::model::FormVersionState, + /// The UI definition for the form. + #[serde(rename = "ui_definition")] + pub ui_definition: std::collections::BTreeMap, + /// The ID of the user who created the version. + #[serde(rename = "user_id")] + pub user_id: i64, + /// The UUID of the user who created the version. + #[serde(rename = "user_uuid")] + pub user_uuid: uuid::Uuid, + /// The version number. + #[serde(rename = "version")] + pub version: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl FormVersion { + pub fn new( + created_at: chrono::DateTime, + data_definition: std::collections::BTreeMap, + id: String, + modified_at: chrono::DateTime, + state: crate::datadogV2::model::FormVersionState, + ui_definition: std::collections::BTreeMap, + user_id: i64, + user_uuid: uuid::Uuid, + ) -> FormVersion { + FormVersion { + created_at, + data_definition, + definition_signature: None, + etag: None, + id, + modified_at, + state, + ui_definition, + user_id, + user_uuid, + version: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn definition_signature(mut self, value: String) -> Self { + self.definition_signature = Some(value); + self + } + + pub fn etag(mut self, value: String) -> Self { + self.etag = Some(value); + self + } + + pub fn version(mut self, value: i64) -> Self { + self.version = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for FormVersion { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct FormVersionVisitor; + impl<'a> Visitor<'a> for FormVersionVisitor { + type Value = FormVersion; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut created_at: Option> = None; + let mut data_definition: Option< + std::collections::BTreeMap, + > = None; + let mut definition_signature: Option = None; + let mut etag: Option = None; + let mut id: Option = None; + let mut modified_at: Option> = None; + let mut state: Option = None; + let mut ui_definition: Option< + std::collections::BTreeMap, + > = None; + let mut user_id: Option = None; + let mut user_uuid: Option = None; + let mut version: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "created_at" => { + created_at = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "data_definition" => { + data_definition = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "definition_signature" => { + if v.is_null() { + continue; + } + definition_signature = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "etag" => { + if v.is_null() { + continue; + } + etag = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "id" => { + id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "modified_at" => { + modified_at = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "state" => { + state = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _state) = state { + match _state { + crate::datadogV2::model::FormVersionState::UnparsedObject( + _state, + ) => { + _unparsed = true; + } + _ => {} + } + } + } + "ui_definition" => { + ui_definition = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "user_id" => { + user_id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "user_uuid" => { + user_uuid = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "version" => { + if v.is_null() { + continue; + } + version = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let created_at = created_at.ok_or_else(|| M::Error::missing_field("created_at"))?; + let data_definition = + data_definition.ok_or_else(|| M::Error::missing_field("data_definition"))?; + let id = id.ok_or_else(|| M::Error::missing_field("id"))?; + let modified_at = + modified_at.ok_or_else(|| M::Error::missing_field("modified_at"))?; + let state = state.ok_or_else(|| M::Error::missing_field("state"))?; + let ui_definition = + ui_definition.ok_or_else(|| M::Error::missing_field("ui_definition"))?; + let user_id = user_id.ok_or_else(|| M::Error::missing_field("user_id"))?; + let user_uuid = user_uuid.ok_or_else(|| M::Error::missing_field("user_uuid"))?; + + let content = FormVersion { + created_at, + data_definition, + definition_signature, + etag, + id, + modified_at, + state, + ui_definition, + user_id, + user_uuid, + version, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(FormVersionVisitor) + } +} diff --git a/src/datadogV2/model/model_form_version_attributes.rs b/src/datadogV2/model/model_form_version_attributes.rs new file mode 100644 index 000000000..3895197cc --- /dev/null +++ b/src/datadogV2/model/model_form_version_attributes.rs @@ -0,0 +1,153 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct FormVersionAttributes { + /// The data definition for the form. + #[serde(rename = "data_definition")] + pub data_definition: std::collections::BTreeMap, + /// The state of the form version. + #[serde(rename = "state")] + pub state: Option, + /// The UI definition for the form. + #[serde(rename = "ui_definition")] + pub ui_definition: std::collections::BTreeMap, + /// Parameters for upserting a form version. + #[serde(rename = "upsert_params")] + pub upsert_params: crate::datadogV2::model::FormVersionUpsertParams, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl FormVersionAttributes { + pub fn new( + data_definition: std::collections::BTreeMap, + ui_definition: std::collections::BTreeMap, + upsert_params: crate::datadogV2::model::FormVersionUpsertParams, + ) -> FormVersionAttributes { + FormVersionAttributes { + data_definition, + state: None, + ui_definition, + upsert_params, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn state(mut self, value: crate::datadogV2::model::FormVersionState) -> Self { + self.state = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for FormVersionAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct FormVersionAttributesVisitor; + impl<'a> Visitor<'a> for FormVersionAttributesVisitor { + type Value = FormVersionAttributes; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data_definition: Option< + std::collections::BTreeMap, + > = None; + let mut state: Option = None; + let mut ui_definition: Option< + std::collections::BTreeMap, + > = None; + let mut upsert_params: Option = + None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "data_definition" => { + data_definition = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "state" => { + if v.is_null() { + continue; + } + state = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _state) = state { + match _state { + crate::datadogV2::model::FormVersionState::UnparsedObject( + _state, + ) => { + _unparsed = true; + } + _ => {} + } + } + } + "ui_definition" => { + ui_definition = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "upsert_params" => { + upsert_params = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let data_definition = + data_definition.ok_or_else(|| M::Error::missing_field("data_definition"))?; + let ui_definition = + ui_definition.ok_or_else(|| M::Error::missing_field("ui_definition"))?; + let upsert_params = + upsert_params.ok_or_else(|| M::Error::missing_field("upsert_params"))?; + + let content = FormVersionAttributes { + data_definition, + state, + ui_definition, + upsert_params, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(FormVersionAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_form_version_data_attributes_response.rs b/src/datadogV2/model/model_form_version_data_attributes_response.rs new file mode 100644 index 000000000..678613bce --- /dev/null +++ b/src/datadogV2/model/model_form_version_data_attributes_response.rs @@ -0,0 +1,215 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Attributes of a form version. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct FormVersionDataAttributesResponse { + /// Creation timestamp. + #[serde(rename = "created_at")] + pub created_at: chrono::DateTime, + /// The data definition for the form. + #[serde(rename = "data_definition")] + pub data_definition: std::collections::BTreeMap, + /// Signature of the form definition. + #[serde(rename = "definition_signature")] + pub definition_signature: String, + /// The entity tag for the version. + #[serde(rename = "etag")] + pub etag: String, + /// Last modification timestamp. + #[serde(rename = "modified_at")] + pub modified_at: chrono::DateTime, + /// The state of the form version. + #[serde(rename = "state")] + pub state: crate::datadogV2::model::FormVersionState, + /// The UI definition for the form. + #[serde(rename = "ui_definition")] + pub ui_definition: std::collections::BTreeMap, + /// The ID of the user who created the version. + #[serde(rename = "user_id")] + pub user_id: i64, + /// The UUID of the user who created the version. + #[serde(rename = "user_uuid")] + pub user_uuid: uuid::Uuid, + /// The version number. + #[serde(rename = "version")] + pub version: i64, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl FormVersionDataAttributesResponse { + pub fn new( + created_at: chrono::DateTime, + data_definition: std::collections::BTreeMap, + definition_signature: String, + etag: String, + modified_at: chrono::DateTime, + state: crate::datadogV2::model::FormVersionState, + ui_definition: std::collections::BTreeMap, + user_id: i64, + user_uuid: uuid::Uuid, + version: i64, + ) -> FormVersionDataAttributesResponse { + FormVersionDataAttributesResponse { + created_at, + data_definition, + definition_signature, + etag, + modified_at, + state, + ui_definition, + user_id, + user_uuid, + version, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for FormVersionDataAttributesResponse { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct FormVersionDataAttributesResponseVisitor; + impl<'a> Visitor<'a> for FormVersionDataAttributesResponseVisitor { + type Value = FormVersionDataAttributesResponse; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut created_at: Option> = None; + let mut data_definition: Option< + std::collections::BTreeMap, + > = None; + let mut definition_signature: Option = None; + let mut etag: Option = None; + let mut modified_at: Option> = None; + let mut state: Option = None; + let mut ui_definition: Option< + std::collections::BTreeMap, + > = None; + let mut user_id: Option = None; + let mut user_uuid: Option = None; + let mut version: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "created_at" => { + created_at = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "data_definition" => { + data_definition = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "definition_signature" => { + definition_signature = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "etag" => { + etag = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "modified_at" => { + modified_at = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "state" => { + state = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _state) = state { + match _state { + crate::datadogV2::model::FormVersionState::UnparsedObject( + _state, + ) => { + _unparsed = true; + } + _ => {} + } + } + } + "ui_definition" => { + ui_definition = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "user_id" => { + user_id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "user_uuid" => { + user_uuid = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "version" => { + version = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let created_at = created_at.ok_or_else(|| M::Error::missing_field("created_at"))?; + let data_definition = + data_definition.ok_or_else(|| M::Error::missing_field("data_definition"))?; + let definition_signature = definition_signature + .ok_or_else(|| M::Error::missing_field("definition_signature"))?; + let etag = etag.ok_or_else(|| M::Error::missing_field("etag"))?; + let modified_at = + modified_at.ok_or_else(|| M::Error::missing_field("modified_at"))?; + let state = state.ok_or_else(|| M::Error::missing_field("state"))?; + let ui_definition = + ui_definition.ok_or_else(|| M::Error::missing_field("ui_definition"))?; + let user_id = user_id.ok_or_else(|| M::Error::missing_field("user_id"))?; + let user_uuid = user_uuid.ok_or_else(|| M::Error::missing_field("user_uuid"))?; + let version = version.ok_or_else(|| M::Error::missing_field("version"))?; + + let content = FormVersionDataAttributesResponse { + created_at, + data_definition, + definition_signature, + etag, + modified_at, + state, + ui_definition, + user_id, + user_uuid, + version, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(FormVersionDataAttributesResponseVisitor) + } +} diff --git a/src/datadogV2/model/model_form_version_data_request.rs b/src/datadogV2/model/model_form_version_data_request.rs new file mode 100644 index 000000000..a3d3c55aa --- /dev/null +++ b/src/datadogV2/model/model_form_version_data_request.rs @@ -0,0 +1,113 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct FormVersionDataRequest { + #[serde(rename = "attributes")] + pub attributes: crate::datadogV2::model::FormVersionAttributes, + /// Type for form versions. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::FormVersionType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl FormVersionDataRequest { + pub fn new( + attributes: crate::datadogV2::model::FormVersionAttributes, + type_: crate::datadogV2::model::FormVersionType, + ) -> FormVersionDataRequest { + FormVersionDataRequest { + attributes, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for FormVersionDataRequest { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct FormVersionDataRequestVisitor; + impl<'a> Visitor<'a> for FormVersionDataRequestVisitor { + type Value = FormVersionDataRequest; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut attributes: Option = None; + let mut type_: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "attributes" => { + attributes = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::FormVersionType::UnparsedObject( + _type_, + ) => { + _unparsed = true; + } + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let attributes = attributes.ok_or_else(|| M::Error::missing_field("attributes"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = FormVersionDataRequest { + attributes, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(FormVersionDataRequestVisitor) + } +} diff --git a/src/datadogV2/model/model_form_version_data_response.rs b/src/datadogV2/model/model_form_version_data_response.rs new file mode 100644 index 000000000..70b1c4236 --- /dev/null +++ b/src/datadogV2/model/model_form_version_data_response.rs @@ -0,0 +1,127 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct FormVersionDataResponse { + /// Attributes of a form version. + #[serde(rename = "attributes")] + pub attributes: crate::datadogV2::model::FormVersionDataAttributesResponse, + /// The version identifier. + #[serde(rename = "id")] + pub id: String, + /// Type for form versions. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::FormVersionType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl FormVersionDataResponse { + pub fn new( + attributes: crate::datadogV2::model::FormVersionDataAttributesResponse, + id: String, + type_: crate::datadogV2::model::FormVersionType, + ) -> FormVersionDataResponse { + FormVersionDataResponse { + attributes, + id, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for FormVersionDataResponse { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct FormVersionDataResponseVisitor; + impl<'a> Visitor<'a> for FormVersionDataResponseVisitor { + type Value = FormVersionDataResponse; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut attributes: Option< + crate::datadogV2::model::FormVersionDataAttributesResponse, + > = None; + let mut id: Option = None; + let mut type_: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "attributes" => { + attributes = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "id" => { + id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::FormVersionType::UnparsedObject( + _type_, + ) => { + _unparsed = true; + } + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let attributes = attributes.ok_or_else(|| M::Error::missing_field("attributes"))?; + let id = id.ok_or_else(|| M::Error::missing_field("id"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = FormVersionDataResponse { + attributes, + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(FormVersionDataResponseVisitor) + } +} diff --git a/src/datadogV2/model/model_form_version_request.rs b/src/datadogV2/model/model_form_version_request.rs new file mode 100644 index 000000000..4be090139 --- /dev/null +++ b/src/datadogV2/model/model_form_version_request.rs @@ -0,0 +1,91 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Request for creating or updating a form version. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct FormVersionRequest { + #[serde(rename = "data")] + pub data: crate::datadogV2::model::FormVersionDataRequest, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl FormVersionRequest { + pub fn new(data: crate::datadogV2::model::FormVersionDataRequest) -> FormVersionRequest { + FormVersionRequest { + data, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for FormVersionRequest { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct FormVersionRequestVisitor; + impl<'a> Visitor<'a> for FormVersionRequestVisitor { + type Value = FormVersionRequest; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "data" => { + data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let data = data.ok_or_else(|| M::Error::missing_field("data"))?; + + let content = FormVersionRequest { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(FormVersionRequestVisitor) + } +} diff --git a/src/datadogV2/model/model_form_version_response.rs b/src/datadogV2/model/model_form_version_response.rs new file mode 100644 index 000000000..f223bcfcc --- /dev/null +++ b/src/datadogV2/model/model_form_version_response.rs @@ -0,0 +1,91 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Response for a form version. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct FormVersionResponse { + #[serde(rename = "data")] + pub data: crate::datadogV2::model::FormVersionDataResponse, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl FormVersionResponse { + pub fn new(data: crate::datadogV2::model::FormVersionDataResponse) -> FormVersionResponse { + FormVersionResponse { + data, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for FormVersionResponse { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct FormVersionResponseVisitor; + impl<'a> Visitor<'a> for FormVersionResponseVisitor { + type Value = FormVersionResponse; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "data" => { + data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let data = data.ok_or_else(|| M::Error::missing_field("data"))?; + + let content = FormVersionResponse { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(FormVersionResponseVisitor) + } +} diff --git a/src/datadogV2/model/model_form_version_state.rs b/src/datadogV2/model/model_form_version_state.rs new file mode 100644 index 000000000..9b9aa2109 --- /dev/null +++ b/src/datadogV2/model/model_form_version_state.rs @@ -0,0 +1,51 @@ +// 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. + +use serde::{Deserialize, Deserializer, Serialize, Serializer}; + +#[non_exhaustive] +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum FormVersionState { + DRAFT, + FROZEN, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for FormVersionState { + fn to_string(&self) -> String { + match self { + Self::DRAFT => String::from("draft"), + Self::FROZEN => String::from("frozen"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for FormVersionState { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match self { + Self::UnparsedObject(v) => v.serialize(serializer), + _ => serializer.serialize_str(self.to_string().as_str()), + } + } +} + +impl<'de> Deserialize<'de> for FormVersionState { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "draft" => Self::DRAFT, + "frozen" => Self::FROZEN, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_form_version_type.rs b/src/datadogV2/model/model_form_version_type.rs new file mode 100644 index 000000000..2d9b66c34 --- /dev/null +++ b/src/datadogV2/model/model_form_version_type.rs @@ -0,0 +1,48 @@ +// 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. + +use serde::{Deserialize, Deserializer, Serialize, Serializer}; + +#[non_exhaustive] +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum FormVersionType { + FORM_VERSIONS, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for FormVersionType { + fn to_string(&self) -> String { + match self { + Self::FORM_VERSIONS => String::from("form_versions"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for FormVersionType { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match self { + Self::UnparsedObject(v) => v.serialize(serializer), + _ => serializer.serialize_str(self.to_string().as_str()), + } + } +} + +impl<'de> Deserialize<'de> for FormVersionType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "form_versions" => Self::FORM_VERSIONS, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_form_version_upsert_params.rs b/src/datadogV2/model/model_form_version_upsert_params.rs new file mode 100644 index 000000000..db821bf74 --- /dev/null +++ b/src/datadogV2/model/model_form_version_upsert_params.rs @@ -0,0 +1,123 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Parameters for upserting a form version. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct FormVersionUpsertParams { + /// The entity tag for conflict detection. + #[serde(rename = "etag")] + pub etag: Option, + /// The match policy for upserting. + #[serde(rename = "match_policy")] + pub match_policy: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl FormVersionUpsertParams { + pub fn new() -> FormVersionUpsertParams { + FormVersionUpsertParams { + etag: None, + match_policy: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn etag(mut self, value: String) -> Self { + self.etag = Some(value); + self + } + + pub fn match_policy(mut self, value: String) -> Self { + self.match_policy = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for FormVersionUpsertParams { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for FormVersionUpsertParams { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct FormVersionUpsertParamsVisitor; + impl<'a> Visitor<'a> for FormVersionUpsertParamsVisitor { + type Value = FormVersionUpsertParams; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut etag: Option = None; + let mut match_policy: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "etag" => { + if v.is_null() { + continue; + } + etag = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "match_policy" => { + if v.is_null() { + continue; + } + match_policy = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = FormVersionUpsertParams { + etag, + match_policy, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(FormVersionUpsertParamsVisitor) + } +} diff --git a/src/datadogV2/model/model_forms_list_response.rs b/src/datadogV2/model/model_forms_list_response.rs new file mode 100644 index 000000000..a2b496358 --- /dev/null +++ b/src/datadogV2/model/model_forms_list_response.rs @@ -0,0 +1,92 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Response containing a list of forms. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct FormsListResponse { + /// An array of forms. + #[serde(rename = "data")] + pub data: Vec, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl FormsListResponse { + pub fn new(data: Vec) -> FormsListResponse { + FormsListResponse { + data, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for FormsListResponse { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct FormsListResponseVisitor; + impl<'a> Visitor<'a> for FormsListResponseVisitor { + type Value = FormsListResponse; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data: Option> = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "data" => { + data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let data = data.ok_or_else(|| M::Error::missing_field("data"))?; + + let content = FormsListResponse { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(FormsListResponseVisitor) + } +} diff --git a/tests/scenarios/features/v2/forms.feature b/tests/scenarios/features/v2/forms.feature new file mode 100644 index 000000000..4ef762ec9 --- /dev/null +++ b/tests/scenarios/features/v2/forms.feature @@ -0,0 +1,229 @@ +@endpoint(forms) @endpoint(forms-v2) +Feature: Forms + Create and manage forms for collecting data from users. + + Background: + Given a valid "apiKeyAuth" key in the system + And a valid "appKeyAuth" key in the system + And an instance of "Forms" API + + @generated @skip @team:DataDog/app-builder-backend + Scenario: Create a form version returns "Bad Request" response + Given operation "UpsertFormVersion" enabled + And new "UpsertFormVersion" request + And request contains "form_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"data_definition": {"updated": "true"}, "state": "draft", "ui_definition": {}, "upsert_params": {"etag": "b51f08b698d88d8027a935d9db649774949f5fb41a0c559bfee6a9a13225c72d", "match_policy": "none"}}, "type": "form_versions"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/app-builder-backend + Scenario: Create a form version returns "Conflict" response + Given operation "UpsertFormVersion" enabled + And new "UpsertFormVersion" request + And request contains "form_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"data_definition": {"updated": "true"}, "state": "draft", "ui_definition": {}, "upsert_params": {"etag": "b51f08b698d88d8027a935d9db649774949f5fb41a0c559bfee6a9a13225c72d", "match_policy": "none"}}, "type": "form_versions"}} + When the request is sent + Then the response status is 409 Conflict + + @generated @skip @team:DataDog/app-builder-backend + Scenario: Create a form version returns "OK" response + Given operation "UpsertFormVersion" enabled + And new "UpsertFormVersion" request + And request contains "form_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"data_definition": {"updated": "true"}, "state": "draft", "ui_definition": {}, "upsert_params": {"etag": "b51f08b698d88d8027a935d9db649774949f5fb41a0c559bfee6a9a13225c72d", "match_policy": "none"}}, "type": "form_versions"}} + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:DataDog/app-builder-backend + Scenario: Create a new form returns "Bad Request" response + Given operation "CreateForm" enabled + And new "CreateForm" request + And body with value {"data": {"attributes": {"data_definition": {}, "description": "test description", "name": "test form happy path", "ui_definition": {}}, "id": "00000000-0000-0000-0000-000000000000", "type": "forms"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/app-builder-backend + Scenario: Create a new form returns "OK" response + Given operation "CreateForm" enabled + And new "CreateForm" request + And body with value {"data": {"attributes": {"data_definition": {}, "description": "test description", "name": "test form happy path", "ui_definition": {}}, "id": "00000000-0000-0000-0000-000000000000", "type": "forms"}} + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:DataDog/app-builder-backend + Scenario: Create and publish a form returns "Bad Request" response + Given operation "CreateAndPublishForm" enabled + And new "CreateAndPublishForm" request + And body with value {"data": {"attributes": {"data_definition": {}, "description": "test description", "name": "test form happy path", "ui_definition": {}}, "id": "00000000-0000-0000-0000-000000000000", "type": "forms"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/app-builder-backend + Scenario: Create and publish a form returns "OK" response + Given operation "CreateAndPublishForm" enabled + And new "CreateAndPublishForm" request + And body with value {"data": {"attributes": {"data_definition": {}, "description": "test description", "name": "test form happy path", "ui_definition": {}}, "id": "00000000-0000-0000-0000-000000000000", "type": "forms"}} + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:DataDog/app-builder-backend + Scenario: Delete a form returns "Bad Request" response + Given operation "DeleteForm" enabled + And new "DeleteForm" 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: Delete a form returns "OK" response + Given operation "DeleteForm" enabled + And new "DeleteForm" 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: Get a form returns "Bad Request" response + Given operation "GetForm" enabled + And new "GetForm" 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: Get a form returns "Not Found" response + Given operation "GetForm" enabled + And new "GetForm" 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: Get a form returns "OK" response + Given operation "GetForm" enabled + And new "GetForm" 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 all forms returns "Bad Request" response + Given operation "ListForms" enabled + And new "ListForms" request + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/app-builder-backend + Scenario: List all forms returns "OK" response + Given operation "ListForms" enabled + And new "ListForms" request + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:DataDog/app-builder-backend + Scenario: Publish a form returns "Bad Request" response + Given operation "PublishForm" enabled + And new "PublishForm" request + And request contains "form_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"version": 1}, "type": "form_publications"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/app-builder-backend + Scenario: Publish a form returns "Not Found" response + Given operation "PublishForm" enabled + And new "PublishForm" request + And request contains "form_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"version": 1}, "type": "form_publications"}} + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/app-builder-backend + Scenario: Publish a form returns "OK" response + Given operation "PublishForm" enabled + And new "PublishForm" request + And request contains "form_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"version": 1}, "type": "form_publications"}} + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:DataDog/app-builder-backend + Scenario: Submit a form returns "Bad Request" response + Given operation "SubmitForm" enabled + And new "SubmitForm" request + And request contains "form_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"submission_data": {}}, "type": "form_submissions"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/app-builder-backend + Scenario: Submit a form returns "Not Found" response + Given operation "SubmitForm" enabled + And new "SubmitForm" request + And request contains "form_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"submission_data": {}}, "type": "form_submissions"}} + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/app-builder-backend + Scenario: Submit a form returns "OK" response + Given operation "SubmitForm" enabled + And new "SubmitForm" request + And request contains "form_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"submission_data": {}}, "type": "form_submissions"}} + 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 + And new "UpdateForm" request + And request contains "form_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"form_update": {"description": "Updated description", "name": "New Form Name"}}, "id": "00000000-0000-0000-0000-000000000000", "type": "forms"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/app-builder-backend + Scenario: Update a form returns "Not Found" response + Given operation "UpdateForm" enabled + And new "UpdateForm" request + And request contains "form_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"form_update": {"description": "Updated description", "name": "New Form Name"}}, "id": "00000000-0000-0000-0000-000000000000", "type": "forms"}} + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/app-builder-backend + Scenario: Update a form returns "OK" response + Given operation "UpdateForm" enabled + And new "UpdateForm" request + And request contains "form_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"form_update": {"description": "Updated description", "name": "New Form Name"}}, "id": "00000000-0000-0000-0000-000000000000", "type": "forms"}} + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:DataDog/app-builder-backend + Scenario: Upsert and publish a form version returns "Bad Request" response + Given operation "UpsertAndPublishFormVersion" enabled + And new "UpsertAndPublishFormVersion" request + And request contains "form_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"data_definition": {"updated": "true"}, "state": "draft", "ui_definition": {}, "upsert_params": {"etag": "b51f08b698d88d8027a935d9db649774949f5fb41a0c559bfee6a9a13225c72d", "match_policy": "none"}}, "type": "form_versions"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/app-builder-backend + Scenario: Upsert and publish a form version returns "Conflict" response + Given operation "UpsertAndPublishFormVersion" enabled + And new "UpsertAndPublishFormVersion" request + And request contains "form_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"data_definition": {"updated": "true"}, "state": "draft", "ui_definition": {}, "upsert_params": {"etag": "b51f08b698d88d8027a935d9db649774949f5fb41a0c559bfee6a9a13225c72d", "match_policy": "none"}}, "type": "form_versions"}} + When the request is sent + Then the response status is 409 Conflict + + @generated @skip @team:DataDog/app-builder-backend + Scenario: Upsert and publish a form version returns "OK" response + Given operation "UpsertAndPublishFormVersion" enabled + And new "UpsertAndPublishFormVersion" request + And request contains "form_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"data_definition": {"updated": "true"}, "state": "draft", "ui_definition": {}, "upsert_params": {"etag": "b51f08b698d88d8027a935d9db649774949f5fb41a0c559bfee6a9a13225c72d", "match_policy": "none"}}, "type": "form_versions"}} + When the request is sent + Then the response status is 200 OK diff --git a/tests/scenarios/features/v2/undo.json b/tests/scenarios/features/v2/undo.json index 7e549784e..8c5aa0610 100644 --- a/tests/scenarios/features/v2/undo.json +++ b/tests/scenarios/features/v2/undo.json @@ -1616,6 +1616,80 @@ "type": "safe" } }, + "ListForms": { + "tag": "Forms", + "undo": { + "type": "safe" + } + }, + "CreateForm": { + "tag": "Forms", + "undo": { + "operationId": "DeleteForm", + "parameters": [ + { + "name": "form_id", + "source": "data.id" + } + ], + "type": "unsafe" + } + }, + "CreateAndPublishForm": { + "tag": "Forms", + "undo": { + "operationId": "DeleteForm", + "parameters": [ + { + "name": "form_id", + "source": "data.id" + } + ], + "type": "unsafe" + } + }, + "DeleteForm": { + "tag": "Forms", + "undo": { + "type": "idempotent" + } + }, + "GetForm": { + "tag": "Forms", + "undo": { + "type": "safe" + } + }, + "UpdateForm": { + "tag": "Forms", + "undo": { + "type": "idempotent" + } + }, + "PublishForm": { + "tag": "Forms", + "undo": { + "type": "unsafe" + } + }, + "SubmitForm": { + "tag": "Forms", + "undo": { + "type": "unsafe" + } + }, + "UpsertFormVersion": { + "tag": "Forms", + "undo": { + "type": "unsafe" + } + }, + "UpsertAndPublishFormVersion": { + "tag": "Forms", + "undo": { + "type": "unsafe" + } + }, "GetHamrOrgConnection": { "tag": "High Availability MultiRegion", "undo": { diff --git a/tests/scenarios/function_mappings.rs b/tests/scenarios/function_mappings.rs index a56b50dfc..ab31bd0bc 100644 --- a/tests/scenarios/function_mappings.rs +++ b/tests/scenarios/function_mappings.rs @@ -91,6 +91,7 @@ pub struct ApiInstances { pub v2_api_downtimes: Option, pub v2_api_error_tracking: Option, pub v2_api_events: Option, + pub v2_api_forms: Option, pub v2_api_high_availability_multi_region: Option, pub v2_api_incidents: Option, @@ -717,6 +718,13 @@ pub fn initialize_api_instance(world: &mut DatadogWorld, api: String) { ), ); } + "Forms" => { + world.api_instances.v2_api_forms = + Some(datadogV2::api_forms::FormsAPI::with_client_and_config( + world.config.clone(), + world.http_client.as_ref().unwrap().clone(), + )); + } "HighAvailabilityMultiRegion" => { world.api_instances.v2_api_high_availability_multi_region = Some(datadogV2::api_high_availability_multi_region::HighAvailabilityMultiRegionAPI::with_client_and_config( world.config.clone(), @@ -3225,6 +3233,38 @@ pub fn collect_function_calls(world: &mut DatadogWorld) { world .function_mappings .insert("v2.GetEvent".into(), test_v2_get_event); + world + .function_mappings + .insert("v2.ListForms".into(), test_v2_list_forms); + world + .function_mappings + .insert("v2.CreateForm".into(), test_v2_create_form); + world.function_mappings.insert( + "v2.CreateAndPublishForm".into(), + test_v2_create_and_publish_form, + ); + world + .function_mappings + .insert("v2.DeleteForm".into(), test_v2_delete_form); + world + .function_mappings + .insert("v2.GetForm".into(), test_v2_get_form); + world + .function_mappings + .insert("v2.UpdateForm".into(), test_v2_update_form); + world + .function_mappings + .insert("v2.PublishForm".into(), test_v2_publish_form); + world + .function_mappings + .insert("v2.SubmitForm".into(), test_v2_submit_form); + world + .function_mappings + .insert("v2.UpsertFormVersion".into(), test_v2_upsert_form_version); + world.function_mappings.insert( + "v2.UpsertAndPublishFormVersion".into(), + test_v2_upsert_and_publish_form_version, + ); world.function_mappings.insert( "v2.GetHamrOrgConnection".into(), test_v2_get_hamr_org_connection, @@ -23830,6 +23870,278 @@ fn test_v2_get_event(world: &mut DatadogWorld, _parameters: &HashMap) { + let api = world + .api_instances + .v2_api_forms + .as_ref() + .expect("api instance not found"); + let name = _parameters + .get("name") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let mut params = datadogV2::api_forms::ListFormsOptionalParams::default(); + params.name = name; + let response = match block_on(api.list_forms_with_http_info(params)) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + +fn test_v2_create_form(world: &mut DatadogWorld, _parameters: &HashMap) { + let api = world + .api_instances + .v2_api_forms + .as_ref() + .expect("api instance not found"); + let body = serde_json::from_value(_parameters.get("body").unwrap().clone()).unwrap(); + let response = match block_on(api.create_form_with_http_info(body)) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + +fn test_v2_create_and_publish_form(world: &mut DatadogWorld, _parameters: &HashMap) { + let api = world + .api_instances + .v2_api_forms + .as_ref() + .expect("api instance not found"); + let body = serde_json::from_value(_parameters.get("body").unwrap().clone()).unwrap(); + let response = match block_on(api.create_and_publish_form_with_http_info(body)) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + +fn test_v2_delete_form(world: &mut DatadogWorld, _parameters: &HashMap) { + let api = world + .api_instances + .v2_api_forms + .as_ref() + .expect("api instance not found"); + let form_id = serde_json::from_value(_parameters.get("form_id").unwrap().clone()).unwrap(); + let response = match block_on(api.delete_form_with_http_info(form_id)) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + +fn test_v2_get_form(world: &mut DatadogWorld, _parameters: &HashMap) { + let api = world + .api_instances + .v2_api_forms + .as_ref() + .expect("api instance not found"); + let form_id = serde_json::from_value(_parameters.get("form_id").unwrap().clone()).unwrap(); + let version = _parameters + .get("version") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let published_version = _parameters + .get("published_version") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let mut params = datadogV2::api_forms::GetFormOptionalParams::default(); + params.version = version; + params.published_version = published_version; + let response = match block_on(api.get_form_with_http_info(form_id, params)) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + +fn test_v2_update_form(world: &mut DatadogWorld, _parameters: &HashMap) { + let api = world + .api_instances + .v2_api_forms + .as_ref() + .expect("api instance not found"); + let form_id = serde_json::from_value(_parameters.get("form_id").unwrap().clone()).unwrap(); + let body = serde_json::from_value(_parameters.get("body").unwrap().clone()).unwrap(); + let response = match block_on(api.update_form_with_http_info(form_id, body)) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + +fn test_v2_publish_form(world: &mut DatadogWorld, _parameters: &HashMap) { + let api = world + .api_instances + .v2_api_forms + .as_ref() + .expect("api instance not found"); + let form_id = serde_json::from_value(_parameters.get("form_id").unwrap().clone()).unwrap(); + let body = serde_json::from_value(_parameters.get("body").unwrap().clone()).unwrap(); + let response = match block_on(api.publish_form_with_http_info(form_id, body)) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + +fn test_v2_submit_form(world: &mut DatadogWorld, _parameters: &HashMap) { + let api = world + .api_instances + .v2_api_forms + .as_ref() + .expect("api instance not found"); + let form_id = serde_json::from_value(_parameters.get("form_id").unwrap().clone()).unwrap(); + let body = serde_json::from_value(_parameters.get("body").unwrap().clone()).unwrap(); + let response = match block_on(api.submit_form_with_http_info(form_id, body)) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + +fn test_v2_upsert_form_version(world: &mut DatadogWorld, _parameters: &HashMap) { + let api = world + .api_instances + .v2_api_forms + .as_ref() + .expect("api instance not found"); + let form_id = serde_json::from_value(_parameters.get("form_id").unwrap().clone()).unwrap(); + let body = serde_json::from_value(_parameters.get("body").unwrap().clone()).unwrap(); + let response = match block_on(api.upsert_form_version_with_http_info(form_id, body)) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + +fn test_v2_upsert_and_publish_form_version( + world: &mut DatadogWorld, + _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_forms + .as_ref() + .expect("api instance not found"); + let form_id = serde_json::from_value(_parameters.get("form_id").unwrap().clone()).unwrap(); + let body = serde_json::from_value(_parameters.get("body").unwrap().clone()).unwrap(); + let response = match block_on(api.upsert_and_publish_form_version_with_http_info(form_id, body)) + { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + fn test_v2_get_hamr_org_connection(world: &mut DatadogWorld, _parameters: &HashMap) { let api = world .api_instances