diff --git a/.generator/schemas/v1/openapi.yaml b/.generator/schemas/v1/openapi.yaml index bb7b61547e7..0d3a83d523e 100644 --- a/.generator/schemas/v1/openapi.yaml +++ b/.generator/schemas/v1/openapi.yaml @@ -7993,6 +7993,7 @@ components: - spans - database_queries - network + - network_path example: rum type: string x-enum-varnames: @@ -8005,6 +8006,7 @@ components: - SPANS - DATABASE_QUERIES - NETWORK + - NETWORK_PATH MonitorFormulaAndFunctionQueryDefinition: description: A formula and function query. oneOf: @@ -8850,6 +8852,7 @@ components: - network-performance alert - cost alert - data-quality alert + - network-path alert example: query alert type: string x-enum-varnames: @@ -8873,6 +8876,7 @@ components: - NETWORK_PERFORMANCE_ALERT - COST_ALERT - DATA_QUALITY_ALERT + - NETWORK_PATH_ALERT MonitorUpdateRequest: description: Object describing a monitor update request. properties: @@ -31680,10 +31684,11 @@ paths: alert`\n- watchdog: `event-v2 alert`\n- event-v2: `event-v2 alert`\n- audit: `audit alert`\n- error-tracking: `error-tracking alert`\n- database-monitoring: `database-monitoring alert`\n- network-performance: `network-performance alert`\n- - cloud cost: `cost alert`\n\n**Notes**:\n- Synthetic monitors are created through - the Synthetics API. See the [Synthetics API](https://docs.datadoghq.com/api/latest/synthetics/) - documentation for more information.\n- Log monitors require an unscoped App - Key.\n\n#### Query Types\n\n##### Metric Alert Query\n\nExample: `time_aggr(time_window):space_aggr:metric{tags} + cloud cost: `cost alert`\n- network-path: `network-path alert`\n\n**Notes**:\n- + Synthetic monitors are created through the Synthetics API. See the [Synthetics + API](https://docs.datadoghq.com/api/latest/synthetics/) documentation for + more information.\n- Log monitors require an unscoped App Key.\n\n#### Query + Types\n\n##### Metric Alert Query\n\nExample: `time_aggr(time_window):space_aggr:metric{tags} [by {key}] operator #`\n\n- `time_aggr`: avg, sum, max, min, change, or pct_change\n- `time_window`: `last_#m` (with `#` between 1 and 10080 depending on the monitor type) or `last_#h`(with `#` between 1 and 168 depending on the monitor type) @@ -31813,7 +31818,15 @@ paths: \ - for `threshold` supports `<`, `<=`, `>`, `>=`, `==`, or `!=`\n - for `change` supports `>`, `<`\n - for `anomaly` supports `>=`\n - for `forecast` supports `>`\n- `#` an integer or decimal number used to set the - threshold." + threshold.\n\n**Network Path Alert Query**\n\nExample: `network-path(query).index(index_name).rollup(rollup_method[, + measure]).last(time_window) operator #`\n\n- `query` The search query - following + the [Log search syntax](https://docs.datadoghq.com/logs/search_syntax/).\n- + `index_name` The data type to monitor on - supports `netpath-path` and `netpath-hop`.\n- + `rollup_method` The stats roll-up method - supports `count`, `avg`, and `cardinality`.\n- + `measure` For `avg` and cardinality `rollup_method` - specify the measure + or the facet name you want to use.\n- `time_window` #m (between 1 and 2880), + #h (between 1 and 48).\n- `operator` `<`, `<=`, `>`, `>=`, `==`, or `!=`.\n- + `#` an integer or decimal number used to set the threshold." operationId: CreateMonitor requestBody: content: diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 5190081e023..70523726660 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -56094,6 +56094,65 @@ components: type: string x-enum-varnames: - SERVICES_LIST + ServiceNowAssignmentGroupAttributes: + description: Attributes of a ServiceNow assignment group + properties: + assignment_group_name: + description: The name of the assignment group + example: Network Team + type: string + assignment_group_sys_id: + description: The system ID of the assignment group in ServiceNow + example: abc123def456 + type: string + instance_id: + description: The ID of the ServiceNow instance + example: 65b3341b-0680-47f9-a6d4-134db45c603e + format: uuid + type: string + required: + - instance_id + - assignment_group_name + - assignment_group_sys_id + type: object + ServiceNowAssignmentGroupData: + description: Data object for a ServiceNow assignment group + properties: + attributes: + $ref: '#/components/schemas/ServiceNowAssignmentGroupAttributes' + id: + description: Unique identifier for the ServiceNow assignment group + example: 65b3341b-0680-47f9-a6d4-134db45c603e + format: uuid + type: string + type: + $ref: '#/components/schemas/ServiceNowAssignmentGroupType' + required: + - id + - type + - attributes + type: object + ServiceNowAssignmentGroupType: + description: Type identifier for ServiceNow assignment group resources + enum: + - assignment_groups + example: assignment_groups + type: string + x-enum-varnames: + - ASSIGNMENT_GROUPS + ServiceNowAssignmentGroupsData: + description: Array of ServiceNow assignment group data objects + items: + $ref: '#/components/schemas/ServiceNowAssignmentGroupData' + type: array + ServiceNowAssignmentGroupsResponse: + description: Response containing ServiceNow assignment groups + properties: + data: + $ref: '#/components/schemas/ServiceNowAssignmentGroupsData' + required: + - data + type: object ServiceNowBasicAuth: description: The definition of the `ServiceNowBasicAuth` object. properties: @@ -56142,6 +56201,65 @@ components: required: - type type: object + ServiceNowBusinessServiceAttributes: + description: Attributes of a ServiceNow business service + properties: + instance_id: + description: The ID of the ServiceNow instance + example: 65b3341b-0680-47f9-a6d4-134db45c603e + format: uuid + type: string + service_name: + description: The name of the business service + example: IT Support + type: string + service_sys_id: + description: The system ID of the business service in ServiceNow + example: abc123def456 + type: string + required: + - instance_id + - service_name + - service_sys_id + type: object + ServiceNowBusinessServiceData: + description: Data object for a ServiceNow business service + properties: + attributes: + $ref: '#/components/schemas/ServiceNowBusinessServiceAttributes' + id: + description: Unique identifier for the ServiceNow business service + example: 65b3341b-0680-47f9-a6d4-134db45c603e + format: uuid + type: string + type: + $ref: '#/components/schemas/ServiceNowBusinessServiceType' + required: + - id + - type + - attributes + type: object + ServiceNowBusinessServiceType: + description: Type identifier for ServiceNow business service resources + enum: + - business_services + example: business_services + type: string + x-enum-varnames: + - BUSINESS_SERVICES + ServiceNowBusinessServicesData: + description: Array of ServiceNow business service data objects + items: + $ref: '#/components/schemas/ServiceNowBusinessServiceData' + type: array + ServiceNowBusinessServicesResponse: + description: Response containing ServiceNow business services + properties: + data: + $ref: '#/components/schemas/ServiceNowBusinessServicesData' + required: + - data + type: object ServiceNowCredentials: description: The definition of the `ServiceNowCredentials` object. oneOf: @@ -56150,6 +56268,54 @@ components: description: The definition of the `ServiceNowCredentialsUpdate` object. oneOf: - $ref: '#/components/schemas/ServiceNowBasicAuthUpdate' + ServiceNowInstanceAttributes: + description: Attributes of a ServiceNow instance + properties: + instance_name: + description: The name of the ServiceNow instance + example: my-servicenow-instance + type: string + required: + - instance_name + type: object + ServiceNowInstanceData: + description: Data object for a ServiceNow instance + properties: + attributes: + $ref: '#/components/schemas/ServiceNowInstanceAttributes' + id: + description: Unique identifier for the ServiceNow instance + example: 65b3341b-0680-47f9-a6d4-134db45c603e + format: uuid + type: string + type: + $ref: '#/components/schemas/ServiceNowInstanceType' + required: + - id + - type + - attributes + type: object + ServiceNowInstanceType: + description: Type identifier for ServiceNow instance resources + enum: + - instance + example: instance + type: string + x-enum-varnames: + - INSTANCE + ServiceNowInstancesData: + description: Array of ServiceNow instance data objects + items: + $ref: '#/components/schemas/ServiceNowInstanceData' + type: array + ServiceNowInstancesResponse: + description: Response containing ServiceNow instances + properties: + data: + $ref: '#/components/schemas/ServiceNowInstancesData' + required: + - data + type: object ServiceNowIntegration: description: The definition of the `ServiceNowIntegration` object. properties: @@ -56179,6 +56345,222 @@ components: required: - type type: object + ServiceNowTemplateAttributes: + description: Attributes of a ServiceNow template + properties: + assignment_group_id: + description: The ID of the assignment group + example: 65b3341b-0680-47f9-a6d4-134db45c603e + format: uuid + type: string + business_service_id: + description: The ID of the business service + example: 65b3341b-0680-47f9-a6d4-134db45c603e + format: uuid + type: string + fields_mapping: + additionalProperties: + type: string + description: Custom field mappings for the template + example: + category: software + priority: '1' + type: object + handle_name: + description: The handle name of the template + example: incident-template + type: string + instance_id: + description: The ID of the ServiceNow instance + example: 65b3341b-0680-47f9-a6d4-134db45c603e + format: uuid + type: string + servicenow_tablename: + description: The name of the destination ServiceNow table + example: incident + type: string + user_id: + description: The ID of the user + example: 65b3341b-0680-47f9-a6d4-134db45c603e + format: uuid + type: string + required: + - instance_id + - handle_name + - servicenow_tablename + type: object + ServiceNowTemplateCreateRequest: + description: Request to create a ServiceNow template + properties: + data: + $ref: '#/components/schemas/ServiceNowTemplateCreateRequestData' + required: + - data + type: object + ServiceNowTemplateCreateRequestAttributes: + description: Attributes for creating a ServiceNow template + properties: + assignment_group_id: + description: The ID of the assignment group + example: 65b3341b-0680-47f9-a6d4-134db45c603e + format: uuid + type: string + business_service_id: + description: The ID of the business service + example: 65b3341b-0680-47f9-a6d4-134db45c603e + format: uuid + type: string + fields_mapping: + additionalProperties: + type: string + description: Custom field mappings for the template + example: + category: software + priority: '1' + type: object + handle_name: + description: The handle name of the template + example: incident-template + type: string + instance_id: + description: The ID of the ServiceNow instance + example: 65b3341b-0680-47f9-a6d4-134db45c603e + format: uuid + type: string + servicenow_tablename: + description: The name of the destination ServiceNow table + example: incident + type: string + user_id: + description: The ID of the user + example: 65b3341b-0680-47f9-a6d4-134db45c603e + format: uuid + type: string + required: + - instance_id + - handle_name + - servicenow_tablename + type: object + ServiceNowTemplateCreateRequestData: + description: Data object for creating a ServiceNow template + properties: + attributes: + $ref: '#/components/schemas/ServiceNowTemplateCreateRequestAttributes' + type: + $ref: '#/components/schemas/ServiceNowTemplateType' + required: + - type + - attributes + type: object + ServiceNowTemplateData: + description: Data object for a ServiceNow template + properties: + attributes: + $ref: '#/components/schemas/ServiceNowTemplateAttributes' + id: + description: Unique identifier for the ServiceNow template + example: 65b3341b-0680-47f9-a6d4-134db45c603e + format: uuid + type: string + type: + $ref: '#/components/schemas/ServiceNowTemplateType' + required: + - id + - type + - attributes + type: object + ServiceNowTemplateResponse: + description: Response containing a single ServiceNow template + properties: + data: + $ref: '#/components/schemas/ServiceNowTemplateData' + required: + - data + type: object + ServiceNowTemplateType: + description: Type identifier for ServiceNow template resources + enum: + - servicenow_templates + example: servicenow_templates + type: string + x-enum-varnames: + - SERVICENOW_TEMPLATES + ServiceNowTemplateUpdateRequest: + description: Request to update a ServiceNow template + properties: + data: + $ref: '#/components/schemas/ServiceNowTemplateUpdateRequestData' + required: + - data + type: object + ServiceNowTemplateUpdateRequestAttributes: + description: Attributes for updating a ServiceNow template + properties: + assignment_group_id: + description: The ID of the assignment group + example: 65b3341b-0680-47f9-a6d4-134db45c603e + format: uuid + type: string + business_service_id: + description: The ID of the business service + example: 65b3341b-0680-47f9-a6d4-134db45c603e + format: uuid + type: string + fields_mapping: + additionalProperties: + type: string + description: Custom field mappings for the template + example: + category: hardware + priority: '2' + type: object + handle_name: + description: The handle name of the template + example: incident-template-updated + type: string + instance_id: + description: The ID of the ServiceNow instance + example: 65b3341b-0680-47f9-a6d4-134db45c603e + format: uuid + type: string + servicenow_tablename: + description: The name of the destination ServiceNow table + example: incident + type: string + user_id: + description: The ID of the user + example: 65b3341b-0680-47f9-a6d4-134db45c603e + format: uuid + type: string + required: + - instance_id + - handle_name + - servicenow_tablename + type: object + ServiceNowTemplateUpdateRequestData: + description: Data object for updating a ServiceNow template + properties: + attributes: + $ref: '#/components/schemas/ServiceNowTemplateUpdateRequestAttributes' + type: + $ref: '#/components/schemas/ServiceNowTemplateType' + required: + - type + - attributes + type: object + ServiceNowTemplatesData: + description: Array of ServiceNow template data objects + items: + $ref: '#/components/schemas/ServiceNowTemplateData' + type: array + ServiceNowTemplatesResponse: + description: Response containing ServiceNow templates + properties: + data: + $ref: '#/components/schemas/ServiceNowTemplatesData' + required: + - data + type: object ServiceNowTicket: description: ServiceNow ticket attached to case nullable: true @@ -56196,6 +56578,74 @@ components: description: Link to the Incident created on ServiceNow type: string type: object + ServiceNowUserAttributes: + description: Attributes of a ServiceNow user + properties: + email: + description: The email address of the user + example: john.doe@example.com + type: string + full_name: + description: The full name of the user + example: John Doe + type: string + instance_id: + description: The ID of the ServiceNow instance + example: 65b3341b-0680-47f9-a6d4-134db45c603e + format: uuid + type: string + user_name: + description: The username of the ServiceNow user + example: john.doe + type: string + user_sys_id: + description: The system ID of the user in ServiceNow + example: abc123def456 + type: string + required: + - instance_id + - user_name + - user_sys_id + - email + type: object + ServiceNowUserData: + description: Data object for a ServiceNow user + properties: + attributes: + $ref: '#/components/schemas/ServiceNowUserAttributes' + id: + description: Unique identifier for the ServiceNow user + example: 65b3341b-0680-47f9-a6d4-134db45c603e + format: uuid + type: string + type: + $ref: '#/components/schemas/ServiceNowUserType' + required: + - id + - type + - attributes + type: object + ServiceNowUserType: + description: Type identifier for ServiceNow user resources + enum: + - users + example: users + type: string + x-enum-varnames: + - USERS + ServiceNowUsersData: + description: Array of ServiceNow user data objects + items: + $ref: '#/components/schemas/ServiceNowUserData' + type: array + ServiceNowUsersResponse: + description: Response containing ServiceNow users + properties: + data: + $ref: '#/components/schemas/ServiceNowUsersData' + required: + - data + type: object Shift: description: An on-call shift with its associated data and relationships. example: @@ -77664,6 +78114,320 @@ paths: operator: OR permissions: - manage_integrations + /api/v2/integration/servicenow/assignment_groups/{instance_id}: + get: + description: Get all assignment groups for a ServiceNow instance. + operationId: ListServiceNowAssignmentGroups + parameters: + - description: The ID of the ServiceNow instance + example: 65b3341b-0680-47f9-a6d4-134db45c603e + in: path + name: instance_id + required: true + schema: + format: uuid + type: string + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/ServiceNowAssignmentGroupsResponse' + description: OK + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Bad Request + '404': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Not Found + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: List ServiceNow assignment groups + tags: + - ServiceNow Integration + x-unstable: '**Note**: This endpoint is in public beta and is subject to change. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + /api/v2/integration/servicenow/business_services/{instance_id}: + get: + description: Get all business services for a ServiceNow instance. + operationId: ListServiceNowBusinessServices + parameters: + - description: The ID of the ServiceNow instance + example: 65b3341b-0680-47f9-a6d4-134db45c603e + in: path + name: instance_id + required: true + schema: + format: uuid + type: string + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/ServiceNowBusinessServicesResponse' + description: OK + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Bad Request + '404': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Not Found + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: List ServiceNow business services + tags: + - ServiceNow Integration + x-unstable: '**Note**: This endpoint is in public beta and is subject to change. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + /api/v2/integration/servicenow/handles: + get: + description: Get all ServiceNow templates for the organization. + operationId: ListServiceNowTemplates + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/ServiceNowTemplatesResponse' + description: OK + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: List ServiceNow templates + tags: + - ServiceNow Integration + x-unstable: '**Note**: This endpoint is in public beta and is subject to change. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + post: + description: Create a new ServiceNow template. + operationId: CreateServiceNowTemplate + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ServiceNowTemplateCreateRequest' + required: true + responses: + '201': + content: + application/json: + schema: + $ref: '#/components/schemas/ServiceNowTemplateResponse' + description: Created + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Bad Request + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: Create ServiceNow template + tags: + - ServiceNow Integration + x-unstable: '**Note**: This endpoint is in public beta and is subject to change. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + /api/v2/integration/servicenow/handles/{template_id}: + delete: + description: Delete a ServiceNow template by ID. + operationId: DeleteServiceNowTemplate + parameters: + - description: The ID of the ServiceNow template to delete + example: 65b3341b-0680-47f9-a6d4-134db45c603e + in: path + name: template_id + required: true + schema: + format: uuid + type: string + responses: + '200': + description: OK + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Bad Request + '404': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Not Found + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: Delete ServiceNow template + tags: + - ServiceNow Integration + x-unstable: '**Note**: This endpoint is in public beta and is subject to change. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + get: + description: Get a ServiceNow template by ID. + operationId: GetServiceNowTemplate + parameters: + - description: The ID of the ServiceNow template to retrieve + example: 65b3341b-0680-47f9-a6d4-134db45c603e + in: path + name: template_id + required: true + schema: + format: uuid + type: string + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/ServiceNowTemplateResponse' + description: OK + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Bad Request + '404': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Not Found + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: Get ServiceNow template + tags: + - ServiceNow Integration + x-unstable: '**Note**: This endpoint is in public beta and is subject to change. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + put: + description: Update a ServiceNow template by ID. + operationId: UpdateServiceNowTemplate + parameters: + - description: The ID of the ServiceNow template to update + example: 65b3341b-0680-47f9-a6d4-134db45c603e + in: path + name: template_id + required: true + schema: + format: uuid + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ServiceNowTemplateUpdateRequest' + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/ServiceNowTemplateResponse' + description: OK + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Bad Request + '404': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Not Found + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: Update ServiceNow template + tags: + - ServiceNow Integration + x-unstable: '**Note**: This endpoint is in public beta and is subject to change. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + /api/v2/integration/servicenow/instances: + get: + description: Get all ServiceNow instances for the organization. + operationId: ListServiceNowInstances + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/ServiceNowInstancesResponse' + description: OK + '404': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Not Found + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: List ServiceNow instances + tags: + - ServiceNow Integration + x-unstable: '**Note**: This endpoint is in public beta and is subject to change. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + /api/v2/integration/servicenow/users/{instance_id}: + get: + description: Get all users for a ServiceNow instance. + operationId: ListServiceNowUsers + parameters: + - description: The ID of the ServiceNow instance + example: 65b3341b-0680-47f9-a6d4-134db45c603e + in: path + name: instance_id + required: true + schema: + format: uuid + type: string + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/ServiceNowUsersResponse' + description: OK + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Bad Request + '404': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Not Found + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: List ServiceNow users + tags: + - ServiceNow Integration + x-unstable: '**Note**: This endpoint is in public beta and is subject to change. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' /api/v2/integrations/cloudflare/accounts: get: description: List Cloudflare accounts. @@ -98811,6 +99575,9 @@ tags: This feature is currently in BETA. If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' name: Service Scorecards +- description: Manage your ServiceNow Integration. ServiceNow is a cloud-based platform + that helps organizations manage digital workflows for enterprise operations. + name: ServiceNow Integration - description: API to create, update, retrieve, and delete Software Catalog entities. externalDocs: url: https://docs.datadoghq.com/service_catalog/service_definitions#metadata-schema-v30-beta diff --git a/api/datadog/configuration.go b/api/datadog/configuration.go index ac6f5f63cce..37a51abda7b 100644 --- a/api/datadog/configuration.go +++ b/api/datadog/configuration.go @@ -759,6 +759,15 @@ func NewConfiguration() *Configuration { "v2.ListJiraAccounts": false, "v2.ListJiraIssueTemplates": false, "v2.UpdateJiraIssueTemplate": false, + "v2.CreateServiceNowTemplate": false, + "v2.DeleteServiceNowTemplate": false, + "v2.GetServiceNowTemplate": false, + "v2.ListServiceNowAssignmentGroups": false, + "v2.ListServiceNowBusinessServices": false, + "v2.ListServiceNowInstances": false, + "v2.ListServiceNowTemplates": false, + "v2.ListServiceNowUsers": false, + "v2.UpdateServiceNowTemplate": false, "v2.AddRoleToRestrictionQuery": false, "v2.CreateRestrictionQuery": false, "v2.DeleteRestrictionQuery": false, diff --git a/api/datadogV1/api_monitors.go b/api/datadogV1/api_monitors.go index 4347056157e..94612e98b3e 100644 --- a/api/datadogV1/api_monitors.go +++ b/api/datadogV1/api_monitors.go @@ -131,6 +131,7 @@ func (a *MonitorsApi) CheckCanDeleteMonitor(ctx _context.Context, monitorIds []i // - database-monitoring: `database-monitoring alert` // - network-performance: `network-performance alert` // - cloud cost: `cost alert` +// - network-path: `network-path alert` // // **Notes**: // - Synthetic monitors are created through the Synthetics API. See the [Synthetics API](https://docs.datadoghq.com/api/latest/synthetics/) documentation for more information. @@ -324,6 +325,18 @@ func (a *MonitorsApi) CheckCanDeleteMonitor(ctx _context.Context, monitorIds []i // - for `forecast` supports `>` // // - `#` an integer or decimal number used to set the threshold. +// +// **Network Path Alert Query** +// +// Example: `network-path(query).index(index_name).rollup(rollup_method[, measure]).last(time_window) operator #` +// +// - `query` The search query - following the [Log search syntax](https://docs.datadoghq.com/logs/search_syntax/). +// - `index_name` The data type to monitor on - supports `netpath-path` and `netpath-hop`. +// - `rollup_method` The stats roll-up method - supports `count`, `avg`, and `cardinality`. +// - `measure` For `avg` and cardinality `rollup_method` - specify the measure or the facet name you want to use. +// - `time_window` #m (between 1 and 2880), #h (between 1 and 48). +// - `operator` `<`, `<=`, `>`, `>=`, `==`, or `!=`. +// - `#` an integer or decimal number used to set the threshold. func (a *MonitorsApi) CreateMonitor(ctx _context.Context, body Monitor) (Monitor, *_nethttp.Response, error) { var ( localVarHTTPMethod = _nethttp.MethodPost diff --git a/api/datadogV1/model_monitor_formula_and_function_events_data_source.go b/api/datadogV1/model_monitor_formula_and_function_events_data_source.go index 56b2385f776..e478c04e99a 100644 --- a/api/datadogV1/model_monitor_formula_and_function_events_data_source.go +++ b/api/datadogV1/model_monitor_formula_and_function_events_data_source.go @@ -24,6 +24,7 @@ const ( MONITORFORMULAANDFUNCTIONEVENTSDATASOURCE_SPANS MonitorFormulaAndFunctionEventsDataSource = "spans" MONITORFORMULAANDFUNCTIONEVENTSDATASOURCE_DATABASE_QUERIES MonitorFormulaAndFunctionEventsDataSource = "database_queries" MONITORFORMULAANDFUNCTIONEVENTSDATASOURCE_NETWORK MonitorFormulaAndFunctionEventsDataSource = "network" + MONITORFORMULAANDFUNCTIONEVENTSDATASOURCE_NETWORK_PATH MonitorFormulaAndFunctionEventsDataSource = "network_path" ) var allowedMonitorFormulaAndFunctionEventsDataSourceEnumValues = []MonitorFormulaAndFunctionEventsDataSource{ @@ -36,6 +37,7 @@ var allowedMonitorFormulaAndFunctionEventsDataSourceEnumValues = []MonitorFormul MONITORFORMULAANDFUNCTIONEVENTSDATASOURCE_SPANS, MONITORFORMULAANDFUNCTIONEVENTSDATASOURCE_DATABASE_QUERIES, MONITORFORMULAANDFUNCTIONEVENTSDATASOURCE_NETWORK, + MONITORFORMULAANDFUNCTIONEVENTSDATASOURCE_NETWORK_PATH, } // GetAllowedValues reeturns the list of possible values. diff --git a/api/datadogV1/model_monitor_type.go b/api/datadogV1/model_monitor_type.go index efbdab6bf56..69d3be42c34 100644 --- a/api/datadogV1/model_monitor_type.go +++ b/api/datadogV1/model_monitor_type.go @@ -35,6 +35,7 @@ const ( MONITORTYPE_NETWORK_PERFORMANCE_ALERT MonitorType = "network-performance alert" MONITORTYPE_COST_ALERT MonitorType = "cost alert" MONITORTYPE_DATA_QUALITY_ALERT MonitorType = "data-quality alert" + MONITORTYPE_NETWORK_PATH_ALERT MonitorType = "network-path alert" ) var allowedMonitorTypeEnumValues = []MonitorType{ @@ -58,6 +59,7 @@ var allowedMonitorTypeEnumValues = []MonitorType{ MONITORTYPE_NETWORK_PERFORMANCE_ALERT, MONITORTYPE_COST_ALERT, MONITORTYPE_DATA_QUALITY_ALERT, + MONITORTYPE_NETWORK_PATH_ALERT, } // GetAllowedValues reeturns the list of possible values. diff --git a/api/datadogV2/api_service_now_integration.go b/api/datadogV2/api_service_now_integration.go new file mode 100644 index 00000000000..839fc29f321 --- /dev/null +++ b/api/datadogV2/api_service_now_integration.go @@ -0,0 +1,874 @@ +// 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" +) + +// ServiceNowIntegrationApi service type +type ServiceNowIntegrationApi datadog.Service + +// CreateServiceNowTemplate Create ServiceNow template. +// Create a new ServiceNow template. +func (a *ServiceNowIntegrationApi) CreateServiceNowTemplate(ctx _context.Context, body ServiceNowTemplateCreateRequest) (ServiceNowTemplateResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPost + localVarPostBody interface{} + localVarReturnValue ServiceNowTemplateResponse + ) + + operationId := "v2.CreateServiceNowTemplate" + 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.ServiceNowIntegrationApi.CreateServiceNowTemplate") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/integration/servicenow/handles" + + 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 { + 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 +} + +// DeleteServiceNowTemplate Delete ServiceNow template. +// Delete a ServiceNow template by ID. +func (a *ServiceNowIntegrationApi) DeleteServiceNowTemplate(ctx _context.Context, templateId uuid.UUID) (*_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodDelete + localVarPostBody interface{} + ) + + operationId := "v2.DeleteServiceNowTemplate" + isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId) + if !isOperationEnabled { + return 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.ServiceNowIntegrationApi.DeleteServiceNowTemplate") + if err != nil { + return nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/integration/servicenow/handles/{template_id}" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{template_id}", _neturl.PathEscape(datadog.ParameterToString(templateId, ""))) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Accept"] = "*/*" + + if a.Client.Cfg.DelegatedTokenConfig != nil { + err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig) + if err != nil { + return 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 nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 404 { + var v JSONAPIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + return localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarHTTPResponse, newErr + } + + return localVarHTTPResponse, nil +} + +// GetServiceNowTemplate Get ServiceNow template. +// Get a ServiceNow template by ID. +func (a *ServiceNowIntegrationApi) GetServiceNowTemplate(ctx _context.Context, templateId uuid.UUID) (ServiceNowTemplateResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarReturnValue ServiceNowTemplateResponse + ) + + operationId := "v2.GetServiceNowTemplate" + 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.ServiceNowIntegrationApi.GetServiceNowTemplate") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/integration/servicenow/handles/{template_id}" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{template_id}", _neturl.PathEscape(datadog.ParameterToString(templateId, ""))) + + 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 == 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 +} + +// ListServiceNowAssignmentGroups List ServiceNow assignment groups. +// Get all assignment groups for a ServiceNow instance. +func (a *ServiceNowIntegrationApi) ListServiceNowAssignmentGroups(ctx _context.Context, instanceId uuid.UUID) (ServiceNowAssignmentGroupsResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarReturnValue ServiceNowAssignmentGroupsResponse + ) + + operationId := "v2.ListServiceNowAssignmentGroups" + 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.ServiceNowIntegrationApi.ListServiceNowAssignmentGroups") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/integration/servicenow/assignment_groups/{instance_id}" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{instance_id}", _neturl.PathEscape(datadog.ParameterToString(instanceId, ""))) + + 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 == 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 +} + +// ListServiceNowBusinessServices List ServiceNow business services. +// Get all business services for a ServiceNow instance. +func (a *ServiceNowIntegrationApi) ListServiceNowBusinessServices(ctx _context.Context, instanceId uuid.UUID) (ServiceNowBusinessServicesResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarReturnValue ServiceNowBusinessServicesResponse + ) + + operationId := "v2.ListServiceNowBusinessServices" + 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.ServiceNowIntegrationApi.ListServiceNowBusinessServices") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/integration/servicenow/business_services/{instance_id}" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{instance_id}", _neturl.PathEscape(datadog.ParameterToString(instanceId, ""))) + + 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 == 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 +} + +// ListServiceNowInstances List ServiceNow instances. +// Get all ServiceNow instances for the organization. +func (a *ServiceNowIntegrationApi) ListServiceNowInstances(ctx _context.Context) (ServiceNowInstancesResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarReturnValue ServiceNowInstancesResponse + ) + + operationId := "v2.ListServiceNowInstances" + 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.ServiceNowIntegrationApi.ListServiceNowInstances") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/integration/servicenow/instances" + + 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 == 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 +} + +// ListServiceNowTemplates List ServiceNow templates. +// Get all ServiceNow templates for the organization. +func (a *ServiceNowIntegrationApi) ListServiceNowTemplates(ctx _context.Context) (ServiceNowTemplatesResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarReturnValue ServiceNowTemplatesResponse + ) + + operationId := "v2.ListServiceNowTemplates" + 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.ServiceNowIntegrationApi.ListServiceNowTemplates") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/integration/servicenow/handles" + + 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 == 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 +} + +// ListServiceNowUsers List ServiceNow users. +// Get all users for a ServiceNow instance. +func (a *ServiceNowIntegrationApi) ListServiceNowUsers(ctx _context.Context, instanceId uuid.UUID) (ServiceNowUsersResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarReturnValue ServiceNowUsersResponse + ) + + operationId := "v2.ListServiceNowUsers" + 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.ServiceNowIntegrationApi.ListServiceNowUsers") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/integration/servicenow/users/{instance_id}" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{instance_id}", _neturl.PathEscape(datadog.ParameterToString(instanceId, ""))) + + 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 == 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 +} + +// UpdateServiceNowTemplate Update ServiceNow template. +// Update a ServiceNow template by ID. +func (a *ServiceNowIntegrationApi) UpdateServiceNowTemplate(ctx _context.Context, templateId uuid.UUID, body ServiceNowTemplateUpdateRequest) (ServiceNowTemplateResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPut + localVarPostBody interface{} + localVarReturnValue ServiceNowTemplateResponse + ) + + operationId := "v2.UpdateServiceNowTemplate" + 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.ServiceNowIntegrationApi.UpdateServiceNowTemplate") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/integration/servicenow/handles/{template_id}" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{template_id}", _neturl.PathEscape(datadog.ParameterToString(templateId, ""))) + + 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 == 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 +} + +// NewServiceNowIntegrationApi Returns NewServiceNowIntegrationApi. +func NewServiceNowIntegrationApi(client *datadog.APIClient) *ServiceNowIntegrationApi { + return &ServiceNowIntegrationApi{ + Client: client, + } +} diff --git a/api/datadogV2/doc.go b/api/datadogV2/doc.go index e5e67a6b323..d34d39ac275 100644 --- a/api/datadogV2/doc.go +++ b/api/datadogV2/doc.go @@ -666,6 +666,15 @@ // - [ServiceScorecardsApi.ListScorecardRules] // - [ServiceScorecardsApi.UpdateScorecardOutcomesAsync] // - [ServiceScorecardsApi.UpdateScorecardRule] +// - [ServiceNowIntegrationApi.CreateServiceNowTemplate] +// - [ServiceNowIntegrationApi.DeleteServiceNowTemplate] +// - [ServiceNowIntegrationApi.GetServiceNowTemplate] +// - [ServiceNowIntegrationApi.ListServiceNowAssignmentGroups] +// - [ServiceNowIntegrationApi.ListServiceNowBusinessServices] +// - [ServiceNowIntegrationApi.ListServiceNowInstances] +// - [ServiceNowIntegrationApi.ListServiceNowTemplates] +// - [ServiceNowIntegrationApi.ListServiceNowUsers] +// - [ServiceNowIntegrationApi.UpdateServiceNowTemplate] // - [SoftwareCatalogApi.DeleteCatalogEntity] // - [SoftwareCatalogApi.DeleteCatalogKind] // - [SoftwareCatalogApi.ListCatalogEntity] diff --git a/api/datadogV2/model_service_now_assignment_group_attributes.go b/api/datadogV2/model_service_now_assignment_group_attributes.go new file mode 100644 index 00000000000..61ef079b1db --- /dev/null +++ b/api/datadogV2/model_service_now_assignment_group_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" +) + +// ServiceNowAssignmentGroupAttributes Attributes of a ServiceNow assignment group +type ServiceNowAssignmentGroupAttributes struct { + // The name of the assignment group + AssignmentGroupName string `json:"assignment_group_name"` + // The system ID of the assignment group in ServiceNow + AssignmentGroupSysId string `json:"assignment_group_sys_id"` + // The ID of the ServiceNow instance + InstanceId uuid.UUID `json:"instance_id"` + // 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:"-"` +} + +// NewServiceNowAssignmentGroupAttributes instantiates a new ServiceNowAssignmentGroupAttributes 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 NewServiceNowAssignmentGroupAttributes(assignmentGroupName string, assignmentGroupSysId string, instanceId uuid.UUID) *ServiceNowAssignmentGroupAttributes { + this := ServiceNowAssignmentGroupAttributes{} + this.AssignmentGroupName = assignmentGroupName + this.AssignmentGroupSysId = assignmentGroupSysId + this.InstanceId = instanceId + return &this +} + +// NewServiceNowAssignmentGroupAttributesWithDefaults instantiates a new ServiceNowAssignmentGroupAttributes 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 NewServiceNowAssignmentGroupAttributesWithDefaults() *ServiceNowAssignmentGroupAttributes { + this := ServiceNowAssignmentGroupAttributes{} + return &this +} + +// GetAssignmentGroupName returns the AssignmentGroupName field value. +func (o *ServiceNowAssignmentGroupAttributes) GetAssignmentGroupName() string { + if o == nil { + var ret string + return ret + } + return o.AssignmentGroupName +} + +// GetAssignmentGroupNameOk returns a tuple with the AssignmentGroupName field value +// and a boolean to check if the value has been set. +func (o *ServiceNowAssignmentGroupAttributes) GetAssignmentGroupNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.AssignmentGroupName, true +} + +// SetAssignmentGroupName sets field value. +func (o *ServiceNowAssignmentGroupAttributes) SetAssignmentGroupName(v string) { + o.AssignmentGroupName = v +} + +// GetAssignmentGroupSysId returns the AssignmentGroupSysId field value. +func (o *ServiceNowAssignmentGroupAttributes) GetAssignmentGroupSysId() string { + if o == nil { + var ret string + return ret + } + return o.AssignmentGroupSysId +} + +// GetAssignmentGroupSysIdOk returns a tuple with the AssignmentGroupSysId field value +// and a boolean to check if the value has been set. +func (o *ServiceNowAssignmentGroupAttributes) GetAssignmentGroupSysIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.AssignmentGroupSysId, true +} + +// SetAssignmentGroupSysId sets field value. +func (o *ServiceNowAssignmentGroupAttributes) SetAssignmentGroupSysId(v string) { + o.AssignmentGroupSysId = v +} + +// GetInstanceId returns the InstanceId field value. +func (o *ServiceNowAssignmentGroupAttributes) GetInstanceId() uuid.UUID { + if o == nil { + var ret uuid.UUID + return ret + } + return o.InstanceId +} + +// GetInstanceIdOk returns a tuple with the InstanceId field value +// and a boolean to check if the value has been set. +func (o *ServiceNowAssignmentGroupAttributes) GetInstanceIdOk() (*uuid.UUID, bool) { + if o == nil { + return nil, false + } + return &o.InstanceId, true +} + +// SetInstanceId sets field value. +func (o *ServiceNowAssignmentGroupAttributes) SetInstanceId(v uuid.UUID) { + o.InstanceId = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ServiceNowAssignmentGroupAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["assignment_group_name"] = o.AssignmentGroupName + toSerialize["assignment_group_sys_id"] = o.AssignmentGroupSysId + toSerialize["instance_id"] = o.InstanceId + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *ServiceNowAssignmentGroupAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + AssignmentGroupName *string `json:"assignment_group_name"` + AssignmentGroupSysId *string `json:"assignment_group_sys_id"` + InstanceId *uuid.UUID `json:"instance_id"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.AssignmentGroupName == nil { + return fmt.Errorf("required field assignment_group_name missing") + } + if all.AssignmentGroupSysId == nil { + return fmt.Errorf("required field assignment_group_sys_id missing") + } + if all.InstanceId == nil { + return fmt.Errorf("required field instance_id missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"assignment_group_name", "assignment_group_sys_id", "instance_id"}) + } else { + return err + } + o.AssignmentGroupName = *all.AssignmentGroupName + o.AssignmentGroupSysId = *all.AssignmentGroupSysId + o.InstanceId = *all.InstanceId + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_service_now_assignment_group_data.go b/api/datadogV2/model_service_now_assignment_group_data.go new file mode 100644 index 00000000000..903cd20a129 --- /dev/null +++ b/api/datadogV2/model_service_now_assignment_group_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" +) + +// ServiceNowAssignmentGroupData Data object for a ServiceNow assignment group +type ServiceNowAssignmentGroupData struct { + // Attributes of a ServiceNow assignment group + Attributes ServiceNowAssignmentGroupAttributes `json:"attributes"` + // Unique identifier for the ServiceNow assignment group + Id uuid.UUID `json:"id"` + // Type identifier for ServiceNow assignment group resources + Type ServiceNowAssignmentGroupType `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:"-"` +} + +// NewServiceNowAssignmentGroupData instantiates a new ServiceNowAssignmentGroupData 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 NewServiceNowAssignmentGroupData(attributes ServiceNowAssignmentGroupAttributes, id uuid.UUID, typeVar ServiceNowAssignmentGroupType) *ServiceNowAssignmentGroupData { + this := ServiceNowAssignmentGroupData{} + this.Attributes = attributes + this.Id = id + this.Type = typeVar + return &this +} + +// NewServiceNowAssignmentGroupDataWithDefaults instantiates a new ServiceNowAssignmentGroupData 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 NewServiceNowAssignmentGroupDataWithDefaults() *ServiceNowAssignmentGroupData { + this := ServiceNowAssignmentGroupData{} + return &this +} + +// GetAttributes returns the Attributes field value. +func (o *ServiceNowAssignmentGroupData) GetAttributes() ServiceNowAssignmentGroupAttributes { + if o == nil { + var ret ServiceNowAssignmentGroupAttributes + 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 *ServiceNowAssignmentGroupData) GetAttributesOk() (*ServiceNowAssignmentGroupAttributes, bool) { + if o == nil { + return nil, false + } + return &o.Attributes, true +} + +// SetAttributes sets field value. +func (o *ServiceNowAssignmentGroupData) SetAttributes(v ServiceNowAssignmentGroupAttributes) { + o.Attributes = v +} + +// GetId returns the Id field value. +func (o *ServiceNowAssignmentGroupData) 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 *ServiceNowAssignmentGroupData) GetIdOk() (*uuid.UUID, bool) { + if o == nil { + return nil, false + } + return &o.Id, true +} + +// SetId sets field value. +func (o *ServiceNowAssignmentGroupData) SetId(v uuid.UUID) { + o.Id = v +} + +// GetType returns the Type field value. +func (o *ServiceNowAssignmentGroupData) GetType() ServiceNowAssignmentGroupType { + if o == nil { + var ret ServiceNowAssignmentGroupType + 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 *ServiceNowAssignmentGroupData) GetTypeOk() (*ServiceNowAssignmentGroupType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *ServiceNowAssignmentGroupData) SetType(v ServiceNowAssignmentGroupType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ServiceNowAssignmentGroupData) 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 *ServiceNowAssignmentGroupData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *ServiceNowAssignmentGroupAttributes `json:"attributes"` + Id *uuid.UUID `json:"id"` + Type *ServiceNowAssignmentGroupType `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.Unmarshal(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_service_now_assignment_group_type.go b/api/datadogV2/model_service_now_assignment_group_type.go new file mode 100644 index 00000000000..881e7d0ce9a --- /dev/null +++ b/api/datadogV2/model_service_now_assignment_group_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" +) + +// ServiceNowAssignmentGroupType Type identifier for ServiceNow assignment group resources +type ServiceNowAssignmentGroupType string + +// List of ServiceNowAssignmentGroupType. +const ( + SERVICENOWASSIGNMENTGROUPTYPE_ASSIGNMENT_GROUPS ServiceNowAssignmentGroupType = "assignment_groups" +) + +var allowedServiceNowAssignmentGroupTypeEnumValues = []ServiceNowAssignmentGroupType{ + SERVICENOWASSIGNMENTGROUPTYPE_ASSIGNMENT_GROUPS, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *ServiceNowAssignmentGroupType) GetAllowedValues() []ServiceNowAssignmentGroupType { + return allowedServiceNowAssignmentGroupTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *ServiceNowAssignmentGroupType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = ServiceNowAssignmentGroupType(value) + return nil +} + +// NewServiceNowAssignmentGroupTypeFromValue returns a pointer to a valid ServiceNowAssignmentGroupType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewServiceNowAssignmentGroupTypeFromValue(v string) (*ServiceNowAssignmentGroupType, error) { + ev := ServiceNowAssignmentGroupType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for ServiceNowAssignmentGroupType: valid values are %v", v, allowedServiceNowAssignmentGroupTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v ServiceNowAssignmentGroupType) IsValid() bool { + for _, existing := range allowedServiceNowAssignmentGroupTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to ServiceNowAssignmentGroupType value. +func (v ServiceNowAssignmentGroupType) Ptr() *ServiceNowAssignmentGroupType { + return &v +} diff --git a/api/datadogV2/model_service_now_assignment_groups_response.go b/api/datadogV2/model_service_now_assignment_groups_response.go new file mode 100644 index 00000000000..7299466fdc4 --- /dev/null +++ b/api/datadogV2/model_service_now_assignment_groups_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" +) + +// ServiceNowAssignmentGroupsResponse Response containing ServiceNow assignment groups +type ServiceNowAssignmentGroupsResponse struct { + // Array of ServiceNow assignment group data objects + Data []ServiceNowAssignmentGroupData `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:"-"` +} + +// NewServiceNowAssignmentGroupsResponse instantiates a new ServiceNowAssignmentGroupsResponse 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 NewServiceNowAssignmentGroupsResponse(data []ServiceNowAssignmentGroupData) *ServiceNowAssignmentGroupsResponse { + this := ServiceNowAssignmentGroupsResponse{} + this.Data = data + return &this +} + +// NewServiceNowAssignmentGroupsResponseWithDefaults instantiates a new ServiceNowAssignmentGroupsResponse 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 NewServiceNowAssignmentGroupsResponseWithDefaults() *ServiceNowAssignmentGroupsResponse { + this := ServiceNowAssignmentGroupsResponse{} + return &this +} + +// GetData returns the Data field value. +func (o *ServiceNowAssignmentGroupsResponse) GetData() []ServiceNowAssignmentGroupData { + if o == nil { + var ret []ServiceNowAssignmentGroupData + 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 *ServiceNowAssignmentGroupsResponse) GetDataOk() (*[]ServiceNowAssignmentGroupData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *ServiceNowAssignmentGroupsResponse) SetData(v []ServiceNowAssignmentGroupData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ServiceNowAssignmentGroupsResponse) 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 *ServiceNowAssignmentGroupsResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *[]ServiceNowAssignmentGroupData `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.Unmarshal(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/api/datadogV2/model_service_now_business_service_attributes.go b/api/datadogV2/model_service_now_business_service_attributes.go new file mode 100644 index 00000000000..f8ec03f47ab --- /dev/null +++ b/api/datadogV2/model_service_now_business_service_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" +) + +// ServiceNowBusinessServiceAttributes Attributes of a ServiceNow business service +type ServiceNowBusinessServiceAttributes struct { + // The ID of the ServiceNow instance + InstanceId uuid.UUID `json:"instance_id"` + // The name of the business service + ServiceName string `json:"service_name"` + // The system ID of the business service in ServiceNow + ServiceSysId string `json:"service_sys_id"` + // 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:"-"` +} + +// NewServiceNowBusinessServiceAttributes instantiates a new ServiceNowBusinessServiceAttributes 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 NewServiceNowBusinessServiceAttributes(instanceId uuid.UUID, serviceName string, serviceSysId string) *ServiceNowBusinessServiceAttributes { + this := ServiceNowBusinessServiceAttributes{} + this.InstanceId = instanceId + this.ServiceName = serviceName + this.ServiceSysId = serviceSysId + return &this +} + +// NewServiceNowBusinessServiceAttributesWithDefaults instantiates a new ServiceNowBusinessServiceAttributes 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 NewServiceNowBusinessServiceAttributesWithDefaults() *ServiceNowBusinessServiceAttributes { + this := ServiceNowBusinessServiceAttributes{} + return &this +} + +// GetInstanceId returns the InstanceId field value. +func (o *ServiceNowBusinessServiceAttributes) GetInstanceId() uuid.UUID { + if o == nil { + var ret uuid.UUID + return ret + } + return o.InstanceId +} + +// GetInstanceIdOk returns a tuple with the InstanceId field value +// and a boolean to check if the value has been set. +func (o *ServiceNowBusinessServiceAttributes) GetInstanceIdOk() (*uuid.UUID, bool) { + if o == nil { + return nil, false + } + return &o.InstanceId, true +} + +// SetInstanceId sets field value. +func (o *ServiceNowBusinessServiceAttributes) SetInstanceId(v uuid.UUID) { + o.InstanceId = v +} + +// GetServiceName returns the ServiceName field value. +func (o *ServiceNowBusinessServiceAttributes) GetServiceName() string { + if o == nil { + var ret string + return ret + } + return o.ServiceName +} + +// GetServiceNameOk returns a tuple with the ServiceName field value +// and a boolean to check if the value has been set. +func (o *ServiceNowBusinessServiceAttributes) GetServiceNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.ServiceName, true +} + +// SetServiceName sets field value. +func (o *ServiceNowBusinessServiceAttributes) SetServiceName(v string) { + o.ServiceName = v +} + +// GetServiceSysId returns the ServiceSysId field value. +func (o *ServiceNowBusinessServiceAttributes) GetServiceSysId() string { + if o == nil { + var ret string + return ret + } + return o.ServiceSysId +} + +// GetServiceSysIdOk returns a tuple with the ServiceSysId field value +// and a boolean to check if the value has been set. +func (o *ServiceNowBusinessServiceAttributes) GetServiceSysIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.ServiceSysId, true +} + +// SetServiceSysId sets field value. +func (o *ServiceNowBusinessServiceAttributes) SetServiceSysId(v string) { + o.ServiceSysId = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ServiceNowBusinessServiceAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["instance_id"] = o.InstanceId + toSerialize["service_name"] = o.ServiceName + toSerialize["service_sys_id"] = o.ServiceSysId + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *ServiceNowBusinessServiceAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + InstanceId *uuid.UUID `json:"instance_id"` + ServiceName *string `json:"service_name"` + ServiceSysId *string `json:"service_sys_id"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.InstanceId == nil { + return fmt.Errorf("required field instance_id missing") + } + if all.ServiceName == nil { + return fmt.Errorf("required field service_name missing") + } + if all.ServiceSysId == nil { + return fmt.Errorf("required field service_sys_id missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"instance_id", "service_name", "service_sys_id"}) + } else { + return err + } + o.InstanceId = *all.InstanceId + o.ServiceName = *all.ServiceName + o.ServiceSysId = *all.ServiceSysId + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_service_now_business_service_data.go b/api/datadogV2/model_service_now_business_service_data.go new file mode 100644 index 00000000000..615d28c958a --- /dev/null +++ b/api/datadogV2/model_service_now_business_service_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" +) + +// ServiceNowBusinessServiceData Data object for a ServiceNow business service +type ServiceNowBusinessServiceData struct { + // Attributes of a ServiceNow business service + Attributes ServiceNowBusinessServiceAttributes `json:"attributes"` + // Unique identifier for the ServiceNow business service + Id uuid.UUID `json:"id"` + // Type identifier for ServiceNow business service resources + Type ServiceNowBusinessServiceType `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:"-"` +} + +// NewServiceNowBusinessServiceData instantiates a new ServiceNowBusinessServiceData 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 NewServiceNowBusinessServiceData(attributes ServiceNowBusinessServiceAttributes, id uuid.UUID, typeVar ServiceNowBusinessServiceType) *ServiceNowBusinessServiceData { + this := ServiceNowBusinessServiceData{} + this.Attributes = attributes + this.Id = id + this.Type = typeVar + return &this +} + +// NewServiceNowBusinessServiceDataWithDefaults instantiates a new ServiceNowBusinessServiceData 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 NewServiceNowBusinessServiceDataWithDefaults() *ServiceNowBusinessServiceData { + this := ServiceNowBusinessServiceData{} + return &this +} + +// GetAttributes returns the Attributes field value. +func (o *ServiceNowBusinessServiceData) GetAttributes() ServiceNowBusinessServiceAttributes { + if o == nil { + var ret ServiceNowBusinessServiceAttributes + 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 *ServiceNowBusinessServiceData) GetAttributesOk() (*ServiceNowBusinessServiceAttributes, bool) { + if o == nil { + return nil, false + } + return &o.Attributes, true +} + +// SetAttributes sets field value. +func (o *ServiceNowBusinessServiceData) SetAttributes(v ServiceNowBusinessServiceAttributes) { + o.Attributes = v +} + +// GetId returns the Id field value. +func (o *ServiceNowBusinessServiceData) 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 *ServiceNowBusinessServiceData) GetIdOk() (*uuid.UUID, bool) { + if o == nil { + return nil, false + } + return &o.Id, true +} + +// SetId sets field value. +func (o *ServiceNowBusinessServiceData) SetId(v uuid.UUID) { + o.Id = v +} + +// GetType returns the Type field value. +func (o *ServiceNowBusinessServiceData) GetType() ServiceNowBusinessServiceType { + if o == nil { + var ret ServiceNowBusinessServiceType + 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 *ServiceNowBusinessServiceData) GetTypeOk() (*ServiceNowBusinessServiceType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *ServiceNowBusinessServiceData) SetType(v ServiceNowBusinessServiceType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ServiceNowBusinessServiceData) 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 *ServiceNowBusinessServiceData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *ServiceNowBusinessServiceAttributes `json:"attributes"` + Id *uuid.UUID `json:"id"` + Type *ServiceNowBusinessServiceType `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.Unmarshal(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_service_now_business_service_type.go b/api/datadogV2/model_service_now_business_service_type.go new file mode 100644 index 00000000000..61cd86f8414 --- /dev/null +++ b/api/datadogV2/model_service_now_business_service_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" +) + +// ServiceNowBusinessServiceType Type identifier for ServiceNow business service resources +type ServiceNowBusinessServiceType string + +// List of ServiceNowBusinessServiceType. +const ( + SERVICENOWBUSINESSSERVICETYPE_BUSINESS_SERVICES ServiceNowBusinessServiceType = "business_services" +) + +var allowedServiceNowBusinessServiceTypeEnumValues = []ServiceNowBusinessServiceType{ + SERVICENOWBUSINESSSERVICETYPE_BUSINESS_SERVICES, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *ServiceNowBusinessServiceType) GetAllowedValues() []ServiceNowBusinessServiceType { + return allowedServiceNowBusinessServiceTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *ServiceNowBusinessServiceType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = ServiceNowBusinessServiceType(value) + return nil +} + +// NewServiceNowBusinessServiceTypeFromValue returns a pointer to a valid ServiceNowBusinessServiceType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewServiceNowBusinessServiceTypeFromValue(v string) (*ServiceNowBusinessServiceType, error) { + ev := ServiceNowBusinessServiceType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for ServiceNowBusinessServiceType: valid values are %v", v, allowedServiceNowBusinessServiceTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v ServiceNowBusinessServiceType) IsValid() bool { + for _, existing := range allowedServiceNowBusinessServiceTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to ServiceNowBusinessServiceType value. +func (v ServiceNowBusinessServiceType) Ptr() *ServiceNowBusinessServiceType { + return &v +} diff --git a/api/datadogV2/model_service_now_business_services_response.go b/api/datadogV2/model_service_now_business_services_response.go new file mode 100644 index 00000000000..32f07a51a17 --- /dev/null +++ b/api/datadogV2/model_service_now_business_services_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" +) + +// ServiceNowBusinessServicesResponse Response containing ServiceNow business services +type ServiceNowBusinessServicesResponse struct { + // Array of ServiceNow business service data objects + Data []ServiceNowBusinessServiceData `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:"-"` +} + +// NewServiceNowBusinessServicesResponse instantiates a new ServiceNowBusinessServicesResponse 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 NewServiceNowBusinessServicesResponse(data []ServiceNowBusinessServiceData) *ServiceNowBusinessServicesResponse { + this := ServiceNowBusinessServicesResponse{} + this.Data = data + return &this +} + +// NewServiceNowBusinessServicesResponseWithDefaults instantiates a new ServiceNowBusinessServicesResponse 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 NewServiceNowBusinessServicesResponseWithDefaults() *ServiceNowBusinessServicesResponse { + this := ServiceNowBusinessServicesResponse{} + return &this +} + +// GetData returns the Data field value. +func (o *ServiceNowBusinessServicesResponse) GetData() []ServiceNowBusinessServiceData { + if o == nil { + var ret []ServiceNowBusinessServiceData + 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 *ServiceNowBusinessServicesResponse) GetDataOk() (*[]ServiceNowBusinessServiceData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *ServiceNowBusinessServicesResponse) SetData(v []ServiceNowBusinessServiceData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ServiceNowBusinessServicesResponse) 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 *ServiceNowBusinessServicesResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *[]ServiceNowBusinessServiceData `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.Unmarshal(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/api/datadogV2/model_service_now_instance_attributes.go b/api/datadogV2/model_service_now_instance_attributes.go new file mode 100644 index 00000000000..1055e59e4c8 --- /dev/null +++ b/api/datadogV2/model_service_now_instance_attributes.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" +) + +// ServiceNowInstanceAttributes Attributes of a ServiceNow instance +type ServiceNowInstanceAttributes struct { + // The name of the ServiceNow instance + InstanceName string `json:"instance_name"` + // 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:"-"` +} + +// NewServiceNowInstanceAttributes instantiates a new ServiceNowInstanceAttributes 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 NewServiceNowInstanceAttributes(instanceName string) *ServiceNowInstanceAttributes { + this := ServiceNowInstanceAttributes{} + this.InstanceName = instanceName + return &this +} + +// NewServiceNowInstanceAttributesWithDefaults instantiates a new ServiceNowInstanceAttributes 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 NewServiceNowInstanceAttributesWithDefaults() *ServiceNowInstanceAttributes { + this := ServiceNowInstanceAttributes{} + return &this +} + +// GetInstanceName returns the InstanceName field value. +func (o *ServiceNowInstanceAttributes) GetInstanceName() string { + if o == nil { + var ret string + return ret + } + return o.InstanceName +} + +// GetInstanceNameOk returns a tuple with the InstanceName field value +// and a boolean to check if the value has been set. +func (o *ServiceNowInstanceAttributes) GetInstanceNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.InstanceName, true +} + +// SetInstanceName sets field value. +func (o *ServiceNowInstanceAttributes) SetInstanceName(v string) { + o.InstanceName = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ServiceNowInstanceAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["instance_name"] = o.InstanceName + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *ServiceNowInstanceAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + InstanceName *string `json:"instance_name"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.InstanceName == nil { + return fmt.Errorf("required field instance_name missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"instance_name"}) + } else { + return err + } + o.InstanceName = *all.InstanceName + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_service_now_instance_data.go b/api/datadogV2/model_service_now_instance_data.go new file mode 100644 index 00000000000..c92d5c4e4f7 --- /dev/null +++ b/api/datadogV2/model_service_now_instance_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" +) + +// ServiceNowInstanceData Data object for a ServiceNow instance +type ServiceNowInstanceData struct { + // Attributes of a ServiceNow instance + Attributes ServiceNowInstanceAttributes `json:"attributes"` + // Unique identifier for the ServiceNow instance + Id uuid.UUID `json:"id"` + // Type identifier for ServiceNow instance resources + Type ServiceNowInstanceType `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:"-"` +} + +// NewServiceNowInstanceData instantiates a new ServiceNowInstanceData 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 NewServiceNowInstanceData(attributes ServiceNowInstanceAttributes, id uuid.UUID, typeVar ServiceNowInstanceType) *ServiceNowInstanceData { + this := ServiceNowInstanceData{} + this.Attributes = attributes + this.Id = id + this.Type = typeVar + return &this +} + +// NewServiceNowInstanceDataWithDefaults instantiates a new ServiceNowInstanceData 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 NewServiceNowInstanceDataWithDefaults() *ServiceNowInstanceData { + this := ServiceNowInstanceData{} + return &this +} + +// GetAttributes returns the Attributes field value. +func (o *ServiceNowInstanceData) GetAttributes() ServiceNowInstanceAttributes { + if o == nil { + var ret ServiceNowInstanceAttributes + 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 *ServiceNowInstanceData) GetAttributesOk() (*ServiceNowInstanceAttributes, bool) { + if o == nil { + return nil, false + } + return &o.Attributes, true +} + +// SetAttributes sets field value. +func (o *ServiceNowInstanceData) SetAttributes(v ServiceNowInstanceAttributes) { + o.Attributes = v +} + +// GetId returns the Id field value. +func (o *ServiceNowInstanceData) 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 *ServiceNowInstanceData) GetIdOk() (*uuid.UUID, bool) { + if o == nil { + return nil, false + } + return &o.Id, true +} + +// SetId sets field value. +func (o *ServiceNowInstanceData) SetId(v uuid.UUID) { + o.Id = v +} + +// GetType returns the Type field value. +func (o *ServiceNowInstanceData) GetType() ServiceNowInstanceType { + if o == nil { + var ret ServiceNowInstanceType + 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 *ServiceNowInstanceData) GetTypeOk() (*ServiceNowInstanceType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *ServiceNowInstanceData) SetType(v ServiceNowInstanceType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ServiceNowInstanceData) 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 *ServiceNowInstanceData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *ServiceNowInstanceAttributes `json:"attributes"` + Id *uuid.UUID `json:"id"` + Type *ServiceNowInstanceType `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.Unmarshal(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_service_now_instance_type.go b/api/datadogV2/model_service_now_instance_type.go new file mode 100644 index 00000000000..6bc7162e331 --- /dev/null +++ b/api/datadogV2/model_service_now_instance_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" +) + +// ServiceNowInstanceType Type identifier for ServiceNow instance resources +type ServiceNowInstanceType string + +// List of ServiceNowInstanceType. +const ( + SERVICENOWINSTANCETYPE_INSTANCE ServiceNowInstanceType = "instance" +) + +var allowedServiceNowInstanceTypeEnumValues = []ServiceNowInstanceType{ + SERVICENOWINSTANCETYPE_INSTANCE, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *ServiceNowInstanceType) GetAllowedValues() []ServiceNowInstanceType { + return allowedServiceNowInstanceTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *ServiceNowInstanceType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = ServiceNowInstanceType(value) + return nil +} + +// NewServiceNowInstanceTypeFromValue returns a pointer to a valid ServiceNowInstanceType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewServiceNowInstanceTypeFromValue(v string) (*ServiceNowInstanceType, error) { + ev := ServiceNowInstanceType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for ServiceNowInstanceType: valid values are %v", v, allowedServiceNowInstanceTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v ServiceNowInstanceType) IsValid() bool { + for _, existing := range allowedServiceNowInstanceTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to ServiceNowInstanceType value. +func (v ServiceNowInstanceType) Ptr() *ServiceNowInstanceType { + return &v +} diff --git a/api/datadogV2/model_service_now_instances_response.go b/api/datadogV2/model_service_now_instances_response.go new file mode 100644 index 00000000000..7fd63266e51 --- /dev/null +++ b/api/datadogV2/model_service_now_instances_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" +) + +// ServiceNowInstancesResponse Response containing ServiceNow instances +type ServiceNowInstancesResponse struct { + // Array of ServiceNow instance data objects + Data []ServiceNowInstanceData `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:"-"` +} + +// NewServiceNowInstancesResponse instantiates a new ServiceNowInstancesResponse 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 NewServiceNowInstancesResponse(data []ServiceNowInstanceData) *ServiceNowInstancesResponse { + this := ServiceNowInstancesResponse{} + this.Data = data + return &this +} + +// NewServiceNowInstancesResponseWithDefaults instantiates a new ServiceNowInstancesResponse 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 NewServiceNowInstancesResponseWithDefaults() *ServiceNowInstancesResponse { + this := ServiceNowInstancesResponse{} + return &this +} + +// GetData returns the Data field value. +func (o *ServiceNowInstancesResponse) GetData() []ServiceNowInstanceData { + if o == nil { + var ret []ServiceNowInstanceData + 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 *ServiceNowInstancesResponse) GetDataOk() (*[]ServiceNowInstanceData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *ServiceNowInstancesResponse) SetData(v []ServiceNowInstanceData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ServiceNowInstancesResponse) 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 *ServiceNowInstancesResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *[]ServiceNowInstanceData `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.Unmarshal(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/api/datadogV2/model_service_now_template_attributes.go b/api/datadogV2/model_service_now_template_attributes.go new file mode 100644 index 00000000000..864c3af6d44 --- /dev/null +++ b/api/datadogV2/model_service_now_template_attributes.go @@ -0,0 +1,307 @@ +// 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" +) + +// ServiceNowTemplateAttributes Attributes of a ServiceNow template +type ServiceNowTemplateAttributes struct { + // The ID of the assignment group + AssignmentGroupId *uuid.UUID `json:"assignment_group_id,omitempty"` + // The ID of the business service + BusinessServiceId *uuid.UUID `json:"business_service_id,omitempty"` + // Custom field mappings for the template + FieldsMapping map[string]string `json:"fields_mapping,omitempty"` + // The handle name of the template + HandleName string `json:"handle_name"` + // The ID of the ServiceNow instance + InstanceId uuid.UUID `json:"instance_id"` + // The name of the destination ServiceNow table + ServicenowTablename string `json:"servicenow_tablename"` + // The ID of the user + UserId *uuid.UUID `json:"user_id,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:"-"` +} + +// NewServiceNowTemplateAttributes instantiates a new ServiceNowTemplateAttributes 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 NewServiceNowTemplateAttributes(handleName string, instanceId uuid.UUID, servicenowTablename string) *ServiceNowTemplateAttributes { + this := ServiceNowTemplateAttributes{} + this.HandleName = handleName + this.InstanceId = instanceId + this.ServicenowTablename = servicenowTablename + return &this +} + +// NewServiceNowTemplateAttributesWithDefaults instantiates a new ServiceNowTemplateAttributes 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 NewServiceNowTemplateAttributesWithDefaults() *ServiceNowTemplateAttributes { + this := ServiceNowTemplateAttributes{} + return &this +} + +// GetAssignmentGroupId returns the AssignmentGroupId field value if set, zero value otherwise. +func (o *ServiceNowTemplateAttributes) GetAssignmentGroupId() uuid.UUID { + if o == nil || o.AssignmentGroupId == nil { + var ret uuid.UUID + return ret + } + return *o.AssignmentGroupId +} + +// GetAssignmentGroupIdOk returns a tuple with the AssignmentGroupId field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ServiceNowTemplateAttributes) GetAssignmentGroupIdOk() (*uuid.UUID, bool) { + if o == nil || o.AssignmentGroupId == nil { + return nil, false + } + return o.AssignmentGroupId, true +} + +// HasAssignmentGroupId returns a boolean if a field has been set. +func (o *ServiceNowTemplateAttributes) HasAssignmentGroupId() bool { + return o != nil && o.AssignmentGroupId != nil +} + +// SetAssignmentGroupId gets a reference to the given uuid.UUID and assigns it to the AssignmentGroupId field. +func (o *ServiceNowTemplateAttributes) SetAssignmentGroupId(v uuid.UUID) { + o.AssignmentGroupId = &v +} + +// GetBusinessServiceId returns the BusinessServiceId field value if set, zero value otherwise. +func (o *ServiceNowTemplateAttributes) GetBusinessServiceId() uuid.UUID { + if o == nil || o.BusinessServiceId == nil { + var ret uuid.UUID + return ret + } + return *o.BusinessServiceId +} + +// GetBusinessServiceIdOk returns a tuple with the BusinessServiceId field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ServiceNowTemplateAttributes) GetBusinessServiceIdOk() (*uuid.UUID, bool) { + if o == nil || o.BusinessServiceId == nil { + return nil, false + } + return o.BusinessServiceId, true +} + +// HasBusinessServiceId returns a boolean if a field has been set. +func (o *ServiceNowTemplateAttributes) HasBusinessServiceId() bool { + return o != nil && o.BusinessServiceId != nil +} + +// SetBusinessServiceId gets a reference to the given uuid.UUID and assigns it to the BusinessServiceId field. +func (o *ServiceNowTemplateAttributes) SetBusinessServiceId(v uuid.UUID) { + o.BusinessServiceId = &v +} + +// GetFieldsMapping returns the FieldsMapping field value if set, zero value otherwise. +func (o *ServiceNowTemplateAttributes) GetFieldsMapping() map[string]string { + if o == nil || o.FieldsMapping == nil { + var ret map[string]string + return ret + } + return o.FieldsMapping +} + +// GetFieldsMappingOk returns a tuple with the FieldsMapping field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ServiceNowTemplateAttributes) GetFieldsMappingOk() (*map[string]string, bool) { + if o == nil || o.FieldsMapping == nil { + return nil, false + } + return &o.FieldsMapping, true +} + +// HasFieldsMapping returns a boolean if a field has been set. +func (o *ServiceNowTemplateAttributes) HasFieldsMapping() bool { + return o != nil && o.FieldsMapping != nil +} + +// SetFieldsMapping gets a reference to the given map[string]string and assigns it to the FieldsMapping field. +func (o *ServiceNowTemplateAttributes) SetFieldsMapping(v map[string]string) { + o.FieldsMapping = v +} + +// GetHandleName returns the HandleName field value. +func (o *ServiceNowTemplateAttributes) GetHandleName() string { + if o == nil { + var ret string + return ret + } + return o.HandleName +} + +// GetHandleNameOk returns a tuple with the HandleName field value +// and a boolean to check if the value has been set. +func (o *ServiceNowTemplateAttributes) GetHandleNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.HandleName, true +} + +// SetHandleName sets field value. +func (o *ServiceNowTemplateAttributes) SetHandleName(v string) { + o.HandleName = v +} + +// GetInstanceId returns the InstanceId field value. +func (o *ServiceNowTemplateAttributes) GetInstanceId() uuid.UUID { + if o == nil { + var ret uuid.UUID + return ret + } + return o.InstanceId +} + +// GetInstanceIdOk returns a tuple with the InstanceId field value +// and a boolean to check if the value has been set. +func (o *ServiceNowTemplateAttributes) GetInstanceIdOk() (*uuid.UUID, bool) { + if o == nil { + return nil, false + } + return &o.InstanceId, true +} + +// SetInstanceId sets field value. +func (o *ServiceNowTemplateAttributes) SetInstanceId(v uuid.UUID) { + o.InstanceId = v +} + +// GetServicenowTablename returns the ServicenowTablename field value. +func (o *ServiceNowTemplateAttributes) GetServicenowTablename() string { + if o == nil { + var ret string + return ret + } + return o.ServicenowTablename +} + +// GetServicenowTablenameOk returns a tuple with the ServicenowTablename field value +// and a boolean to check if the value has been set. +func (o *ServiceNowTemplateAttributes) GetServicenowTablenameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.ServicenowTablename, true +} + +// SetServicenowTablename sets field value. +func (o *ServiceNowTemplateAttributes) SetServicenowTablename(v string) { + o.ServicenowTablename = v +} + +// GetUserId returns the UserId field value if set, zero value otherwise. +func (o *ServiceNowTemplateAttributes) GetUserId() uuid.UUID { + if o == nil || o.UserId == nil { + var ret uuid.UUID + return ret + } + return *o.UserId +} + +// GetUserIdOk returns a tuple with the UserId field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ServiceNowTemplateAttributes) GetUserIdOk() (*uuid.UUID, bool) { + if o == nil || o.UserId == nil { + return nil, false + } + return o.UserId, true +} + +// HasUserId returns a boolean if a field has been set. +func (o *ServiceNowTemplateAttributes) HasUserId() bool { + return o != nil && o.UserId != nil +} + +// SetUserId gets a reference to the given uuid.UUID and assigns it to the UserId field. +func (o *ServiceNowTemplateAttributes) SetUserId(v uuid.UUID) { + o.UserId = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ServiceNowTemplateAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.AssignmentGroupId != nil { + toSerialize["assignment_group_id"] = o.AssignmentGroupId + } + if o.BusinessServiceId != nil { + toSerialize["business_service_id"] = o.BusinessServiceId + } + if o.FieldsMapping != nil { + toSerialize["fields_mapping"] = o.FieldsMapping + } + toSerialize["handle_name"] = o.HandleName + toSerialize["instance_id"] = o.InstanceId + toSerialize["servicenow_tablename"] = o.ServicenowTablename + if o.UserId != nil { + toSerialize["user_id"] = o.UserId + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *ServiceNowTemplateAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + AssignmentGroupId *uuid.UUID `json:"assignment_group_id,omitempty"` + BusinessServiceId *uuid.UUID `json:"business_service_id,omitempty"` + FieldsMapping map[string]string `json:"fields_mapping,omitempty"` + HandleName *string `json:"handle_name"` + InstanceId *uuid.UUID `json:"instance_id"` + ServicenowTablename *string `json:"servicenow_tablename"` + UserId *uuid.UUID `json:"user_id,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.HandleName == nil { + return fmt.Errorf("required field handle_name missing") + } + if all.InstanceId == nil { + return fmt.Errorf("required field instance_id missing") + } + if all.ServicenowTablename == nil { + return fmt.Errorf("required field servicenow_tablename missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"assignment_group_id", "business_service_id", "fields_mapping", "handle_name", "instance_id", "servicenow_tablename", "user_id"}) + } else { + return err + } + o.AssignmentGroupId = all.AssignmentGroupId + o.BusinessServiceId = all.BusinessServiceId + o.FieldsMapping = all.FieldsMapping + o.HandleName = *all.HandleName + o.InstanceId = *all.InstanceId + o.ServicenowTablename = *all.ServicenowTablename + o.UserId = all.UserId + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_service_now_template_create_request.go b/api/datadogV2/model_service_now_template_create_request.go new file mode 100644 index 00000000000..c16d7f28be0 --- /dev/null +++ b/api/datadogV2/model_service_now_template_create_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" +) + +// ServiceNowTemplateCreateRequest Request to create a ServiceNow template +type ServiceNowTemplateCreateRequest struct { + // Data object for creating a ServiceNow template + Data ServiceNowTemplateCreateRequestData `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:"-"` +} + +// NewServiceNowTemplateCreateRequest instantiates a new ServiceNowTemplateCreateRequest 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 NewServiceNowTemplateCreateRequest(data ServiceNowTemplateCreateRequestData) *ServiceNowTemplateCreateRequest { + this := ServiceNowTemplateCreateRequest{} + this.Data = data + return &this +} + +// NewServiceNowTemplateCreateRequestWithDefaults instantiates a new ServiceNowTemplateCreateRequest 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 NewServiceNowTemplateCreateRequestWithDefaults() *ServiceNowTemplateCreateRequest { + this := ServiceNowTemplateCreateRequest{} + return &this +} + +// GetData returns the Data field value. +func (o *ServiceNowTemplateCreateRequest) GetData() ServiceNowTemplateCreateRequestData { + if o == nil { + var ret ServiceNowTemplateCreateRequestData + 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 *ServiceNowTemplateCreateRequest) GetDataOk() (*ServiceNowTemplateCreateRequestData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *ServiceNowTemplateCreateRequest) SetData(v ServiceNowTemplateCreateRequestData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ServiceNowTemplateCreateRequest) 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 *ServiceNowTemplateCreateRequest) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *ServiceNowTemplateCreateRequestData `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.Unmarshal(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_service_now_template_create_request_attributes.go b/api/datadogV2/model_service_now_template_create_request_attributes.go new file mode 100644 index 00000000000..6df83f3d03b --- /dev/null +++ b/api/datadogV2/model_service_now_template_create_request_attributes.go @@ -0,0 +1,307 @@ +// 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" +) + +// ServiceNowTemplateCreateRequestAttributes Attributes for creating a ServiceNow template +type ServiceNowTemplateCreateRequestAttributes struct { + // The ID of the assignment group + AssignmentGroupId *uuid.UUID `json:"assignment_group_id,omitempty"` + // The ID of the business service + BusinessServiceId *uuid.UUID `json:"business_service_id,omitempty"` + // Custom field mappings for the template + FieldsMapping map[string]string `json:"fields_mapping,omitempty"` + // The handle name of the template + HandleName string `json:"handle_name"` + // The ID of the ServiceNow instance + InstanceId uuid.UUID `json:"instance_id"` + // The name of the destination ServiceNow table + ServicenowTablename string `json:"servicenow_tablename"` + // The ID of the user + UserId *uuid.UUID `json:"user_id,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:"-"` +} + +// NewServiceNowTemplateCreateRequestAttributes instantiates a new ServiceNowTemplateCreateRequestAttributes 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 NewServiceNowTemplateCreateRequestAttributes(handleName string, instanceId uuid.UUID, servicenowTablename string) *ServiceNowTemplateCreateRequestAttributes { + this := ServiceNowTemplateCreateRequestAttributes{} + this.HandleName = handleName + this.InstanceId = instanceId + this.ServicenowTablename = servicenowTablename + return &this +} + +// NewServiceNowTemplateCreateRequestAttributesWithDefaults instantiates a new ServiceNowTemplateCreateRequestAttributes 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 NewServiceNowTemplateCreateRequestAttributesWithDefaults() *ServiceNowTemplateCreateRequestAttributes { + this := ServiceNowTemplateCreateRequestAttributes{} + return &this +} + +// GetAssignmentGroupId returns the AssignmentGroupId field value if set, zero value otherwise. +func (o *ServiceNowTemplateCreateRequestAttributes) GetAssignmentGroupId() uuid.UUID { + if o == nil || o.AssignmentGroupId == nil { + var ret uuid.UUID + return ret + } + return *o.AssignmentGroupId +} + +// GetAssignmentGroupIdOk returns a tuple with the AssignmentGroupId field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ServiceNowTemplateCreateRequestAttributes) GetAssignmentGroupIdOk() (*uuid.UUID, bool) { + if o == nil || o.AssignmentGroupId == nil { + return nil, false + } + return o.AssignmentGroupId, true +} + +// HasAssignmentGroupId returns a boolean if a field has been set. +func (o *ServiceNowTemplateCreateRequestAttributes) HasAssignmentGroupId() bool { + return o != nil && o.AssignmentGroupId != nil +} + +// SetAssignmentGroupId gets a reference to the given uuid.UUID and assigns it to the AssignmentGroupId field. +func (o *ServiceNowTemplateCreateRequestAttributes) SetAssignmentGroupId(v uuid.UUID) { + o.AssignmentGroupId = &v +} + +// GetBusinessServiceId returns the BusinessServiceId field value if set, zero value otherwise. +func (o *ServiceNowTemplateCreateRequestAttributes) GetBusinessServiceId() uuid.UUID { + if o == nil || o.BusinessServiceId == nil { + var ret uuid.UUID + return ret + } + return *o.BusinessServiceId +} + +// GetBusinessServiceIdOk returns a tuple with the BusinessServiceId field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ServiceNowTemplateCreateRequestAttributes) GetBusinessServiceIdOk() (*uuid.UUID, bool) { + if o == nil || o.BusinessServiceId == nil { + return nil, false + } + return o.BusinessServiceId, true +} + +// HasBusinessServiceId returns a boolean if a field has been set. +func (o *ServiceNowTemplateCreateRequestAttributes) HasBusinessServiceId() bool { + return o != nil && o.BusinessServiceId != nil +} + +// SetBusinessServiceId gets a reference to the given uuid.UUID and assigns it to the BusinessServiceId field. +func (o *ServiceNowTemplateCreateRequestAttributes) SetBusinessServiceId(v uuid.UUID) { + o.BusinessServiceId = &v +} + +// GetFieldsMapping returns the FieldsMapping field value if set, zero value otherwise. +func (o *ServiceNowTemplateCreateRequestAttributes) GetFieldsMapping() map[string]string { + if o == nil || o.FieldsMapping == nil { + var ret map[string]string + return ret + } + return o.FieldsMapping +} + +// GetFieldsMappingOk returns a tuple with the FieldsMapping field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ServiceNowTemplateCreateRequestAttributes) GetFieldsMappingOk() (*map[string]string, bool) { + if o == nil || o.FieldsMapping == nil { + return nil, false + } + return &o.FieldsMapping, true +} + +// HasFieldsMapping returns a boolean if a field has been set. +func (o *ServiceNowTemplateCreateRequestAttributes) HasFieldsMapping() bool { + return o != nil && o.FieldsMapping != nil +} + +// SetFieldsMapping gets a reference to the given map[string]string and assigns it to the FieldsMapping field. +func (o *ServiceNowTemplateCreateRequestAttributes) SetFieldsMapping(v map[string]string) { + o.FieldsMapping = v +} + +// GetHandleName returns the HandleName field value. +func (o *ServiceNowTemplateCreateRequestAttributes) GetHandleName() string { + if o == nil { + var ret string + return ret + } + return o.HandleName +} + +// GetHandleNameOk returns a tuple with the HandleName field value +// and a boolean to check if the value has been set. +func (o *ServiceNowTemplateCreateRequestAttributes) GetHandleNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.HandleName, true +} + +// SetHandleName sets field value. +func (o *ServiceNowTemplateCreateRequestAttributes) SetHandleName(v string) { + o.HandleName = v +} + +// GetInstanceId returns the InstanceId field value. +func (o *ServiceNowTemplateCreateRequestAttributes) GetInstanceId() uuid.UUID { + if o == nil { + var ret uuid.UUID + return ret + } + return o.InstanceId +} + +// GetInstanceIdOk returns a tuple with the InstanceId field value +// and a boolean to check if the value has been set. +func (o *ServiceNowTemplateCreateRequestAttributes) GetInstanceIdOk() (*uuid.UUID, bool) { + if o == nil { + return nil, false + } + return &o.InstanceId, true +} + +// SetInstanceId sets field value. +func (o *ServiceNowTemplateCreateRequestAttributes) SetInstanceId(v uuid.UUID) { + o.InstanceId = v +} + +// GetServicenowTablename returns the ServicenowTablename field value. +func (o *ServiceNowTemplateCreateRequestAttributes) GetServicenowTablename() string { + if o == nil { + var ret string + return ret + } + return o.ServicenowTablename +} + +// GetServicenowTablenameOk returns a tuple with the ServicenowTablename field value +// and a boolean to check if the value has been set. +func (o *ServiceNowTemplateCreateRequestAttributes) GetServicenowTablenameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.ServicenowTablename, true +} + +// SetServicenowTablename sets field value. +func (o *ServiceNowTemplateCreateRequestAttributes) SetServicenowTablename(v string) { + o.ServicenowTablename = v +} + +// GetUserId returns the UserId field value if set, zero value otherwise. +func (o *ServiceNowTemplateCreateRequestAttributes) GetUserId() uuid.UUID { + if o == nil || o.UserId == nil { + var ret uuid.UUID + return ret + } + return *o.UserId +} + +// GetUserIdOk returns a tuple with the UserId field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ServiceNowTemplateCreateRequestAttributes) GetUserIdOk() (*uuid.UUID, bool) { + if o == nil || o.UserId == nil { + return nil, false + } + return o.UserId, true +} + +// HasUserId returns a boolean if a field has been set. +func (o *ServiceNowTemplateCreateRequestAttributes) HasUserId() bool { + return o != nil && o.UserId != nil +} + +// SetUserId gets a reference to the given uuid.UUID and assigns it to the UserId field. +func (o *ServiceNowTemplateCreateRequestAttributes) SetUserId(v uuid.UUID) { + o.UserId = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ServiceNowTemplateCreateRequestAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.AssignmentGroupId != nil { + toSerialize["assignment_group_id"] = o.AssignmentGroupId + } + if o.BusinessServiceId != nil { + toSerialize["business_service_id"] = o.BusinessServiceId + } + if o.FieldsMapping != nil { + toSerialize["fields_mapping"] = o.FieldsMapping + } + toSerialize["handle_name"] = o.HandleName + toSerialize["instance_id"] = o.InstanceId + toSerialize["servicenow_tablename"] = o.ServicenowTablename + if o.UserId != nil { + toSerialize["user_id"] = o.UserId + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *ServiceNowTemplateCreateRequestAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + AssignmentGroupId *uuid.UUID `json:"assignment_group_id,omitempty"` + BusinessServiceId *uuid.UUID `json:"business_service_id,omitempty"` + FieldsMapping map[string]string `json:"fields_mapping,omitempty"` + HandleName *string `json:"handle_name"` + InstanceId *uuid.UUID `json:"instance_id"` + ServicenowTablename *string `json:"servicenow_tablename"` + UserId *uuid.UUID `json:"user_id,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.HandleName == nil { + return fmt.Errorf("required field handle_name missing") + } + if all.InstanceId == nil { + return fmt.Errorf("required field instance_id missing") + } + if all.ServicenowTablename == nil { + return fmt.Errorf("required field servicenow_tablename missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"assignment_group_id", "business_service_id", "fields_mapping", "handle_name", "instance_id", "servicenow_tablename", "user_id"}) + } else { + return err + } + o.AssignmentGroupId = all.AssignmentGroupId + o.BusinessServiceId = all.BusinessServiceId + o.FieldsMapping = all.FieldsMapping + o.HandleName = *all.HandleName + o.InstanceId = *all.InstanceId + o.ServicenowTablename = *all.ServicenowTablename + o.UserId = all.UserId + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_service_now_template_create_request_data.go b/api/datadogV2/model_service_now_template_create_request_data.go new file mode 100644 index 00000000000..cdbfefb8068 --- /dev/null +++ b/api/datadogV2/model_service_now_template_create_request_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" +) + +// ServiceNowTemplateCreateRequestData Data object for creating a ServiceNow template +type ServiceNowTemplateCreateRequestData struct { + // Attributes for creating a ServiceNow template + Attributes ServiceNowTemplateCreateRequestAttributes `json:"attributes"` + // Type identifier for ServiceNow template resources + Type ServiceNowTemplateType `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:"-"` +} + +// NewServiceNowTemplateCreateRequestData instantiates a new ServiceNowTemplateCreateRequestData 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 NewServiceNowTemplateCreateRequestData(attributes ServiceNowTemplateCreateRequestAttributes, typeVar ServiceNowTemplateType) *ServiceNowTemplateCreateRequestData { + this := ServiceNowTemplateCreateRequestData{} + this.Attributes = attributes + this.Type = typeVar + return &this +} + +// NewServiceNowTemplateCreateRequestDataWithDefaults instantiates a new ServiceNowTemplateCreateRequestData 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 NewServiceNowTemplateCreateRequestDataWithDefaults() *ServiceNowTemplateCreateRequestData { + this := ServiceNowTemplateCreateRequestData{} + return &this +} + +// GetAttributes returns the Attributes field value. +func (o *ServiceNowTemplateCreateRequestData) GetAttributes() ServiceNowTemplateCreateRequestAttributes { + if o == nil { + var ret ServiceNowTemplateCreateRequestAttributes + 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 *ServiceNowTemplateCreateRequestData) GetAttributesOk() (*ServiceNowTemplateCreateRequestAttributes, bool) { + if o == nil { + return nil, false + } + return &o.Attributes, true +} + +// SetAttributes sets field value. +func (o *ServiceNowTemplateCreateRequestData) SetAttributes(v ServiceNowTemplateCreateRequestAttributes) { + o.Attributes = v +} + +// GetType returns the Type field value. +func (o *ServiceNowTemplateCreateRequestData) GetType() ServiceNowTemplateType { + if o == nil { + var ret ServiceNowTemplateType + 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 *ServiceNowTemplateCreateRequestData) GetTypeOk() (*ServiceNowTemplateType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *ServiceNowTemplateCreateRequestData) SetType(v ServiceNowTemplateType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ServiceNowTemplateCreateRequestData) 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 *ServiceNowTemplateCreateRequestData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *ServiceNowTemplateCreateRequestAttributes `json:"attributes"` + Type *ServiceNowTemplateType `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.Unmarshal(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_service_now_template_data.go b/api/datadogV2/model_service_now_template_data.go new file mode 100644 index 00000000000..1fb369760ea --- /dev/null +++ b/api/datadogV2/model_service_now_template_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" +) + +// ServiceNowTemplateData Data object for a ServiceNow template +type ServiceNowTemplateData struct { + // Attributes of a ServiceNow template + Attributes ServiceNowTemplateAttributes `json:"attributes"` + // Unique identifier for the ServiceNow template + Id uuid.UUID `json:"id"` + // Type identifier for ServiceNow template resources + Type ServiceNowTemplateType `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:"-"` +} + +// NewServiceNowTemplateData instantiates a new ServiceNowTemplateData 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 NewServiceNowTemplateData(attributes ServiceNowTemplateAttributes, id uuid.UUID, typeVar ServiceNowTemplateType) *ServiceNowTemplateData { + this := ServiceNowTemplateData{} + this.Attributes = attributes + this.Id = id + this.Type = typeVar + return &this +} + +// NewServiceNowTemplateDataWithDefaults instantiates a new ServiceNowTemplateData 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 NewServiceNowTemplateDataWithDefaults() *ServiceNowTemplateData { + this := ServiceNowTemplateData{} + return &this +} + +// GetAttributes returns the Attributes field value. +func (o *ServiceNowTemplateData) GetAttributes() ServiceNowTemplateAttributes { + if o == nil { + var ret ServiceNowTemplateAttributes + 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 *ServiceNowTemplateData) GetAttributesOk() (*ServiceNowTemplateAttributes, bool) { + if o == nil { + return nil, false + } + return &o.Attributes, true +} + +// SetAttributes sets field value. +func (o *ServiceNowTemplateData) SetAttributes(v ServiceNowTemplateAttributes) { + o.Attributes = v +} + +// GetId returns the Id field value. +func (o *ServiceNowTemplateData) 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 *ServiceNowTemplateData) GetIdOk() (*uuid.UUID, bool) { + if o == nil { + return nil, false + } + return &o.Id, true +} + +// SetId sets field value. +func (o *ServiceNowTemplateData) SetId(v uuid.UUID) { + o.Id = v +} + +// GetType returns the Type field value. +func (o *ServiceNowTemplateData) GetType() ServiceNowTemplateType { + if o == nil { + var ret ServiceNowTemplateType + 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 *ServiceNowTemplateData) GetTypeOk() (*ServiceNowTemplateType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *ServiceNowTemplateData) SetType(v ServiceNowTemplateType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ServiceNowTemplateData) 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 *ServiceNowTemplateData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *ServiceNowTemplateAttributes `json:"attributes"` + Id *uuid.UUID `json:"id"` + Type *ServiceNowTemplateType `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.Unmarshal(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_service_now_template_response.go b/api/datadogV2/model_service_now_template_response.go new file mode 100644 index 00000000000..b3d00969c9c --- /dev/null +++ b/api/datadogV2/model_service_now_template_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" +) + +// ServiceNowTemplateResponse Response containing a single ServiceNow template +type ServiceNowTemplateResponse struct { + // Data object for a ServiceNow template + Data ServiceNowTemplateData `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:"-"` +} + +// NewServiceNowTemplateResponse instantiates a new ServiceNowTemplateResponse 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 NewServiceNowTemplateResponse(data ServiceNowTemplateData) *ServiceNowTemplateResponse { + this := ServiceNowTemplateResponse{} + this.Data = data + return &this +} + +// NewServiceNowTemplateResponseWithDefaults instantiates a new ServiceNowTemplateResponse 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 NewServiceNowTemplateResponseWithDefaults() *ServiceNowTemplateResponse { + this := ServiceNowTemplateResponse{} + return &this +} + +// GetData returns the Data field value. +func (o *ServiceNowTemplateResponse) GetData() ServiceNowTemplateData { + if o == nil { + var ret ServiceNowTemplateData + 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 *ServiceNowTemplateResponse) GetDataOk() (*ServiceNowTemplateData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *ServiceNowTemplateResponse) SetData(v ServiceNowTemplateData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ServiceNowTemplateResponse) 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 *ServiceNowTemplateResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *ServiceNowTemplateData `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.Unmarshal(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_service_now_template_type.go b/api/datadogV2/model_service_now_template_type.go new file mode 100644 index 00000000000..ac1c0703c88 --- /dev/null +++ b/api/datadogV2/model_service_now_template_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" +) + +// ServiceNowTemplateType Type identifier for ServiceNow template resources +type ServiceNowTemplateType string + +// List of ServiceNowTemplateType. +const ( + SERVICENOWTEMPLATETYPE_SERVICENOW_TEMPLATES ServiceNowTemplateType = "servicenow_templates" +) + +var allowedServiceNowTemplateTypeEnumValues = []ServiceNowTemplateType{ + SERVICENOWTEMPLATETYPE_SERVICENOW_TEMPLATES, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *ServiceNowTemplateType) GetAllowedValues() []ServiceNowTemplateType { + return allowedServiceNowTemplateTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *ServiceNowTemplateType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = ServiceNowTemplateType(value) + return nil +} + +// NewServiceNowTemplateTypeFromValue returns a pointer to a valid ServiceNowTemplateType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewServiceNowTemplateTypeFromValue(v string) (*ServiceNowTemplateType, error) { + ev := ServiceNowTemplateType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for ServiceNowTemplateType: valid values are %v", v, allowedServiceNowTemplateTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v ServiceNowTemplateType) IsValid() bool { + for _, existing := range allowedServiceNowTemplateTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to ServiceNowTemplateType value. +func (v ServiceNowTemplateType) Ptr() *ServiceNowTemplateType { + return &v +} diff --git a/api/datadogV2/model_service_now_template_update_request.go b/api/datadogV2/model_service_now_template_update_request.go new file mode 100644 index 00000000000..61157b8589c --- /dev/null +++ b/api/datadogV2/model_service_now_template_update_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" +) + +// ServiceNowTemplateUpdateRequest Request to update a ServiceNow template +type ServiceNowTemplateUpdateRequest struct { + // Data object for updating a ServiceNow template + Data ServiceNowTemplateUpdateRequestData `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:"-"` +} + +// NewServiceNowTemplateUpdateRequest instantiates a new ServiceNowTemplateUpdateRequest 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 NewServiceNowTemplateUpdateRequest(data ServiceNowTemplateUpdateRequestData) *ServiceNowTemplateUpdateRequest { + this := ServiceNowTemplateUpdateRequest{} + this.Data = data + return &this +} + +// NewServiceNowTemplateUpdateRequestWithDefaults instantiates a new ServiceNowTemplateUpdateRequest 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 NewServiceNowTemplateUpdateRequestWithDefaults() *ServiceNowTemplateUpdateRequest { + this := ServiceNowTemplateUpdateRequest{} + return &this +} + +// GetData returns the Data field value. +func (o *ServiceNowTemplateUpdateRequest) GetData() ServiceNowTemplateUpdateRequestData { + if o == nil { + var ret ServiceNowTemplateUpdateRequestData + 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 *ServiceNowTemplateUpdateRequest) GetDataOk() (*ServiceNowTemplateUpdateRequestData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *ServiceNowTemplateUpdateRequest) SetData(v ServiceNowTemplateUpdateRequestData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ServiceNowTemplateUpdateRequest) 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 *ServiceNowTemplateUpdateRequest) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *ServiceNowTemplateUpdateRequestData `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.Unmarshal(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_service_now_template_update_request_attributes.go b/api/datadogV2/model_service_now_template_update_request_attributes.go new file mode 100644 index 00000000000..392f62f0fb0 --- /dev/null +++ b/api/datadogV2/model_service_now_template_update_request_attributes.go @@ -0,0 +1,307 @@ +// 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" +) + +// ServiceNowTemplateUpdateRequestAttributes Attributes for updating a ServiceNow template +type ServiceNowTemplateUpdateRequestAttributes struct { + // The ID of the assignment group + AssignmentGroupId *uuid.UUID `json:"assignment_group_id,omitempty"` + // The ID of the business service + BusinessServiceId *uuid.UUID `json:"business_service_id,omitempty"` + // Custom field mappings for the template + FieldsMapping map[string]string `json:"fields_mapping,omitempty"` + // The handle name of the template + HandleName string `json:"handle_name"` + // The ID of the ServiceNow instance + InstanceId uuid.UUID `json:"instance_id"` + // The name of the destination ServiceNow table + ServicenowTablename string `json:"servicenow_tablename"` + // The ID of the user + UserId *uuid.UUID `json:"user_id,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:"-"` +} + +// NewServiceNowTemplateUpdateRequestAttributes instantiates a new ServiceNowTemplateUpdateRequestAttributes 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 NewServiceNowTemplateUpdateRequestAttributes(handleName string, instanceId uuid.UUID, servicenowTablename string) *ServiceNowTemplateUpdateRequestAttributes { + this := ServiceNowTemplateUpdateRequestAttributes{} + this.HandleName = handleName + this.InstanceId = instanceId + this.ServicenowTablename = servicenowTablename + return &this +} + +// NewServiceNowTemplateUpdateRequestAttributesWithDefaults instantiates a new ServiceNowTemplateUpdateRequestAttributes 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 NewServiceNowTemplateUpdateRequestAttributesWithDefaults() *ServiceNowTemplateUpdateRequestAttributes { + this := ServiceNowTemplateUpdateRequestAttributes{} + return &this +} + +// GetAssignmentGroupId returns the AssignmentGroupId field value if set, zero value otherwise. +func (o *ServiceNowTemplateUpdateRequestAttributes) GetAssignmentGroupId() uuid.UUID { + if o == nil || o.AssignmentGroupId == nil { + var ret uuid.UUID + return ret + } + return *o.AssignmentGroupId +} + +// GetAssignmentGroupIdOk returns a tuple with the AssignmentGroupId field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ServiceNowTemplateUpdateRequestAttributes) GetAssignmentGroupIdOk() (*uuid.UUID, bool) { + if o == nil || o.AssignmentGroupId == nil { + return nil, false + } + return o.AssignmentGroupId, true +} + +// HasAssignmentGroupId returns a boolean if a field has been set. +func (o *ServiceNowTemplateUpdateRequestAttributes) HasAssignmentGroupId() bool { + return o != nil && o.AssignmentGroupId != nil +} + +// SetAssignmentGroupId gets a reference to the given uuid.UUID and assigns it to the AssignmentGroupId field. +func (o *ServiceNowTemplateUpdateRequestAttributes) SetAssignmentGroupId(v uuid.UUID) { + o.AssignmentGroupId = &v +} + +// GetBusinessServiceId returns the BusinessServiceId field value if set, zero value otherwise. +func (o *ServiceNowTemplateUpdateRequestAttributes) GetBusinessServiceId() uuid.UUID { + if o == nil || o.BusinessServiceId == nil { + var ret uuid.UUID + return ret + } + return *o.BusinessServiceId +} + +// GetBusinessServiceIdOk returns a tuple with the BusinessServiceId field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ServiceNowTemplateUpdateRequestAttributes) GetBusinessServiceIdOk() (*uuid.UUID, bool) { + if o == nil || o.BusinessServiceId == nil { + return nil, false + } + return o.BusinessServiceId, true +} + +// HasBusinessServiceId returns a boolean if a field has been set. +func (o *ServiceNowTemplateUpdateRequestAttributes) HasBusinessServiceId() bool { + return o != nil && o.BusinessServiceId != nil +} + +// SetBusinessServiceId gets a reference to the given uuid.UUID and assigns it to the BusinessServiceId field. +func (o *ServiceNowTemplateUpdateRequestAttributes) SetBusinessServiceId(v uuid.UUID) { + o.BusinessServiceId = &v +} + +// GetFieldsMapping returns the FieldsMapping field value if set, zero value otherwise. +func (o *ServiceNowTemplateUpdateRequestAttributes) GetFieldsMapping() map[string]string { + if o == nil || o.FieldsMapping == nil { + var ret map[string]string + return ret + } + return o.FieldsMapping +} + +// GetFieldsMappingOk returns a tuple with the FieldsMapping field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ServiceNowTemplateUpdateRequestAttributes) GetFieldsMappingOk() (*map[string]string, bool) { + if o == nil || o.FieldsMapping == nil { + return nil, false + } + return &o.FieldsMapping, true +} + +// HasFieldsMapping returns a boolean if a field has been set. +func (o *ServiceNowTemplateUpdateRequestAttributes) HasFieldsMapping() bool { + return o != nil && o.FieldsMapping != nil +} + +// SetFieldsMapping gets a reference to the given map[string]string and assigns it to the FieldsMapping field. +func (o *ServiceNowTemplateUpdateRequestAttributes) SetFieldsMapping(v map[string]string) { + o.FieldsMapping = v +} + +// GetHandleName returns the HandleName field value. +func (o *ServiceNowTemplateUpdateRequestAttributes) GetHandleName() string { + if o == nil { + var ret string + return ret + } + return o.HandleName +} + +// GetHandleNameOk returns a tuple with the HandleName field value +// and a boolean to check if the value has been set. +func (o *ServiceNowTemplateUpdateRequestAttributes) GetHandleNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.HandleName, true +} + +// SetHandleName sets field value. +func (o *ServiceNowTemplateUpdateRequestAttributes) SetHandleName(v string) { + o.HandleName = v +} + +// GetInstanceId returns the InstanceId field value. +func (o *ServiceNowTemplateUpdateRequestAttributes) GetInstanceId() uuid.UUID { + if o == nil { + var ret uuid.UUID + return ret + } + return o.InstanceId +} + +// GetInstanceIdOk returns a tuple with the InstanceId field value +// and a boolean to check if the value has been set. +func (o *ServiceNowTemplateUpdateRequestAttributes) GetInstanceIdOk() (*uuid.UUID, bool) { + if o == nil { + return nil, false + } + return &o.InstanceId, true +} + +// SetInstanceId sets field value. +func (o *ServiceNowTemplateUpdateRequestAttributes) SetInstanceId(v uuid.UUID) { + o.InstanceId = v +} + +// GetServicenowTablename returns the ServicenowTablename field value. +func (o *ServiceNowTemplateUpdateRequestAttributes) GetServicenowTablename() string { + if o == nil { + var ret string + return ret + } + return o.ServicenowTablename +} + +// GetServicenowTablenameOk returns a tuple with the ServicenowTablename field value +// and a boolean to check if the value has been set. +func (o *ServiceNowTemplateUpdateRequestAttributes) GetServicenowTablenameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.ServicenowTablename, true +} + +// SetServicenowTablename sets field value. +func (o *ServiceNowTemplateUpdateRequestAttributes) SetServicenowTablename(v string) { + o.ServicenowTablename = v +} + +// GetUserId returns the UserId field value if set, zero value otherwise. +func (o *ServiceNowTemplateUpdateRequestAttributes) GetUserId() uuid.UUID { + if o == nil || o.UserId == nil { + var ret uuid.UUID + return ret + } + return *o.UserId +} + +// GetUserIdOk returns a tuple with the UserId field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ServiceNowTemplateUpdateRequestAttributes) GetUserIdOk() (*uuid.UUID, bool) { + if o == nil || o.UserId == nil { + return nil, false + } + return o.UserId, true +} + +// HasUserId returns a boolean if a field has been set. +func (o *ServiceNowTemplateUpdateRequestAttributes) HasUserId() bool { + return o != nil && o.UserId != nil +} + +// SetUserId gets a reference to the given uuid.UUID and assigns it to the UserId field. +func (o *ServiceNowTemplateUpdateRequestAttributes) SetUserId(v uuid.UUID) { + o.UserId = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ServiceNowTemplateUpdateRequestAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.AssignmentGroupId != nil { + toSerialize["assignment_group_id"] = o.AssignmentGroupId + } + if o.BusinessServiceId != nil { + toSerialize["business_service_id"] = o.BusinessServiceId + } + if o.FieldsMapping != nil { + toSerialize["fields_mapping"] = o.FieldsMapping + } + toSerialize["handle_name"] = o.HandleName + toSerialize["instance_id"] = o.InstanceId + toSerialize["servicenow_tablename"] = o.ServicenowTablename + if o.UserId != nil { + toSerialize["user_id"] = o.UserId + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *ServiceNowTemplateUpdateRequestAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + AssignmentGroupId *uuid.UUID `json:"assignment_group_id,omitempty"` + BusinessServiceId *uuid.UUID `json:"business_service_id,omitempty"` + FieldsMapping map[string]string `json:"fields_mapping,omitempty"` + HandleName *string `json:"handle_name"` + InstanceId *uuid.UUID `json:"instance_id"` + ServicenowTablename *string `json:"servicenow_tablename"` + UserId *uuid.UUID `json:"user_id,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.HandleName == nil { + return fmt.Errorf("required field handle_name missing") + } + if all.InstanceId == nil { + return fmt.Errorf("required field instance_id missing") + } + if all.ServicenowTablename == nil { + return fmt.Errorf("required field servicenow_tablename missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"assignment_group_id", "business_service_id", "fields_mapping", "handle_name", "instance_id", "servicenow_tablename", "user_id"}) + } else { + return err + } + o.AssignmentGroupId = all.AssignmentGroupId + o.BusinessServiceId = all.BusinessServiceId + o.FieldsMapping = all.FieldsMapping + o.HandleName = *all.HandleName + o.InstanceId = *all.InstanceId + o.ServicenowTablename = *all.ServicenowTablename + o.UserId = all.UserId + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_service_now_template_update_request_data.go b/api/datadogV2/model_service_now_template_update_request_data.go new file mode 100644 index 00000000000..154c49cfdcb --- /dev/null +++ b/api/datadogV2/model_service_now_template_update_request_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" +) + +// ServiceNowTemplateUpdateRequestData Data object for updating a ServiceNow template +type ServiceNowTemplateUpdateRequestData struct { + // Attributes for updating a ServiceNow template + Attributes ServiceNowTemplateUpdateRequestAttributes `json:"attributes"` + // Type identifier for ServiceNow template resources + Type ServiceNowTemplateType `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:"-"` +} + +// NewServiceNowTemplateUpdateRequestData instantiates a new ServiceNowTemplateUpdateRequestData 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 NewServiceNowTemplateUpdateRequestData(attributes ServiceNowTemplateUpdateRequestAttributes, typeVar ServiceNowTemplateType) *ServiceNowTemplateUpdateRequestData { + this := ServiceNowTemplateUpdateRequestData{} + this.Attributes = attributes + this.Type = typeVar + return &this +} + +// NewServiceNowTemplateUpdateRequestDataWithDefaults instantiates a new ServiceNowTemplateUpdateRequestData 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 NewServiceNowTemplateUpdateRequestDataWithDefaults() *ServiceNowTemplateUpdateRequestData { + this := ServiceNowTemplateUpdateRequestData{} + return &this +} + +// GetAttributes returns the Attributes field value. +func (o *ServiceNowTemplateUpdateRequestData) GetAttributes() ServiceNowTemplateUpdateRequestAttributes { + if o == nil { + var ret ServiceNowTemplateUpdateRequestAttributes + 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 *ServiceNowTemplateUpdateRequestData) GetAttributesOk() (*ServiceNowTemplateUpdateRequestAttributes, bool) { + if o == nil { + return nil, false + } + return &o.Attributes, true +} + +// SetAttributes sets field value. +func (o *ServiceNowTemplateUpdateRequestData) SetAttributes(v ServiceNowTemplateUpdateRequestAttributes) { + o.Attributes = v +} + +// GetType returns the Type field value. +func (o *ServiceNowTemplateUpdateRequestData) GetType() ServiceNowTemplateType { + if o == nil { + var ret ServiceNowTemplateType + 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 *ServiceNowTemplateUpdateRequestData) GetTypeOk() (*ServiceNowTemplateType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *ServiceNowTemplateUpdateRequestData) SetType(v ServiceNowTemplateType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ServiceNowTemplateUpdateRequestData) 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 *ServiceNowTemplateUpdateRequestData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *ServiceNowTemplateUpdateRequestAttributes `json:"attributes"` + Type *ServiceNowTemplateType `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.Unmarshal(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_service_now_templates_response.go b/api/datadogV2/model_service_now_templates_response.go new file mode 100644 index 00000000000..32da4fbe3ae --- /dev/null +++ b/api/datadogV2/model_service_now_templates_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" +) + +// ServiceNowTemplatesResponse Response containing ServiceNow templates +type ServiceNowTemplatesResponse struct { + // Array of ServiceNow template data objects + Data []ServiceNowTemplateData `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:"-"` +} + +// NewServiceNowTemplatesResponse instantiates a new ServiceNowTemplatesResponse 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 NewServiceNowTemplatesResponse(data []ServiceNowTemplateData) *ServiceNowTemplatesResponse { + this := ServiceNowTemplatesResponse{} + this.Data = data + return &this +} + +// NewServiceNowTemplatesResponseWithDefaults instantiates a new ServiceNowTemplatesResponse 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 NewServiceNowTemplatesResponseWithDefaults() *ServiceNowTemplatesResponse { + this := ServiceNowTemplatesResponse{} + return &this +} + +// GetData returns the Data field value. +func (o *ServiceNowTemplatesResponse) GetData() []ServiceNowTemplateData { + if o == nil { + var ret []ServiceNowTemplateData + 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 *ServiceNowTemplatesResponse) GetDataOk() (*[]ServiceNowTemplateData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *ServiceNowTemplatesResponse) SetData(v []ServiceNowTemplateData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ServiceNowTemplatesResponse) 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 *ServiceNowTemplatesResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *[]ServiceNowTemplateData `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.Unmarshal(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/api/datadogV2/model_service_now_user_attributes.go b/api/datadogV2/model_service_now_user_attributes.go new file mode 100644 index 00000000000..d0ed12eb8ca --- /dev/null +++ b/api/datadogV2/model_service_now_user_attributes.go @@ -0,0 +1,234 @@ +// 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" +) + +// ServiceNowUserAttributes Attributes of a ServiceNow user +type ServiceNowUserAttributes struct { + // The email address of the user + Email string `json:"email"` + // The full name of the user + FullName *string `json:"full_name,omitempty"` + // The ID of the ServiceNow instance + InstanceId uuid.UUID `json:"instance_id"` + // The username of the ServiceNow user + UserName string `json:"user_name"` + // The system ID of the user in ServiceNow + UserSysId string `json:"user_sys_id"` + // 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:"-"` +} + +// NewServiceNowUserAttributes instantiates a new ServiceNowUserAttributes 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 NewServiceNowUserAttributes(email string, instanceId uuid.UUID, userName string, userSysId string) *ServiceNowUserAttributes { + this := ServiceNowUserAttributes{} + this.Email = email + this.InstanceId = instanceId + this.UserName = userName + this.UserSysId = userSysId + return &this +} + +// NewServiceNowUserAttributesWithDefaults instantiates a new ServiceNowUserAttributes 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 NewServiceNowUserAttributesWithDefaults() *ServiceNowUserAttributes { + this := ServiceNowUserAttributes{} + return &this +} + +// GetEmail returns the Email field value. +func (o *ServiceNowUserAttributes) GetEmail() string { + if o == nil { + var ret string + return ret + } + return o.Email +} + +// GetEmailOk returns a tuple with the Email field value +// and a boolean to check if the value has been set. +func (o *ServiceNowUserAttributes) GetEmailOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Email, true +} + +// SetEmail sets field value. +func (o *ServiceNowUserAttributes) SetEmail(v string) { + o.Email = v +} + +// GetFullName returns the FullName field value if set, zero value otherwise. +func (o *ServiceNowUserAttributes) GetFullName() string { + if o == nil || o.FullName == nil { + var ret string + return ret + } + return *o.FullName +} + +// GetFullNameOk returns a tuple with the FullName field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ServiceNowUserAttributes) GetFullNameOk() (*string, bool) { + if o == nil || o.FullName == nil { + return nil, false + } + return o.FullName, true +} + +// HasFullName returns a boolean if a field has been set. +func (o *ServiceNowUserAttributes) HasFullName() bool { + return o != nil && o.FullName != nil +} + +// SetFullName gets a reference to the given string and assigns it to the FullName field. +func (o *ServiceNowUserAttributes) SetFullName(v string) { + o.FullName = &v +} + +// GetInstanceId returns the InstanceId field value. +func (o *ServiceNowUserAttributes) GetInstanceId() uuid.UUID { + if o == nil { + var ret uuid.UUID + return ret + } + return o.InstanceId +} + +// GetInstanceIdOk returns a tuple with the InstanceId field value +// and a boolean to check if the value has been set. +func (o *ServiceNowUserAttributes) GetInstanceIdOk() (*uuid.UUID, bool) { + if o == nil { + return nil, false + } + return &o.InstanceId, true +} + +// SetInstanceId sets field value. +func (o *ServiceNowUserAttributes) SetInstanceId(v uuid.UUID) { + o.InstanceId = v +} + +// GetUserName returns the UserName field value. +func (o *ServiceNowUserAttributes) GetUserName() string { + if o == nil { + var ret string + return ret + } + return o.UserName +} + +// GetUserNameOk returns a tuple with the UserName field value +// and a boolean to check if the value has been set. +func (o *ServiceNowUserAttributes) GetUserNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.UserName, true +} + +// SetUserName sets field value. +func (o *ServiceNowUserAttributes) SetUserName(v string) { + o.UserName = v +} + +// GetUserSysId returns the UserSysId field value. +func (o *ServiceNowUserAttributes) GetUserSysId() string { + if o == nil { + var ret string + return ret + } + return o.UserSysId +} + +// GetUserSysIdOk returns a tuple with the UserSysId field value +// and a boolean to check if the value has been set. +func (o *ServiceNowUserAttributes) GetUserSysIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.UserSysId, true +} + +// SetUserSysId sets field value. +func (o *ServiceNowUserAttributes) SetUserSysId(v string) { + o.UserSysId = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ServiceNowUserAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["email"] = o.Email + if o.FullName != nil { + toSerialize["full_name"] = o.FullName + } + toSerialize["instance_id"] = o.InstanceId + toSerialize["user_name"] = o.UserName + toSerialize["user_sys_id"] = o.UserSysId + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *ServiceNowUserAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Email *string `json:"email"` + FullName *string `json:"full_name,omitempty"` + InstanceId *uuid.UUID `json:"instance_id"` + UserName *string `json:"user_name"` + UserSysId *string `json:"user_sys_id"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Email == nil { + return fmt.Errorf("required field email missing") + } + if all.InstanceId == nil { + return fmt.Errorf("required field instance_id missing") + } + if all.UserName == nil { + return fmt.Errorf("required field user_name missing") + } + if all.UserSysId == nil { + return fmt.Errorf("required field user_sys_id missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"email", "full_name", "instance_id", "user_name", "user_sys_id"}) + } else { + return err + } + o.Email = *all.Email + o.FullName = all.FullName + o.InstanceId = *all.InstanceId + o.UserName = *all.UserName + o.UserSysId = *all.UserSysId + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_service_now_user_data.go b/api/datadogV2/model_service_now_user_data.go new file mode 100644 index 00000000000..3b6a5476082 --- /dev/null +++ b/api/datadogV2/model_service_now_user_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" +) + +// ServiceNowUserData Data object for a ServiceNow user +type ServiceNowUserData struct { + // Attributes of a ServiceNow user + Attributes ServiceNowUserAttributes `json:"attributes"` + // Unique identifier for the ServiceNow user + Id uuid.UUID `json:"id"` + // Type identifier for ServiceNow user resources + Type ServiceNowUserType `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:"-"` +} + +// NewServiceNowUserData instantiates a new ServiceNowUserData 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 NewServiceNowUserData(attributes ServiceNowUserAttributes, id uuid.UUID, typeVar ServiceNowUserType) *ServiceNowUserData { + this := ServiceNowUserData{} + this.Attributes = attributes + this.Id = id + this.Type = typeVar + return &this +} + +// NewServiceNowUserDataWithDefaults instantiates a new ServiceNowUserData 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 NewServiceNowUserDataWithDefaults() *ServiceNowUserData { + this := ServiceNowUserData{} + return &this +} + +// GetAttributes returns the Attributes field value. +func (o *ServiceNowUserData) GetAttributes() ServiceNowUserAttributes { + if o == nil { + var ret ServiceNowUserAttributes + 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 *ServiceNowUserData) GetAttributesOk() (*ServiceNowUserAttributes, bool) { + if o == nil { + return nil, false + } + return &o.Attributes, true +} + +// SetAttributes sets field value. +func (o *ServiceNowUserData) SetAttributes(v ServiceNowUserAttributes) { + o.Attributes = v +} + +// GetId returns the Id field value. +func (o *ServiceNowUserData) 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 *ServiceNowUserData) GetIdOk() (*uuid.UUID, bool) { + if o == nil { + return nil, false + } + return &o.Id, true +} + +// SetId sets field value. +func (o *ServiceNowUserData) SetId(v uuid.UUID) { + o.Id = v +} + +// GetType returns the Type field value. +func (o *ServiceNowUserData) GetType() ServiceNowUserType { + if o == nil { + var ret ServiceNowUserType + 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 *ServiceNowUserData) GetTypeOk() (*ServiceNowUserType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *ServiceNowUserData) SetType(v ServiceNowUserType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ServiceNowUserData) 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 *ServiceNowUserData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *ServiceNowUserAttributes `json:"attributes"` + Id *uuid.UUID `json:"id"` + Type *ServiceNowUserType `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.Unmarshal(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_service_now_user_type.go b/api/datadogV2/model_service_now_user_type.go new file mode 100644 index 00000000000..69647afcecf --- /dev/null +++ b/api/datadogV2/model_service_now_user_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" +) + +// ServiceNowUserType Type identifier for ServiceNow user resources +type ServiceNowUserType string + +// List of ServiceNowUserType. +const ( + SERVICENOWUSERTYPE_USERS ServiceNowUserType = "users" +) + +var allowedServiceNowUserTypeEnumValues = []ServiceNowUserType{ + SERVICENOWUSERTYPE_USERS, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *ServiceNowUserType) GetAllowedValues() []ServiceNowUserType { + return allowedServiceNowUserTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *ServiceNowUserType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = ServiceNowUserType(value) + return nil +} + +// NewServiceNowUserTypeFromValue returns a pointer to a valid ServiceNowUserType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewServiceNowUserTypeFromValue(v string) (*ServiceNowUserType, error) { + ev := ServiceNowUserType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for ServiceNowUserType: valid values are %v", v, allowedServiceNowUserTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v ServiceNowUserType) IsValid() bool { + for _, existing := range allowedServiceNowUserTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to ServiceNowUserType value. +func (v ServiceNowUserType) Ptr() *ServiceNowUserType { + return &v +} diff --git a/api/datadogV2/model_service_now_users_response.go b/api/datadogV2/model_service_now_users_response.go new file mode 100644 index 00000000000..c83a82f7b38 --- /dev/null +++ b/api/datadogV2/model_service_now_users_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" +) + +// ServiceNowUsersResponse Response containing ServiceNow users +type ServiceNowUsersResponse struct { + // Array of ServiceNow user data objects + Data []ServiceNowUserData `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:"-"` +} + +// NewServiceNowUsersResponse instantiates a new ServiceNowUsersResponse 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 NewServiceNowUsersResponse(data []ServiceNowUserData) *ServiceNowUsersResponse { + this := ServiceNowUsersResponse{} + this.Data = data + return &this +} + +// NewServiceNowUsersResponseWithDefaults instantiates a new ServiceNowUsersResponse 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 NewServiceNowUsersResponseWithDefaults() *ServiceNowUsersResponse { + this := ServiceNowUsersResponse{} + return &this +} + +// GetData returns the Data field value. +func (o *ServiceNowUsersResponse) GetData() []ServiceNowUserData { + if o == nil { + var ret []ServiceNowUserData + 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 *ServiceNowUsersResponse) GetDataOk() (*[]ServiceNowUserData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *ServiceNowUsersResponse) SetData(v []ServiceNowUserData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ServiceNowUsersResponse) 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 *ServiceNowUsersResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *[]ServiceNowUserData `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.Unmarshal(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/servicenow-integration/CreateServiceNowTemplate.go b/examples/v2/servicenow-integration/CreateServiceNowTemplate.go new file mode 100644 index 00000000000..e3e000f7df1 --- /dev/null +++ b/examples/v2/servicenow-integration/CreateServiceNowTemplate.go @@ -0,0 +1,48 @@ +// Create ServiceNow template returns "Created" 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() { + body := datadogV2.ServiceNowTemplateCreateRequest{ + Data: datadogV2.ServiceNowTemplateCreateRequestData{ + Attributes: datadogV2.ServiceNowTemplateCreateRequestAttributes{ + AssignmentGroupId: datadog.PtrUUID(uuid.MustParse("65b3341b-0680-47f9-a6d4-134db45c603e")), + BusinessServiceId: datadog.PtrUUID(uuid.MustParse("65b3341b-0680-47f9-a6d4-134db45c603e")), + FieldsMapping: map[string]string{ + "category": "software", + "priority": "1", + }, + HandleName: "incident-template", + InstanceId: uuid.MustParse("65b3341b-0680-47f9-a6d4-134db45c603e"), + ServicenowTablename: "incident", + UserId: datadog.PtrUUID(uuid.MustParse("65b3341b-0680-47f9-a6d4-134db45c603e")), + }, + Type: datadogV2.SERVICENOWTEMPLATETYPE_SERVICENOW_TEMPLATES, + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + configuration.SetUnstableOperationEnabled("v2.CreateServiceNowTemplate", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewServiceNowIntegrationApi(apiClient) + resp, r, err := api.CreateServiceNowTemplate(ctx, body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `ServiceNowIntegrationApi.CreateServiceNowTemplate`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `ServiceNowIntegrationApi.CreateServiceNowTemplate`:\n%s\n", responseContent) +} diff --git a/examples/v2/servicenow-integration/DeleteServiceNowTemplate.go b/examples/v2/servicenow-integration/DeleteServiceNowTemplate.go new file mode 100644 index 00000000000..cb3b2be2740 --- /dev/null +++ b/examples/v2/servicenow-integration/DeleteServiceNowTemplate.go @@ -0,0 +1,27 @@ +// Delete ServiceNow template returns "OK" response + +package main + +import ( + "context" + "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() { + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + configuration.SetUnstableOperationEnabled("v2.DeleteServiceNowTemplate", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewServiceNowIntegrationApi(apiClient) + r, err := api.DeleteServiceNowTemplate(ctx, uuid.MustParse("9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d")) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `ServiceNowIntegrationApi.DeleteServiceNowTemplate`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } +} diff --git a/examples/v2/servicenow-integration/GetServiceNowTemplate.go b/examples/v2/servicenow-integration/GetServiceNowTemplate.go new file mode 100644 index 00000000000..4a95ceb53f8 --- /dev/null +++ b/examples/v2/servicenow-integration/GetServiceNowTemplate.go @@ -0,0 +1,31 @@ +// Get ServiceNow template 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() { + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + configuration.SetUnstableOperationEnabled("v2.GetServiceNowTemplate", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewServiceNowIntegrationApi(apiClient) + resp, r, err := api.GetServiceNowTemplate(ctx, uuid.MustParse("9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d")) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `ServiceNowIntegrationApi.GetServiceNowTemplate`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `ServiceNowIntegrationApi.GetServiceNowTemplate`:\n%s\n", responseContent) +} diff --git a/examples/v2/servicenow-integration/ListServiceNowAssignmentGroups.go b/examples/v2/servicenow-integration/ListServiceNowAssignmentGroups.go new file mode 100644 index 00000000000..ac829f1a4f6 --- /dev/null +++ b/examples/v2/servicenow-integration/ListServiceNowAssignmentGroups.go @@ -0,0 +1,31 @@ +// List ServiceNow assignment groups 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() { + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + configuration.SetUnstableOperationEnabled("v2.ListServiceNowAssignmentGroups", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewServiceNowIntegrationApi(apiClient) + resp, r, err := api.ListServiceNowAssignmentGroups(ctx, uuid.MustParse("9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d")) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `ServiceNowIntegrationApi.ListServiceNowAssignmentGroups`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `ServiceNowIntegrationApi.ListServiceNowAssignmentGroups`:\n%s\n", responseContent) +} diff --git a/examples/v2/servicenow-integration/ListServiceNowBusinessServices.go b/examples/v2/servicenow-integration/ListServiceNowBusinessServices.go new file mode 100644 index 00000000000..77748b1cc2c --- /dev/null +++ b/examples/v2/servicenow-integration/ListServiceNowBusinessServices.go @@ -0,0 +1,31 @@ +// List ServiceNow business services 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() { + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + configuration.SetUnstableOperationEnabled("v2.ListServiceNowBusinessServices", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewServiceNowIntegrationApi(apiClient) + resp, r, err := api.ListServiceNowBusinessServices(ctx, uuid.MustParse("9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d")) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `ServiceNowIntegrationApi.ListServiceNowBusinessServices`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `ServiceNowIntegrationApi.ListServiceNowBusinessServices`:\n%s\n", responseContent) +} diff --git a/examples/v2/servicenow-integration/ListServiceNowInstances.go b/examples/v2/servicenow-integration/ListServiceNowInstances.go new file mode 100644 index 00000000000..8118f6e4af7 --- /dev/null +++ b/examples/v2/servicenow-integration/ListServiceNowInstances.go @@ -0,0 +1,30 @@ +// List ServiceNow instances 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.ListServiceNowInstances", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewServiceNowIntegrationApi(apiClient) + resp, r, err := api.ListServiceNowInstances(ctx) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `ServiceNowIntegrationApi.ListServiceNowInstances`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `ServiceNowIntegrationApi.ListServiceNowInstances`:\n%s\n", responseContent) +} diff --git a/examples/v2/servicenow-integration/ListServiceNowTemplates.go b/examples/v2/servicenow-integration/ListServiceNowTemplates.go new file mode 100644 index 00000000000..1ec60f2f16d --- /dev/null +++ b/examples/v2/servicenow-integration/ListServiceNowTemplates.go @@ -0,0 +1,30 @@ +// List ServiceNow templates 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.ListServiceNowTemplates", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewServiceNowIntegrationApi(apiClient) + resp, r, err := api.ListServiceNowTemplates(ctx) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `ServiceNowIntegrationApi.ListServiceNowTemplates`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `ServiceNowIntegrationApi.ListServiceNowTemplates`:\n%s\n", responseContent) +} diff --git a/examples/v2/servicenow-integration/ListServiceNowUsers.go b/examples/v2/servicenow-integration/ListServiceNowUsers.go new file mode 100644 index 00000000000..1d9a5f3d0f3 --- /dev/null +++ b/examples/v2/servicenow-integration/ListServiceNowUsers.go @@ -0,0 +1,31 @@ +// List ServiceNow users 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() { + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + configuration.SetUnstableOperationEnabled("v2.ListServiceNowUsers", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewServiceNowIntegrationApi(apiClient) + resp, r, err := api.ListServiceNowUsers(ctx, uuid.MustParse("9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d")) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `ServiceNowIntegrationApi.ListServiceNowUsers`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `ServiceNowIntegrationApi.ListServiceNowUsers`:\n%s\n", responseContent) +} diff --git a/examples/v2/servicenow-integration/UpdateServiceNowTemplate.go b/examples/v2/servicenow-integration/UpdateServiceNowTemplate.go new file mode 100644 index 00000000000..47542bd490d --- /dev/null +++ b/examples/v2/servicenow-integration/UpdateServiceNowTemplate.go @@ -0,0 +1,48 @@ +// Update ServiceNow template 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() { + body := datadogV2.ServiceNowTemplateUpdateRequest{ + Data: datadogV2.ServiceNowTemplateUpdateRequestData{ + Attributes: datadogV2.ServiceNowTemplateUpdateRequestAttributes{ + AssignmentGroupId: datadog.PtrUUID(uuid.MustParse("65b3341b-0680-47f9-a6d4-134db45c603e")), + BusinessServiceId: datadog.PtrUUID(uuid.MustParse("65b3341b-0680-47f9-a6d4-134db45c603e")), + FieldsMapping: map[string]string{ + "category": "hardware", + "priority": "2", + }, + HandleName: "incident-template-updated", + InstanceId: uuid.MustParse("65b3341b-0680-47f9-a6d4-134db45c603e"), + ServicenowTablename: "incident", + UserId: datadog.PtrUUID(uuid.MustParse("65b3341b-0680-47f9-a6d4-134db45c603e")), + }, + Type: datadogV2.SERVICENOWTEMPLATETYPE_SERVICENOW_TEMPLATES, + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + configuration.SetUnstableOperationEnabled("v2.UpdateServiceNowTemplate", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewServiceNowIntegrationApi(apiClient) + resp, r, err := api.UpdateServiceNowTemplate(ctx, uuid.MustParse("9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d"), body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `ServiceNowIntegrationApi.UpdateServiceNowTemplate`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `ServiceNowIntegrationApi.UpdateServiceNowTemplate`:\n%s\n", responseContent) +} diff --git a/tests/scenarios/api_mappings.go b/tests/scenarios/api_mappings.go index ff1fdb41238..1b8279d1e04 100644 --- a/tests/scenarios/api_mappings.go +++ b/tests/scenarios/api_mappings.go @@ -86,6 +86,7 @@ var apiMappings = map[string]map[string]reflect.Value{ "JiraIntegrationApi": reflect.ValueOf(datadogV2.NewJiraIntegrationApi), "MicrosoftTeamsIntegrationApi": reflect.ValueOf(datadogV2.NewMicrosoftTeamsIntegrationApi), "OpsgenieIntegrationApi": reflect.ValueOf(datadogV2.NewOpsgenieIntegrationApi), + "ServiceNowIntegrationApi": reflect.ValueOf(datadogV2.NewServiceNowIntegrationApi), "CloudflareIntegrationApi": reflect.ValueOf(datadogV2.NewCloudflareIntegrationApi), "ConfluentCloudApi": reflect.ValueOf(datadogV2.NewConfluentCloudApi), "FastlyIntegrationApi": reflect.ValueOf(datadogV2.NewFastlyIntegrationApi), diff --git a/tests/scenarios/features/v2/servicenow_integration.feature b/tests/scenarios/features/v2/servicenow_integration.feature new file mode 100644 index 00000000000..24f9878c0d8 --- /dev/null +++ b/tests/scenarios/features/v2/servicenow_integration.feature @@ -0,0 +1,194 @@ +@endpoint(servicenow-integration) @endpoint(servicenow-integration-v2) +Feature: ServiceNow Integration + Manage your ServiceNow Integration. ServiceNow is a cloud-based platform + that helps organizations manage digital workflows for enterprise + operations. + + Background: + Given a valid "apiKeyAuth" key in the system + And a valid "appKeyAuth" key in the system + And an instance of "ServiceNowIntegration" API + + @generated @skip @team:Datadog/collaboration-integrations + Scenario: Create ServiceNow template returns "Bad Request" response + Given operation "CreateServiceNowTemplate" enabled + And new "CreateServiceNowTemplate" request + And body with value {"data": {"attributes": {"assignment_group_id": "65b3341b-0680-47f9-a6d4-134db45c603e", "business_service_id": "65b3341b-0680-47f9-a6d4-134db45c603e", "fields_mapping": {"category": "software", "priority": "1"}, "handle_name": "incident-template", "instance_id": "65b3341b-0680-47f9-a6d4-134db45c603e", "servicenow_tablename": "incident", "user_id": "65b3341b-0680-47f9-a6d4-134db45c603e"}, "type": "servicenow_templates"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:Datadog/collaboration-integrations + Scenario: Create ServiceNow template returns "Created" response + Given operation "CreateServiceNowTemplate" enabled + And new "CreateServiceNowTemplate" request + And body with value {"data": {"attributes": {"assignment_group_id": "65b3341b-0680-47f9-a6d4-134db45c603e", "business_service_id": "65b3341b-0680-47f9-a6d4-134db45c603e", "fields_mapping": {"category": "software", "priority": "1"}, "handle_name": "incident-template", "instance_id": "65b3341b-0680-47f9-a6d4-134db45c603e", "servicenow_tablename": "incident", "user_id": "65b3341b-0680-47f9-a6d4-134db45c603e"}, "type": "servicenow_templates"}} + When the request is sent + Then the response status is 201 Created + + @generated @skip @team:Datadog/collaboration-integrations + Scenario: Delete ServiceNow template returns "Bad Request" response + Given operation "DeleteServiceNowTemplate" enabled + And new "DeleteServiceNowTemplate" request + And request contains "template_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:Datadog/collaboration-integrations + Scenario: Delete ServiceNow template returns "Not Found" response + Given operation "DeleteServiceNowTemplate" enabled + And new "DeleteServiceNowTemplate" request + And request contains "template_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:Datadog/collaboration-integrations + Scenario: Delete ServiceNow template returns "OK" response + Given operation "DeleteServiceNowTemplate" enabled + And new "DeleteServiceNowTemplate" request + And request contains "template_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:Datadog/collaboration-integrations + Scenario: Get ServiceNow template returns "Bad Request" response + Given operation "GetServiceNowTemplate" enabled + And new "GetServiceNowTemplate" request + And request contains "template_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:Datadog/collaboration-integrations + Scenario: Get ServiceNow template returns "Not Found" response + Given operation "GetServiceNowTemplate" enabled + And new "GetServiceNowTemplate" request + And request contains "template_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:Datadog/collaboration-integrations + Scenario: Get ServiceNow template returns "OK" response + Given operation "GetServiceNowTemplate" enabled + And new "GetServiceNowTemplate" request + And request contains "template_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:Datadog/collaboration-integrations + Scenario: List ServiceNow assignment groups returns "Bad Request" response + Given operation "ListServiceNowAssignmentGroups" enabled + And new "ListServiceNowAssignmentGroups" request + And request contains "instance_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:Datadog/collaboration-integrations + Scenario: List ServiceNow assignment groups returns "Not Found" response + Given operation "ListServiceNowAssignmentGroups" enabled + And new "ListServiceNowAssignmentGroups" request + And request contains "instance_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:Datadog/collaboration-integrations + Scenario: List ServiceNow assignment groups returns "OK" response + Given operation "ListServiceNowAssignmentGroups" enabled + And new "ListServiceNowAssignmentGroups" request + And request contains "instance_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:Datadog/collaboration-integrations + Scenario: List ServiceNow business services returns "Bad Request" response + Given operation "ListServiceNowBusinessServices" enabled + And new "ListServiceNowBusinessServices" request + And request contains "instance_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:Datadog/collaboration-integrations + Scenario: List ServiceNow business services returns "Not Found" response + Given operation "ListServiceNowBusinessServices" enabled + And new "ListServiceNowBusinessServices" request + And request contains "instance_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:Datadog/collaboration-integrations + Scenario: List ServiceNow business services returns "OK" response + Given operation "ListServiceNowBusinessServices" enabled + And new "ListServiceNowBusinessServices" request + And request contains "instance_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:Datadog/collaboration-integrations + Scenario: List ServiceNow instances returns "Not Found" response + Given operation "ListServiceNowInstances" enabled + And new "ListServiceNowInstances" request + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:Datadog/collaboration-integrations + Scenario: List ServiceNow instances returns "OK" response + Given operation "ListServiceNowInstances" enabled + And new "ListServiceNowInstances" request + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:Datadog/collaboration-integrations + Scenario: List ServiceNow templates returns "OK" response + Given operation "ListServiceNowTemplates" enabled + And new "ListServiceNowTemplates" request + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:Datadog/collaboration-integrations + Scenario: List ServiceNow users returns "Bad Request" response + Given operation "ListServiceNowUsers" enabled + And new "ListServiceNowUsers" request + And request contains "instance_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:Datadog/collaboration-integrations + Scenario: List ServiceNow users returns "Not Found" response + Given operation "ListServiceNowUsers" enabled + And new "ListServiceNowUsers" request + And request contains "instance_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:Datadog/collaboration-integrations + Scenario: List ServiceNow users returns "OK" response + Given operation "ListServiceNowUsers" enabled + And new "ListServiceNowUsers" request + And request contains "instance_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:Datadog/collaboration-integrations + Scenario: Update ServiceNow template returns "Bad Request" response + Given operation "UpdateServiceNowTemplate" enabled + And new "UpdateServiceNowTemplate" request + And request contains "template_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"assignment_group_id": "65b3341b-0680-47f9-a6d4-134db45c603e", "business_service_id": "65b3341b-0680-47f9-a6d4-134db45c603e", "fields_mapping": {"category": "hardware", "priority": "2"}, "handle_name": "incident-template-updated", "instance_id": "65b3341b-0680-47f9-a6d4-134db45c603e", "servicenow_tablename": "incident", "user_id": "65b3341b-0680-47f9-a6d4-134db45c603e"}, "type": "servicenow_templates"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:Datadog/collaboration-integrations + Scenario: Update ServiceNow template returns "Not Found" response + Given operation "UpdateServiceNowTemplate" enabled + And new "UpdateServiceNowTemplate" request + And request contains "template_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"assignment_group_id": "65b3341b-0680-47f9-a6d4-134db45c603e", "business_service_id": "65b3341b-0680-47f9-a6d4-134db45c603e", "fields_mapping": {"category": "hardware", "priority": "2"}, "handle_name": "incident-template-updated", "instance_id": "65b3341b-0680-47f9-a6d4-134db45c603e", "servicenow_tablename": "incident", "user_id": "65b3341b-0680-47f9-a6d4-134db45c603e"}, "type": "servicenow_templates"}} + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:Datadog/collaboration-integrations + Scenario: Update ServiceNow template returns "OK" response + Given operation "UpdateServiceNowTemplate" enabled + And new "UpdateServiceNowTemplate" request + And request contains "template_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"assignment_group_id": "65b3341b-0680-47f9-a6d4-134db45c603e", "business_service_id": "65b3341b-0680-47f9-a6d4-134db45c603e", "fields_mapping": {"category": "hardware", "priority": "2"}, "handle_name": "incident-template-updated", "instance_id": "65b3341b-0680-47f9-a6d4-134db45c603e", "servicenow_tablename": "incident", "user_id": "65b3341b-0680-47f9-a6d4-134db45c603e"}, "type": "servicenow_templates"}} + When the request is sent + Then the response status is 200 OK diff --git a/tests/scenarios/features/v2/undo.json b/tests/scenarios/features/v2/undo.json index b8d90f223ac..5a347bddf11 100644 --- a/tests/scenarios/features/v2/undo.json +++ b/tests/scenarios/features/v2/undo.json @@ -2231,6 +2231,67 @@ "type": "idempotent" } }, + "ListServiceNowAssignmentGroups": { + "tag": "ServiceNow Integration", + "undo": { + "type": "safe" + } + }, + "ListServiceNowBusinessServices": { + "tag": "ServiceNow Integration", + "undo": { + "type": "safe" + } + }, + "ListServiceNowTemplates": { + "tag": "ServiceNow Integration", + "undo": { + "type": "safe" + } + }, + "CreateServiceNowTemplate": { + "tag": "ServiceNow Integration", + "undo": { + "operationId": "DeleteServiceNowTemplate", + "parameters": [ + { + "name": "template_id", + "source": "" + } + ], + "type": "unsafe" + } + }, + "DeleteServiceNowTemplate": { + "tag": "ServiceNow Integration", + "undo": { + "type": "idempotent" + } + }, + "GetServiceNowTemplate": { + "tag": "ServiceNow Integration", + "undo": { + "type": "safe" + } + }, + "UpdateServiceNowTemplate": { + "tag": "ServiceNow Integration", + "undo": { + "type": "idempotent" + } + }, + "ListServiceNowInstances": { + "tag": "ServiceNow Integration", + "undo": { + "type": "safe" + } + }, + "ListServiceNowUsers": { + "tag": "ServiceNow Integration", + "undo": { + "type": "safe" + } + }, "ListCloudflareAccounts": { "tag": "Cloudflare Integration", "undo": {