From d882c23c0f9bc9c266173191da8c5f9920ea72ab Mon Sep 17 00:00:00 2001 From: "ci.datadog-api-spec" Date: Fri, 5 Jun 2026 23:26:03 +0000 Subject: [PATCH] Regenerate client from commit 9c4cf89 of spec repo --- .generator/schemas/v2/openapi.yaml | 750 ++++++++++++++++++ api/datadog/configuration.go | 5 + api/datadogV2/api_forms.go | 537 +++++++++++++ api/datadogV2/doc.go | 5 + api/datadogV2/model_create_form_data.go | 146 ++++ .../model_create_form_data_attributes.go | 317 ++++++++ api/datadogV2/model_create_form_request.go | 110 +++ api/datadogV2/model_delete_form_data.go | 145 ++++ api/datadogV2/model_delete_form_response.go | 111 +++ api/datadogV2/model_form_data.go | 180 +++++ api/datadogV2/model_form_data_attributes.go | 673 ++++++++++++++++ api/datadogV2/model_form_data_definition.go | 252 ++++++ .../model_form_data_definition_type.go | 64 ++ .../model_form_datastore_config_attributes.go | 167 ++++ .../model_form_publication_attributes.go | 371 +++++++++ api/datadogV2/model_form_response.go | 110 +++ api/datadogV2/model_form_type.go | 64 ++ api/datadogV2/model_form_ui_definition.go | 146 ++++ .../model_form_ui_definition_ui_theme.go | 112 +++ ...rm_ui_definition_ui_theme_primary_color.go | 80 ++ .../model_form_version_attributes.go | 453 +++++++++++ api/datadogV2/model_form_version_state.go | 66 ++ api/datadogV2/model_forms_response.go | 101 +++ examples/v2/forms/CreateAndPublishForm.go | 44 + examples/v2/forms/CreateForm.go | 44 + examples/v2/forms/DeleteForm.go | 34 + examples/v2/forms/GetForm.go | 34 + examples/v2/forms/ListForms.go | 30 + tests/scenarios/api_mappings.go | 1 + ...o_Create_a_form_returns_OK_response.freeze | 1 + ...rio_Create_a_form_returns_OK_response.yaml | 41 + ..._publish_a_form_returns_OK_response.freeze | 1 + ...nd_publish_a_form_returns_OK_response.yaml | 41 + ...o_Delete_a_form_returns_OK_response.freeze | 1 + ...rio_Delete_a_form_returns_OK_response.yaml | 57 ++ ...t_a_form_returns_Not_Found_response.freeze | 1 + ...Get_a_form_returns_Not_Found_response.yaml | 20 + ...ario_Get_a_form_returns_OK_response.freeze | 1 + ...enario_Get_a_form_returns_OK_response.yaml | 58 ++ ...ario_List_forms_returns_OK_response.freeze | 1 + ...enario_List_forms_returns_OK_response.yaml | 62 ++ tests/scenarios/features/v2/forms.feature | 107 +++ tests/scenarios/features/v2/given.json | 24 + tests/scenarios/features/v2/undo.json | 44 + 44 files changed, 5612 insertions(+) create mode 100644 api/datadogV2/api_forms.go create mode 100644 api/datadogV2/model_create_form_data.go create mode 100644 api/datadogV2/model_create_form_data_attributes.go create mode 100644 api/datadogV2/model_create_form_request.go create mode 100644 api/datadogV2/model_delete_form_data.go create mode 100644 api/datadogV2/model_delete_form_response.go create mode 100644 api/datadogV2/model_form_data.go create mode 100644 api/datadogV2/model_form_data_attributes.go create mode 100644 api/datadogV2/model_form_data_definition.go create mode 100644 api/datadogV2/model_form_data_definition_type.go create mode 100644 api/datadogV2/model_form_datastore_config_attributes.go create mode 100644 api/datadogV2/model_form_publication_attributes.go create mode 100644 api/datadogV2/model_form_response.go create mode 100644 api/datadogV2/model_form_type.go create mode 100644 api/datadogV2/model_form_ui_definition.go create mode 100644 api/datadogV2/model_form_ui_definition_ui_theme.go create mode 100644 api/datadogV2/model_form_ui_definition_ui_theme_primary_color.go create mode 100644 api/datadogV2/model_form_version_attributes.go create mode 100644 api/datadogV2/model_form_version_state.go create mode 100644 api/datadogV2/model_forms_response.go create mode 100644 examples/v2/forms/CreateAndPublishForm.go create mode 100644 examples/v2/forms/CreateForm.go create mode 100644 examples/v2/forms/DeleteForm.go create mode 100644 examples/v2/forms/GetForm.go create mode 100644 examples/v2/forms/ListForms.go create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Forms/Scenario_Create_a_form_returns_OK_response.freeze create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Forms/Scenario_Create_a_form_returns_OK_response.yaml create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Forms/Scenario_Create_and_publish_a_form_returns_OK_response.freeze create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Forms/Scenario_Create_and_publish_a_form_returns_OK_response.yaml create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Forms/Scenario_Delete_a_form_returns_OK_response.freeze create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Forms/Scenario_Delete_a_form_returns_OK_response.yaml create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Forms/Scenario_Get_a_form_returns_Not_Found_response.freeze create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Forms/Scenario_Get_a_form_returns_Not_Found_response.yaml create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Forms/Scenario_Get_a_form_returns_OK_response.freeze create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Forms/Scenario_Get_a_form_returns_OK_response.yaml create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Forms/Scenario_List_forms_returns_OK_response.freeze create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Forms/Scenario_List_forms_returns_OK_response.yaml create mode 100644 tests/scenarios/features/v2/forms.feature diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 2b0efd759c6..45fdcb36f38 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -23216,6 +23216,57 @@ components: required: - data type: object + CreateFormData: + description: The data for creating a form. + properties: + attributes: + $ref: "#/components/schemas/CreateFormDataAttributes" + type: + $ref: "#/components/schemas/FormType" + required: + - attributes + - type + type: object + CreateFormDataAttributes: + description: The attributes for creating a form. + properties: + anonymous: + description: Whether the form accepts anonymous submissions. + example: false + type: boolean + data_definition: + $ref: "#/components/schemas/FormDataDefinition" + description: + description: The description of the form. + example: A form to collect user feedback. + type: string + idp_survey: + description: Whether the form is an IDP survey. + example: false + type: boolean + name: + description: The name of the form. + example: User Feedback Form + type: string + single_response: + description: Whether each user can only submit one response. + example: false + type: boolean + ui_definition: + $ref: "#/components/schemas/FormUiDefinition" + required: + - data_definition + - name + - ui_definition + type: object + CreateFormRequest: + description: A request to create a form. + properties: + data: + $ref: "#/components/schemas/CreateFormData" + required: + - data + type: object CreateIncidentNotificationRuleRequest: description: Create request for a notification rule. properties: @@ -29031,6 +29082,26 @@ components: required: - data type: object + DeleteFormData: + description: The data returned when a form is deleted. + properties: + id: + description: The ID of the deleted form. + example: 844dfd88-aa84-4db4-8979-e7bdbb9c1dc3 + format: uuid + type: string + type: + $ref: "#/components/schemas/FormType" + required: + - id + - type + type: object + DeleteFormResponse: + description: A response returned after deleting a form. + properties: + data: + $ref: "#/components/schemas/DeleteFormData" + type: object DeletedSuiteResponseData: description: Data object for a deleted Synthetic test suite. properties: @@ -36737,6 +36808,232 @@ components: - type - attributes type: object + FormData: + description: A form resource object. + properties: + attributes: + $ref: "#/components/schemas/FormDataAttributes" + id: + description: The ID of the form. + example: 22f6006a-2302-4926-9396-d2dfcf7b0b34 + format: uuid + type: string + type: + $ref: "#/components/schemas/FormType" + required: + - id + - type + - attributes + type: object + FormDataAttributes: + description: The attributes of a form. + properties: + active: + description: Whether the form is currently active. + example: true + type: boolean + anonymous: + description: Whether the form accepts anonymous submissions. + example: false + type: boolean + created_at: + description: The time at which the form was created. + example: "2026-05-29T20:06:13.677353Z" + format: date-time + type: string + datastore_config: + $ref: "#/components/schemas/FormDatastoreConfigAttributes" + description: + description: The description of the form. + example: A form to collect user feedback. + type: string + end_date: + description: The date and time at which the form stops accepting responses. + example: + format: date-time + nullable: true + type: string + has_submitted: + description: Whether the current user has already submitted this form. Only present for forms with `single_response` set to `true`. + nullable: true + type: boolean + idp_survey: + description: Whether the form is an IDP survey. + example: false + type: boolean + modified_at: + description: The time at which the form was last modified. + example: "2026-05-29T20:06:13.677353Z" + format: date-time + type: string + name: + description: The name of the form. + example: User Feedback Form + type: string + org_id: + description: The ID of the organization that owns this form. + example: 2 + format: int64 + type: integer + publication: + $ref: "#/components/schemas/FormPublicationAttributes" + self_service: + description: Whether the form is available in the self-service catalog. + example: false + type: boolean + single_response: + description: Whether each user can only submit one response. + example: false + type: boolean + user_id: + description: The ID of the user who created this form. + example: 10001 + format: int64 + type: integer + user_uuid: + description: The UUID of the user who created this form. + example: 1fc709aa-be19-4539-a47d-52a30d78a978 + format: uuid + type: string + version: + $ref: "#/components/schemas/FormVersionAttributes" + required: + - active + - anonymous + - created_at + - datastore_config + - description + - idp_survey + - modified_at + - name + - org_id + - self_service + - single_response + - user_id + - user_uuid + type: object + FormDataDefinition: + additionalProperties: {} + description: A JSON Schema definition that describes the form's data fields. + properties: + description: + description: A description shown to form respondents. + example: Welcome to the Engineering Experience Survey. + type: string + properties: + additionalProperties: {} + description: A map of field names to their JSON Schema definitions. + type: object + required: + description: List of field names that must be answered. + items: + type: string + type: array + title: + description: The title of the form schema. + example: Developer Experience Survey + type: string + type: + $ref: "#/components/schemas/FormDataDefinitionType" + type: object + FormDataDefinitionType: + description: The root schema type. Always "object". + enum: + - object + type: string + x-enum-varnames: + - OBJECT + FormDataList: + description: A list of form resource objects. + items: + $ref: "#/components/schemas/FormData" + type: array + FormDatastoreConfigAttributes: + description: The datastore configuration for a form. + properties: + datastore_id: + description: The ID of the datastore. + example: 5108ea24-dd83-4696-9caa-f069f73d0fad + format: uuid + type: string + primary_column_name: + description: The name of the primary column in the datastore. + example: id + type: string + primary_key_generation_strategy: + description: The strategy used to generate primary keys in the datastore. + example: none + type: string + required: + - datastore_id + - primary_column_name + - primary_key_generation_strategy + type: object + FormPublicationAttributes: + description: The attributes of a form publication. + properties: + created_at: + description: The time at which the publication was created. + example: "2026-05-29T20:06:13.677353Z" + format: date-time + type: string + form_id: + description: The ID of the form. + example: afc67600-0511-43b1-9b18-578fb4979bd3 + format: uuid + type: string + form_version: + description: The version number that was published. + example: 1 + format: int64 + type: integer + id: + description: The ID of the form publication. + example: "42" + type: string + modified_at: + description: The time at which the publication was last modified. + example: "2026-05-29T20:06:13.677353Z" + format: date-time + type: string + org_id: + description: The ID of the organization that owns this publication. + example: 2 + format: int64 + type: integer + publish_seq: + description: The sequential publication number for this form. + example: 1 + format: int64 + type: integer + user_id: + description: The ID of the user who created this publication. + example: 10001 + format: int64 + type: integer + user_uuid: + description: The UUID of the user who created this publication. + example: 1fc709aa-be19-4539-a47d-52a30d78a978 + format: uuid + type: string + required: + - created_at + - form_id + - form_version + - modified_at + - org_id + - publish_seq + - user_id + - user_uuid + type: object + FormResponse: + description: A response containing a single form. + properties: + data: + $ref: "#/components/schemas/FormData" + required: + - data + type: object FormTrigger: description: "Trigger a workflow from a Form." properties: @@ -36755,6 +37052,132 @@ components: required: - formTrigger type: object + FormType: + description: The resource type for a form. + enum: + - forms + example: forms + type: string + x-enum-varnames: + - FORMS + FormUiDefinition: + additionalProperties: {} + description: UI configuration for rendering form fields, including widget overrides, field ordering, and themes. + properties: + "ui:order": + description: The order in which form fields are displayed. + items: + type: string + type: array + "ui:theme": + $ref: "#/components/schemas/FormUiDefinitionUiTheme" + type: object + FormUiDefinitionUiTheme: + description: The visual theme applied to the form. + properties: + primaryColor: + $ref: "#/components/schemas/FormUiDefinitionUiThemePrimaryColor" + type: object + FormUiDefinitionUiThemePrimaryColor: + description: The primary color of the form theme. + enum: + - gray + - red + - orange + - yellow + - green + - light-blue + - dark-blue + - magenta + - indigo + type: string + x-enum-varnames: + - GRAY + - RED + - ORANGE + - YELLOW + - GREEN + - LIGHT_BLUE + - DARK_BLUE + - MAGENTA + - INDIGO + FormVersionAttributes: + description: The attributes of a form version. + properties: + created_at: + description: The time at which the version was created. + example: "2026-05-29T20:06:14.895921Z" + format: date-time + type: string + data_definition: + $ref: "#/components/schemas/FormDataDefinition" + definition_signature: + description: The signature of the version definition. + example: '{"signature":"b7f312957a80cea2c8c9950532b205a90a3f8a7ebb7e52fc25437a25d903d545","version":1}' + type: string + etag: + description: The ETag for optimistic concurrency control. + example: b51f08b698d88d8027a935d9db649774949f5fb41a0c559bfee6a9a13225c72d + nullable: true + type: string + id: + description: The ID of the form version. + example: "126" + type: string + modified_at: + description: The time at which the version was last modified. + example: "2026-05-29T20:06:14.949163Z" + format: date-time + type: string + state: + $ref: "#/components/schemas/FormVersionState" + ui_definition: + $ref: "#/components/schemas/FormUiDefinition" + user_id: + description: The ID of the user who created this version. + example: 10001 + format: int64 + type: integer + user_uuid: + description: The UUID of the user who created this version. + example: 1fc709aa-be19-4539-a47d-52a30d78a978 + format: uuid + type: string + version: + description: The sequential version number. + example: 1 + format: int64 + type: integer + required: + - created_at + - data_definition + - definition_signature + - etag + - modified_at + - state + - ui_definition + - user_id + - user_uuid + - version + type: object + FormVersionState: + description: The state of a form version. + enum: + - draft + - frozen + example: frozen + type: string + x-enum-varnames: + - DRAFT + - FROZEN + FormsResponse: + description: A response containing a list of forms. + properties: + data: + $ref: "#/components/schemas/FormDataList" + required: + - data + type: object FormulaLimit: description: |- Message for specifying limits to the number of values returned by a query. @@ -124635,6 +125058,330 @@ paths: permissions: - feature_flag_config_write - feature_flag_environment_config_read + /api/v2/forms: + get: + description: Get all forms for the authenticated user's organization. + operationId: ListForms + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + - attributes: + active: true + anonymous: false + created_at: "2026-05-29T20:06:14.895284Z" + datastore_config: + datastore_id: 00000000-0000-0000-0000-000000000000 + primary_column_name: "" + primary_key_generation_strategy: "" + description: A form to collect user feedback. + end_date: + idp_survey: false + modified_at: "2026-05-29T20:06:14.895285Z" + name: User Feedback Form + org_id: 2 + self_service: false + single_response: false + user_id: 10001 + user_uuid: 1fc709aa-be19-4539-a47d-52a30d78a978 + id: 22f6006a-2302-4926-9396-d2dfcf7b0b34 + type: forms + schema: + $ref: "#/components/schemas/FormsResponse" + 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 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. + operationId: CreateForm + requestBody: + content: + application/json: + examples: + default: + value: + data: + attributes: + anonymous: false + data_definition: {} + description: A form to collect user feedback. + idp_survey: false + name: User Feedback Form + single_response: false + ui_definition: {} + type: forms + schema: + $ref: "#/components/schemas/CreateFormRequest" + required: true + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + attributes: + active: true + anonymous: false + created_at: "2026-05-29T20:06:14.895284Z" + datastore_config: + datastore_id: 5108ea24-dd83-4696-9caa-f069f73d0fad + primary_column_name: id + primary_key_generation_strategy: none + description: A form to collect user feedback. + end_date: + idp_survey: false + modified_at: "2026-05-29T20:06:14.895285Z" + name: User Feedback Form + org_id: 2 + self_service: false + single_response: false + user_id: 10001 + user_uuid: 1fc709aa-be19-4539-a47d-52a30d78a978 + id: 22f6006a-2302-4926-9396-d2dfcf7b0b34 + type: forms + 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 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: Creates a new form and immediately publishes its initial version. + operationId: CreateAndPublishForm + requestBody: + content: + application/json: + examples: + default: + value: + data: + attributes: + anonymous: false + data_definition: {} + description: A form to collect user feedback. + idp_survey: false + name: User Feedback Form + single_response: false + ui_definition: {} + type: forms + schema: + $ref: "#/components/schemas/CreateFormRequest" + required: true + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + attributes: + active: true + anonymous: false + created_at: "2026-05-29T20:06:14.895284Z" + datastore_config: + datastore_id: 5108ea24-dd83-4696-9caa-f069f73d0fad + primary_column_name: id + primary_key_generation_strategy: none + description: A form to collect user feedback. + end_date: + idp_survey: false + modified_at: "2026-05-29T20:06:14.895285Z" + name: User Feedback Form + org_id: 2 + self_service: false + single_response: false + user_id: 10001 + user_uuid: 1fc709aa-be19-4539-a47d-52a30d78a978 + id: 22f6006a-2302-4926-9396-d2dfcf7b0b34 + type: forms + 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 its ID. + operationId: DeleteForm + parameters: + - description: The ID of the form. + example: 844dfd88-aa84-4db4-8979-e7bdbb9c1dc3 + in: path + name: form_id + required: true + schema: + format: uuid + type: string + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + id: 844dfd88-aa84-4db4-8979-e7bdbb9c1dc3 + type: forms + schema: + $ref: "#/components/schemas/DeleteFormResponse" + 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 its ID. + operationId: GetForm + parameters: + - description: The ID of the form. + example: 22f6006a-2302-4926-9396-d2dfcf7b0b34 + in: path + name: form_id + required: true + schema: + format: uuid + type: string + - description: The version of the form to retrieve. Use 'latest' for the most recent draft, 'published' for the last published version, or a specific version number. + in: query + name: version + required: false + schema: + default: latest + type: string + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + attributes: + active: true + anonymous: false + created_at: "2026-05-29T20:06:14.895284Z" + datastore_config: + datastore_id: 5108ea24-dd83-4696-9caa-f069f73d0fad + primary_column_name: id + primary_key_generation_strategy: none + description: A form to collect user feedback. + end_date: + idp_survey: false + modified_at: "2026-05-29T20:06:14.895285Z" + name: User Feedback Form + org_id: 2 + self_service: false + single_response: false + user_id: 10001 + user_uuid: 1fc709aa-be19-4539-a47d-52a30d78a978 + id: 22f6006a-2302-4926-9396-d2dfcf7b0b34 + type: forms + 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/). /api/v2/hamr: get: description: |- @@ -179871,6 +180618,9 @@ tags: Package Upgrade Deployments (`/upgrade`): - Upgrade the Datadog Agent to specific versions name: Fleet Automation + - description: |- + The Datadog Forms API lets you create and manage forms within the App Builder platform. You can configure form settings, manage versions, publish forms, and handle sharing configurations. + 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/api/datadog/configuration.go b/api/datadog/configuration.go index 01237e20cd3..70bd832fba7 100644 --- a/api/datadog/configuration.go +++ b/api/datadog/configuration.go @@ -897,6 +897,11 @@ func NewConfiguration() *Configuration { "v2.TriggerDeploymentGatesEvaluation": false, "v2.UpdateDeploymentGate": false, "v2.UpdateDeploymentRule": false, + "v2.CreateAndPublishForm": false, + "v2.CreateForm": false, + "v2.DeleteForm": false, + "v2.GetForm": false, + "v2.ListForms": false, "v2.CreateHamrOrgConnection": false, "v2.GetHamrOrgConnection": false, "v2.DeleteEntityIntegrationConfig": false, diff --git a/api/datadogV2/api_forms.go b/api/datadogV2/api_forms.go new file mode 100644 index 00000000000..f31664977bc --- /dev/null +++ b/api/datadogV2/api_forms.go @@ -0,0 +1,537 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + _context "context" + _fmt "fmt" + _log "log" + _nethttp "net/http" + _neturl "net/url" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/google/uuid" +) + +// FormsApi service type +type FormsApi datadog.Service + +// CreateAndPublishForm Create and publish a form. +// Creates a new form and immediately publishes its initial version. +func (a *FormsApi) CreateAndPublishForm(ctx _context.Context, body CreateFormRequest) (FormResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPost + localVarPostBody interface{} + localVarReturnValue FormResponse + ) + + operationId := "v2.CreateAndPublishForm" + isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId) + if !isOperationEnabled { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)} + } + if isOperationEnabled && a.Client.Cfg.Debug { + _log.Printf("WARNING: Using unstable operation '%s'", operationId) + } + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.FormsApi.CreateAndPublishForm") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/forms/create_and_publish" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Content-Type"] = "application/json" + localVarHeaderParams["Accept"] = "application/json" + + // body params + localVarPostBody = &body + if a.Client.Cfg.DelegatedTokenConfig != nil { + err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig) + if err != nil { + return localVarReturnValue, nil, err + } + } else { + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + } + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 401 { + var v JSONAPIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +// CreateForm Create a form. +// Create a new form. +func (a *FormsApi) CreateForm(ctx _context.Context, body CreateFormRequest) (FormResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPost + localVarPostBody interface{} + localVarReturnValue FormResponse + ) + + operationId := "v2.CreateForm" + isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId) + if !isOperationEnabled { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)} + } + if isOperationEnabled && a.Client.Cfg.Debug { + _log.Printf("WARNING: Using unstable operation '%s'", operationId) + } + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.FormsApi.CreateForm") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/forms" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Content-Type"] = "application/json" + localVarHeaderParams["Accept"] = "application/json" + + // body params + localVarPostBody = &body + if a.Client.Cfg.DelegatedTokenConfig != nil { + err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig) + if err != nil { + return localVarReturnValue, nil, err + } + } else { + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + } + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 401 { + var v JSONAPIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +// DeleteForm Delete a form. +// Delete a form by its ID. +func (a *FormsApi) DeleteForm(ctx _context.Context, formId uuid.UUID) (DeleteFormResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodDelete + localVarPostBody interface{} + localVarReturnValue DeleteFormResponse + ) + + operationId := "v2.DeleteForm" + isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId) + if !isOperationEnabled { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)} + } + if isOperationEnabled && a.Client.Cfg.Debug { + _log.Printf("WARNING: Using unstable operation '%s'", operationId) + } + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.FormsApi.DeleteForm") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/forms/{form_id}" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{form_id}", _neturl.PathEscape(datadog.ParameterToString(formId, ""))) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Accept"] = "application/json" + + if a.Client.Cfg.DelegatedTokenConfig != nil { + err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig) + if err != nil { + return localVarReturnValue, nil, err + } + } else { + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + } + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 401 { + var v JSONAPIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +// GetFormOptionalParameters holds optional parameters for GetForm. +type GetFormOptionalParameters struct { + Version *string +} + +// NewGetFormOptionalParameters creates an empty struct for parameters. +func NewGetFormOptionalParameters() *GetFormOptionalParameters { + this := GetFormOptionalParameters{} + return &this +} + +// WithVersion sets the corresponding parameter name and returns the struct. +func (r *GetFormOptionalParameters) WithVersion(version string) *GetFormOptionalParameters { + r.Version = &version + return r +} + +// GetForm Get a form. +// Get a form by its ID. +func (a *FormsApi) GetForm(ctx _context.Context, formId uuid.UUID, o ...GetFormOptionalParameters) (FormResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarReturnValue FormResponse + optionalParams GetFormOptionalParameters + ) + + if len(o) > 1 { + return localVarReturnValue, nil, datadog.ReportError("only one argument of type GetFormOptionalParameters is allowed") + } + if len(o) == 1 { + optionalParams = o[0] + } + + operationId := "v2.GetForm" + isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId) + if !isOperationEnabled { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)} + } + if isOperationEnabled && a.Client.Cfg.Debug { + _log.Printf("WARNING: Using unstable operation '%s'", operationId) + } + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.FormsApi.GetForm") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/forms/{form_id}" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{form_id}", _neturl.PathEscape(datadog.ParameterToString(formId, ""))) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + if optionalParams.Version != nil { + localVarQueryParams.Add("version", datadog.ParameterToString(*optionalParams.Version, "")) + } + localVarHeaderParams["Accept"] = "application/json" + + if a.Client.Cfg.DelegatedTokenConfig != nil { + err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig) + if err != nil { + return localVarReturnValue, nil, err + } + } else { + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + } + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 401 || localVarHTTPResponse.StatusCode == 404 { + var v JSONAPIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +// ListForms List forms. +// Get all forms for the authenticated user's organization. +func (a *FormsApi) ListForms(ctx _context.Context) (FormsResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarReturnValue FormsResponse + ) + + operationId := "v2.ListForms" + isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId) + if !isOperationEnabled { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)} + } + if isOperationEnabled && a.Client.Cfg.Debug { + _log.Printf("WARNING: Using unstable operation '%s'", operationId) + } + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.FormsApi.ListForms") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/forms" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Accept"] = "application/json" + + if a.Client.Cfg.DelegatedTokenConfig != nil { + err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig) + if err != nil { + return localVarReturnValue, nil, err + } + } else { + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + } + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 401 { + var v JSONAPIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +// NewFormsApi Returns NewFormsApi. +func NewFormsApi(client *datadog.APIClient) *FormsApi { + return &FormsApi{ + Client: client, + } +} diff --git a/api/datadogV2/doc.go b/api/datadogV2/doc.go index 0a19a63b108..e33262fbe72 100644 --- a/api/datadogV2/doc.go +++ b/api/datadogV2/doc.go @@ -435,6 +435,11 @@ // - [FleetAutomationApi.ListFleetTracers] // - [FleetAutomationApi.TriggerFleetSchedule] // - [FleetAutomationApi.UpdateFleetSchedule] +// - [FormsApi.CreateAndPublishForm] +// - [FormsApi.CreateForm] +// - [FormsApi.DeleteForm] +// - [FormsApi.GetForm] +// - [FormsApi.ListForms] // - [GCPIntegrationApi.CreateGCPSTSAccount] // - [GCPIntegrationApi.DeleteGCPSTSAccount] // - [GCPIntegrationApi.GetGCPSTSDelegate] diff --git a/api/datadogV2/model_create_form_data.go b/api/datadogV2/model_create_form_data.go new file mode 100644 index 00000000000..6e5cb319769 --- /dev/null +++ b/api/datadogV2/model_create_form_data.go @@ -0,0 +1,146 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// CreateFormData The data for creating a form. +type CreateFormData struct { + // The attributes for creating a form. + Attributes CreateFormDataAttributes `json:"attributes"` + // The resource type for a form. + Type FormType `json:"type"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewCreateFormData instantiates a new CreateFormData object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewCreateFormData(attributes CreateFormDataAttributes, typeVar FormType) *CreateFormData { + this := CreateFormData{} + this.Attributes = attributes + this.Type = typeVar + return &this +} + +// NewCreateFormDataWithDefaults instantiates a new CreateFormData object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewCreateFormDataWithDefaults() *CreateFormData { + this := CreateFormData{} + return &this +} + +// GetAttributes returns the Attributes field value. +func (o *CreateFormData) GetAttributes() CreateFormDataAttributes { + if o == nil { + var ret CreateFormDataAttributes + return ret + } + return o.Attributes +} + +// GetAttributesOk returns a tuple with the Attributes field value +// and a boolean to check if the value has been set. +func (o *CreateFormData) GetAttributesOk() (*CreateFormDataAttributes, bool) { + if o == nil { + return nil, false + } + return &o.Attributes, true +} + +// SetAttributes sets field value. +func (o *CreateFormData) SetAttributes(v CreateFormDataAttributes) { + o.Attributes = v +} + +// GetType returns the Type field value. +func (o *CreateFormData) GetType() FormType { + if o == nil { + var ret FormType + return ret + } + return o.Type +} + +// GetTypeOk returns a tuple with the Type field value +// and a boolean to check if the value has been set. +func (o *CreateFormData) GetTypeOk() (*FormType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *CreateFormData) SetType(v FormType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o CreateFormData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["attributes"] = o.Attributes + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *CreateFormData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *CreateFormDataAttributes `json:"attributes"` + Type *FormType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Attributes == nil { + return fmt.Errorf("required field attributes missing") + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "type"}) + } else { + return err + } + + hasInvalidField := false + if all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Attributes = *all.Attributes + if !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = *all.Type + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_create_form_data_attributes.go b/api/datadogV2/model_create_form_data_attributes.go new file mode 100644 index 00000000000..19a92979f06 --- /dev/null +++ b/api/datadogV2/model_create_form_data_attributes.go @@ -0,0 +1,317 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// CreateFormDataAttributes The attributes for creating a form. +type CreateFormDataAttributes struct { + // Whether the form accepts anonymous submissions. + Anonymous *bool `json:"anonymous,omitempty"` + // A JSON Schema definition that describes the form's data fields. + DataDefinition FormDataDefinition `json:"data_definition"` + // The description of the form. + Description *string `json:"description,omitempty"` + // Whether the form is an IDP survey. + IdpSurvey *bool `json:"idp_survey,omitempty"` + // The name of the form. + Name string `json:"name"` + // Whether each user can only submit one response. + SingleResponse *bool `json:"single_response,omitempty"` + // UI configuration for rendering form fields, including widget overrides, field ordering, and themes. + UiDefinition FormUiDefinition `json:"ui_definition"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewCreateFormDataAttributes instantiates a new CreateFormDataAttributes object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewCreateFormDataAttributes(dataDefinition FormDataDefinition, name string, uiDefinition FormUiDefinition) *CreateFormDataAttributes { + this := CreateFormDataAttributes{} + this.DataDefinition = dataDefinition + this.Name = name + this.UiDefinition = uiDefinition + return &this +} + +// NewCreateFormDataAttributesWithDefaults instantiates a new CreateFormDataAttributes object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewCreateFormDataAttributesWithDefaults() *CreateFormDataAttributes { + this := CreateFormDataAttributes{} + return &this +} + +// GetAnonymous returns the Anonymous field value if set, zero value otherwise. +func (o *CreateFormDataAttributes) GetAnonymous() bool { + if o == nil || o.Anonymous == nil { + var ret bool + return ret + } + return *o.Anonymous +} + +// GetAnonymousOk returns a tuple with the Anonymous field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CreateFormDataAttributes) GetAnonymousOk() (*bool, bool) { + if o == nil || o.Anonymous == nil { + return nil, false + } + return o.Anonymous, true +} + +// HasAnonymous returns a boolean if a field has been set. +func (o *CreateFormDataAttributes) HasAnonymous() bool { + return o != nil && o.Anonymous != nil +} + +// SetAnonymous gets a reference to the given bool and assigns it to the Anonymous field. +func (o *CreateFormDataAttributes) SetAnonymous(v bool) { + o.Anonymous = &v +} + +// GetDataDefinition returns the DataDefinition field value. +func (o *CreateFormDataAttributes) GetDataDefinition() FormDataDefinition { + if o == nil { + var ret FormDataDefinition + return ret + } + return o.DataDefinition +} + +// GetDataDefinitionOk returns a tuple with the DataDefinition field value +// and a boolean to check if the value has been set. +func (o *CreateFormDataAttributes) GetDataDefinitionOk() (*FormDataDefinition, bool) { + if o == nil { + return nil, false + } + return &o.DataDefinition, true +} + +// SetDataDefinition sets field value. +func (o *CreateFormDataAttributes) SetDataDefinition(v FormDataDefinition) { + o.DataDefinition = v +} + +// GetDescription returns the Description field value if set, zero value otherwise. +func (o *CreateFormDataAttributes) GetDescription() string { + if o == nil || o.Description == nil { + var ret string + return ret + } + return *o.Description +} + +// GetDescriptionOk returns a tuple with the Description field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CreateFormDataAttributes) GetDescriptionOk() (*string, bool) { + if o == nil || o.Description == nil { + return nil, false + } + return o.Description, true +} + +// HasDescription returns a boolean if a field has been set. +func (o *CreateFormDataAttributes) HasDescription() bool { + return o != nil && o.Description != nil +} + +// SetDescription gets a reference to the given string and assigns it to the Description field. +func (o *CreateFormDataAttributes) SetDescription(v string) { + o.Description = &v +} + +// GetIdpSurvey returns the IdpSurvey field value if set, zero value otherwise. +func (o *CreateFormDataAttributes) GetIdpSurvey() bool { + if o == nil || o.IdpSurvey == nil { + var ret bool + return ret + } + return *o.IdpSurvey +} + +// GetIdpSurveyOk returns a tuple with the IdpSurvey field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CreateFormDataAttributes) GetIdpSurveyOk() (*bool, bool) { + if o == nil || o.IdpSurvey == nil { + return nil, false + } + return o.IdpSurvey, true +} + +// HasIdpSurvey returns a boolean if a field has been set. +func (o *CreateFormDataAttributes) HasIdpSurvey() bool { + return o != nil && o.IdpSurvey != nil +} + +// SetIdpSurvey gets a reference to the given bool and assigns it to the IdpSurvey field. +func (o *CreateFormDataAttributes) SetIdpSurvey(v bool) { + o.IdpSurvey = &v +} + +// GetName returns the Name field value. +func (o *CreateFormDataAttributes) GetName() string { + if o == nil { + var ret string + return ret + } + return o.Name +} + +// GetNameOk returns a tuple with the Name field value +// and a boolean to check if the value has been set. +func (o *CreateFormDataAttributes) GetNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Name, true +} + +// SetName sets field value. +func (o *CreateFormDataAttributes) SetName(v string) { + o.Name = v +} + +// GetSingleResponse returns the SingleResponse field value if set, zero value otherwise. +func (o *CreateFormDataAttributes) GetSingleResponse() bool { + if o == nil || o.SingleResponse == nil { + var ret bool + return ret + } + return *o.SingleResponse +} + +// GetSingleResponseOk returns a tuple with the SingleResponse field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CreateFormDataAttributes) GetSingleResponseOk() (*bool, bool) { + if o == nil || o.SingleResponse == nil { + return nil, false + } + return o.SingleResponse, true +} + +// HasSingleResponse returns a boolean if a field has been set. +func (o *CreateFormDataAttributes) HasSingleResponse() bool { + return o != nil && o.SingleResponse != nil +} + +// SetSingleResponse gets a reference to the given bool and assigns it to the SingleResponse field. +func (o *CreateFormDataAttributes) SetSingleResponse(v bool) { + o.SingleResponse = &v +} + +// GetUiDefinition returns the UiDefinition field value. +func (o *CreateFormDataAttributes) GetUiDefinition() FormUiDefinition { + if o == nil { + var ret FormUiDefinition + return ret + } + return o.UiDefinition +} + +// GetUiDefinitionOk returns a tuple with the UiDefinition field value +// and a boolean to check if the value has been set. +func (o *CreateFormDataAttributes) GetUiDefinitionOk() (*FormUiDefinition, bool) { + if o == nil { + return nil, false + } + return &o.UiDefinition, true +} + +// SetUiDefinition sets field value. +func (o *CreateFormDataAttributes) SetUiDefinition(v FormUiDefinition) { + o.UiDefinition = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o CreateFormDataAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Anonymous != nil { + toSerialize["anonymous"] = o.Anonymous + } + toSerialize["data_definition"] = o.DataDefinition + if o.Description != nil { + toSerialize["description"] = o.Description + } + if o.IdpSurvey != nil { + toSerialize["idp_survey"] = o.IdpSurvey + } + toSerialize["name"] = o.Name + if o.SingleResponse != nil { + toSerialize["single_response"] = o.SingleResponse + } + toSerialize["ui_definition"] = o.UiDefinition + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *CreateFormDataAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Anonymous *bool `json:"anonymous,omitempty"` + DataDefinition *FormDataDefinition `json:"data_definition"` + Description *string `json:"description,omitempty"` + IdpSurvey *bool `json:"idp_survey,omitempty"` + Name *string `json:"name"` + SingleResponse *bool `json:"single_response,omitempty"` + UiDefinition *FormUiDefinition `json:"ui_definition"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.DataDefinition == nil { + return fmt.Errorf("required field data_definition missing") + } + if all.Name == nil { + return fmt.Errorf("required field name missing") + } + if all.UiDefinition == nil { + return fmt.Errorf("required field ui_definition missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"anonymous", "data_definition", "description", "idp_survey", "name", "single_response", "ui_definition"}) + } else { + return err + } + + hasInvalidField := false + o.Anonymous = all.Anonymous + if all.DataDefinition.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.DataDefinition = *all.DataDefinition + o.Description = all.Description + o.IdpSurvey = all.IdpSurvey + o.Name = *all.Name + o.SingleResponse = all.SingleResponse + if all.UiDefinition.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.UiDefinition = *all.UiDefinition + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_create_form_request.go b/api/datadogV2/model_create_form_request.go new file mode 100644 index 00000000000..03d0542716a --- /dev/null +++ b/api/datadogV2/model_create_form_request.go @@ -0,0 +1,110 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// CreateFormRequest A request to create a form. +type CreateFormRequest struct { + // The data for creating a form. + Data CreateFormData `json:"data"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewCreateFormRequest instantiates a new CreateFormRequest object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewCreateFormRequest(data CreateFormData) *CreateFormRequest { + this := CreateFormRequest{} + this.Data = data + return &this +} + +// NewCreateFormRequestWithDefaults instantiates a new CreateFormRequest object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewCreateFormRequestWithDefaults() *CreateFormRequest { + this := CreateFormRequest{} + return &this +} + +// GetData returns the Data field value. +func (o *CreateFormRequest) GetData() CreateFormData { + if o == nil { + var ret CreateFormData + return ret + } + return o.Data +} + +// GetDataOk returns a tuple with the Data field value +// and a boolean to check if the value has been set. +func (o *CreateFormRequest) GetDataOk() (*CreateFormData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *CreateFormRequest) SetData(v CreateFormData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o CreateFormRequest) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["data"] = o.Data + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *CreateFormRequest) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *CreateFormData `json:"data"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Data == nil { + return fmt.Errorf("required field data missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + + hasInvalidField := false + if all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Data = *all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_delete_form_data.go b/api/datadogV2/model_delete_form_data.go new file mode 100644 index 00000000000..b30b9128b6f --- /dev/null +++ b/api/datadogV2/model_delete_form_data.go @@ -0,0 +1,145 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/google/uuid" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// DeleteFormData The data returned when a form is deleted. +type DeleteFormData struct { + // The ID of the deleted form. + Id uuid.UUID `json:"id"` + // The resource type for a form. + Type FormType `json:"type"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewDeleteFormData instantiates a new DeleteFormData object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewDeleteFormData(id uuid.UUID, typeVar FormType) *DeleteFormData { + this := DeleteFormData{} + this.Id = id + this.Type = typeVar + return &this +} + +// NewDeleteFormDataWithDefaults instantiates a new DeleteFormData object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewDeleteFormDataWithDefaults() *DeleteFormData { + this := DeleteFormData{} + return &this +} + +// GetId returns the Id field value. +func (o *DeleteFormData) GetId() uuid.UUID { + if o == nil { + var ret uuid.UUID + return ret + } + return o.Id +} + +// GetIdOk returns a tuple with the Id field value +// and a boolean to check if the value has been set. +func (o *DeleteFormData) GetIdOk() (*uuid.UUID, bool) { + if o == nil { + return nil, false + } + return &o.Id, true +} + +// SetId sets field value. +func (o *DeleteFormData) SetId(v uuid.UUID) { + o.Id = v +} + +// GetType returns the Type field value. +func (o *DeleteFormData) GetType() FormType { + if o == nil { + var ret FormType + return ret + } + return o.Type +} + +// GetTypeOk returns a tuple with the Type field value +// and a boolean to check if the value has been set. +func (o *DeleteFormData) GetTypeOk() (*FormType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *DeleteFormData) SetType(v FormType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o DeleteFormData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["id"] = o.Id + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *DeleteFormData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Id *uuid.UUID `json:"id"` + Type *FormType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Id == nil { + return fmt.Errorf("required field id missing") + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"id", "type"}) + } else { + return err + } + + hasInvalidField := false + o.Id = *all.Id + if !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = *all.Type + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_delete_form_response.go b/api/datadogV2/model_delete_form_response.go new file mode 100644 index 00000000000..eba77bcee0c --- /dev/null +++ b/api/datadogV2/model_delete_form_response.go @@ -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. + +package datadogV2 + +import ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// DeleteFormResponse A response returned after deleting a form. +type DeleteFormResponse struct { + // The data returned when a form is deleted. + Data *DeleteFormData `json:"data,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewDeleteFormResponse instantiates a new DeleteFormResponse object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewDeleteFormResponse() *DeleteFormResponse { + this := DeleteFormResponse{} + return &this +} + +// NewDeleteFormResponseWithDefaults instantiates a new DeleteFormResponse object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewDeleteFormResponseWithDefaults() *DeleteFormResponse { + this := DeleteFormResponse{} + return &this +} + +// GetData returns the Data field value if set, zero value otherwise. +func (o *DeleteFormResponse) GetData() DeleteFormData { + if o == nil || o.Data == nil { + var ret DeleteFormData + return ret + } + return *o.Data +} + +// GetDataOk returns a tuple with the Data field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *DeleteFormResponse) GetDataOk() (*DeleteFormData, bool) { + if o == nil || o.Data == nil { + return nil, false + } + return o.Data, true +} + +// HasData returns a boolean if a field has been set. +func (o *DeleteFormResponse) HasData() bool { + return o != nil && o.Data != nil +} + +// SetData gets a reference to the given DeleteFormData and assigns it to the Data field. +func (o *DeleteFormResponse) SetData(v DeleteFormData) { + o.Data = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o DeleteFormResponse) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Data != nil { + toSerialize["data"] = o.Data + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *DeleteFormResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *DeleteFormData `json:"data,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + + hasInvalidField := false + if all.Data != nil && all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Data = all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_form_data.go b/api/datadogV2/model_form_data.go new file mode 100644 index 00000000000..6a24b7782cd --- /dev/null +++ b/api/datadogV2/model_form_data.go @@ -0,0 +1,180 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/google/uuid" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// FormData A form resource object. +type FormData struct { + // The attributes of a form. + Attributes FormDataAttributes `json:"attributes"` + // The ID of the form. + Id uuid.UUID `json:"id"` + // The resource type for a form. + Type FormType `json:"type"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewFormData instantiates a new FormData object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewFormData(attributes FormDataAttributes, id uuid.UUID, typeVar FormType) *FormData { + this := FormData{} + this.Attributes = attributes + this.Id = id + this.Type = typeVar + return &this +} + +// NewFormDataWithDefaults instantiates a new FormData object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewFormDataWithDefaults() *FormData { + this := FormData{} + return &this +} + +// GetAttributes returns the Attributes field value. +func (o *FormData) GetAttributes() FormDataAttributes { + if o == nil { + var ret FormDataAttributes + return ret + } + return o.Attributes +} + +// GetAttributesOk returns a tuple with the Attributes field value +// and a boolean to check if the value has been set. +func (o *FormData) GetAttributesOk() (*FormDataAttributes, bool) { + if o == nil { + return nil, false + } + return &o.Attributes, true +} + +// SetAttributes sets field value. +func (o *FormData) SetAttributes(v FormDataAttributes) { + o.Attributes = v +} + +// GetId returns the Id field value. +func (o *FormData) GetId() uuid.UUID { + if o == nil { + var ret uuid.UUID + return ret + } + return o.Id +} + +// GetIdOk returns a tuple with the Id field value +// and a boolean to check if the value has been set. +func (o *FormData) GetIdOk() (*uuid.UUID, bool) { + if o == nil { + return nil, false + } + return &o.Id, true +} + +// SetId sets field value. +func (o *FormData) SetId(v uuid.UUID) { + o.Id = v +} + +// GetType returns the Type field value. +func (o *FormData) GetType() FormType { + if o == nil { + var ret FormType + return ret + } + return o.Type +} + +// GetTypeOk returns a tuple with the Type field value +// and a boolean to check if the value has been set. +func (o *FormData) GetTypeOk() (*FormType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *FormData) SetType(v FormType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o FormData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["attributes"] = o.Attributes + toSerialize["id"] = o.Id + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *FormData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *FormDataAttributes `json:"attributes"` + Id *uuid.UUID `json:"id"` + Type *FormType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Attributes == nil { + return fmt.Errorf("required field attributes missing") + } + if all.Id == nil { + return fmt.Errorf("required field id missing") + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "id", "type"}) + } else { + return err + } + + hasInvalidField := false + if all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Attributes = *all.Attributes + o.Id = *all.Id + if !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = *all.Type + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_form_data_attributes.go b/api/datadogV2/model_form_data_attributes.go new file mode 100644 index 00000000000..206b70bb3ab --- /dev/null +++ b/api/datadogV2/model_form_data_attributes.go @@ -0,0 +1,673 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + "time" + + "github.com/google/uuid" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// FormDataAttributes The attributes of a form. +type FormDataAttributes struct { + // Whether the form is currently active. + Active bool `json:"active"` + // Whether the form accepts anonymous submissions. + Anonymous bool `json:"anonymous"` + // The time at which the form was created. + CreatedAt time.Time `json:"created_at"` + // The datastore configuration for a form. + DatastoreConfig FormDatastoreConfigAttributes `json:"datastore_config"` + // The description of the form. + Description string `json:"description"` + // The date and time at which the form stops accepting responses. + EndDate datadog.NullableTime `json:"end_date,omitempty"` + // Whether the current user has already submitted this form. Only present for forms with `single_response` set to `true`. + HasSubmitted datadog.NullableBool `json:"has_submitted,omitempty"` + // Whether the form is an IDP survey. + IdpSurvey bool `json:"idp_survey"` + // The time at which the form was last modified. + ModifiedAt time.Time `json:"modified_at"` + // The name of the form. + Name string `json:"name"` + // The ID of the organization that owns this form. + OrgId int64 `json:"org_id"` + // The attributes of a form publication. + Publication *FormPublicationAttributes `json:"publication,omitempty"` + // Whether the form is available in the self-service catalog. + SelfService bool `json:"self_service"` + // Whether each user can only submit one response. + SingleResponse bool `json:"single_response"` + // The ID of the user who created this form. + UserId int64 `json:"user_id"` + // The UUID of the user who created this form. + UserUuid uuid.UUID `json:"user_uuid"` + // The attributes of a form version. + Version *FormVersionAttributes `json:"version,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewFormDataAttributes instantiates a new FormDataAttributes object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewFormDataAttributes(active bool, anonymous bool, createdAt time.Time, datastoreConfig FormDatastoreConfigAttributes, description string, idpSurvey bool, modifiedAt time.Time, name string, orgId int64, selfService bool, singleResponse bool, userId int64, userUuid uuid.UUID) *FormDataAttributes { + this := FormDataAttributes{} + this.Active = active + this.Anonymous = anonymous + this.CreatedAt = createdAt + this.DatastoreConfig = datastoreConfig + this.Description = description + this.IdpSurvey = idpSurvey + this.ModifiedAt = modifiedAt + this.Name = name + this.OrgId = orgId + this.SelfService = selfService + this.SingleResponse = singleResponse + this.UserId = userId + this.UserUuid = userUuid + return &this +} + +// NewFormDataAttributesWithDefaults instantiates a new FormDataAttributes object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewFormDataAttributesWithDefaults() *FormDataAttributes { + this := FormDataAttributes{} + return &this +} + +// GetActive returns the Active field value. +func (o *FormDataAttributes) GetActive() bool { + if o == nil { + var ret bool + return ret + } + return o.Active +} + +// GetActiveOk returns a tuple with the Active field value +// and a boolean to check if the value has been set. +func (o *FormDataAttributes) GetActiveOk() (*bool, bool) { + if o == nil { + return nil, false + } + return &o.Active, true +} + +// SetActive sets field value. +func (o *FormDataAttributes) SetActive(v bool) { + o.Active = v +} + +// GetAnonymous returns the Anonymous field value. +func (o *FormDataAttributes) GetAnonymous() bool { + if o == nil { + var ret bool + return ret + } + return o.Anonymous +} + +// GetAnonymousOk returns a tuple with the Anonymous field value +// and a boolean to check if the value has been set. +func (o *FormDataAttributes) GetAnonymousOk() (*bool, bool) { + if o == nil { + return nil, false + } + return &o.Anonymous, true +} + +// SetAnonymous sets field value. +func (o *FormDataAttributes) SetAnonymous(v bool) { + o.Anonymous = v +} + +// GetCreatedAt returns the CreatedAt field value. +func (o *FormDataAttributes) GetCreatedAt() time.Time { + if o == nil { + var ret time.Time + return ret + } + return o.CreatedAt +} + +// GetCreatedAtOk returns a tuple with the CreatedAt field value +// and a boolean to check if the value has been set. +func (o *FormDataAttributes) GetCreatedAtOk() (*time.Time, bool) { + if o == nil { + return nil, false + } + return &o.CreatedAt, true +} + +// SetCreatedAt sets field value. +func (o *FormDataAttributes) SetCreatedAt(v time.Time) { + o.CreatedAt = v +} + +// GetDatastoreConfig returns the DatastoreConfig field value. +func (o *FormDataAttributes) GetDatastoreConfig() FormDatastoreConfigAttributes { + if o == nil { + var ret FormDatastoreConfigAttributes + return ret + } + return o.DatastoreConfig +} + +// GetDatastoreConfigOk returns a tuple with the DatastoreConfig field value +// and a boolean to check if the value has been set. +func (o *FormDataAttributes) GetDatastoreConfigOk() (*FormDatastoreConfigAttributes, bool) { + if o == nil { + return nil, false + } + return &o.DatastoreConfig, true +} + +// SetDatastoreConfig sets field value. +func (o *FormDataAttributes) SetDatastoreConfig(v FormDatastoreConfigAttributes) { + o.DatastoreConfig = v +} + +// GetDescription returns the Description field value. +func (o *FormDataAttributes) GetDescription() string { + if o == nil { + var ret string + return ret + } + return o.Description +} + +// GetDescriptionOk returns a tuple with the Description field value +// and a boolean to check if the value has been set. +func (o *FormDataAttributes) GetDescriptionOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Description, true +} + +// SetDescription sets field value. +func (o *FormDataAttributes) SetDescription(v string) { + o.Description = v +} + +// GetEndDate returns the EndDate field value if set, zero value otherwise (both if not set or set to explicit null). +func (o *FormDataAttributes) GetEndDate() time.Time { + if o == nil || o.EndDate.Get() == nil { + var ret time.Time + return ret + } + return *o.EndDate.Get() +} + +// GetEndDateOk returns a tuple with the EndDate field value if set, nil otherwise +// and a boolean to check if the value has been set. +// NOTE: If the value is an explicit nil, `nil, true` will be returned. +func (o *FormDataAttributes) GetEndDateOk() (*time.Time, bool) { + if o == nil { + return nil, false + } + return o.EndDate.Get(), o.EndDate.IsSet() +} + +// HasEndDate returns a boolean if a field has been set. +func (o *FormDataAttributes) HasEndDate() bool { + return o != nil && o.EndDate.IsSet() +} + +// SetEndDate gets a reference to the given datadog.NullableTime and assigns it to the EndDate field. +func (o *FormDataAttributes) SetEndDate(v time.Time) { + o.EndDate.Set(&v) +} + +// SetEndDateNil sets the value for EndDate to be an explicit nil. +func (o *FormDataAttributes) SetEndDateNil() { + o.EndDate.Set(nil) +} + +// UnsetEndDate ensures that no value is present for EndDate, not even an explicit nil. +func (o *FormDataAttributes) UnsetEndDate() { + o.EndDate.Unset() +} + +// GetHasSubmitted returns the HasSubmitted field value if set, zero value otherwise (both if not set or set to explicit null). +func (o *FormDataAttributes) GetHasSubmitted() bool { + if o == nil || o.HasSubmitted.Get() == nil { + var ret bool + return ret + } + return *o.HasSubmitted.Get() +} + +// GetHasSubmittedOk returns a tuple with the HasSubmitted field value if set, nil otherwise +// and a boolean to check if the value has been set. +// NOTE: If the value is an explicit nil, `nil, true` will be returned. +func (o *FormDataAttributes) GetHasSubmittedOk() (*bool, bool) { + if o == nil { + return nil, false + } + return o.HasSubmitted.Get(), o.HasSubmitted.IsSet() +} + +// HasHasSubmitted returns a boolean if a field has been set. +func (o *FormDataAttributes) HasHasSubmitted() bool { + return o != nil && o.HasSubmitted.IsSet() +} + +// SetHasSubmitted gets a reference to the given datadog.NullableBool and assigns it to the HasSubmitted field. +func (o *FormDataAttributes) SetHasSubmitted(v bool) { + o.HasSubmitted.Set(&v) +} + +// SetHasSubmittedNil sets the value for HasSubmitted to be an explicit nil. +func (o *FormDataAttributes) SetHasSubmittedNil() { + o.HasSubmitted.Set(nil) +} + +// UnsetHasSubmitted ensures that no value is present for HasSubmitted, not even an explicit nil. +func (o *FormDataAttributes) UnsetHasSubmitted() { + o.HasSubmitted.Unset() +} + +// GetIdpSurvey returns the IdpSurvey field value. +func (o *FormDataAttributes) GetIdpSurvey() bool { + if o == nil { + var ret bool + return ret + } + return o.IdpSurvey +} + +// GetIdpSurveyOk returns a tuple with the IdpSurvey field value +// and a boolean to check if the value has been set. +func (o *FormDataAttributes) GetIdpSurveyOk() (*bool, bool) { + if o == nil { + return nil, false + } + return &o.IdpSurvey, true +} + +// SetIdpSurvey sets field value. +func (o *FormDataAttributes) SetIdpSurvey(v bool) { + o.IdpSurvey = v +} + +// GetModifiedAt returns the ModifiedAt field value. +func (o *FormDataAttributes) GetModifiedAt() time.Time { + if o == nil { + var ret time.Time + return ret + } + return o.ModifiedAt +} + +// GetModifiedAtOk returns a tuple with the ModifiedAt field value +// and a boolean to check if the value has been set. +func (o *FormDataAttributes) GetModifiedAtOk() (*time.Time, bool) { + if o == nil { + return nil, false + } + return &o.ModifiedAt, true +} + +// SetModifiedAt sets field value. +func (o *FormDataAttributes) SetModifiedAt(v time.Time) { + o.ModifiedAt = v +} + +// GetName returns the Name field value. +func (o *FormDataAttributes) GetName() string { + if o == nil { + var ret string + return ret + } + return o.Name +} + +// GetNameOk returns a tuple with the Name field value +// and a boolean to check if the value has been set. +func (o *FormDataAttributes) GetNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Name, true +} + +// SetName sets field value. +func (o *FormDataAttributes) SetName(v string) { + o.Name = v +} + +// GetOrgId returns the OrgId field value. +func (o *FormDataAttributes) GetOrgId() int64 { + if o == nil { + var ret int64 + return ret + } + return o.OrgId +} + +// GetOrgIdOk returns a tuple with the OrgId field value +// and a boolean to check if the value has been set. +func (o *FormDataAttributes) GetOrgIdOk() (*int64, bool) { + if o == nil { + return nil, false + } + return &o.OrgId, true +} + +// SetOrgId sets field value. +func (o *FormDataAttributes) SetOrgId(v int64) { + o.OrgId = v +} + +// GetPublication returns the Publication field value if set, zero value otherwise. +func (o *FormDataAttributes) GetPublication() FormPublicationAttributes { + if o == nil || o.Publication == nil { + var ret FormPublicationAttributes + return ret + } + return *o.Publication +} + +// GetPublicationOk returns a tuple with the Publication field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *FormDataAttributes) GetPublicationOk() (*FormPublicationAttributes, bool) { + if o == nil || o.Publication == nil { + return nil, false + } + return o.Publication, true +} + +// HasPublication returns a boolean if a field has been set. +func (o *FormDataAttributes) HasPublication() bool { + return o != nil && o.Publication != nil +} + +// SetPublication gets a reference to the given FormPublicationAttributes and assigns it to the Publication field. +func (o *FormDataAttributes) SetPublication(v FormPublicationAttributes) { + o.Publication = &v +} + +// GetSelfService returns the SelfService field value. +func (o *FormDataAttributes) GetSelfService() bool { + if o == nil { + var ret bool + return ret + } + return o.SelfService +} + +// GetSelfServiceOk returns a tuple with the SelfService field value +// and a boolean to check if the value has been set. +func (o *FormDataAttributes) GetSelfServiceOk() (*bool, bool) { + if o == nil { + return nil, false + } + return &o.SelfService, true +} + +// SetSelfService sets field value. +func (o *FormDataAttributes) SetSelfService(v bool) { + o.SelfService = v +} + +// GetSingleResponse returns the SingleResponse field value. +func (o *FormDataAttributes) GetSingleResponse() bool { + if o == nil { + var ret bool + return ret + } + return o.SingleResponse +} + +// GetSingleResponseOk returns a tuple with the SingleResponse field value +// and a boolean to check if the value has been set. +func (o *FormDataAttributes) GetSingleResponseOk() (*bool, bool) { + if o == nil { + return nil, false + } + return &o.SingleResponse, true +} + +// SetSingleResponse sets field value. +func (o *FormDataAttributes) SetSingleResponse(v bool) { + o.SingleResponse = v +} + +// GetUserId returns the UserId field value. +func (o *FormDataAttributes) GetUserId() int64 { + if o == nil { + var ret int64 + return ret + } + return o.UserId +} + +// GetUserIdOk returns a tuple with the UserId field value +// and a boolean to check if the value has been set. +func (o *FormDataAttributes) GetUserIdOk() (*int64, bool) { + if o == nil { + return nil, false + } + return &o.UserId, true +} + +// SetUserId sets field value. +func (o *FormDataAttributes) SetUserId(v int64) { + o.UserId = v +} + +// GetUserUuid returns the UserUuid field value. +func (o *FormDataAttributes) GetUserUuid() uuid.UUID { + if o == nil { + var ret uuid.UUID + return ret + } + return o.UserUuid +} + +// GetUserUuidOk returns a tuple with the UserUuid field value +// and a boolean to check if the value has been set. +func (o *FormDataAttributes) GetUserUuidOk() (*uuid.UUID, bool) { + if o == nil { + return nil, false + } + return &o.UserUuid, true +} + +// SetUserUuid sets field value. +func (o *FormDataAttributes) SetUserUuid(v uuid.UUID) { + o.UserUuid = v +} + +// GetVersion returns the Version field value if set, zero value otherwise. +func (o *FormDataAttributes) GetVersion() FormVersionAttributes { + if o == nil || o.Version == nil { + var ret FormVersionAttributes + return ret + } + return *o.Version +} + +// GetVersionOk returns a tuple with the Version field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *FormDataAttributes) GetVersionOk() (*FormVersionAttributes, bool) { + if o == nil || o.Version == nil { + return nil, false + } + return o.Version, true +} + +// HasVersion returns a boolean if a field has been set. +func (o *FormDataAttributes) HasVersion() bool { + return o != nil && o.Version != nil +} + +// SetVersion gets a reference to the given FormVersionAttributes and assigns it to the Version field. +func (o *FormDataAttributes) SetVersion(v FormVersionAttributes) { + o.Version = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o FormDataAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["active"] = o.Active + toSerialize["anonymous"] = o.Anonymous + if o.CreatedAt.Nanosecond() == 0 { + toSerialize["created_at"] = o.CreatedAt.Format("2006-01-02T15:04:05Z07:00") + } else { + toSerialize["created_at"] = o.CreatedAt.Format("2006-01-02T15:04:05.000Z07:00") + } + toSerialize["datastore_config"] = o.DatastoreConfig + toSerialize["description"] = o.Description + if o.EndDate.IsSet() { + toSerialize["end_date"] = o.EndDate.Get() + } + if o.HasSubmitted.IsSet() { + toSerialize["has_submitted"] = o.HasSubmitted.Get() + } + toSerialize["idp_survey"] = o.IdpSurvey + if o.ModifiedAt.Nanosecond() == 0 { + toSerialize["modified_at"] = o.ModifiedAt.Format("2006-01-02T15:04:05Z07:00") + } else { + toSerialize["modified_at"] = o.ModifiedAt.Format("2006-01-02T15:04:05.000Z07:00") + } + toSerialize["name"] = o.Name + toSerialize["org_id"] = o.OrgId + if o.Publication != nil { + toSerialize["publication"] = o.Publication + } + toSerialize["self_service"] = o.SelfService + toSerialize["single_response"] = o.SingleResponse + toSerialize["user_id"] = o.UserId + toSerialize["user_uuid"] = o.UserUuid + if o.Version != nil { + toSerialize["version"] = o.Version + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *FormDataAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Active *bool `json:"active"` + Anonymous *bool `json:"anonymous"` + CreatedAt *time.Time `json:"created_at"` + DatastoreConfig *FormDatastoreConfigAttributes `json:"datastore_config"` + Description *string `json:"description"` + EndDate datadog.NullableTime `json:"end_date,omitempty"` + HasSubmitted datadog.NullableBool `json:"has_submitted,omitempty"` + IdpSurvey *bool `json:"idp_survey"` + ModifiedAt *time.Time `json:"modified_at"` + Name *string `json:"name"` + OrgId *int64 `json:"org_id"` + Publication *FormPublicationAttributes `json:"publication,omitempty"` + SelfService *bool `json:"self_service"` + SingleResponse *bool `json:"single_response"` + UserId *int64 `json:"user_id"` + UserUuid *uuid.UUID `json:"user_uuid"` + Version *FormVersionAttributes `json:"version,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Active == nil { + return fmt.Errorf("required field active missing") + } + if all.Anonymous == nil { + return fmt.Errorf("required field anonymous missing") + } + if all.CreatedAt == nil { + return fmt.Errorf("required field created_at missing") + } + if all.DatastoreConfig == nil { + return fmt.Errorf("required field datastore_config missing") + } + if all.Description == nil { + return fmt.Errorf("required field description missing") + } + if all.IdpSurvey == nil { + return fmt.Errorf("required field idp_survey missing") + } + if all.ModifiedAt == nil { + return fmt.Errorf("required field modified_at missing") + } + if all.Name == nil { + return fmt.Errorf("required field name missing") + } + if all.OrgId == nil { + return fmt.Errorf("required field org_id missing") + } + if all.SelfService == nil { + return fmt.Errorf("required field self_service missing") + } + if all.SingleResponse == nil { + return fmt.Errorf("required field single_response missing") + } + if all.UserId == nil { + return fmt.Errorf("required field user_id missing") + } + if all.UserUuid == nil { + return fmt.Errorf("required field user_uuid missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"active", "anonymous", "created_at", "datastore_config", "description", "end_date", "has_submitted", "idp_survey", "modified_at", "name", "org_id", "publication", "self_service", "single_response", "user_id", "user_uuid", "version"}) + } else { + return err + } + + hasInvalidField := false + o.Active = *all.Active + o.Anonymous = *all.Anonymous + o.CreatedAt = *all.CreatedAt + if all.DatastoreConfig.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.DatastoreConfig = *all.DatastoreConfig + o.Description = *all.Description + o.EndDate = all.EndDate + o.HasSubmitted = all.HasSubmitted + o.IdpSurvey = *all.IdpSurvey + o.ModifiedAt = *all.ModifiedAt + o.Name = *all.Name + o.OrgId = *all.OrgId + if all.Publication != nil && all.Publication.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Publication = all.Publication + o.SelfService = *all.SelfService + o.SingleResponse = *all.SingleResponse + o.UserId = *all.UserId + o.UserUuid = *all.UserUuid + if all.Version != nil && all.Version.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Version = all.Version + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_form_data_definition.go b/api/datadogV2/model_form_data_definition.go new file mode 100644 index 00000000000..f36da3c1364 --- /dev/null +++ b/api/datadogV2/model_form_data_definition.go @@ -0,0 +1,252 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// FormDataDefinition A JSON Schema definition that describes the form's data fields. +type FormDataDefinition struct { + // A description shown to form respondents. + Description *string `json:"description,omitempty"` + // A map of field names to their JSON Schema definitions. + Properties map[string]interface{} `json:"properties,omitempty"` + // List of field names that must be answered. + Required []string `json:"required,omitempty"` + // The title of the form schema. + Title *string `json:"title,omitempty"` + // The root schema type. Always "object". + Type *FormDataDefinitionType `json:"type,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewFormDataDefinition instantiates a new FormDataDefinition object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewFormDataDefinition() *FormDataDefinition { + this := FormDataDefinition{} + return &this +} + +// NewFormDataDefinitionWithDefaults instantiates a new FormDataDefinition object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewFormDataDefinitionWithDefaults() *FormDataDefinition { + this := FormDataDefinition{} + return &this +} + +// GetDescription returns the Description field value if set, zero value otherwise. +func (o *FormDataDefinition) GetDescription() string { + if o == nil || o.Description == nil { + var ret string + return ret + } + return *o.Description +} + +// GetDescriptionOk returns a tuple with the Description field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *FormDataDefinition) GetDescriptionOk() (*string, bool) { + if o == nil || o.Description == nil { + return nil, false + } + return o.Description, true +} + +// HasDescription returns a boolean if a field has been set. +func (o *FormDataDefinition) HasDescription() bool { + return o != nil && o.Description != nil +} + +// SetDescription gets a reference to the given string and assigns it to the Description field. +func (o *FormDataDefinition) SetDescription(v string) { + o.Description = &v +} + +// GetProperties returns the Properties field value if set, zero value otherwise. +func (o *FormDataDefinition) GetProperties() map[string]interface{} { + if o == nil || o.Properties == nil { + var ret map[string]interface{} + return ret + } + return o.Properties +} + +// GetPropertiesOk returns a tuple with the Properties field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *FormDataDefinition) GetPropertiesOk() (*map[string]interface{}, bool) { + if o == nil || o.Properties == nil { + return nil, false + } + return &o.Properties, true +} + +// HasProperties returns a boolean if a field has been set. +func (o *FormDataDefinition) HasProperties() bool { + return o != nil && o.Properties != nil +} + +// SetProperties gets a reference to the given map[string]interface{} and assigns it to the Properties field. +func (o *FormDataDefinition) SetProperties(v map[string]interface{}) { + o.Properties = v +} + +// GetRequired returns the Required field value if set, zero value otherwise. +func (o *FormDataDefinition) GetRequired() []string { + if o == nil || o.Required == nil { + var ret []string + return ret + } + return o.Required +} + +// GetRequiredOk returns a tuple with the Required field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *FormDataDefinition) GetRequiredOk() (*[]string, bool) { + if o == nil || o.Required == nil { + return nil, false + } + return &o.Required, true +} + +// HasRequired returns a boolean if a field has been set. +func (o *FormDataDefinition) HasRequired() bool { + return o != nil && o.Required != nil +} + +// SetRequired gets a reference to the given []string and assigns it to the Required field. +func (o *FormDataDefinition) SetRequired(v []string) { + o.Required = v +} + +// GetTitle returns the Title field value if set, zero value otherwise. +func (o *FormDataDefinition) GetTitle() string { + if o == nil || o.Title == nil { + var ret string + return ret + } + return *o.Title +} + +// GetTitleOk returns a tuple with the Title field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *FormDataDefinition) GetTitleOk() (*string, bool) { + if o == nil || o.Title == nil { + return nil, false + } + return o.Title, true +} + +// HasTitle returns a boolean if a field has been set. +func (o *FormDataDefinition) HasTitle() bool { + return o != nil && o.Title != nil +} + +// SetTitle gets a reference to the given string and assigns it to the Title field. +func (o *FormDataDefinition) SetTitle(v string) { + o.Title = &v +} + +// GetType returns the Type field value if set, zero value otherwise. +func (o *FormDataDefinition) GetType() FormDataDefinitionType { + if o == nil || o.Type == nil { + var ret FormDataDefinitionType + return ret + } + return *o.Type +} + +// GetTypeOk returns a tuple with the Type field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *FormDataDefinition) GetTypeOk() (*FormDataDefinitionType, bool) { + if o == nil || o.Type == nil { + return nil, false + } + return o.Type, true +} + +// HasType returns a boolean if a field has been set. +func (o *FormDataDefinition) HasType() bool { + return o != nil && o.Type != nil +} + +// SetType gets a reference to the given FormDataDefinitionType and assigns it to the Type field. +func (o *FormDataDefinition) SetType(v FormDataDefinitionType) { + o.Type = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o FormDataDefinition) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Description != nil { + toSerialize["description"] = o.Description + } + if o.Properties != nil { + toSerialize["properties"] = o.Properties + } + if o.Required != nil { + toSerialize["required"] = o.Required + } + if o.Title != nil { + toSerialize["title"] = o.Title + } + if o.Type != nil { + toSerialize["type"] = o.Type + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *FormDataDefinition) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Description *string `json:"description,omitempty"` + Properties map[string]interface{} `json:"properties,omitempty"` + Required []string `json:"required,omitempty"` + Title *string `json:"title,omitempty"` + Type *FormDataDefinitionType `json:"type,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"description", "properties", "required", "title", "type"}) + } else { + return err + } + + hasInvalidField := false + o.Description = all.Description + o.Properties = all.Properties + o.Required = all.Required + o.Title = all.Title + if all.Type != nil && !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = all.Type + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_form_data_definition_type.go b/api/datadogV2/model_form_data_definition_type.go new file mode 100644 index 00000000000..ff850752643 --- /dev/null +++ b/api/datadogV2/model_form_data_definition_type.go @@ -0,0 +1,64 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// FormDataDefinitionType The root schema type. Always "object". +type FormDataDefinitionType string + +// List of FormDataDefinitionType. +const ( + FORMDATADEFINITIONTYPE_OBJECT FormDataDefinitionType = "object" +) + +var allowedFormDataDefinitionTypeEnumValues = []FormDataDefinitionType{ + FORMDATADEFINITIONTYPE_OBJECT, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *FormDataDefinitionType) GetAllowedValues() []FormDataDefinitionType { + return allowedFormDataDefinitionTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *FormDataDefinitionType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = FormDataDefinitionType(value) + return nil +} + +// NewFormDataDefinitionTypeFromValue returns a pointer to a valid FormDataDefinitionType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewFormDataDefinitionTypeFromValue(v string) (*FormDataDefinitionType, error) { + ev := FormDataDefinitionType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for FormDataDefinitionType: valid values are %v", v, allowedFormDataDefinitionTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v FormDataDefinitionType) IsValid() bool { + for _, existing := range allowedFormDataDefinitionTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to FormDataDefinitionType value. +func (v FormDataDefinitionType) Ptr() *FormDataDefinitionType { + return &v +} diff --git a/api/datadogV2/model_form_datastore_config_attributes.go b/api/datadogV2/model_form_datastore_config_attributes.go new file mode 100644 index 00000000000..c5d62657143 --- /dev/null +++ b/api/datadogV2/model_form_datastore_config_attributes.go @@ -0,0 +1,167 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/google/uuid" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// FormDatastoreConfigAttributes The datastore configuration for a form. +type FormDatastoreConfigAttributes struct { + // The ID of the datastore. + DatastoreId uuid.UUID `json:"datastore_id"` + // The name of the primary column in the datastore. + PrimaryColumnName string `json:"primary_column_name"` + // The strategy used to generate primary keys in the datastore. + PrimaryKeyGenerationStrategy string `json:"primary_key_generation_strategy"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewFormDatastoreConfigAttributes instantiates a new FormDatastoreConfigAttributes object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewFormDatastoreConfigAttributes(datastoreId uuid.UUID, primaryColumnName string, primaryKeyGenerationStrategy string) *FormDatastoreConfigAttributes { + this := FormDatastoreConfigAttributes{} + this.DatastoreId = datastoreId + this.PrimaryColumnName = primaryColumnName + this.PrimaryKeyGenerationStrategy = primaryKeyGenerationStrategy + return &this +} + +// NewFormDatastoreConfigAttributesWithDefaults instantiates a new FormDatastoreConfigAttributes object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewFormDatastoreConfigAttributesWithDefaults() *FormDatastoreConfigAttributes { + this := FormDatastoreConfigAttributes{} + return &this +} + +// GetDatastoreId returns the DatastoreId field value. +func (o *FormDatastoreConfigAttributes) GetDatastoreId() uuid.UUID { + if o == nil { + var ret uuid.UUID + return ret + } + return o.DatastoreId +} + +// GetDatastoreIdOk returns a tuple with the DatastoreId field value +// and a boolean to check if the value has been set. +func (o *FormDatastoreConfigAttributes) GetDatastoreIdOk() (*uuid.UUID, bool) { + if o == nil { + return nil, false + } + return &o.DatastoreId, true +} + +// SetDatastoreId sets field value. +func (o *FormDatastoreConfigAttributes) SetDatastoreId(v uuid.UUID) { + o.DatastoreId = v +} + +// GetPrimaryColumnName returns the PrimaryColumnName field value. +func (o *FormDatastoreConfigAttributes) GetPrimaryColumnName() string { + if o == nil { + var ret string + return ret + } + return o.PrimaryColumnName +} + +// GetPrimaryColumnNameOk returns a tuple with the PrimaryColumnName field value +// and a boolean to check if the value has been set. +func (o *FormDatastoreConfigAttributes) GetPrimaryColumnNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.PrimaryColumnName, true +} + +// SetPrimaryColumnName sets field value. +func (o *FormDatastoreConfigAttributes) SetPrimaryColumnName(v string) { + o.PrimaryColumnName = v +} + +// GetPrimaryKeyGenerationStrategy returns the PrimaryKeyGenerationStrategy field value. +func (o *FormDatastoreConfigAttributes) GetPrimaryKeyGenerationStrategy() string { + if o == nil { + var ret string + return ret + } + return o.PrimaryKeyGenerationStrategy +} + +// GetPrimaryKeyGenerationStrategyOk returns a tuple with the PrimaryKeyGenerationStrategy field value +// and a boolean to check if the value has been set. +func (o *FormDatastoreConfigAttributes) GetPrimaryKeyGenerationStrategyOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.PrimaryKeyGenerationStrategy, true +} + +// SetPrimaryKeyGenerationStrategy sets field value. +func (o *FormDatastoreConfigAttributes) SetPrimaryKeyGenerationStrategy(v string) { + o.PrimaryKeyGenerationStrategy = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o FormDatastoreConfigAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["datastore_id"] = o.DatastoreId + toSerialize["primary_column_name"] = o.PrimaryColumnName + toSerialize["primary_key_generation_strategy"] = o.PrimaryKeyGenerationStrategy + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *FormDatastoreConfigAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + DatastoreId *uuid.UUID `json:"datastore_id"` + PrimaryColumnName *string `json:"primary_column_name"` + PrimaryKeyGenerationStrategy *string `json:"primary_key_generation_strategy"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.DatastoreId == nil { + return fmt.Errorf("required field datastore_id missing") + } + if all.PrimaryColumnName == nil { + return fmt.Errorf("required field primary_column_name missing") + } + if all.PrimaryKeyGenerationStrategy == nil { + return fmt.Errorf("required field primary_key_generation_strategy missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"datastore_id", "primary_column_name", "primary_key_generation_strategy"}) + } else { + return err + } + o.DatastoreId = *all.DatastoreId + o.PrimaryColumnName = *all.PrimaryColumnName + o.PrimaryKeyGenerationStrategy = *all.PrimaryKeyGenerationStrategy + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_form_publication_attributes.go b/api/datadogV2/model_form_publication_attributes.go new file mode 100644 index 00000000000..3d87d82f163 --- /dev/null +++ b/api/datadogV2/model_form_publication_attributes.go @@ -0,0 +1,371 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + "time" + + "github.com/google/uuid" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// FormPublicationAttributes The attributes of a form publication. +type FormPublicationAttributes struct { + // The time at which the publication was created. + CreatedAt time.Time `json:"created_at"` + // The ID of the form. + FormId uuid.UUID `json:"form_id"` + // The version number that was published. + FormVersion int64 `json:"form_version"` + // The ID of the form publication. + Id *string `json:"id,omitempty"` + // The time at which the publication was last modified. + ModifiedAt time.Time `json:"modified_at"` + // The ID of the organization that owns this publication. + OrgId int64 `json:"org_id"` + // The sequential publication number for this form. + PublishSeq int64 `json:"publish_seq"` + // The ID of the user who created this publication. + UserId int64 `json:"user_id"` + // The UUID of the user who created this publication. + UserUuid uuid.UUID `json:"user_uuid"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewFormPublicationAttributes instantiates a new FormPublicationAttributes object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewFormPublicationAttributes(createdAt time.Time, formId uuid.UUID, formVersion int64, modifiedAt time.Time, orgId int64, publishSeq int64, userId int64, userUuid uuid.UUID) *FormPublicationAttributes { + this := FormPublicationAttributes{} + this.CreatedAt = createdAt + this.FormId = formId + this.FormVersion = formVersion + this.ModifiedAt = modifiedAt + this.OrgId = orgId + this.PublishSeq = publishSeq + this.UserId = userId + this.UserUuid = userUuid + return &this +} + +// NewFormPublicationAttributesWithDefaults instantiates a new FormPublicationAttributes object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewFormPublicationAttributesWithDefaults() *FormPublicationAttributes { + this := FormPublicationAttributes{} + return &this +} + +// GetCreatedAt returns the CreatedAt field value. +func (o *FormPublicationAttributes) GetCreatedAt() time.Time { + if o == nil { + var ret time.Time + return ret + } + return o.CreatedAt +} + +// GetCreatedAtOk returns a tuple with the CreatedAt field value +// and a boolean to check if the value has been set. +func (o *FormPublicationAttributes) GetCreatedAtOk() (*time.Time, bool) { + if o == nil { + return nil, false + } + return &o.CreatedAt, true +} + +// SetCreatedAt sets field value. +func (o *FormPublicationAttributes) SetCreatedAt(v time.Time) { + o.CreatedAt = v +} + +// GetFormId returns the FormId field value. +func (o *FormPublicationAttributes) GetFormId() uuid.UUID { + if o == nil { + var ret uuid.UUID + return ret + } + return o.FormId +} + +// GetFormIdOk returns a tuple with the FormId field value +// and a boolean to check if the value has been set. +func (o *FormPublicationAttributes) GetFormIdOk() (*uuid.UUID, bool) { + if o == nil { + return nil, false + } + return &o.FormId, true +} + +// SetFormId sets field value. +func (o *FormPublicationAttributes) SetFormId(v uuid.UUID) { + o.FormId = v +} + +// GetFormVersion returns the FormVersion field value. +func (o *FormPublicationAttributes) GetFormVersion() int64 { + if o == nil { + var ret int64 + return ret + } + return o.FormVersion +} + +// GetFormVersionOk returns a tuple with the FormVersion field value +// and a boolean to check if the value has been set. +func (o *FormPublicationAttributes) GetFormVersionOk() (*int64, bool) { + if o == nil { + return nil, false + } + return &o.FormVersion, true +} + +// SetFormVersion sets field value. +func (o *FormPublicationAttributes) SetFormVersion(v int64) { + o.FormVersion = v +} + +// GetId returns the Id field value if set, zero value otherwise. +func (o *FormPublicationAttributes) GetId() string { + if o == nil || o.Id == nil { + var ret string + return ret + } + return *o.Id +} + +// GetIdOk returns a tuple with the Id field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *FormPublicationAttributes) GetIdOk() (*string, bool) { + if o == nil || o.Id == nil { + return nil, false + } + return o.Id, true +} + +// HasId returns a boolean if a field has been set. +func (o *FormPublicationAttributes) HasId() bool { + return o != nil && o.Id != nil +} + +// SetId gets a reference to the given string and assigns it to the Id field. +func (o *FormPublicationAttributes) SetId(v string) { + o.Id = &v +} + +// GetModifiedAt returns the ModifiedAt field value. +func (o *FormPublicationAttributes) GetModifiedAt() time.Time { + if o == nil { + var ret time.Time + return ret + } + return o.ModifiedAt +} + +// GetModifiedAtOk returns a tuple with the ModifiedAt field value +// and a boolean to check if the value has been set. +func (o *FormPublicationAttributes) GetModifiedAtOk() (*time.Time, bool) { + if o == nil { + return nil, false + } + return &o.ModifiedAt, true +} + +// SetModifiedAt sets field value. +func (o *FormPublicationAttributes) SetModifiedAt(v time.Time) { + o.ModifiedAt = v +} + +// GetOrgId returns the OrgId field value. +func (o *FormPublicationAttributes) GetOrgId() int64 { + if o == nil { + var ret int64 + return ret + } + return o.OrgId +} + +// GetOrgIdOk returns a tuple with the OrgId field value +// and a boolean to check if the value has been set. +func (o *FormPublicationAttributes) GetOrgIdOk() (*int64, bool) { + if o == nil { + return nil, false + } + return &o.OrgId, true +} + +// SetOrgId sets field value. +func (o *FormPublicationAttributes) SetOrgId(v int64) { + o.OrgId = v +} + +// GetPublishSeq returns the PublishSeq field value. +func (o *FormPublicationAttributes) GetPublishSeq() int64 { + if o == nil { + var ret int64 + return ret + } + return o.PublishSeq +} + +// GetPublishSeqOk returns a tuple with the PublishSeq field value +// and a boolean to check if the value has been set. +func (o *FormPublicationAttributes) GetPublishSeqOk() (*int64, bool) { + if o == nil { + return nil, false + } + return &o.PublishSeq, true +} + +// SetPublishSeq sets field value. +func (o *FormPublicationAttributes) SetPublishSeq(v int64) { + o.PublishSeq = v +} + +// GetUserId returns the UserId field value. +func (o *FormPublicationAttributes) GetUserId() int64 { + if o == nil { + var ret int64 + return ret + } + return o.UserId +} + +// GetUserIdOk returns a tuple with the UserId field value +// and a boolean to check if the value has been set. +func (o *FormPublicationAttributes) GetUserIdOk() (*int64, bool) { + if o == nil { + return nil, false + } + return &o.UserId, true +} + +// SetUserId sets field value. +func (o *FormPublicationAttributes) SetUserId(v int64) { + o.UserId = v +} + +// GetUserUuid returns the UserUuid field value. +func (o *FormPublicationAttributes) GetUserUuid() uuid.UUID { + if o == nil { + var ret uuid.UUID + return ret + } + return o.UserUuid +} + +// GetUserUuidOk returns a tuple with the UserUuid field value +// and a boolean to check if the value has been set. +func (o *FormPublicationAttributes) GetUserUuidOk() (*uuid.UUID, bool) { + if o == nil { + return nil, false + } + return &o.UserUuid, true +} + +// SetUserUuid sets field value. +func (o *FormPublicationAttributes) SetUserUuid(v uuid.UUID) { + o.UserUuid = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o FormPublicationAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.CreatedAt.Nanosecond() == 0 { + toSerialize["created_at"] = o.CreatedAt.Format("2006-01-02T15:04:05Z07:00") + } else { + toSerialize["created_at"] = o.CreatedAt.Format("2006-01-02T15:04:05.000Z07:00") + } + toSerialize["form_id"] = o.FormId + toSerialize["form_version"] = o.FormVersion + if o.Id != nil { + toSerialize["id"] = o.Id + } + if o.ModifiedAt.Nanosecond() == 0 { + toSerialize["modified_at"] = o.ModifiedAt.Format("2006-01-02T15:04:05Z07:00") + } else { + toSerialize["modified_at"] = o.ModifiedAt.Format("2006-01-02T15:04:05.000Z07:00") + } + toSerialize["org_id"] = o.OrgId + toSerialize["publish_seq"] = o.PublishSeq + toSerialize["user_id"] = o.UserId + toSerialize["user_uuid"] = o.UserUuid + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *FormPublicationAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + CreatedAt *time.Time `json:"created_at"` + FormId *uuid.UUID `json:"form_id"` + FormVersion *int64 `json:"form_version"` + Id *string `json:"id,omitempty"` + ModifiedAt *time.Time `json:"modified_at"` + OrgId *int64 `json:"org_id"` + PublishSeq *int64 `json:"publish_seq"` + UserId *int64 `json:"user_id"` + UserUuid *uuid.UUID `json:"user_uuid"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.CreatedAt == nil { + return fmt.Errorf("required field created_at missing") + } + if all.FormId == nil { + return fmt.Errorf("required field form_id missing") + } + if all.FormVersion == nil { + return fmt.Errorf("required field form_version missing") + } + if all.ModifiedAt == nil { + return fmt.Errorf("required field modified_at missing") + } + if all.OrgId == nil { + return fmt.Errorf("required field org_id missing") + } + if all.PublishSeq == nil { + return fmt.Errorf("required field publish_seq missing") + } + if all.UserId == nil { + return fmt.Errorf("required field user_id missing") + } + if all.UserUuid == nil { + return fmt.Errorf("required field user_uuid missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"created_at", "form_id", "form_version", "id", "modified_at", "org_id", "publish_seq", "user_id", "user_uuid"}) + } else { + return err + } + o.CreatedAt = *all.CreatedAt + o.FormId = *all.FormId + o.FormVersion = *all.FormVersion + o.Id = all.Id + o.ModifiedAt = *all.ModifiedAt + o.OrgId = *all.OrgId + o.PublishSeq = *all.PublishSeq + o.UserId = *all.UserId + o.UserUuid = *all.UserUuid + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_form_response.go b/api/datadogV2/model_form_response.go new file mode 100644 index 00000000000..938e6d62559 --- /dev/null +++ b/api/datadogV2/model_form_response.go @@ -0,0 +1,110 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// FormResponse A response containing a single form. +type FormResponse struct { + // A form resource object. + Data FormData `json:"data"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewFormResponse instantiates a new FormResponse object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewFormResponse(data FormData) *FormResponse { + this := FormResponse{} + this.Data = data + return &this +} + +// NewFormResponseWithDefaults instantiates a new FormResponse object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewFormResponseWithDefaults() *FormResponse { + this := FormResponse{} + return &this +} + +// GetData returns the Data field value. +func (o *FormResponse) GetData() FormData { + if o == nil { + var ret FormData + return ret + } + return o.Data +} + +// GetDataOk returns a tuple with the Data field value +// and a boolean to check if the value has been set. +func (o *FormResponse) GetDataOk() (*FormData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *FormResponse) SetData(v FormData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o FormResponse) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["data"] = o.Data + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *FormResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *FormData `json:"data"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Data == nil { + return fmt.Errorf("required field data missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + + hasInvalidField := false + if all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Data = *all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_form_type.go b/api/datadogV2/model_form_type.go new file mode 100644 index 00000000000..655dcc398c5 --- /dev/null +++ b/api/datadogV2/model_form_type.go @@ -0,0 +1,64 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// FormType The resource type for a form. +type FormType string + +// List of FormType. +const ( + FORMTYPE_FORMS FormType = "forms" +) + +var allowedFormTypeEnumValues = []FormType{ + FORMTYPE_FORMS, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *FormType) GetAllowedValues() []FormType { + return allowedFormTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *FormType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = FormType(value) + return nil +} + +// NewFormTypeFromValue returns a pointer to a valid FormType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewFormTypeFromValue(v string) (*FormType, error) { + ev := FormType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for FormType: valid values are %v", v, allowedFormTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v FormType) IsValid() bool { + for _, existing := range allowedFormTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to FormType value. +func (v FormType) Ptr() *FormType { + return &v +} diff --git a/api/datadogV2/model_form_ui_definition.go b/api/datadogV2/model_form_ui_definition.go new file mode 100644 index 00000000000..312aa8bc95d --- /dev/null +++ b/api/datadogV2/model_form_ui_definition.go @@ -0,0 +1,146 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// FormUiDefinition UI configuration for rendering form fields, including widget overrides, field ordering, and themes. +type FormUiDefinition struct { + // The order in which form fields are displayed. + UiOrder []string `json:"ui:order,omitempty"` + // The visual theme applied to the form. + UiTheme *FormUiDefinitionUiTheme `json:"ui:theme,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewFormUiDefinition instantiates a new FormUiDefinition object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewFormUiDefinition() *FormUiDefinition { + this := FormUiDefinition{} + return &this +} + +// NewFormUiDefinitionWithDefaults instantiates a new FormUiDefinition object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewFormUiDefinitionWithDefaults() *FormUiDefinition { + this := FormUiDefinition{} + return &this +} + +// GetUiOrder returns the UiOrder field value if set, zero value otherwise. +func (o *FormUiDefinition) GetUiOrder() []string { + if o == nil || o.UiOrder == nil { + var ret []string + return ret + } + return o.UiOrder +} + +// GetUiOrderOk returns a tuple with the UiOrder field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *FormUiDefinition) GetUiOrderOk() (*[]string, bool) { + if o == nil || o.UiOrder == nil { + return nil, false + } + return &o.UiOrder, true +} + +// HasUiOrder returns a boolean if a field has been set. +func (o *FormUiDefinition) HasUiOrder() bool { + return o != nil && o.UiOrder != nil +} + +// SetUiOrder gets a reference to the given []string and assigns it to the UiOrder field. +func (o *FormUiDefinition) SetUiOrder(v []string) { + o.UiOrder = v +} + +// GetUiTheme returns the UiTheme field value if set, zero value otherwise. +func (o *FormUiDefinition) GetUiTheme() FormUiDefinitionUiTheme { + if o == nil || o.UiTheme == nil { + var ret FormUiDefinitionUiTheme + return ret + } + return *o.UiTheme +} + +// GetUiThemeOk returns a tuple with the UiTheme field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *FormUiDefinition) GetUiThemeOk() (*FormUiDefinitionUiTheme, bool) { + if o == nil || o.UiTheme == nil { + return nil, false + } + return o.UiTheme, true +} + +// HasUiTheme returns a boolean if a field has been set. +func (o *FormUiDefinition) HasUiTheme() bool { + return o != nil && o.UiTheme != nil +} + +// SetUiTheme gets a reference to the given FormUiDefinitionUiTheme and assigns it to the UiTheme field. +func (o *FormUiDefinition) SetUiTheme(v FormUiDefinitionUiTheme) { + o.UiTheme = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o FormUiDefinition) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.UiOrder != nil { + toSerialize["ui:order"] = o.UiOrder + } + if o.UiTheme != nil { + toSerialize["ui:theme"] = o.UiTheme + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *FormUiDefinition) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + UiOrder []string `json:"ui:order,omitempty"` + UiTheme *FormUiDefinitionUiTheme `json:"ui:theme,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"ui:order", "ui:theme"}) + } else { + return err + } + + hasInvalidField := false + o.UiOrder = all.UiOrder + if all.UiTheme != nil && all.UiTheme.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.UiTheme = all.UiTheme + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_form_ui_definition_ui_theme.go b/api/datadogV2/model_form_ui_definition_ui_theme.go new file mode 100644 index 00000000000..355e6a7fe11 --- /dev/null +++ b/api/datadogV2/model_form_ui_definition_ui_theme.go @@ -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. + +package datadogV2 + +import ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// FormUiDefinitionUiTheme The visual theme applied to the form. +type FormUiDefinitionUiTheme struct { + // The primary color of the form theme. + PrimaryColor *FormUiDefinitionUiThemePrimaryColor `json:"primaryColor,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewFormUiDefinitionUiTheme instantiates a new FormUiDefinitionUiTheme object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewFormUiDefinitionUiTheme() *FormUiDefinitionUiTheme { + this := FormUiDefinitionUiTheme{} + return &this +} + +// NewFormUiDefinitionUiThemeWithDefaults instantiates a new FormUiDefinitionUiTheme object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewFormUiDefinitionUiThemeWithDefaults() *FormUiDefinitionUiTheme { + this := FormUiDefinitionUiTheme{} + return &this +} + +// GetPrimaryColor returns the PrimaryColor field value if set, zero value otherwise. +func (o *FormUiDefinitionUiTheme) GetPrimaryColor() FormUiDefinitionUiThemePrimaryColor { + if o == nil || o.PrimaryColor == nil { + var ret FormUiDefinitionUiThemePrimaryColor + return ret + } + return *o.PrimaryColor +} + +// GetPrimaryColorOk returns a tuple with the PrimaryColor field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *FormUiDefinitionUiTheme) GetPrimaryColorOk() (*FormUiDefinitionUiThemePrimaryColor, bool) { + if o == nil || o.PrimaryColor == nil { + return nil, false + } + return o.PrimaryColor, true +} + +// HasPrimaryColor returns a boolean if a field has been set. +func (o *FormUiDefinitionUiTheme) HasPrimaryColor() bool { + return o != nil && o.PrimaryColor != nil +} + +// SetPrimaryColor gets a reference to the given FormUiDefinitionUiThemePrimaryColor and assigns it to the PrimaryColor field. +func (o *FormUiDefinitionUiTheme) SetPrimaryColor(v FormUiDefinitionUiThemePrimaryColor) { + o.PrimaryColor = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o FormUiDefinitionUiTheme) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.PrimaryColor != nil { + toSerialize["primaryColor"] = o.PrimaryColor + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *FormUiDefinitionUiTheme) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + PrimaryColor *FormUiDefinitionUiThemePrimaryColor `json:"primaryColor,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"primaryColor"}) + } else { + return err + } + + hasInvalidField := false + if all.PrimaryColor != nil && !all.PrimaryColor.IsValid() { + hasInvalidField = true + } else { + o.PrimaryColor = all.PrimaryColor + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_form_ui_definition_ui_theme_primary_color.go b/api/datadogV2/model_form_ui_definition_ui_theme_primary_color.go new file mode 100644 index 00000000000..656ec72d451 --- /dev/null +++ b/api/datadogV2/model_form_ui_definition_ui_theme_primary_color.go @@ -0,0 +1,80 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// FormUiDefinitionUiThemePrimaryColor The primary color of the form theme. +type FormUiDefinitionUiThemePrimaryColor string + +// List of FormUiDefinitionUiThemePrimaryColor. +const ( + FORMUIDEFINITIONUITHEMEPRIMARYCOLOR_GRAY FormUiDefinitionUiThemePrimaryColor = "gray" + FORMUIDEFINITIONUITHEMEPRIMARYCOLOR_RED FormUiDefinitionUiThemePrimaryColor = "red" + FORMUIDEFINITIONUITHEMEPRIMARYCOLOR_ORANGE FormUiDefinitionUiThemePrimaryColor = "orange" + FORMUIDEFINITIONUITHEMEPRIMARYCOLOR_YELLOW FormUiDefinitionUiThemePrimaryColor = "yellow" + FORMUIDEFINITIONUITHEMEPRIMARYCOLOR_GREEN FormUiDefinitionUiThemePrimaryColor = "green" + FORMUIDEFINITIONUITHEMEPRIMARYCOLOR_LIGHT_BLUE FormUiDefinitionUiThemePrimaryColor = "light-blue" + FORMUIDEFINITIONUITHEMEPRIMARYCOLOR_DARK_BLUE FormUiDefinitionUiThemePrimaryColor = "dark-blue" + FORMUIDEFINITIONUITHEMEPRIMARYCOLOR_MAGENTA FormUiDefinitionUiThemePrimaryColor = "magenta" + FORMUIDEFINITIONUITHEMEPRIMARYCOLOR_INDIGO FormUiDefinitionUiThemePrimaryColor = "indigo" +) + +var allowedFormUiDefinitionUiThemePrimaryColorEnumValues = []FormUiDefinitionUiThemePrimaryColor{ + FORMUIDEFINITIONUITHEMEPRIMARYCOLOR_GRAY, + FORMUIDEFINITIONUITHEMEPRIMARYCOLOR_RED, + FORMUIDEFINITIONUITHEMEPRIMARYCOLOR_ORANGE, + FORMUIDEFINITIONUITHEMEPRIMARYCOLOR_YELLOW, + FORMUIDEFINITIONUITHEMEPRIMARYCOLOR_GREEN, + FORMUIDEFINITIONUITHEMEPRIMARYCOLOR_LIGHT_BLUE, + FORMUIDEFINITIONUITHEMEPRIMARYCOLOR_DARK_BLUE, + FORMUIDEFINITIONUITHEMEPRIMARYCOLOR_MAGENTA, + FORMUIDEFINITIONUITHEMEPRIMARYCOLOR_INDIGO, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *FormUiDefinitionUiThemePrimaryColor) GetAllowedValues() []FormUiDefinitionUiThemePrimaryColor { + return allowedFormUiDefinitionUiThemePrimaryColorEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *FormUiDefinitionUiThemePrimaryColor) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = FormUiDefinitionUiThemePrimaryColor(value) + return nil +} + +// NewFormUiDefinitionUiThemePrimaryColorFromValue returns a pointer to a valid FormUiDefinitionUiThemePrimaryColor +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewFormUiDefinitionUiThemePrimaryColorFromValue(v string) (*FormUiDefinitionUiThemePrimaryColor, error) { + ev := FormUiDefinitionUiThemePrimaryColor(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for FormUiDefinitionUiThemePrimaryColor: valid values are %v", v, allowedFormUiDefinitionUiThemePrimaryColorEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v FormUiDefinitionUiThemePrimaryColor) IsValid() bool { + for _, existing := range allowedFormUiDefinitionUiThemePrimaryColorEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to FormUiDefinitionUiThemePrimaryColor value. +func (v FormUiDefinitionUiThemePrimaryColor) Ptr() *FormUiDefinitionUiThemePrimaryColor { + return &v +} diff --git a/api/datadogV2/model_form_version_attributes.go b/api/datadogV2/model_form_version_attributes.go new file mode 100644 index 00000000000..5dd5e596d0c --- /dev/null +++ b/api/datadogV2/model_form_version_attributes.go @@ -0,0 +1,453 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + "time" + + "github.com/google/uuid" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// FormVersionAttributes The attributes of a form version. +type FormVersionAttributes struct { + // The time at which the version was created. + CreatedAt time.Time `json:"created_at"` + // A JSON Schema definition that describes the form's data fields. + DataDefinition FormDataDefinition `json:"data_definition"` + // The signature of the version definition. + DefinitionSignature string `json:"definition_signature"` + // The ETag for optimistic concurrency control. + Etag datadog.NullableString `json:"etag"` + // The ID of the form version. + Id *string `json:"id,omitempty"` + // The time at which the version was last modified. + ModifiedAt time.Time `json:"modified_at"` + // The state of a form version. + State FormVersionState `json:"state"` + // UI configuration for rendering form fields, including widget overrides, field ordering, and themes. + UiDefinition FormUiDefinition `json:"ui_definition"` + // The ID of the user who created this version. + UserId int64 `json:"user_id"` + // The UUID of the user who created this version. + UserUuid uuid.UUID `json:"user_uuid"` + // The sequential version number. + Version int64 `json:"version"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewFormVersionAttributes instantiates a new FormVersionAttributes object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewFormVersionAttributes(createdAt time.Time, dataDefinition FormDataDefinition, definitionSignature string, etag datadog.NullableString, modifiedAt time.Time, state FormVersionState, uiDefinition FormUiDefinition, userId int64, userUuid uuid.UUID, version int64) *FormVersionAttributes { + this := FormVersionAttributes{} + this.CreatedAt = createdAt + this.DataDefinition = dataDefinition + this.DefinitionSignature = definitionSignature + this.Etag = etag + this.ModifiedAt = modifiedAt + this.State = state + this.UiDefinition = uiDefinition + this.UserId = userId + this.UserUuid = userUuid + this.Version = version + return &this +} + +// NewFormVersionAttributesWithDefaults instantiates a new FormVersionAttributes object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewFormVersionAttributesWithDefaults() *FormVersionAttributes { + this := FormVersionAttributes{} + return &this +} + +// GetCreatedAt returns the CreatedAt field value. +func (o *FormVersionAttributes) GetCreatedAt() time.Time { + if o == nil { + var ret time.Time + return ret + } + return o.CreatedAt +} + +// GetCreatedAtOk returns a tuple with the CreatedAt field value +// and a boolean to check if the value has been set. +func (o *FormVersionAttributes) GetCreatedAtOk() (*time.Time, bool) { + if o == nil { + return nil, false + } + return &o.CreatedAt, true +} + +// SetCreatedAt sets field value. +func (o *FormVersionAttributes) SetCreatedAt(v time.Time) { + o.CreatedAt = v +} + +// GetDataDefinition returns the DataDefinition field value. +func (o *FormVersionAttributes) GetDataDefinition() FormDataDefinition { + if o == nil { + var ret FormDataDefinition + return ret + } + return o.DataDefinition +} + +// GetDataDefinitionOk returns a tuple with the DataDefinition field value +// and a boolean to check if the value has been set. +func (o *FormVersionAttributes) GetDataDefinitionOk() (*FormDataDefinition, bool) { + if o == nil { + return nil, false + } + return &o.DataDefinition, true +} + +// SetDataDefinition sets field value. +func (o *FormVersionAttributes) SetDataDefinition(v FormDataDefinition) { + o.DataDefinition = v +} + +// GetDefinitionSignature returns the DefinitionSignature field value. +func (o *FormVersionAttributes) GetDefinitionSignature() string { + if o == nil { + var ret string + return ret + } + return o.DefinitionSignature +} + +// GetDefinitionSignatureOk returns a tuple with the DefinitionSignature field value +// and a boolean to check if the value has been set. +func (o *FormVersionAttributes) GetDefinitionSignatureOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.DefinitionSignature, true +} + +// SetDefinitionSignature sets field value. +func (o *FormVersionAttributes) SetDefinitionSignature(v string) { + o.DefinitionSignature = v +} + +// GetEtag returns the Etag field value. +// If the value is explicit nil, the zero value for string will be returned. +func (o *FormVersionAttributes) GetEtag() string { + if o == nil || o.Etag.Get() == nil { + var ret string + return ret + } + return *o.Etag.Get() +} + +// GetEtagOk returns a tuple with the Etag field value +// and a boolean to check if the value has been set. +// NOTE: If the value is an explicit nil, `nil, true` will be returned. +func (o *FormVersionAttributes) GetEtagOk() (*string, bool) { + if o == nil { + return nil, false + } + return o.Etag.Get(), o.Etag.IsSet() +} + +// SetEtag sets field value. +func (o *FormVersionAttributes) SetEtag(v string) { + o.Etag.Set(&v) +} + +// GetId returns the Id field value if set, zero value otherwise. +func (o *FormVersionAttributes) GetId() string { + if o == nil || o.Id == nil { + var ret string + return ret + } + return *o.Id +} + +// GetIdOk returns a tuple with the Id field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *FormVersionAttributes) GetIdOk() (*string, bool) { + if o == nil || o.Id == nil { + return nil, false + } + return o.Id, true +} + +// HasId returns a boolean if a field has been set. +func (o *FormVersionAttributes) HasId() bool { + return o != nil && o.Id != nil +} + +// SetId gets a reference to the given string and assigns it to the Id field. +func (o *FormVersionAttributes) SetId(v string) { + o.Id = &v +} + +// GetModifiedAt returns the ModifiedAt field value. +func (o *FormVersionAttributes) GetModifiedAt() time.Time { + if o == nil { + var ret time.Time + return ret + } + return o.ModifiedAt +} + +// GetModifiedAtOk returns a tuple with the ModifiedAt field value +// and a boolean to check if the value has been set. +func (o *FormVersionAttributes) GetModifiedAtOk() (*time.Time, bool) { + if o == nil { + return nil, false + } + return &o.ModifiedAt, true +} + +// SetModifiedAt sets field value. +func (o *FormVersionAttributes) SetModifiedAt(v time.Time) { + o.ModifiedAt = v +} + +// GetState returns the State field value. +func (o *FormVersionAttributes) GetState() FormVersionState { + if o == nil { + var ret FormVersionState + return ret + } + return o.State +} + +// GetStateOk returns a tuple with the State field value +// and a boolean to check if the value has been set. +func (o *FormVersionAttributes) GetStateOk() (*FormVersionState, bool) { + if o == nil { + return nil, false + } + return &o.State, true +} + +// SetState sets field value. +func (o *FormVersionAttributes) SetState(v FormVersionState) { + o.State = v +} + +// GetUiDefinition returns the UiDefinition field value. +func (o *FormVersionAttributes) GetUiDefinition() FormUiDefinition { + if o == nil { + var ret FormUiDefinition + return ret + } + return o.UiDefinition +} + +// GetUiDefinitionOk returns a tuple with the UiDefinition field value +// and a boolean to check if the value has been set. +func (o *FormVersionAttributes) GetUiDefinitionOk() (*FormUiDefinition, bool) { + if o == nil { + return nil, false + } + return &o.UiDefinition, true +} + +// SetUiDefinition sets field value. +func (o *FormVersionAttributes) SetUiDefinition(v FormUiDefinition) { + o.UiDefinition = v +} + +// GetUserId returns the UserId field value. +func (o *FormVersionAttributes) GetUserId() int64 { + if o == nil { + var ret int64 + return ret + } + return o.UserId +} + +// GetUserIdOk returns a tuple with the UserId field value +// and a boolean to check if the value has been set. +func (o *FormVersionAttributes) GetUserIdOk() (*int64, bool) { + if o == nil { + return nil, false + } + return &o.UserId, true +} + +// SetUserId sets field value. +func (o *FormVersionAttributes) SetUserId(v int64) { + o.UserId = v +} + +// GetUserUuid returns the UserUuid field value. +func (o *FormVersionAttributes) GetUserUuid() uuid.UUID { + if o == nil { + var ret uuid.UUID + return ret + } + return o.UserUuid +} + +// GetUserUuidOk returns a tuple with the UserUuid field value +// and a boolean to check if the value has been set. +func (o *FormVersionAttributes) GetUserUuidOk() (*uuid.UUID, bool) { + if o == nil { + return nil, false + } + return &o.UserUuid, true +} + +// SetUserUuid sets field value. +func (o *FormVersionAttributes) SetUserUuid(v uuid.UUID) { + o.UserUuid = v +} + +// GetVersion returns the Version field value. +func (o *FormVersionAttributes) GetVersion() int64 { + if o == nil { + var ret int64 + return ret + } + return o.Version +} + +// GetVersionOk returns a tuple with the Version field value +// and a boolean to check if the value has been set. +func (o *FormVersionAttributes) GetVersionOk() (*int64, bool) { + if o == nil { + return nil, false + } + return &o.Version, true +} + +// SetVersion sets field value. +func (o *FormVersionAttributes) SetVersion(v int64) { + o.Version = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o FormVersionAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.CreatedAt.Nanosecond() == 0 { + toSerialize["created_at"] = o.CreatedAt.Format("2006-01-02T15:04:05Z07:00") + } else { + toSerialize["created_at"] = o.CreatedAt.Format("2006-01-02T15:04:05.000Z07:00") + } + toSerialize["data_definition"] = o.DataDefinition + toSerialize["definition_signature"] = o.DefinitionSignature + toSerialize["etag"] = o.Etag.Get() + if o.Id != nil { + toSerialize["id"] = o.Id + } + if o.ModifiedAt.Nanosecond() == 0 { + toSerialize["modified_at"] = o.ModifiedAt.Format("2006-01-02T15:04:05Z07:00") + } else { + toSerialize["modified_at"] = o.ModifiedAt.Format("2006-01-02T15:04:05.000Z07:00") + } + toSerialize["state"] = o.State + toSerialize["ui_definition"] = o.UiDefinition + toSerialize["user_id"] = o.UserId + toSerialize["user_uuid"] = o.UserUuid + toSerialize["version"] = o.Version + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *FormVersionAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + CreatedAt *time.Time `json:"created_at"` + DataDefinition *FormDataDefinition `json:"data_definition"` + DefinitionSignature *string `json:"definition_signature"` + Etag datadog.NullableString `json:"etag"` + Id *string `json:"id,omitempty"` + ModifiedAt *time.Time `json:"modified_at"` + State *FormVersionState `json:"state"` + UiDefinition *FormUiDefinition `json:"ui_definition"` + UserId *int64 `json:"user_id"` + UserUuid *uuid.UUID `json:"user_uuid"` + Version *int64 `json:"version"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.CreatedAt == nil { + return fmt.Errorf("required field created_at missing") + } + if all.DataDefinition == nil { + return fmt.Errorf("required field data_definition missing") + } + if all.DefinitionSignature == nil { + return fmt.Errorf("required field definition_signature missing") + } + if !all.Etag.IsSet() { + return fmt.Errorf("required field etag missing") + } + if all.ModifiedAt == nil { + return fmt.Errorf("required field modified_at missing") + } + if all.State == nil { + return fmt.Errorf("required field state missing") + } + if all.UiDefinition == nil { + return fmt.Errorf("required field ui_definition missing") + } + if all.UserId == nil { + return fmt.Errorf("required field user_id missing") + } + if all.UserUuid == nil { + return fmt.Errorf("required field user_uuid missing") + } + if all.Version == nil { + return fmt.Errorf("required field version missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"created_at", "data_definition", "definition_signature", "etag", "id", "modified_at", "state", "ui_definition", "user_id", "user_uuid", "version"}) + } else { + return err + } + + hasInvalidField := false + o.CreatedAt = *all.CreatedAt + if all.DataDefinition.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.DataDefinition = *all.DataDefinition + o.DefinitionSignature = *all.DefinitionSignature + o.Etag = all.Etag + o.Id = all.Id + o.ModifiedAt = *all.ModifiedAt + if !all.State.IsValid() { + hasInvalidField = true + } else { + o.State = *all.State + } + if all.UiDefinition.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.UiDefinition = *all.UiDefinition + o.UserId = *all.UserId + o.UserUuid = *all.UserUuid + o.Version = *all.Version + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_form_version_state.go b/api/datadogV2/model_form_version_state.go new file mode 100644 index 00000000000..f98d19c74ff --- /dev/null +++ b/api/datadogV2/model_form_version_state.go @@ -0,0 +1,66 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// FormVersionState The state of a form version. +type FormVersionState string + +// List of FormVersionState. +const ( + FORMVERSIONSTATE_DRAFT FormVersionState = "draft" + FORMVERSIONSTATE_FROZEN FormVersionState = "frozen" +) + +var allowedFormVersionStateEnumValues = []FormVersionState{ + FORMVERSIONSTATE_DRAFT, + FORMVERSIONSTATE_FROZEN, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *FormVersionState) GetAllowedValues() []FormVersionState { + return allowedFormVersionStateEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *FormVersionState) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = FormVersionState(value) + return nil +} + +// NewFormVersionStateFromValue returns a pointer to a valid FormVersionState +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewFormVersionStateFromValue(v string) (*FormVersionState, error) { + ev := FormVersionState(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for FormVersionState: valid values are %v", v, allowedFormVersionStateEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v FormVersionState) IsValid() bool { + for _, existing := range allowedFormVersionStateEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to FormVersionState value. +func (v FormVersionState) Ptr() *FormVersionState { + return &v +} diff --git a/api/datadogV2/model_forms_response.go b/api/datadogV2/model_forms_response.go new file mode 100644 index 00000000000..bffb24514cd --- /dev/null +++ b/api/datadogV2/model_forms_response.go @@ -0,0 +1,101 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// FormsResponse A response containing a list of forms. +type FormsResponse struct { + // A list of form resource objects. + Data []FormData `json:"data"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewFormsResponse instantiates a new FormsResponse object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewFormsResponse(data []FormData) *FormsResponse { + this := FormsResponse{} + this.Data = data + return &this +} + +// NewFormsResponseWithDefaults instantiates a new FormsResponse object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewFormsResponseWithDefaults() *FormsResponse { + this := FormsResponse{} + return &this +} + +// GetData returns the Data field value. +func (o *FormsResponse) GetData() []FormData { + if o == nil { + var ret []FormData + return ret + } + return o.Data +} + +// GetDataOk returns a tuple with the Data field value +// and a boolean to check if the value has been set. +func (o *FormsResponse) GetDataOk() (*[]FormData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *FormsResponse) SetData(v []FormData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o FormsResponse) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["data"] = o.Data + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *FormsResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *[]FormData `json:"data"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Data == nil { + return fmt.Errorf("required field data missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + o.Data = *all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/examples/v2/forms/CreateAndPublishForm.go b/examples/v2/forms/CreateAndPublishForm.go new file mode 100644 index 00000000000..e74a999b2d4 --- /dev/null +++ b/examples/v2/forms/CreateAndPublishForm.go @@ -0,0 +1,44 @@ +// Create and publish a form returns "OK" response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + body := datadogV2.CreateFormRequest{ + Data: datadogV2.CreateFormData{ + Attributes: datadogV2.CreateFormDataAttributes{ + Anonymous: datadog.PtrBool(false), + DataDefinition: datadogV2.FormDataDefinition{}, + Description: datadog.PtrString("A form to collect user feedback."), + IdpSurvey: datadog.PtrBool(false), + Name: "User Feedback Form", + SingleResponse: datadog.PtrBool(false), + UiDefinition: datadogV2.FormUiDefinition{}, + }, + Type: datadogV2.FORMTYPE_FORMS, + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + configuration.SetUnstableOperationEnabled("v2.CreateAndPublishForm", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewFormsApi(apiClient) + resp, r, err := api.CreateAndPublishForm(ctx, body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `FormsApi.CreateAndPublishForm`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `FormsApi.CreateAndPublishForm`:\n%s\n", responseContent) +} diff --git a/examples/v2/forms/CreateForm.go b/examples/v2/forms/CreateForm.go new file mode 100644 index 00000000000..88c3100cea4 --- /dev/null +++ b/examples/v2/forms/CreateForm.go @@ -0,0 +1,44 @@ +// Create a form returns "OK" response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + body := datadogV2.CreateFormRequest{ + Data: datadogV2.CreateFormData{ + Attributes: datadogV2.CreateFormDataAttributes{ + Anonymous: datadog.PtrBool(false), + DataDefinition: datadogV2.FormDataDefinition{}, + Description: datadog.PtrString("A form to collect user feedback."), + IdpSurvey: datadog.PtrBool(false), + Name: "User Feedback Form", + SingleResponse: datadog.PtrBool(false), + UiDefinition: datadogV2.FormUiDefinition{}, + }, + Type: datadogV2.FORMTYPE_FORMS, + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + configuration.SetUnstableOperationEnabled("v2.CreateForm", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewFormsApi(apiClient) + resp, r, err := api.CreateForm(ctx, body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `FormsApi.CreateForm`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `FormsApi.CreateForm`:\n%s\n", responseContent) +} diff --git a/examples/v2/forms/DeleteForm.go b/examples/v2/forms/DeleteForm.go new file mode 100644 index 00000000000..9fc04f1c535 --- /dev/null +++ b/examples/v2/forms/DeleteForm.go @@ -0,0 +1,34 @@ +// Delete a form returns "OK" response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" + "github.com/google/uuid" +) + +func main() { + // there is a valid "form" in the system + FormDataID := uuid.MustParse(os.Getenv("FORM_DATA_ID")) + + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + configuration.SetUnstableOperationEnabled("v2.DeleteForm", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewFormsApi(apiClient) + resp, r, err := api.DeleteForm(ctx, FormDataID) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `FormsApi.DeleteForm`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `FormsApi.DeleteForm`:\n%s\n", responseContent) +} diff --git a/examples/v2/forms/GetForm.go b/examples/v2/forms/GetForm.go new file mode 100644 index 00000000000..138da145feb --- /dev/null +++ b/examples/v2/forms/GetForm.go @@ -0,0 +1,34 @@ +// Get a form returns "OK" response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" + "github.com/google/uuid" +) + +func main() { + // there is a valid "form" in the system + FormDataID := uuid.MustParse(os.Getenv("FORM_DATA_ID")) + + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + configuration.SetUnstableOperationEnabled("v2.GetForm", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewFormsApi(apiClient) + resp, r, err := api.GetForm(ctx, FormDataID, *datadogV2.NewGetFormOptionalParameters()) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `FormsApi.GetForm`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `FormsApi.GetForm`:\n%s\n", responseContent) +} diff --git a/examples/v2/forms/ListForms.go b/examples/v2/forms/ListForms.go new file mode 100644 index 00000000000..2efac7de4ce --- /dev/null +++ b/examples/v2/forms/ListForms.go @@ -0,0 +1,30 @@ +// List forms returns "OK" response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + configuration.SetUnstableOperationEnabled("v2.ListForms", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewFormsApi(apiClient) + resp, r, err := api.ListForms(ctx) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `FormsApi.ListForms`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `FormsApi.ListForms`:\n%s\n", responseContent) +} diff --git a/tests/scenarios/api_mappings.go b/tests/scenarios/api_mappings.go index 2fac3efcda0..127aa080dc1 100644 --- a/tests/scenarios/api_mappings.go +++ b/tests/scenarios/api_mappings.go @@ -91,6 +91,7 @@ var apiMappings = map[string]map[string]reflect.Value{ "ErrorTrackingApi": reflect.ValueOf(datadogV2.NewErrorTrackingApi), "EventsApi": reflect.ValueOf(datadogV2.NewEventsApi), "FeatureFlagsApi": reflect.ValueOf(datadogV2.NewFeatureFlagsApi), + "FormsApi": reflect.ValueOf(datadogV2.NewFormsApi), "HighAvailabilityMultiRegionApi": reflect.ValueOf(datadogV2.NewHighAvailabilityMultiRegionApi), "EntityIntegrationConfigsApi": reflect.ValueOf(datadogV2.NewEntityIntegrationConfigsApi), "IncidentsApi": reflect.ValueOf(datadogV2.NewIncidentsApi), diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Forms/Scenario_Create_a_form_returns_OK_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Forms/Scenario_Create_a_form_returns_OK_response.freeze new file mode 100644 index 00000000000..094857b451b --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Forms/Scenario_Create_a_form_returns_OK_response.freeze @@ -0,0 +1 @@ +2026-06-04T18:34:02.931Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Forms/Scenario_Create_a_form_returns_OK_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Forms/Scenario_Create_a_form_returns_OK_response.yaml new file mode 100644 index 00000000000..0b2e06b0424 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Forms/Scenario_Create_a_form_returns_OK_response.yaml @@ -0,0 +1,41 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"anonymous":false,"data_definition":{},"description":"A form to collect user feedback.","idp_survey":false,"name":"User Feedback Form","single_response":false,"ui_definition":{}},"type":"forms"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v2/forms + response: + body: '{"data":{"id":"edb7d6d5-e21c-4fd0-845d-679317b5c2c9","type":"forms","attributes":{"active":true,"anonymous":false,"created_at":"2026-06-04T18:34:04.103183Z","datastore_config":{"datastore_id":"7cc8dadd-3529-4d0f-b8cb-f8c11c165867","primary_column_name":"id","primary_key_generation_strategy":"none"},"description":"A + form to collect user feedback.","idp_survey":false,"modified_at":"2026-06-04T18:34:04.103183Z","name":"User + Feedback Form","org_id":321813,"self_service":false,"single_response":false,"user_id":2320499,"user_uuid":"9919ec9b-ebc7-49ee-8dc8-03626e717cca","version":{"id":"354653","state":"draft","version":1,"etag":"b51f08b698d88d8027a935d9db649774949f5fb41a0c559bfee6a9a13225c72d","definition_signature":"{\"signature\":\"{\\\"version\\\":2,\\\"algorithm\\\":\\\"ecdsa-p384\\\",\\\"pubkey\\\":\\\"XOOWpRG1rFvaLHaG9qLf+GG78llET0BKnZtokyAtLfg=\\\",\\\"timestamp\\\":1780598044,\\\"proof\\\":\\\"MGQCMHsaS9oy6ZDzhUZuJQAYiivxgo9XKx5NjTW/0wafPecXBQ3lr27bKejXr4ihAuwxsgIwPfgedZacZ4t3Qg8p0+jrXH5MBdZx9hrat8mijVibYuLUd2n+bxaY0xcghHKwbtu4\\\"}\",\"version\":1}","data_definition":{},"ui_definition":{},"created_at":"2026-06-04T18:34:04.103183Z","modified_at":"2026-06-04T18:34:04.103183Z","user_id":2320499,"user_uuid":"9919ec9b-ebc7-49ee-8dc8-03626e717cca"}}}}' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK +- request: + body: '' + form: {} + headers: + Accept: + - application/json + id: 1 + method: DELETE + url: https://api.datadoghq.com/api/v2/forms/edb7d6d5-e21c-4fd0-845d-679317b5c2c9 + response: + body: '{"data":{"id":"edb7d6d5-e21c-4fd0-845d-679317b5c2c9","type":"forms"}}' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Forms/Scenario_Create_and_publish_a_form_returns_OK_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Forms/Scenario_Create_and_publish_a_form_returns_OK_response.freeze new file mode 100644 index 00000000000..0add2d175dc --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Forms/Scenario_Create_and_publish_a_form_returns_OK_response.freeze @@ -0,0 +1 @@ +2026-06-04T18:34:04.703Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Forms/Scenario_Create_and_publish_a_form_returns_OK_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Forms/Scenario_Create_and_publish_a_form_returns_OK_response.yaml new file mode 100644 index 00000000000..d7955d63f16 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Forms/Scenario_Create_and_publish_a_form_returns_OK_response.yaml @@ -0,0 +1,41 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"anonymous":false,"data_definition":{},"description":"A form to collect user feedback.","idp_survey":false,"name":"User Feedback Form","single_response":false,"ui_definition":{}},"type":"forms"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v2/forms/create_and_publish + response: + body: '{"data":{"id":"65318f43-ac0f-4990-add8-9847eee98fd8","type":"forms","attributes":{"active":true,"anonymous":false,"created_at":"2026-06-04T18:34:05.178222Z","datastore_config":{"datastore_id":"c89fc16a-53fb-4439-a007-1ebec095b1b7","primary_column_name":"id","primary_key_generation_strategy":"none"},"description":"A + form to collect user feedback.","idp_survey":false,"modified_at":"2026-06-04T18:34:05.178222Z","name":"User + Feedback Form","org_id":321813,"publication":{"id":"357922","org_id":321813,"form_id":"65318f43-ac0f-4990-add8-9847eee98fd8","publish_seq":1,"form_version":1,"created_at":"2026-06-04T18:34:05.178222Z","modified_at":"2026-06-04T18:34:05.178222Z","user_id":2320499,"user_uuid":"9919ec9b-ebc7-49ee-8dc8-03626e717cca"},"self_service":false,"single_response":false,"user_id":2320499,"user_uuid":"9919ec9b-ebc7-49ee-8dc8-03626e717cca","version":{"id":"354654","state":"frozen","version":1,"etag":"b51f08b698d88d8027a935d9db649774949f5fb41a0c559bfee6a9a13225c72d","definition_signature":"{\"signature\":\"{\\\"version\\\":2,\\\"algorithm\\\":\\\"ecdsa-p384\\\",\\\"pubkey\\\":\\\"XOOWpRG1rFvaLHaG9qLf+GG78llET0BKnZtokyAtLfg=\\\",\\\"timestamp\\\":1780598045,\\\"proof\\\":\\\"MGYCMQCPPczYtNvj1RLjrQkIrQNHHVgB3nxFIjn5jgwUE0tweuTV1kZnaYYUg+gl1Eh5+tMCMQCajq1cy1MaWEbzHA0EcDC6LjyQ5ajqqngb3RMQwzP8ewvsh+uzkPD2v6AHjnW115o=\\\"}\",\"version\":1}","data_definition":{},"ui_definition":{},"created_at":"2026-06-04T18:34:05.178222Z","modified_at":"2026-06-04T18:34:05.178222Z","user_id":2320499,"user_uuid":"9919ec9b-ebc7-49ee-8dc8-03626e717cca"}}}}' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK +- request: + body: '' + form: {} + headers: + Accept: + - application/json + id: 1 + method: DELETE + url: https://api.datadoghq.com/api/v2/forms/65318f43-ac0f-4990-add8-9847eee98fd8 + response: + body: '{"data":{"id":"65318f43-ac0f-4990-add8-9847eee98fd8","type":"forms"}}' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Forms/Scenario_Delete_a_form_returns_OK_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Forms/Scenario_Delete_a_form_returns_OK_response.freeze new file mode 100644 index 00000000000..602659c5aad --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Forms/Scenario_Delete_a_form_returns_OK_response.freeze @@ -0,0 +1 @@ +2026-06-04T18:34:05.786Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Forms/Scenario_Delete_a_form_returns_OK_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Forms/Scenario_Delete_a_form_returns_OK_response.yaml new file mode 100644 index 00000000000..f17d3175216 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Forms/Scenario_Delete_a_form_returns_OK_response.yaml @@ -0,0 +1,57 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"anonymous":false,"data_definition":{},"description":"A simple test form.","idp_survey":false,"name":"Test-Delete_a_form_returns_OK_response-1780598045","single_response":false,"ui_definition":{}},"type":"forms"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v2/forms + response: + body: '{"data":{"id":"257a9d32-6ed0-429b-9745-75366363caf3","type":"forms","attributes":{"active":true,"anonymous":false,"created_at":"2026-06-04T18:34:06.128238Z","datastore_config":{"datastore_id":"1e33b83f-0733-454e-9404-c032a479548e","primary_column_name":"id","primary_key_generation_strategy":"none"},"description":"A + simple test form.","idp_survey":false,"modified_at":"2026-06-04T18:34:06.128238Z","name":"Test-Delete_a_form_returns_OK_response-1780598045","org_id":321813,"self_service":false,"single_response":false,"user_id":2320499,"user_uuid":"9919ec9b-ebc7-49ee-8dc8-03626e717cca","version":{"id":"354655","state":"draft","version":1,"etag":"b51f08b698d88d8027a935d9db649774949f5fb41a0c559bfee6a9a13225c72d","definition_signature":"{\"signature\":\"{\\\"version\\\":2,\\\"algorithm\\\":\\\"ecdsa-p384\\\",\\\"pubkey\\\":\\\"XOOWpRG1rFvaLHaG9qLf+GG78llET0BKnZtokyAtLfg=\\\",\\\"timestamp\\\":1780598046,\\\"proof\\\":\\\"MGQCMDR3p4Wc6qLinT0JK9tT2I3NBvYMx43pPcUuCOyMapne99sS2RJe0woOU68I0GbQvwIwQMw7OQruNsIuTNJxK0zthVCFnXaxLASIvl2NsyomT9s/p2cgEzOY4T+XyRl6i27c\\\"}\",\"version\":1}","data_definition":{},"ui_definition":{},"created_at":"2026-06-04T18:34:06.128238Z","modified_at":"2026-06-04T18:34:06.128238Z","user_id":2320499,"user_uuid":"9919ec9b-ebc7-49ee-8dc8-03626e717cca"}}}}' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK +- request: + body: '' + form: {} + headers: + Accept: + - application/json + id: 1 + method: DELETE + url: https://api.datadoghq.com/api/v2/forms/257a9d32-6ed0-429b-9745-75366363caf3 + response: + body: '{"data":{"id":"257a9d32-6ed0-429b-9745-75366363caf3","type":"forms"}}' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK +- request: + body: '' + form: {} + headers: + Accept: + - application/json + id: 2 + method: DELETE + url: https://api.datadoghq.com/api/v2/forms/257a9d32-6ed0-429b-9745-75366363caf3 + response: + body: '{}' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Forms/Scenario_Get_a_form_returns_Not_Found_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Forms/Scenario_Get_a_form_returns_Not_Found_response.freeze new file mode 100644 index 00000000000..9e0e0d98675 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Forms/Scenario_Get_a_form_returns_Not_Found_response.freeze @@ -0,0 +1 @@ +2026-06-04T18:34:06.925Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Forms/Scenario_Get_a_form_returns_Not_Found_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Forms/Scenario_Get_a_form_returns_Not_Found_response.yaml new file mode 100644 index 00000000000..359b5f3a6ce --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Forms/Scenario_Get_a_form_returns_Not_Found_response.yaml @@ -0,0 +1,20 @@ +interactions: +- request: + body: '' + form: {} + headers: + Accept: + - application/json + id: 0 + method: GET + url: https://api.datadoghq.com/api/v2/forms/00000000-0000-0000-0000-000000000001 + response: + body: '{"errors":[{"status":"404","id":"bccf11bd-13c7-4911-9c00-58c00b6f8f52","title":"form + not found"}]}' + code: 404 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 404 Not Found +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Forms/Scenario_Get_a_form_returns_OK_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Forms/Scenario_Get_a_form_returns_OK_response.freeze new file mode 100644 index 00000000000..aea0ca127d2 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Forms/Scenario_Get_a_form_returns_OK_response.freeze @@ -0,0 +1 @@ +2026-06-04T18:34:07.294Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Forms/Scenario_Get_a_form_returns_OK_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Forms/Scenario_Get_a_form_returns_OK_response.yaml new file mode 100644 index 00000000000..58deea5e782 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Forms/Scenario_Get_a_form_returns_OK_response.yaml @@ -0,0 +1,58 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"anonymous":false,"data_definition":{},"description":"A simple test form.","idp_survey":false,"name":"Test-Get_a_form_returns_OK_response-1780598047","single_response":false,"ui_definition":{}},"type":"forms"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v2/forms + response: + body: '{"data":{"id":"b42493d4-fbd0-4139-b4b9-4815f414621d","type":"forms","attributes":{"active":true,"anonymous":false,"created_at":"2026-06-04T18:34:07.632566Z","datastore_config":{"datastore_id":"9aace6ce-ee9d-4c81-b176-22bed53ff080","primary_column_name":"id","primary_key_generation_strategy":"none"},"description":"A + simple test form.","idp_survey":false,"modified_at":"2026-06-04T18:34:07.632566Z","name":"Test-Get_a_form_returns_OK_response-1780598047","org_id":321813,"self_service":false,"single_response":false,"user_id":2320499,"user_uuid":"9919ec9b-ebc7-49ee-8dc8-03626e717cca","version":{"id":"354656","state":"draft","version":1,"etag":"b51f08b698d88d8027a935d9db649774949f5fb41a0c559bfee6a9a13225c72d","definition_signature":"{\"signature\":\"{\\\"version\\\":2,\\\"algorithm\\\":\\\"ecdsa-p384\\\",\\\"pubkey\\\":\\\"XOOWpRG1rFvaLHaG9qLf+GG78llET0BKnZtokyAtLfg=\\\",\\\"timestamp\\\":1780598047,\\\"proof\\\":\\\"MGUCMQCkP+Usa2zK0v4SsSDBHsE4p88u025oyaRrAnNTiTXLwGr3K0W4/MAFeeosBwZonE0CMGYsqH/GAJUKeY0ZZGl8GZp2QeY1l3byimzWXRLf36CHhuB1Pshv/7bi0WoYYCOQIg==\\\"}\",\"version\":1}","data_definition":{},"ui_definition":{},"created_at":"2026-06-04T18:34:07.632566Z","modified_at":"2026-06-04T18:34:07.632566Z","user_id":2320499,"user_uuid":"9919ec9b-ebc7-49ee-8dc8-03626e717cca"}}}}' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK +- request: + body: '' + form: {} + headers: + Accept: + - application/json + id: 1 + method: GET + url: https://api.datadoghq.com/api/v2/forms/b42493d4-fbd0-4139-b4b9-4815f414621d + response: + body: '{"data":{"id":"b42493d4-fbd0-4139-b4b9-4815f414621d","type":"forms","attributes":{"active":true,"anonymous":false,"created_at":"2026-06-04T18:34:07.632566Z","datastore_config":{"datastore_id":"9aace6ce-ee9d-4c81-b176-22bed53ff080","primary_column_name":"id","primary_key_generation_strategy":"none"},"description":"A + simple test form.","idp_survey":false,"modified_at":"2026-06-04T18:34:07.632566Z","name":"Test-Get_a_form_returns_OK_response-1780598047","org_id":321813,"self_service":false,"single_response":false,"user_id":2320499,"user_uuid":"9919ec9b-ebc7-49ee-8dc8-03626e717cca","version":{"id":"354656","state":"draft","version":1,"etag":"b51f08b698d88d8027a935d9db649774949f5fb41a0c559bfee6a9a13225c72d","definition_signature":"{\"signature\":\"{\\\"version\\\":2,\\\"algorithm\\\":\\\"ecdsa-p384\\\",\\\"pubkey\\\":\\\"XOOWpRG1rFvaLHaG9qLf+GG78llET0BKnZtokyAtLfg=\\\",\\\"timestamp\\\":1780598047,\\\"proof\\\":\\\"MGUCMQCkP+Usa2zK0v4SsSDBHsE4p88u025oyaRrAnNTiTXLwGr3K0W4/MAFeeosBwZonE0CMGYsqH/GAJUKeY0ZZGl8GZp2QeY1l3byimzWXRLf36CHhuB1Pshv/7bi0WoYYCOQIg==\\\"}\",\"version\":1}","data_definition":{},"ui_definition":{},"created_at":"2026-06-04T18:34:07.632566Z","modified_at":"2026-06-04T18:34:07.632566Z","user_id":2320499,"user_uuid":"9919ec9b-ebc7-49ee-8dc8-03626e717cca"}}}}' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK +- request: + body: '' + form: {} + headers: + Accept: + - application/json + id: 2 + method: DELETE + url: https://api.datadoghq.com/api/v2/forms/b42493d4-fbd0-4139-b4b9-4815f414621d + response: + body: '{"data":{"id":"b42493d4-fbd0-4139-b4b9-4815f414621d","type":"forms"}}' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Forms/Scenario_List_forms_returns_OK_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Forms/Scenario_List_forms_returns_OK_response.freeze new file mode 100644 index 00000000000..e1050a989d0 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Forms/Scenario_List_forms_returns_OK_response.freeze @@ -0,0 +1 @@ +2026-06-04T18:34:08.479Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Forms/Scenario_List_forms_returns_OK_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Forms/Scenario_List_forms_returns_OK_response.yaml new file mode 100644 index 00000000000..3d2bbc51539 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Forms/Scenario_List_forms_returns_OK_response.yaml @@ -0,0 +1,62 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"anonymous":false,"data_definition":{},"description":"A simple test form.","idp_survey":false,"name":"Test-List_forms_returns_OK_response-1780598048","single_response":false,"ui_definition":{}},"type":"forms"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v2/forms + response: + body: '{"data":{"id":"d71d1aef-539d-4951-b98e-ff4c0c4f97bb","type":"forms","attributes":{"active":true,"anonymous":false,"created_at":"2026-06-04T18:34:08.937305Z","datastore_config":{"datastore_id":"76b9f7b4-99d8-4a55-b95c-260cac22820d","primary_column_name":"id","primary_key_generation_strategy":"none"},"description":"A + simple test form.","idp_survey":false,"modified_at":"2026-06-04T18:34:08.937305Z","name":"Test-List_forms_returns_OK_response-1780598048","org_id":321813,"self_service":false,"single_response":false,"user_id":2320499,"user_uuid":"9919ec9b-ebc7-49ee-8dc8-03626e717cca","version":{"id":"354657","state":"draft","version":1,"etag":"b51f08b698d88d8027a935d9db649774949f5fb41a0c559bfee6a9a13225c72d","definition_signature":"{\"signature\":\"{\\\"version\\\":2,\\\"algorithm\\\":\\\"ecdsa-p384\\\",\\\"pubkey\\\":\\\"XOOWpRG1rFvaLHaG9qLf+GG78llET0BKnZtokyAtLfg=\\\",\\\"timestamp\\\":1780598048,\\\"proof\\\":\\\"MGUCMBSAXvYX++PAyywDBLlJsqgHq1ug3WLtMqKQRwx50qdAdj1UP1W58NnN9/DP70HavAIxANwA4guivHrOqlL36ETzde//0mI55MJ8Yv0ynU2p+QhqCSuJEHHgUUWjk0wYKJuZog==\\\"}\",\"version\":1}","data_definition":{},"ui_definition":{},"created_at":"2026-06-04T18:34:08.937305Z","modified_at":"2026-06-04T18:34:08.937305Z","user_id":2320499,"user_uuid":"9919ec9b-ebc7-49ee-8dc8-03626e717cca"}}}}' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK +- request: + body: '' + form: {} + headers: + Accept: + - application/json + id: 1 + method: GET + url: https://api.datadoghq.com/api/v2/forms + response: + body: '{"data":[{"id":"7af864d6-8c2f-41e5-b80d-1be56ea33d23","type":"forms","attributes":{"active":true,"anonymous":false,"created_at":"2026-06-04T18:05:41.512876Z","datastore_config":{"datastore_id":"543a7e0e-0f0f-4b14-8911-2f20df5f1b07","primary_column_name":"id","primary_key_generation_strategy":"none"},"description":"A + form to collect user feedback.","idp_survey":false,"modified_at":"2026-06-04T18:05:41.512876Z","name":"User + Feedback Form","org_id":321813,"self_service":false,"single_response":false,"user_id":1445416,"user_uuid":"3ad549bf-eba0-11e9-a77a-0705486660d0"}},{"id":"b2953c07-9385-4de2-9cd3-af3f5d6c7d09","type":"forms","attributes":{"active":true,"anonymous":false,"created_at":"2026-06-04T18:15:44.116619Z","datastore_config":{"datastore_id":"77b4b384-27d6-4619-bb55-1b2158d0080b","primary_column_name":"id","primary_key_generation_strategy":"none"},"description":"A + form to collect user feedback.","idp_survey":false,"modified_at":"2026-06-04T18:15:44.116619Z","name":"User + Feedback Form","org_id":321813,"self_service":false,"single_response":false,"user_id":1445416,"user_uuid":"3ad549bf-eba0-11e9-a77a-0705486660d0"}},{"id":"d71d1aef-539d-4951-b98e-ff4c0c4f97bb","type":"forms","attributes":{"active":true,"anonymous":false,"created_at":"2026-06-04T18:34:08.937305Z","datastore_config":{"datastore_id":"76b9f7b4-99d8-4a55-b95c-260cac22820d","primary_column_name":"id","primary_key_generation_strategy":"none"},"description":"A + simple test form.","idp_survey":false,"modified_at":"2026-06-04T18:34:08.937305Z","name":"Test-List_forms_returns_OK_response-1780598048","org_id":321813,"self_service":false,"single_response":false,"user_id":2320499,"user_uuid":"9919ec9b-ebc7-49ee-8dc8-03626e717cca"}}]}' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK +- request: + body: '' + form: {} + headers: + Accept: + - application/json + id: 2 + method: DELETE + url: https://api.datadoghq.com/api/v2/forms/d71d1aef-539d-4951-b98e-ff4c0c4f97bb + response: + body: '{"data":{"id":"d71d1aef-539d-4951-b98e-ff4c0c4f97bb","type":"forms"}}' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 200 OK +version: 2 diff --git a/tests/scenarios/features/v2/forms.feature b/tests/scenarios/features/v2/forms.feature new file mode 100644 index 00000000000..40823edbc0f --- /dev/null +++ b/tests/scenarios/features/v2/forms.feature @@ -0,0 +1,107 @@ +@endpoint(forms) @endpoint(forms-v2) +Feature: Forms + The Datadog Forms API lets you create and manage forms within the App + Builder platform. You can configure form settings, manage versions, + publish forms, and handle sharing configurations. + + 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 returns "Bad Request" response + Given operation "CreateForm" enabled + And new "CreateForm" request + And body with value {"data": {"attributes": {"anonymous": false, "data_definition": {"description": "Welcome to the Engineering Experience Survey.", "required": [], "title": "Developer Experience Survey", "type": "object"}, "description": "A form to collect user feedback.", "idp_survey": false, "name": "User Feedback Form", "single_response": false, "ui_definition": {"ui:order": [], "ui:theme": {"primaryColor": "gray"}}}, "type": "forms"}} + When the request is sent + Then the response status is 400 Bad Request + + @team:DataDog/app-builder-backend + Scenario: Create a form returns "OK" response + Given operation "CreateForm" enabled + And new "CreateForm" request + And body with value {"data": {"attributes": {"anonymous": false, "data_definition": {}, "description": "A form to collect user feedback.", "idp_survey": false, "name": "User Feedback Form", "single_response": false, "ui_definition": {}}, "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": {"anonymous": false, "data_definition": {"description": "Welcome to the Engineering Experience Survey.", "required": [], "title": "Developer Experience Survey", "type": "object"}, "description": "A form to collect user feedback.", "idp_survey": false, "name": "User Feedback Form", "single_response": false, "ui_definition": {"ui:order": [], "ui:theme": {"primaryColor": "gray"}}}, "type": "forms"}} + When the request is sent + Then the response status is 400 Bad Request + + @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": {"anonymous": false, "data_definition": {}, "description": "A form to collect user feedback.", "idp_survey": false, "name": "User Feedback Form", "single_response": false, "ui_definition": {}}, "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 + + @team:DataDog/app-builder-backend + Scenario: Delete a form returns "OK" response + Given operation "DeleteForm" enabled + And there is a valid "form" in the system + And new "DeleteForm" request + And request contains "form_id" parameter from "form.data.id" + When the request is sent + Then the response status is 200 OK + And the response "data.id" has the same value as "form.data.id" + And the response "data.type" is equal to "forms" + + @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 + + @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 with value "00000000-0000-0000-0000-000000000001" + When the request is sent + Then the response status is 404 Not Found + + @team:DataDog/app-builder-backend + Scenario: Get a form returns "OK" response + Given operation "GetForm" enabled + And there is a valid "form" in the system + And new "GetForm" request + And request contains "form_id" parameter from "form.data.id" + When the request is sent + Then the response status is 200 OK + And the response "data.id" has the same value as "form.data.id" + And the response "data.type" is equal to "forms" + And the response "data.attributes.name" is equal to "{{ unique }}" + + @generated @skip @team:DataDog/app-builder-backend + Scenario: List 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 + + @team:DataDog/app-builder-backend + Scenario: List forms returns "OK" response + Given operation "ListForms" enabled + And there is a valid "form" in the system + And new "ListForms" request + When the request is sent + Then the response status is 200 OK + And the response "data" has item with field "id" with value "{{ form.data.id }}" + And the response "data" has item with field "type" with value "forms" + And the response "data" has item with field "attributes.name" with value "{{ unique }}" diff --git a/tests/scenarios/features/v2/given.json b/tests/scenarios/features/v2/given.json index 097f6a07d55..c516f8069f8 100644 --- a/tests/scenarios/features/v2/given.json +++ b/tests/scenarios/features/v2/given.json @@ -498,6 +498,30 @@ "tag": "Feature Flags", "operationId": "UpdateAllocationsForFeatureFlagInEnvironment" }, + { + "parameters": [ + { + "name": "body", + "value": "{\n \"data\": {\n \"type\": \"forms\",\n \"attributes\": {\n \"name\": \"{{ unique }}\",\n \"description\": \"A simple test form.\",\n \"anonymous\": false,\n \"single_response\": false,\n \"idp_survey\": false,\n \"data_definition\": {},\n \"ui_definition\": {}\n }\n }\n}" + } + ], + "step": "there is a valid \"form\" in the system", + "key": "form", + "tag": "Forms", + "operationId": "CreateForm" + }, + { + "parameters": [ + { + "name": "body", + "value": "{\n \"data\": {\n \"type\": \"forms\",\n \"attributes\": {\n \"name\": \"{{ unique }}\",\n \"description\": \"A simple test form.\",\n \"anonymous\": false,\n \"single_response\": false,\n \"idp_survey\": false,\n \"data_definition\": {},\n \"ui_definition\": {}\n }\n }\n}" + } + ], + "step": "there is a valid \"form_published\" in the system", + "key": "form_published", + "tag": "Forms", + "operationId": "CreateAndPublishForm" + }, { "parameters": [ { diff --git a/tests/scenarios/features/v2/undo.json b/tests/scenarios/features/v2/undo.json index 1ee7a011229..a3f19194671 100644 --- a/tests/scenarios/features/v2/undo.json +++ b/tests/scenarios/features/v2/undo.json @@ -2609,6 +2609,50 @@ "type": "unsafe" } }, + "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" + } + }, "GetHamrOrgConnection": { "tag": "High Availability MultiRegion", "undo": {