diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 4331313d34b..39a69b50729 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -23382,6 +23382,8 @@ components: properties: attributes: $ref: "#/components/schemas/CreateBackfilledDegradationRequestDataAttributes" + relationships: + $ref: "#/components/schemas/CreateBackfilledDegradationRequestDataRelationships" type: $ref: "#/components/schemas/PatchDegradationRequestDataType" required: @@ -23425,6 +23427,34 @@ components: - started_at - status type: object + CreateBackfilledDegradationRequestDataRelationships: + description: The supported relationships for creating a backfilled degradation. + properties: + template: + $ref: "#/components/schemas/CreateBackfilledDegradationRequestDataRelationshipsTemplate" + description: The template used to create the backfilled degradation. + type: object + CreateBackfilledDegradationRequestDataRelationshipsTemplate: + description: The template used to create the backfilled degradation. + properties: + data: + $ref: "#/components/schemas/CreateBackfilledDegradationRequestDataRelationshipsTemplateData" + required: + - data + type: object + CreateBackfilledDegradationRequestDataRelationshipsTemplateData: + description: The data object identifying the template used to create the backfilled degradation. + properties: + id: + description: The ID of the degradation template. + example: "" + type: string + type: + $ref: "#/components/schemas/PatchDegradationTemplateRequestDataType" + required: + - type + - id + type: object CreateBackfilledMaintenanceRequest: description: Request object for creating a backfilled maintenance. example: @@ -23454,6 +23484,8 @@ components: properties: attributes: $ref: "#/components/schemas/CreateBackfilledMaintenanceRequestDataAttributes" + relationships: + $ref: "#/components/schemas/CreateBackfilledMaintenanceRequestDataRelationships" type: $ref: "#/components/schemas/PatchMaintenanceRequestDataType" required: @@ -23501,6 +23533,34 @@ components: - started_at - status type: object + CreateBackfilledMaintenanceRequestDataRelationships: + description: The supported relationships for creating a backfilled maintenance. + properties: + template: + $ref: "#/components/schemas/CreateBackfilledMaintenanceRequestDataRelationshipsTemplate" + description: The template used to create the backfilled maintenance. + type: object + CreateBackfilledMaintenanceRequestDataRelationshipsTemplate: + description: The template used to create the backfilled maintenance. + properties: + data: + $ref: "#/components/schemas/CreateBackfilledMaintenanceRequestDataRelationshipsTemplateData" + required: + - data + type: object + CreateBackfilledMaintenanceRequestDataRelationshipsTemplateData: + description: The data object identifying the template used to create the backfilled maintenance. + properties: + id: + description: The ID of the maintenance template. + example: "" + type: string + type: + $ref: "#/components/schemas/PatchMaintenanceTemplateRequestDataType" + required: + - type + - id + type: object CreateCampaignRequest: description: Request to create a new campaign. properties: @@ -23953,6 +24013,8 @@ components: properties: attributes: $ref: "#/components/schemas/CreateDegradationRequestDataAttributes" + relationships: + $ref: "#/components/schemas/CreateDegradationRequestDataRelationships" type: $ref: "#/components/schemas/PatchDegradationRequestDataType" required: @@ -24019,6 +24081,101 @@ components: - IDENTIFIED - MONITORING - RESOLVED + CreateDegradationRequestDataRelationships: + description: The supported relationships for creating a degradation. + properties: + template: + $ref: "#/components/schemas/CreateDegradationRequestDataRelationshipsTemplate" + description: The template used to create the degradation. + type: object + CreateDegradationRequestDataRelationshipsTemplate: + description: The template used to create the degradation. + properties: + data: + $ref: "#/components/schemas/CreateDegradationRequestDataRelationshipsTemplateData" + required: + - data + type: object + CreateDegradationRequestDataRelationshipsTemplateData: + description: The data object identifying the template used to create the degradation. + properties: + id: + description: The ID of the degradation template. + example: "" + type: string + type: + $ref: "#/components/schemas/PatchDegradationTemplateRequestDataType" + required: + - type + - id + type: object + CreateDegradationTemplateRequest: + description: Request object for creating a degradation template. + properties: + data: + $ref: "#/components/schemas/CreateDegradationTemplateRequestData" + type: object + CreateDegradationTemplateRequestData: + description: The data object for creating a degradation template. + properties: + attributes: + $ref: "#/components/schemas/CreateDegradationTemplateRequestDataAttributes" + type: + $ref: "#/components/schemas/PatchDegradationTemplateRequestDataType" + required: + - type + type: object + CreateDegradationTemplateRequestDataAttributes: + description: The attributes for creating a degradation template. + properties: + components_affected: + description: The components affected by a degradation created from this template. + items: + $ref: "#/components/schemas/CreateDegradationTemplateRequestDataAttributesComponentsAffectedItems" + type: array + degradation_title: + description: The title used for a degradation created from this template. + type: string + name: + description: The name of the degradation template. + example: "" + type: string + updates: + description: The pre-filled updates for a degradation created from this template. + items: + $ref: "#/components/schemas/CreateDegradationTemplateRequestDataAttributesUpdatesItems" + type: array + required: + - name + type: object + CreateDegradationTemplateRequestDataAttributesComponentsAffectedItems: + description: A component affected by a degradation created from this template. + properties: + id: + description: The ID of the component. Must be a component of type `component`. + example: "" + type: string + name: + description: The name of the component. + readOnly: true + type: string + status: + $ref: "#/components/schemas/PatchDegradationTemplateRequestDataAttributesComponentsAffectedItemsStatus" + required: + - id + - status + type: object + CreateDegradationTemplateRequestDataAttributesUpdatesItems: + description: A pre-filled update for a degradation created from this template. + properties: + message: + description: The message of the update. + type: string + status: + $ref: "#/components/schemas/CreateDegradationRequestDataAttributesStatus" + required: + - status + type: object CreateDeploymentGateParams: description: Parameters for creating a deployment gate. properties: @@ -24469,6 +24626,8 @@ components: properties: attributes: $ref: "#/components/schemas/CreateMaintenanceRequestDataAttributes" + relationships: + $ref: "#/components/schemas/CreateMaintenanceRequestDataRelationships" type: $ref: "#/components/schemas/PatchMaintenanceRequestDataType" required: @@ -24545,6 +24704,77 @@ components: x-enum-varnames: - IN_PROGRESS - COMPLETED + CreateMaintenanceRequestDataRelationships: + description: The supported relationships for creating a maintenance. + properties: + template: + $ref: "#/components/schemas/CreateMaintenanceRequestDataRelationshipsTemplate" + description: The template used to create the maintenance. + type: object + CreateMaintenanceRequestDataRelationshipsTemplate: + description: The template used to create the maintenance. + properties: + data: + $ref: "#/components/schemas/CreateMaintenanceRequestDataRelationshipsTemplateData" + required: + - data + type: object + CreateMaintenanceRequestDataRelationshipsTemplateData: + description: The data object identifying the template used to create the maintenance. + properties: + id: + description: The ID of the maintenance template. + example: "" + type: string + type: + $ref: "#/components/schemas/PatchMaintenanceTemplateRequestDataType" + required: + - type + - id + type: object + CreateMaintenanceTemplateRequest: + description: Request object for creating a maintenance template. + properties: + data: + $ref: "#/components/schemas/CreateMaintenanceTemplateRequestData" + type: object + CreateMaintenanceTemplateRequestData: + description: The data object for creating a maintenance template. + properties: + attributes: + $ref: "#/components/schemas/CreateMaintenanceTemplateRequestDataAttributes" + type: + $ref: "#/components/schemas/PatchMaintenanceTemplateRequestDataType" + required: + - type + type: object + CreateMaintenanceTemplateRequestDataAttributes: + description: The attributes for creating a maintenance template. + properties: + completed_description: + description: The description shown when a maintenance created from this template is completed. + type: string + component_ids: + description: The IDs of the components affected by a maintenance created from this template. + items: + type: string + type: array + in_progress_description: + description: The description shown while a maintenance created from this template is in progress. + type: string + maintenance_title: + description: The title used for a maintenance created from this template. + type: string + name: + description: The name of the maintenance template. + example: "" + type: string + scheduled_description: + description: The description shown when a maintenance created from this template is scheduled. + type: string + required: + - name + type: object CreateNotificationChannelAttributes: description: Attributes for creating an on-call notification channel. properties: @@ -31495,6 +31725,9 @@ components: status_page: $ref: "#/components/schemas/DegradationDataRelationshipsStatusPage" description: The status page the degradation belongs to. + template: + $ref: "#/components/schemas/DegradationDataRelationshipsTemplate" + description: The template the degradation was created from. type: object DegradationDataRelationshipsCreatedByUser: description: The Datadog user who created the degradation. @@ -31560,11 +31793,206 @@ components: - type - id type: object + DegradationDataRelationshipsTemplate: + description: The template the degradation was created from. + properties: + data: + $ref: "#/components/schemas/DegradationDataRelationshipsTemplateData" + required: + - data + type: object + DegradationDataRelationshipsTemplateData: + description: The data object identifying the template the degradation was created from. + properties: + id: + description: The ID of the degradation template. + example: "" + type: string + type: + $ref: "#/components/schemas/PatchDegradationTemplateRequestDataType" + required: + - type + - id + type: object DegradationIncluded: description: An included resource related to a degradation or maintenance. oneOf: - $ref: "#/components/schemas/StatusPagesUser" - $ref: "#/components/schemas/StatusPageAsIncluded" + DegradationTemplate: + description: Response object for a single degradation template. + properties: + data: + $ref: "#/components/schemas/DegradationTemplateData" + included: + description: The included related resources of a degradation template. Client must explicitly request these resources by name in the `include` query parameter. + items: + $ref: "#/components/schemas/DegradationIncluded" + type: array + type: object + DegradationTemplateArray: + description: Response object for a list of degradation templates. + properties: + data: + description: A list of degradation template data objects. + items: + $ref: "#/components/schemas/DegradationTemplateData" + type: array + included: + description: The included related resources of a degradation template. Client must explicitly request these resources by name in the `include` query parameter. + items: + $ref: "#/components/schemas/DegradationIncluded" + type: array + required: + - data + type: object + DegradationTemplateData: + description: The data object for a degradation template. + properties: + attributes: + $ref: "#/components/schemas/DegradationTemplateDataAttributes" + id: + description: The ID of the degradation template. + type: string + relationships: + $ref: "#/components/schemas/DegradationTemplateDataRelationships" + type: + $ref: "#/components/schemas/PatchDegradationTemplateRequestDataType" + required: + - type + type: object + DegradationTemplateDataAttributes: + description: The attributes of a degradation template. + properties: + components_affected: + description: The components affected by a degradation created from this template. + items: + $ref: "#/components/schemas/DegradationTemplateDataAttributesComponentsAffectedItems" + type: array + created_at: + description: Timestamp of when the degradation template was created. + format: date-time + type: string + degradation_title: + description: The title used for a degradation created from this template. + type: string + modified_at: + description: Timestamp of when the degradation template was last modified. + format: date-time + type: string + name: + description: The name of the degradation template. + type: string + updates: + description: The pre-filled updates for a degradation created from this template. + items: + $ref: "#/components/schemas/DegradationTemplateDataAttributesUpdatesItems" + type: array + type: object + DegradationTemplateDataAttributesComponentsAffectedItems: + description: A component affected by a degradation created from this template. + properties: + id: + description: The ID of the component. + example: "" + type: string + name: + description: The name of the component. + readOnly: true + type: string + status: + $ref: "#/components/schemas/PatchDegradationTemplateRequestDataAttributesComponentsAffectedItemsStatus" + required: + - id + - status + type: object + DegradationTemplateDataAttributesUpdatesItems: + description: A pre-filled update for a degradation created from this template. + properties: + message: + description: The message of the update. + type: string + status: + $ref: "#/components/schemas/CreateDegradationRequestDataAttributesStatus" + required: + - status + type: object + DegradationTemplateDataRelationships: + description: The relationships of a degradation template. + properties: + created_by_user: + $ref: "#/components/schemas/DegradationTemplateDataRelationshipsCreatedByUser" + description: The Datadog user who created the degradation template. + last_modified_by_user: + $ref: "#/components/schemas/DegradationTemplateDataRelationshipsLastModifiedByUser" + description: The Datadog user who last modified the degradation template. + status_page: + $ref: "#/components/schemas/DegradationTemplateDataRelationshipsStatusPage" + description: The status page the degradation template belongs to. + type: object + DegradationTemplateDataRelationshipsCreatedByUser: + description: The Datadog user who created the degradation template. + properties: + data: + $ref: "#/components/schemas/DegradationTemplateDataRelationshipsCreatedByUserData" + required: + - data + type: object + DegradationTemplateDataRelationshipsCreatedByUserData: + description: The data object identifying the Datadog user who created the degradation template. + properties: + id: + description: The ID of the Datadog user who created the degradation template. + example: "" + type: string + type: + $ref: "#/components/schemas/StatusPagesUserType" + required: + - type + - id + type: object + DegradationTemplateDataRelationshipsLastModifiedByUser: + description: The Datadog user who last modified the degradation template. + properties: + data: + $ref: "#/components/schemas/DegradationTemplateDataRelationshipsLastModifiedByUserData" + required: + - data + type: object + DegradationTemplateDataRelationshipsLastModifiedByUserData: + description: The data object identifying the Datadog user who last modified the degradation template. + properties: + id: + description: The ID of the Datadog user who last modified the degradation template. + example: "" + type: string + type: + $ref: "#/components/schemas/StatusPagesUserType" + required: + - type + - id + type: object + DegradationTemplateDataRelationshipsStatusPage: + description: The status page the degradation template belongs to. + properties: + data: + $ref: "#/components/schemas/DegradationTemplateDataRelationshipsStatusPageData" + required: + - data + type: object + DegradationTemplateDataRelationshipsStatusPageData: + description: The data object identifying the status page associated with a degradation template. + properties: + id: + description: The ID of the status page. + example: "" + type: string + type: + $ref: "#/components/schemas/StatusPageDataType" + required: + - type + - id + type: object DegradationUpdate: description: Response object for a degradation update. properties: @@ -60895,6 +61323,9 @@ components: status_page: $ref: "#/components/schemas/MaintenanceDataRelationshipsStatusPage" description: The status page the maintenance belongs to. + template: + $ref: "#/components/schemas/MaintenanceDataRelationshipsTemplate" + description: The template the maintenance was created from. type: object MaintenanceDataRelationshipsCreatedByUser: description: The Datadog user who created the maintenance. @@ -60962,6 +61393,177 @@ components: - type - id type: object + MaintenanceDataRelationshipsTemplate: + description: The template the maintenance was created from. + properties: + data: + $ref: "#/components/schemas/MaintenanceDataRelationshipsTemplateData" + required: + - data + type: object + MaintenanceDataRelationshipsTemplateData: + description: The data object identifying the template the maintenance was created from. + properties: + id: + description: The ID of the maintenance template. + example: "" + type: string + type: + $ref: "#/components/schemas/PatchMaintenanceTemplateRequestDataType" + required: + - type + - id + type: object + MaintenanceTemplate: + description: Response object for a single maintenance template. + properties: + data: + $ref: "#/components/schemas/MaintenanceTemplateData" + included: + description: The included related resources of a maintenance template. Client must explicitly request these resources by name in the `include` query parameter. + items: + $ref: "#/components/schemas/DegradationIncluded" + type: array + type: object + MaintenanceTemplateArray: + description: Response object for a list of maintenance templates. + properties: + data: + description: A list of maintenance template data objects. + items: + $ref: "#/components/schemas/MaintenanceTemplateData" + type: array + included: + description: The included related resources of a maintenance template. Client must explicitly request these resources by name in the `include` query parameter. + items: + $ref: "#/components/schemas/DegradationIncluded" + type: array + required: + - data + type: object + MaintenanceTemplateData: + description: The data object for a maintenance template. + properties: + attributes: + $ref: "#/components/schemas/MaintenanceTemplateDataAttributes" + id: + description: The ID of the maintenance template. + type: string + relationships: + $ref: "#/components/schemas/MaintenanceTemplateDataRelationships" + type: + $ref: "#/components/schemas/PatchMaintenanceTemplateRequestDataType" + required: + - type + type: object + MaintenanceTemplateDataAttributes: + description: The attributes of a maintenance template. + properties: + completed_description: + description: The description shown when a maintenance created from this template is completed. + type: string + component_ids: + description: The IDs of the components affected by a maintenance created from this template. + items: + type: string + type: array + created_at: + description: Timestamp of when the maintenance template was created. + format: date-time + type: string + in_progress_description: + description: The description shown while a maintenance created from this template is in progress. + type: string + maintenance_title: + description: The title used for a maintenance created from this template. + type: string + modified_at: + description: Timestamp of when the maintenance template was last modified. + format: date-time + type: string + name: + description: The name of the maintenance template. + type: string + scheduled_description: + description: The description shown when a maintenance created from this template is scheduled. + type: string + type: object + MaintenanceTemplateDataRelationships: + description: The relationships of a maintenance template. + properties: + created_by_user: + $ref: "#/components/schemas/MaintenanceTemplateDataRelationshipsCreatedByUser" + description: The Datadog user who created the maintenance template. + last_modified_by_user: + $ref: "#/components/schemas/MaintenanceTemplateDataRelationshipsLastModifiedByUser" + description: The Datadog user who last modified the maintenance template. + status_page: + $ref: "#/components/schemas/MaintenanceTemplateDataRelationshipsStatusPage" + description: The status page the maintenance template belongs to. + type: object + MaintenanceTemplateDataRelationshipsCreatedByUser: + description: The Datadog user who created the maintenance template. + properties: + data: + $ref: "#/components/schemas/MaintenanceTemplateDataRelationshipsCreatedByUserData" + required: + - data + type: object + MaintenanceTemplateDataRelationshipsCreatedByUserData: + description: The data object identifying the Datadog user who created the maintenance template. + properties: + id: + description: The ID of the Datadog user who created the maintenance template. + example: "" + type: string + type: + $ref: "#/components/schemas/StatusPagesUserType" + required: + - type + - id + type: object + MaintenanceTemplateDataRelationshipsLastModifiedByUser: + description: The Datadog user who last modified the maintenance template. + properties: + data: + $ref: "#/components/schemas/MaintenanceTemplateDataRelationshipsLastModifiedByUserData" + required: + - data + type: object + MaintenanceTemplateDataRelationshipsLastModifiedByUserData: + description: The data object identifying the Datadog user who last modified the maintenance template. + properties: + id: + description: The ID of the Datadog user who last modified the maintenance template. + example: "" + type: string + type: + $ref: "#/components/schemas/StatusPagesUserType" + required: + - type + - id + type: object + MaintenanceTemplateDataRelationshipsStatusPage: + description: The status page the maintenance template belongs to. + properties: + data: + $ref: "#/components/schemas/MaintenanceTemplateDataRelationshipsStatusPageData" + required: + - data + type: object + MaintenanceTemplateDataRelationshipsStatusPageData: + description: The data object identifying the status page associated with a maintenance template. + properties: + id: + description: The ID of the status page. + example: "" + type: string + type: + $ref: "#/components/schemas/StatusPageDataType" + required: + - type + - id + type: object MaintenanceWindow: description: A maintenance window that defines a scheduled time period during which case-related notifications and automation rules are suppressed. Each maintenance window applies to cases matching a specified query. properties: @@ -76223,6 +76825,8 @@ components: example: "1234abcd-12ab-34cd-56ef-123456abcdef" format: uuid type: string + relationships: + $ref: "#/components/schemas/PatchDegradationRequestDataRelationships" type: $ref: "#/components/schemas/PatchDegradationRequestDataType" required: @@ -76284,6 +76888,34 @@ components: - IDENTIFIED - MONITORING - RESOLVED + PatchDegradationRequestDataRelationships: + description: The supported relationships for updating a degradation. + properties: + template: + $ref: "#/components/schemas/PatchDegradationRequestDataRelationshipsTemplate" + description: The template used to create the degradation. + type: object + PatchDegradationRequestDataRelationshipsTemplate: + description: The template used to create the degradation. + properties: + data: + $ref: "#/components/schemas/PatchDegradationRequestDataRelationshipsTemplateData" + required: + - data + type: object + PatchDegradationRequestDataRelationshipsTemplateData: + description: The data object identifying the template used to create the degradation. + properties: + id: + description: The ID of the degradation template. + example: "" + type: string + type: + $ref: "#/components/schemas/PatchDegradationTemplateRequestDataType" + required: + - type + - id + type: object PatchDegradationRequestDataType: default: degradations description: Degradations resource type. @@ -76293,6 +76925,98 @@ components: type: string x-enum-varnames: - DEGRADATIONS + PatchDegradationTemplateRequest: + description: Request object for updating a degradation template. + properties: + data: + $ref: "#/components/schemas/PatchDegradationTemplateRequestData" + type: object + PatchDegradationTemplateRequestData: + description: The data object for updating a degradation template. + properties: + attributes: + $ref: "#/components/schemas/PatchDegradationTemplateRequestDataAttributes" + id: + description: The ID of the degradation template. + example: "" + type: string + type: + $ref: "#/components/schemas/PatchDegradationTemplateRequestDataType" + required: + - type + - id + type: object + PatchDegradationTemplateRequestDataAttributes: + description: The supported attributes for updating a degradation template. + properties: + components_affected: + description: The components affected by a degradation created from this template. + items: + $ref: "#/components/schemas/PatchDegradationTemplateRequestDataAttributesComponentsAffectedItems" + type: array + degradation_title: + description: The title used for a degradation created from this template. + type: string + name: + description: The name of the degradation template. + type: string + updates: + description: The pre-filled updates for a degradation created from this template. + items: + $ref: "#/components/schemas/PatchDegradationTemplateRequestDataAttributesUpdatesItems" + type: array + type: object + PatchDegradationTemplateRequestDataAttributesComponentsAffectedItems: + description: A component affected by a degradation created from this template. + properties: + id: + description: The ID of the component. Must be a component of type `component`. + example: "" + type: string + name: + description: The name of the component. + readOnly: true + type: string + status: + $ref: "#/components/schemas/PatchDegradationTemplateRequestDataAttributesComponentsAffectedItemsStatus" + required: + - id + - status + type: object + PatchDegradationTemplateRequestDataAttributesComponentsAffectedItemsStatus: + description: The status of the component. + enum: + - operational + - degraded + - partial_outage + - major_outage + example: operational + type: string + x-enum-varnames: + - OPERATIONAL + - DEGRADED + - PARTIAL_OUTAGE + - MAJOR_OUTAGE + PatchDegradationTemplateRequestDataAttributesUpdatesItems: + description: A pre-filled update for a degradation created from this template. + properties: + message: + description: The message of the update. + type: string + status: + $ref: "#/components/schemas/CreateDegradationRequestDataAttributesStatus" + required: + - status + type: object + PatchDegradationTemplateRequestDataType: + default: degradation_templates + description: Degradation templates resource type. + enum: + - degradation_templates + example: degradation_templates + type: string + x-enum-varnames: + - DEGRADATION_TEMPLATES PatchDegradationUpdateRequest: description: Request object for editing a degradation update. example: @@ -76382,6 +77106,8 @@ components: example: "1234abcd-12ab-34cd-56ef-123456abcdef" format: uuid type: string + relationships: + $ref: "#/components/schemas/PatchMaintenanceRequestDataRelationships" type: $ref: "#/components/schemas/PatchMaintenanceRequestDataType" required: @@ -76449,6 +77175,34 @@ components: x-enum-varnames: - OPERATIONAL - MAINTENANCE + PatchMaintenanceRequestDataRelationships: + description: The supported relationships for updating a maintenance. + properties: + template: + $ref: "#/components/schemas/PatchMaintenanceRequestDataRelationshipsTemplate" + description: The template used to create the maintenance. + type: object + PatchMaintenanceRequestDataRelationshipsTemplate: + description: The template used to create the maintenance. + properties: + data: + $ref: "#/components/schemas/PatchMaintenanceRequestDataRelationshipsTemplateData" + required: + - data + type: object + PatchMaintenanceRequestDataRelationshipsTemplateData: + description: The data object identifying the template used to create the maintenance. + properties: + id: + description: The ID of the maintenance template. + example: "" + type: string + type: + $ref: "#/components/schemas/PatchMaintenanceTemplateRequestDataType" + required: + - type + - id + type: object PatchMaintenanceRequestDataType: default: maintenances description: Maintenances resource type. @@ -76458,6 +77212,60 @@ components: type: string x-enum-varnames: - MAINTENANCES + PatchMaintenanceTemplateRequest: + description: Request object for updating a maintenance template. + properties: + data: + $ref: "#/components/schemas/PatchMaintenanceTemplateRequestData" + type: object + PatchMaintenanceTemplateRequestData: + description: The data object for updating a maintenance template. + properties: + attributes: + $ref: "#/components/schemas/PatchMaintenanceTemplateRequestDataAttributes" + id: + description: The ID of the maintenance template. + example: "" + type: string + type: + $ref: "#/components/schemas/PatchMaintenanceTemplateRequestDataType" + required: + - type + - id + type: object + PatchMaintenanceTemplateRequestDataAttributes: + description: The supported attributes for updating a maintenance template. + properties: + completed_description: + description: The description shown when a maintenance created from this template is completed. + type: string + component_ids: + description: The IDs of the components affected by a maintenance created from this template. + items: + type: string + type: array + in_progress_description: + description: The description shown while a maintenance created from this template is in progress. + type: string + maintenance_title: + description: The title used for a maintenance created from this template. + type: string + name: + description: The name of the maintenance template. + type: string + scheduled_description: + description: The description shown when a maintenance created from this template is scheduled. + type: string + type: object + PatchMaintenanceTemplateRequestDataType: + default: maintenance_templates + description: Maintenance templates resource type. + enum: + - maintenance_templates + example: maintenance_templates + type: string + x-enum-varnames: + - MAINTENANCE_TEMPLATES PatchNotificationRuleParameters: description: Body of the notification rule patch request. properties: @@ -193440,6 +194248,11 @@ paths: name: sort schema: type: string + - description: Optional source ID filter. Returns only degradations whose source matches this ID (for example, an incident ID). + in: query + name: filter[source_id] + schema: + type: string responses: "200": content: @@ -193996,6 +194809,280 @@ paths: operator: AND permissions: - status_pages_settings_write + /api/v2/statuspages/{page_id}/degradation_templates: + get: + description: Lists all degradation templates for a status page. + operationId: ListDegradationTemplates + parameters: + - description: "Comma-separated list of resources to include. Supported values: created_by_user, last_modified_by_user, status_page." + in: query + name: include + schema: + type: string + - description: The ID of the status page. + in: path + name: page_id + required: true + schema: + format: uuid + type: string + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + - attributes: + components_affected: + - id: 1234abcd-12ab-34cd-56ef-123456abcdef + status: degraded + degradation_title: Elevated API Latency + name: Elevated API Latency + updates: + - message: We are investigating the issue. + status: investigating + id: 00000000-0000-0000-0000-000000000003 + type: degradation_templates + schema: + $ref: "#/components/schemas/DegradationTemplateArray" + description: OK + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - status_pages_settings_read + summary: List degradation templates + tags: + - Status Pages + post: + description: Creates a new degradation template. + operationId: CreateDegradationTemplate + parameters: + - description: The ID of the status page. + in: path + name: page_id + required: true + schema: + format: uuid + type: string + - description: "Comma-separated list of resources to include. Supported values: created_by_user, last_modified_by_user, status_page." + in: query + name: include + schema: + type: string + requestBody: + content: + application/json: + examples: + default: + value: + data: + attributes: + components_affected: + - id: 1234abcd-12ab-34cd-56ef-123456abcdef + status: degraded + degradation_title: Elevated API Latency + name: Elevated API Latency + updates: + - message: We are investigating the issue. + status: investigating + type: degradation_templates + schema: + $ref: "#/components/schemas/CreateDegradationTemplateRequest" + required: true + responses: + "201": + content: + application/json: + examples: + default: + value: + data: + attributes: + components_affected: + - id: 1234abcd-12ab-34cd-56ef-123456abcdef + status: degraded + degradation_title: Elevated API Latency + name: Elevated API Latency + updates: + - message: We are investigating the issue. + status: investigating + id: 00000000-0000-0000-0000-000000000003 + type: degradation_templates + schema: + $ref: "#/components/schemas/DegradationTemplate" + description: Created + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - status_pages_settings_write + summary: Create degradation template + tags: + - Status Pages + /api/v2/statuspages/{page_id}/degradation_templates/{template_id}: + delete: + description: Deletes a degradation template by its ID (soft delete). + operationId: DeleteDegradationTemplate + parameters: + - description: The ID of the status page. + in: path + name: page_id + required: true + schema: + format: uuid + type: string + - description: The ID of the degradation or maintenance template. + in: path + name: template_id + required: true + schema: + format: uuid + type: string + responses: + "204": + description: No Content + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - status_pages_settings_write + summary: Delete degradation template + tags: + - Status Pages + get: + description: Retrieves a specific degradation template by its ID. + operationId: GetDegradationTemplate + parameters: + - description: The ID of the status page. + in: path + name: page_id + required: true + schema: + format: uuid + type: string + - description: The ID of the degradation or maintenance template. + in: path + name: template_id + required: true + schema: + format: uuid + type: string + - description: "Comma-separated list of resources to include. Supported values: created_by_user, last_modified_by_user, status_page." + in: query + name: include + schema: + type: string + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + attributes: + components_affected: + - id: 1234abcd-12ab-34cd-56ef-123456abcdef + status: degraded + degradation_title: Elevated API Latency + name: Elevated API Latency + updates: + - message: We are investigating the issue. + status: investigating + id: 00000000-0000-0000-0000-000000000003 + type: degradation_templates + schema: + $ref: "#/components/schemas/DegradationTemplate" + description: OK + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - status_pages_settings_read + summary: Get degradation template + tags: + - Status Pages + patch: + description: Updates an existing degradation template's attributes. + operationId: UpdateDegradationTemplate + parameters: + - description: The ID of the degradation or maintenance template. + in: path + name: template_id + required: true + schema: + format: uuid + type: string + - description: "Comma-separated list of resources to include. Supported values: created_by_user, last_modified_by_user, status_page." + in: query + name: include + schema: + type: string + - description: The ID of the status page. + in: path + name: page_id + required: true + schema: + format: uuid + type: string + requestBody: + content: + application/json: + examples: + default: + value: + data: + attributes: + degradation_title: Elevated API Latency for 40 minutes + name: Elevated API Latency + id: 00000000-0000-0000-0000-000000000003 + type: degradation_templates + schema: + $ref: "#/components/schemas/PatchDegradationTemplateRequest" + required: true + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + attributes: + components_affected: + - id: 1234abcd-12ab-34cd-56ef-123456abcdef + status: degraded + degradation_title: Elevated API Latency for 40 minutes + name: Elevated API Latency + updates: + - message: We are investigating the issue. + status: investigating + id: 00000000-0000-0000-0000-000000000003 + type: degradation_templates + schema: + $ref: "#/components/schemas/DegradationTemplate" + description: OK + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - status_pages_settings_write + summary: Update degradation template + tags: + - Status Pages /api/v2/statuspages/{page_id}/degradations: post: description: Creates a new degradation. @@ -194452,6 +195539,277 @@ paths: summary: Edit degradation update tags: - Status Pages + /api/v2/statuspages/{page_id}/maintenance_templates: + get: + description: Lists all maintenance templates for a status page. + operationId: ListMaintenanceTemplates + parameters: + - description: The ID of the status page. + in: path + name: page_id + required: true + schema: + format: uuid + type: string + - description: "Comma-separated list of resources to include. Supported values: created_by_user, last_modified_by_user, status_page." + in: query + name: include + schema: + type: string + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + - attributes: + completed_description: We have completed maintenance on the API to improve performance. + component_ids: + - 1234abcd-12ab-34cd-56ef-123456abcdef + in_progress_description: We are currently performing maintenance on the API to improve performance. + maintenance_title: API Maintenance + name: API Maintenance + scheduled_description: We will be performing maintenance on the API to improve performance. + id: 00000000-0000-0000-0000-000000000004 + type: maintenance_templates + schema: + $ref: "#/components/schemas/MaintenanceTemplateArray" + description: OK + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - status_pages_settings_read + summary: List maintenance templates + tags: + - Status Pages + post: + description: Creates a new maintenance template. + operationId: CreateMaintenanceTemplate + parameters: + - description: The ID of the status page. + in: path + name: page_id + required: true + schema: + format: uuid + type: string + - description: "Comma-separated list of resources to include. Supported values: created_by_user, last_modified_by_user, status_page." + in: query + name: include + schema: + type: string + requestBody: + content: + application/json: + examples: + default: + value: + data: + attributes: + completed_description: We have completed maintenance on the API to improve performance. + component_ids: + - 1234abcd-12ab-34cd-56ef-123456abcdef + in_progress_description: We are currently performing maintenance on the API to improve performance. + maintenance_title: API Maintenance + name: API Maintenance + scheduled_description: We will be performing maintenance on the API to improve performance. + type: maintenance_templates + schema: + $ref: "#/components/schemas/CreateMaintenanceTemplateRequest" + required: true + responses: + "201": + content: + application/json: + examples: + default: + value: + data: + attributes: + completed_description: We have completed maintenance on the API to improve performance. + component_ids: + - 1234abcd-12ab-34cd-56ef-123456abcdef + in_progress_description: We are currently performing maintenance on the API to improve performance. + maintenance_title: API Maintenance + name: API Maintenance + scheduled_description: We will be performing maintenance on the API to improve performance. + id: 00000000-0000-0000-0000-000000000004 + type: maintenance_templates + schema: + $ref: "#/components/schemas/MaintenanceTemplate" + description: Created + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - status_pages_settings_write + summary: Create maintenance template + tags: + - Status Pages + /api/v2/statuspages/{page_id}/maintenance_templates/{template_id}: + delete: + description: Deletes a maintenance template by its ID (soft delete). + operationId: DeleteMaintenanceTemplate + parameters: + - description: The ID of the status page. + in: path + name: page_id + required: true + schema: + format: uuid + type: string + - description: The ID of the degradation or maintenance template. + in: path + name: template_id + required: true + schema: + format: uuid + type: string + responses: + "204": + description: No Content + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - status_pages_settings_write + summary: Delete maintenance template + tags: + - Status Pages + get: + description: Retrieves a specific maintenance template by its ID. + operationId: GetMaintenanceTemplate + parameters: + - description: The ID of the status page. + in: path + name: page_id + required: true + schema: + format: uuid + type: string + - description: The ID of the degradation or maintenance template. + in: path + name: template_id + required: true + schema: + format: uuid + type: string + - description: "Comma-separated list of resources to include. Supported values: created_by_user, last_modified_by_user, status_page." + in: query + name: include + schema: + type: string + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + attributes: + completed_description: We have completed maintenance on the API to improve performance. + component_ids: + - 1234abcd-12ab-34cd-56ef-123456abcdef + in_progress_description: We are currently performing maintenance on the API to improve performance. + maintenance_title: API Maintenance + name: API Maintenance + scheduled_description: We will be performing maintenance on the API to improve performance. + id: 00000000-0000-0000-0000-000000000004 + type: maintenance_templates + schema: + $ref: "#/components/schemas/MaintenanceTemplate" + description: OK + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - status_pages_settings_read + summary: Get maintenance template + tags: + - Status Pages + patch: + description: Updates an existing maintenance template's attributes. + operationId: UpdateMaintenanceTemplate + parameters: + - description: The ID of the status page. + in: path + name: page_id + required: true + schema: + format: uuid + type: string + - description: The ID of the degradation or maintenance template. + in: path + name: template_id + required: true + schema: + format: uuid + type: string + - description: "Comma-separated list of resources to include. Supported values: created_by_user, last_modified_by_user, status_page." + in: query + name: include + schema: + type: string + requestBody: + content: + application/json: + examples: + default: + value: + data: + attributes: + completed_description: We have completed maintenance on the API to improve performance. + in_progress_description: We are currently performing maintenance on the API to improve performance for 40 minutes. + maintenance_title: API Maintenance + scheduled_description: We will be performing maintenance on the API to improve performance for 40 minutes. + id: 00000000-0000-0000-0000-000000000004 + type: maintenance_templates + schema: + $ref: "#/components/schemas/PatchMaintenanceTemplateRequest" + required: true + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + attributes: + completed_description: We have completed maintenance on the API to improve performance. + component_ids: + - 1234abcd-12ab-34cd-56ef-123456abcdef + in_progress_description: We are currently performing maintenance on the API to improve performance for 40 minutes. + maintenance_title: API Maintenance + name: API Maintenance + scheduled_description: We will be performing maintenance on the API to improve performance for 40 minutes. + id: 00000000-0000-0000-0000-000000000004 + type: maintenance_templates + schema: + $ref: "#/components/schemas/MaintenanceTemplate" + description: OK + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - status_pages_settings_write + summary: Update maintenance template + tags: + - Status Pages /api/v2/statuspages/{page_id}/maintenances: post: description: Schedules a new maintenance. diff --git a/api/datadogV2/api_status_pages.go b/api/datadogV2/api_status_pages.go index 408f2325872..2f3bf01bcf6 100644 --- a/api/datadogV2/api_status_pages.go +++ b/api/datadogV2/api_status_pages.go @@ -462,6 +462,115 @@ func (a *StatusPagesApi) CreateDegradation(ctx _context.Context, pageId uuid.UUI return localVarReturnValue, localVarHTTPResponse, nil } +// CreateDegradationTemplateOptionalParameters holds optional parameters for CreateDegradationTemplate. +type CreateDegradationTemplateOptionalParameters struct { + Include *string +} + +// NewCreateDegradationTemplateOptionalParameters creates an empty struct for parameters. +func NewCreateDegradationTemplateOptionalParameters() *CreateDegradationTemplateOptionalParameters { + this := CreateDegradationTemplateOptionalParameters{} + return &this +} + +// WithInclude sets the corresponding parameter name and returns the struct. +func (r *CreateDegradationTemplateOptionalParameters) WithInclude(include string) *CreateDegradationTemplateOptionalParameters { + r.Include = &include + return r +} + +// CreateDegradationTemplate Create degradation template. +// Creates a new degradation template. +func (a *StatusPagesApi) CreateDegradationTemplate(ctx _context.Context, pageId uuid.UUID, body CreateDegradationTemplateRequest, o ...CreateDegradationTemplateOptionalParameters) (DegradationTemplate, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPost + localVarPostBody interface{} + localVarReturnValue DegradationTemplate + optionalParams CreateDegradationTemplateOptionalParameters + ) + + if len(o) > 1 { + return localVarReturnValue, nil, datadog.ReportError("only one argument of type CreateDegradationTemplateOptionalParameters is allowed") + } + if len(o) == 1 { + optionalParams = o[0] + } + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.StatusPagesApi.CreateDegradationTemplate") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/statuspages/{page_id}/degradation_templates" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{page_id}", _neturl.PathEscape(datadog.ParameterToString(pageId, ""))) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + if optionalParams.Include != nil { + localVarQueryParams.Add("include", datadog.ParameterToString(*optionalParams.Include, "")) + } + 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 == 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 +} + // CreateMaintenanceOptionalParameters holds optional parameters for CreateMaintenance. type CreateMaintenanceOptionalParameters struct { NotifySubscribers *bool @@ -581,6 +690,115 @@ func (a *StatusPagesApi) CreateMaintenance(ctx _context.Context, pageId uuid.UUI return localVarReturnValue, localVarHTTPResponse, nil } +// CreateMaintenanceTemplateOptionalParameters holds optional parameters for CreateMaintenanceTemplate. +type CreateMaintenanceTemplateOptionalParameters struct { + Include *string +} + +// NewCreateMaintenanceTemplateOptionalParameters creates an empty struct for parameters. +func NewCreateMaintenanceTemplateOptionalParameters() *CreateMaintenanceTemplateOptionalParameters { + this := CreateMaintenanceTemplateOptionalParameters{} + return &this +} + +// WithInclude sets the corresponding parameter name and returns the struct. +func (r *CreateMaintenanceTemplateOptionalParameters) WithInclude(include string) *CreateMaintenanceTemplateOptionalParameters { + r.Include = &include + return r +} + +// CreateMaintenanceTemplate Create maintenance template. +// Creates a new maintenance template. +func (a *StatusPagesApi) CreateMaintenanceTemplate(ctx _context.Context, pageId uuid.UUID, body CreateMaintenanceTemplateRequest, o ...CreateMaintenanceTemplateOptionalParameters) (MaintenanceTemplate, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPost + localVarPostBody interface{} + localVarReturnValue MaintenanceTemplate + optionalParams CreateMaintenanceTemplateOptionalParameters + ) + + if len(o) > 1 { + return localVarReturnValue, nil, datadog.ReportError("only one argument of type CreateMaintenanceTemplateOptionalParameters is allowed") + } + if len(o) == 1 { + optionalParams = o[0] + } + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.StatusPagesApi.CreateMaintenanceTemplate") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/statuspages/{page_id}/maintenance_templates" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{page_id}", _neturl.PathEscape(datadog.ParameterToString(pageId, ""))) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + if optionalParams.Include != nil { + localVarQueryParams.Add("include", datadog.ParameterToString(*optionalParams.Include, "")) + } + 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 == 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 +} + // CreateStatusPageOptionalParameters holds optional parameters for CreateStatusPage. type CreateStatusPageOptionalParameters struct { Include *string @@ -827,31 +1045,592 @@ func (a *StatusPagesApi) DeleteDegradation(ctx _context.Context, pageId uuid.UUI return localVarHTTPResponse, nil } -// DeleteStatusPage Delete status page. -// Deletes a status page by its ID. -func (a *StatusPagesApi) DeleteStatusPage(ctx _context.Context, pageId uuid.UUID) (*_nethttp.Response, error) { +// DeleteDegradationTemplate Delete degradation template. +// Deletes a degradation template by its ID (soft delete). +func (a *StatusPagesApi) DeleteDegradationTemplate(ctx _context.Context, pageId uuid.UUID, templateId uuid.UUID) (*_nethttp.Response, error) { var ( localVarHTTPMethod = _nethttp.MethodDelete localVarPostBody interface{} ) - localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.StatusPagesApi.DeleteStatusPage") + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.StatusPagesApi.DeleteDegradationTemplate") + if err != nil { + return nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/statuspages/{page_id}/degradation_templates/{template_id}" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{page_id}", _neturl.PathEscape(datadog.ParameterToString(pageId, ""))) + 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 == 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 +} + +// DeleteMaintenanceTemplate Delete maintenance template. +// Deletes a maintenance template by its ID (soft delete). +func (a *StatusPagesApi) DeleteMaintenanceTemplate(ctx _context.Context, pageId uuid.UUID, templateId uuid.UUID) (*_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodDelete + localVarPostBody interface{} + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.StatusPagesApi.DeleteMaintenanceTemplate") + if err != nil { + return nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/statuspages/{page_id}/maintenance_templates/{template_id}" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{page_id}", _neturl.PathEscape(datadog.ParameterToString(pageId, ""))) + 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 == 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 +} + +// DeleteStatusPage Delete status page. +// Deletes a status page by its ID. +func (a *StatusPagesApi) DeleteStatusPage(ctx _context.Context, pageId uuid.UUID) (*_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodDelete + localVarPostBody interface{} + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.StatusPagesApi.DeleteStatusPage") + if err != nil { + return nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/statuspages/{page_id}" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{page_id}", _neturl.PathEscape(datadog.ParameterToString(pageId, ""))) + + 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 == 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 +} + +// EditDegradationUpdateOptionalParameters holds optional parameters for EditDegradationUpdate. +type EditDegradationUpdateOptionalParameters struct { + Include *string +} + +// NewEditDegradationUpdateOptionalParameters creates an empty struct for parameters. +func NewEditDegradationUpdateOptionalParameters() *EditDegradationUpdateOptionalParameters { + this := EditDegradationUpdateOptionalParameters{} + return &this +} + +// WithInclude sets the corresponding parameter name and returns the struct. +func (r *EditDegradationUpdateOptionalParameters) WithInclude(include string) *EditDegradationUpdateOptionalParameters { + r.Include = &include + return r +} + +// EditDegradationUpdate Edit degradation update. +// Edits a specific degradation update. +func (a *StatusPagesApi) EditDegradationUpdate(ctx _context.Context, degradationId uuid.UUID, pageId uuid.UUID, updateId uuid.UUID, body PatchDegradationUpdateRequest, o ...EditDegradationUpdateOptionalParameters) (DegradationUpdate, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPatch + localVarPostBody interface{} + localVarReturnValue DegradationUpdate + optionalParams EditDegradationUpdateOptionalParameters + ) + + if len(o) > 1 { + return localVarReturnValue, nil, datadog.ReportError("only one argument of type EditDegradationUpdateOptionalParameters is allowed") + } + if len(o) == 1 { + optionalParams = o[0] + } + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.StatusPagesApi.EditDegradationUpdate") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/statuspages/{page_id}/degradations/{degradation_id}/updates/{update_id}" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{degradation_id}", _neturl.PathEscape(datadog.ParameterToString(degradationId, ""))) + localVarPath = datadog.ReplacePathParameter(localVarPath, "{page_id}", _neturl.PathEscape(datadog.ParameterToString(pageId, ""))) + localVarPath = datadog.ReplacePathParameter(localVarPath, "{update_id}", _neturl.PathEscape(datadog.ParameterToString(updateId, ""))) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + if optionalParams.Include != nil { + localVarQueryParams.Add("include", datadog.ParameterToString(*optionalParams.Include, "")) + } + 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 == 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 +} + +// GetComponentOptionalParameters holds optional parameters for GetComponent. +type GetComponentOptionalParameters struct { + Include *string +} + +// NewGetComponentOptionalParameters creates an empty struct for parameters. +func NewGetComponentOptionalParameters() *GetComponentOptionalParameters { + this := GetComponentOptionalParameters{} + return &this +} + +// WithInclude sets the corresponding parameter name and returns the struct. +func (r *GetComponentOptionalParameters) WithInclude(include string) *GetComponentOptionalParameters { + r.Include = &include + return r +} + +// GetComponent Get component. +// Retrieves a specific component by its ID. +func (a *StatusPagesApi) GetComponent(ctx _context.Context, pageId uuid.UUID, componentId uuid.UUID, o ...GetComponentOptionalParameters) (StatusPagesComponent, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarReturnValue StatusPagesComponent + optionalParams GetComponentOptionalParameters + ) + + if len(o) > 1 { + return localVarReturnValue, nil, datadog.ReportError("only one argument of type GetComponentOptionalParameters is allowed") + } + if len(o) == 1 { + optionalParams = o[0] + } + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.StatusPagesApi.GetComponent") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/statuspages/{page_id}/components/{component_id}" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{page_id}", _neturl.PathEscape(datadog.ParameterToString(pageId, ""))) + localVarPath = datadog.ReplacePathParameter(localVarPath, "{component_id}", _neturl.PathEscape(datadog.ParameterToString(componentId, ""))) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + if optionalParams.Include != nil { + localVarQueryParams.Add("include", datadog.ParameterToString(*optionalParams.Include, "")) + } + 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 +} + +// GetDegradationOptionalParameters holds optional parameters for GetDegradation. +type GetDegradationOptionalParameters struct { + Include *string +} + +// NewGetDegradationOptionalParameters creates an empty struct for parameters. +func NewGetDegradationOptionalParameters() *GetDegradationOptionalParameters { + this := GetDegradationOptionalParameters{} + return &this +} + +// WithInclude sets the corresponding parameter name and returns the struct. +func (r *GetDegradationOptionalParameters) WithInclude(include string) *GetDegradationOptionalParameters { + r.Include = &include + return r +} + +// GetDegradation Get degradation. +// Retrieves a specific degradation by its ID. +func (a *StatusPagesApi) GetDegradation(ctx _context.Context, pageId uuid.UUID, degradationId uuid.UUID, o ...GetDegradationOptionalParameters) (Degradation, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarReturnValue Degradation + optionalParams GetDegradationOptionalParameters + ) + + if len(o) > 1 { + return localVarReturnValue, nil, datadog.ReportError("only one argument of type GetDegradationOptionalParameters is allowed") + } + if len(o) == 1 { + optionalParams = o[0] + } + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.StatusPagesApi.GetDegradation") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/statuspages/{page_id}/degradations/{degradation_id}" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{page_id}", _neturl.PathEscape(datadog.ParameterToString(pageId, ""))) + localVarPath = datadog.ReplacePathParameter(localVarPath, "{degradation_id}", _neturl.PathEscape(datadog.ParameterToString(degradationId, ""))) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + if optionalParams.Include != nil { + localVarQueryParams.Add("include", datadog.ParameterToString(*optionalParams.Include, "")) + } + 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 +} + +// GetDegradationTemplateOptionalParameters holds optional parameters for GetDegradationTemplate. +type GetDegradationTemplateOptionalParameters struct { + Include *string +} + +// NewGetDegradationTemplateOptionalParameters creates an empty struct for parameters. +func NewGetDegradationTemplateOptionalParameters() *GetDegradationTemplateOptionalParameters { + this := GetDegradationTemplateOptionalParameters{} + return &this +} + +// WithInclude sets the corresponding parameter name and returns the struct. +func (r *GetDegradationTemplateOptionalParameters) WithInclude(include string) *GetDegradationTemplateOptionalParameters { + r.Include = &include + return r +} + +// GetDegradationTemplate Get degradation template. +// Retrieves a specific degradation template by its ID. +func (a *StatusPagesApi) GetDegradationTemplate(ctx _context.Context, pageId uuid.UUID, templateId uuid.UUID, o ...GetDegradationTemplateOptionalParameters) (DegradationTemplate, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarReturnValue DegradationTemplate + optionalParams GetDegradationTemplateOptionalParameters + ) + + if len(o) > 1 { + return localVarReturnValue, nil, datadog.ReportError("only one argument of type GetDegradationTemplateOptionalParameters is allowed") + } + if len(o) == 1 { + optionalParams = o[0] + } + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.StatusPagesApi.GetDegradationTemplate") if err != nil { - return nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} } - localVarPath := localBasePath + "/api/v2/statuspages/{page_id}" + localVarPath := localBasePath + "/api/v2/statuspages/{page_id}/degradation_templates/{template_id}" localVarPath = datadog.ReplacePathParameter(localVarPath, "{page_id}", _neturl.PathEscape(datadog.ParameterToString(pageId, ""))) + 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 optionalParams.Include != nil { + localVarQueryParams.Add("include", datadog.ParameterToString(*optionalParams.Include, "")) + } + localVarHeaderParams["Accept"] = "application/json" if a.Client.Cfg.DelegatedTokenConfig != nil { err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig) if err != nil { - return nil, err + return localVarReturnValue, nil, err } } else { datadog.SetAuthKeys( @@ -863,17 +1642,17 @@ func (a *StatusPagesApi) DeleteStatusPage(ctx _context.Context, pageId uuid.UUID } req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) if err != nil { - return nil, err + return localVarReturnValue, nil, err } localVarHTTPResponse, err := a.Client.CallAPI(req) if err != nil || localVarHTTPResponse == nil { - return localVarHTTPResponse, err + return localVarReturnValue, localVarHTTPResponse, err } localVarBody, err := datadog.ReadBody(localVarHTTPResponse) if err != nil { - return localVarHTTPResponse, err + return localVarReturnValue, localVarHTTPResponse, err } if localVarHTTPResponse.StatusCode >= 300 { @@ -885,59 +1664,67 @@ func (a *StatusPagesApi) DeleteStatusPage(ctx _context.Context, pageId uuid.UUID var v APIErrorResponse err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) if err != nil { - return localVarHTTPResponse, newErr + return localVarReturnValue, localVarHTTPResponse, newErr } newErr.ErrorModel = v } - return localVarHTTPResponse, newErr + return localVarReturnValue, localVarHTTPResponse, newErr } - return localVarHTTPResponse, nil + 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 } -// EditDegradationUpdateOptionalParameters holds optional parameters for EditDegradationUpdate. -type EditDegradationUpdateOptionalParameters struct { +// GetMaintenanceOptionalParameters holds optional parameters for GetMaintenance. +type GetMaintenanceOptionalParameters struct { Include *string } -// NewEditDegradationUpdateOptionalParameters creates an empty struct for parameters. -func NewEditDegradationUpdateOptionalParameters() *EditDegradationUpdateOptionalParameters { - this := EditDegradationUpdateOptionalParameters{} +// NewGetMaintenanceOptionalParameters creates an empty struct for parameters. +func NewGetMaintenanceOptionalParameters() *GetMaintenanceOptionalParameters { + this := GetMaintenanceOptionalParameters{} return &this } // WithInclude sets the corresponding parameter name and returns the struct. -func (r *EditDegradationUpdateOptionalParameters) WithInclude(include string) *EditDegradationUpdateOptionalParameters { +func (r *GetMaintenanceOptionalParameters) WithInclude(include string) *GetMaintenanceOptionalParameters { r.Include = &include return r } -// EditDegradationUpdate Edit degradation update. -// Edits a specific degradation update. -func (a *StatusPagesApi) EditDegradationUpdate(ctx _context.Context, degradationId uuid.UUID, pageId uuid.UUID, updateId uuid.UUID, body PatchDegradationUpdateRequest, o ...EditDegradationUpdateOptionalParameters) (DegradationUpdate, *_nethttp.Response, error) { +// GetMaintenance Get maintenance. +// Retrieves a specific maintenance by its ID. +func (a *StatusPagesApi) GetMaintenance(ctx _context.Context, pageId uuid.UUID, maintenanceId uuid.UUID, o ...GetMaintenanceOptionalParameters) (Maintenance, *_nethttp.Response, error) { var ( - localVarHTTPMethod = _nethttp.MethodPatch + localVarHTTPMethod = _nethttp.MethodGet localVarPostBody interface{} - localVarReturnValue DegradationUpdate - optionalParams EditDegradationUpdateOptionalParameters + localVarReturnValue Maintenance + optionalParams GetMaintenanceOptionalParameters ) if len(o) > 1 { - return localVarReturnValue, nil, datadog.ReportError("only one argument of type EditDegradationUpdateOptionalParameters is allowed") + return localVarReturnValue, nil, datadog.ReportError("only one argument of type GetMaintenanceOptionalParameters is allowed") } if len(o) == 1 { optionalParams = o[0] } - localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.StatusPagesApi.EditDegradationUpdate") + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.StatusPagesApi.GetMaintenance") if err != nil { return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} } - localVarPath := localBasePath + "/api/v2/statuspages/{page_id}/degradations/{degradation_id}/updates/{update_id}" - localVarPath = datadog.ReplacePathParameter(localVarPath, "{degradation_id}", _neturl.PathEscape(datadog.ParameterToString(degradationId, ""))) + localVarPath := localBasePath + "/api/v2/statuspages/{page_id}/maintenances/{maintenance_id}" localVarPath = datadog.ReplacePathParameter(localVarPath, "{page_id}", _neturl.PathEscape(datadog.ParameterToString(pageId, ""))) - localVarPath = datadog.ReplacePathParameter(localVarPath, "{update_id}", _neturl.PathEscape(datadog.ParameterToString(updateId, ""))) + localVarPath = datadog.ReplacePathParameter(localVarPath, "{maintenance_id}", _neturl.PathEscape(datadog.ParameterToString(maintenanceId, ""))) localVarHeaderParams := make(map[string]string) localVarQueryParams := _neturl.Values{} @@ -945,11 +1732,8 @@ func (a *StatusPagesApi) EditDegradationUpdate(ctx _context.Context, degradation if optionalParams.Include != nil { localVarQueryParams.Add("include", datadog.ParameterToString(*optionalParams.Include, "")) } - 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 { @@ -1006,48 +1790,48 @@ func (a *StatusPagesApi) EditDegradationUpdate(ctx _context.Context, degradation return localVarReturnValue, localVarHTTPResponse, nil } -// GetComponentOptionalParameters holds optional parameters for GetComponent. -type GetComponentOptionalParameters struct { +// GetMaintenanceTemplateOptionalParameters holds optional parameters for GetMaintenanceTemplate. +type GetMaintenanceTemplateOptionalParameters struct { Include *string } -// NewGetComponentOptionalParameters creates an empty struct for parameters. -func NewGetComponentOptionalParameters() *GetComponentOptionalParameters { - this := GetComponentOptionalParameters{} +// NewGetMaintenanceTemplateOptionalParameters creates an empty struct for parameters. +func NewGetMaintenanceTemplateOptionalParameters() *GetMaintenanceTemplateOptionalParameters { + this := GetMaintenanceTemplateOptionalParameters{} return &this } // WithInclude sets the corresponding parameter name and returns the struct. -func (r *GetComponentOptionalParameters) WithInclude(include string) *GetComponentOptionalParameters { +func (r *GetMaintenanceTemplateOptionalParameters) WithInclude(include string) *GetMaintenanceTemplateOptionalParameters { r.Include = &include return r } -// GetComponent Get component. -// Retrieves a specific component by its ID. -func (a *StatusPagesApi) GetComponent(ctx _context.Context, pageId uuid.UUID, componentId uuid.UUID, o ...GetComponentOptionalParameters) (StatusPagesComponent, *_nethttp.Response, error) { +// GetMaintenanceTemplate Get maintenance template. +// Retrieves a specific maintenance template by its ID. +func (a *StatusPagesApi) GetMaintenanceTemplate(ctx _context.Context, pageId uuid.UUID, templateId uuid.UUID, o ...GetMaintenanceTemplateOptionalParameters) (MaintenanceTemplate, *_nethttp.Response, error) { var ( localVarHTTPMethod = _nethttp.MethodGet localVarPostBody interface{} - localVarReturnValue StatusPagesComponent - optionalParams GetComponentOptionalParameters + localVarReturnValue MaintenanceTemplate + optionalParams GetMaintenanceTemplateOptionalParameters ) if len(o) > 1 { - return localVarReturnValue, nil, datadog.ReportError("only one argument of type GetComponentOptionalParameters is allowed") + return localVarReturnValue, nil, datadog.ReportError("only one argument of type GetMaintenanceTemplateOptionalParameters is allowed") } if len(o) == 1 { optionalParams = o[0] } - localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.StatusPagesApi.GetComponent") + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.StatusPagesApi.GetMaintenanceTemplate") if err != nil { return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} } - localVarPath := localBasePath + "/api/v2/statuspages/{page_id}/components/{component_id}" + localVarPath := localBasePath + "/api/v2/statuspages/{page_id}/maintenance_templates/{template_id}" localVarPath = datadog.ReplacePathParameter(localVarPath, "{page_id}", _neturl.PathEscape(datadog.ParameterToString(pageId, ""))) - localVarPath = datadog.ReplacePathParameter(localVarPath, "{component_id}", _neturl.PathEscape(datadog.ParameterToString(componentId, ""))) + localVarPath = datadog.ReplacePathParameter(localVarPath, "{template_id}", _neturl.PathEscape(datadog.ParameterToString(templateId, ""))) localVarHeaderParams := make(map[string]string) localVarQueryParams := _neturl.Values{} @@ -1113,48 +1897,47 @@ func (a *StatusPagesApi) GetComponent(ctx _context.Context, pageId uuid.UUID, co return localVarReturnValue, localVarHTTPResponse, nil } -// GetDegradationOptionalParameters holds optional parameters for GetDegradation. -type GetDegradationOptionalParameters struct { +// GetStatusPageOptionalParameters holds optional parameters for GetStatusPage. +type GetStatusPageOptionalParameters struct { Include *string } -// NewGetDegradationOptionalParameters creates an empty struct for parameters. -func NewGetDegradationOptionalParameters() *GetDegradationOptionalParameters { - this := GetDegradationOptionalParameters{} +// NewGetStatusPageOptionalParameters creates an empty struct for parameters. +func NewGetStatusPageOptionalParameters() *GetStatusPageOptionalParameters { + this := GetStatusPageOptionalParameters{} return &this } // WithInclude sets the corresponding parameter name and returns the struct. -func (r *GetDegradationOptionalParameters) WithInclude(include string) *GetDegradationOptionalParameters { +func (r *GetStatusPageOptionalParameters) WithInclude(include string) *GetStatusPageOptionalParameters { r.Include = &include return r } -// GetDegradation Get degradation. -// Retrieves a specific degradation by its ID. -func (a *StatusPagesApi) GetDegradation(ctx _context.Context, pageId uuid.UUID, degradationId uuid.UUID, o ...GetDegradationOptionalParameters) (Degradation, *_nethttp.Response, error) { +// GetStatusPage Get status page. +// Retrieves a specific status page by its ID. +func (a *StatusPagesApi) GetStatusPage(ctx _context.Context, pageId uuid.UUID, o ...GetStatusPageOptionalParameters) (StatusPage, *_nethttp.Response, error) { var ( localVarHTTPMethod = _nethttp.MethodGet localVarPostBody interface{} - localVarReturnValue Degradation - optionalParams GetDegradationOptionalParameters + localVarReturnValue StatusPage + optionalParams GetStatusPageOptionalParameters ) if len(o) > 1 { - return localVarReturnValue, nil, datadog.ReportError("only one argument of type GetDegradationOptionalParameters is allowed") + return localVarReturnValue, nil, datadog.ReportError("only one argument of type GetStatusPageOptionalParameters is allowed") } if len(o) == 1 { optionalParams = o[0] } - localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.StatusPagesApi.GetDegradation") + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.StatusPagesApi.GetStatusPage") if err != nil { return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} } - localVarPath := localBasePath + "/api/v2/statuspages/{page_id}/degradations/{degradation_id}" + localVarPath := localBasePath + "/api/v2/statuspages/{page_id}" localVarPath = datadog.ReplacePathParameter(localVarPath, "{page_id}", _neturl.PathEscape(datadog.ParameterToString(pageId, ""))) - localVarPath = datadog.ReplacePathParameter(localVarPath, "{degradation_id}", _neturl.PathEscape(datadog.ParameterToString(degradationId, ""))) localVarHeaderParams := make(map[string]string) localVarQueryParams := _neturl.Values{} @@ -1220,48 +2003,47 @@ func (a *StatusPagesApi) GetDegradation(ctx _context.Context, pageId uuid.UUID, return localVarReturnValue, localVarHTTPResponse, nil } -// GetMaintenanceOptionalParameters holds optional parameters for GetMaintenance. -type GetMaintenanceOptionalParameters struct { +// ListComponentsOptionalParameters holds optional parameters for ListComponents. +type ListComponentsOptionalParameters struct { Include *string } -// NewGetMaintenanceOptionalParameters creates an empty struct for parameters. -func NewGetMaintenanceOptionalParameters() *GetMaintenanceOptionalParameters { - this := GetMaintenanceOptionalParameters{} +// NewListComponentsOptionalParameters creates an empty struct for parameters. +func NewListComponentsOptionalParameters() *ListComponentsOptionalParameters { + this := ListComponentsOptionalParameters{} return &this } // WithInclude sets the corresponding parameter name and returns the struct. -func (r *GetMaintenanceOptionalParameters) WithInclude(include string) *GetMaintenanceOptionalParameters { +func (r *ListComponentsOptionalParameters) WithInclude(include string) *ListComponentsOptionalParameters { r.Include = &include return r } -// GetMaintenance Get maintenance. -// Retrieves a specific maintenance by its ID. -func (a *StatusPagesApi) GetMaintenance(ctx _context.Context, pageId uuid.UUID, maintenanceId uuid.UUID, o ...GetMaintenanceOptionalParameters) (Maintenance, *_nethttp.Response, error) { +// ListComponents List components. +// Lists all components for a status page. +func (a *StatusPagesApi) ListComponents(ctx _context.Context, pageId uuid.UUID, o ...ListComponentsOptionalParameters) (StatusPagesComponentArray, *_nethttp.Response, error) { var ( localVarHTTPMethod = _nethttp.MethodGet localVarPostBody interface{} - localVarReturnValue Maintenance - optionalParams GetMaintenanceOptionalParameters + localVarReturnValue StatusPagesComponentArray + optionalParams ListComponentsOptionalParameters ) if len(o) > 1 { - return localVarReturnValue, nil, datadog.ReportError("only one argument of type GetMaintenanceOptionalParameters is allowed") + return localVarReturnValue, nil, datadog.ReportError("only one argument of type ListComponentsOptionalParameters is allowed") } if len(o) == 1 { optionalParams = o[0] } - localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.StatusPagesApi.GetMaintenance") + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.StatusPagesApi.ListComponents") if err != nil { return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} } - localVarPath := localBasePath + "/api/v2/statuspages/{page_id}/maintenances/{maintenance_id}" + localVarPath := localBasePath + "/api/v2/statuspages/{page_id}/components" localVarPath = datadog.ReplacePathParameter(localVarPath, "{page_id}", _neturl.PathEscape(datadog.ParameterToString(pageId, ""))) - localVarPath = datadog.ReplacePathParameter(localVarPath, "{maintenance_id}", _neturl.PathEscape(datadog.ParameterToString(maintenanceId, ""))) localVarHeaderParams := make(map[string]string) localVarQueryParams := _neturl.Values{} @@ -1327,46 +2109,46 @@ func (a *StatusPagesApi) GetMaintenance(ctx _context.Context, pageId uuid.UUID, return localVarReturnValue, localVarHTTPResponse, nil } -// GetStatusPageOptionalParameters holds optional parameters for GetStatusPage. -type GetStatusPageOptionalParameters struct { +// ListDegradationTemplatesOptionalParameters holds optional parameters for ListDegradationTemplates. +type ListDegradationTemplatesOptionalParameters struct { Include *string } -// NewGetStatusPageOptionalParameters creates an empty struct for parameters. -func NewGetStatusPageOptionalParameters() *GetStatusPageOptionalParameters { - this := GetStatusPageOptionalParameters{} +// NewListDegradationTemplatesOptionalParameters creates an empty struct for parameters. +func NewListDegradationTemplatesOptionalParameters() *ListDegradationTemplatesOptionalParameters { + this := ListDegradationTemplatesOptionalParameters{} return &this } // WithInclude sets the corresponding parameter name and returns the struct. -func (r *GetStatusPageOptionalParameters) WithInclude(include string) *GetStatusPageOptionalParameters { +func (r *ListDegradationTemplatesOptionalParameters) WithInclude(include string) *ListDegradationTemplatesOptionalParameters { r.Include = &include return r } -// GetStatusPage Get status page. -// Retrieves a specific status page by its ID. -func (a *StatusPagesApi) GetStatusPage(ctx _context.Context, pageId uuid.UUID, o ...GetStatusPageOptionalParameters) (StatusPage, *_nethttp.Response, error) { +// ListDegradationTemplates List degradation templates. +// Lists all degradation templates for a status page. +func (a *StatusPagesApi) ListDegradationTemplates(ctx _context.Context, pageId uuid.UUID, o ...ListDegradationTemplatesOptionalParameters) (DegradationTemplateArray, *_nethttp.Response, error) { var ( localVarHTTPMethod = _nethttp.MethodGet localVarPostBody interface{} - localVarReturnValue StatusPage - optionalParams GetStatusPageOptionalParameters + localVarReturnValue DegradationTemplateArray + optionalParams ListDegradationTemplatesOptionalParameters ) if len(o) > 1 { - return localVarReturnValue, nil, datadog.ReportError("only one argument of type GetStatusPageOptionalParameters is allowed") + return localVarReturnValue, nil, datadog.ReportError("only one argument of type ListDegradationTemplatesOptionalParameters is allowed") } if len(o) == 1 { optionalParams = o[0] } - localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.StatusPagesApi.GetStatusPage") + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.StatusPagesApi.ListDegradationTemplates") if err != nil { return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} } - localVarPath := localBasePath + "/api/v2/statuspages/{page_id}" + localVarPath := localBasePath + "/api/v2/statuspages/{page_id}/degradation_templates" localVarPath = datadog.ReplacePathParameter(localVarPath, "{page_id}", _neturl.PathEscape(datadog.ParameterToString(pageId, ""))) localVarHeaderParams := make(map[string]string) @@ -1433,54 +2215,113 @@ func (a *StatusPagesApi) GetStatusPage(ctx _context.Context, pageId uuid.UUID, o return localVarReturnValue, localVarHTTPResponse, nil } -// ListComponentsOptionalParameters holds optional parameters for ListComponents. -type ListComponentsOptionalParameters struct { - Include *string +// ListDegradationsOptionalParameters holds optional parameters for ListDegradations. +type ListDegradationsOptionalParameters struct { + FilterPageId *string + PageOffset *int64 + PageLimit *int64 + Include *string + FilterStatus *string + Sort *string + FilterSourceId *string } -// NewListComponentsOptionalParameters creates an empty struct for parameters. -func NewListComponentsOptionalParameters() *ListComponentsOptionalParameters { - this := ListComponentsOptionalParameters{} +// NewListDegradationsOptionalParameters creates an empty struct for parameters. +func NewListDegradationsOptionalParameters() *ListDegradationsOptionalParameters { + this := ListDegradationsOptionalParameters{} return &this } +// WithFilterPageId sets the corresponding parameter name and returns the struct. +func (r *ListDegradationsOptionalParameters) WithFilterPageId(filterPageId string) *ListDegradationsOptionalParameters { + r.FilterPageId = &filterPageId + return r +} + +// WithPageOffset sets the corresponding parameter name and returns the struct. +func (r *ListDegradationsOptionalParameters) WithPageOffset(pageOffset int64) *ListDegradationsOptionalParameters { + r.PageOffset = &pageOffset + return r +} + +// WithPageLimit sets the corresponding parameter name and returns the struct. +func (r *ListDegradationsOptionalParameters) WithPageLimit(pageLimit int64) *ListDegradationsOptionalParameters { + r.PageLimit = &pageLimit + return r +} + // WithInclude sets the corresponding parameter name and returns the struct. -func (r *ListComponentsOptionalParameters) WithInclude(include string) *ListComponentsOptionalParameters { +func (r *ListDegradationsOptionalParameters) WithInclude(include string) *ListDegradationsOptionalParameters { r.Include = &include return r } -// ListComponents List components. -// Lists all components for a status page. -func (a *StatusPagesApi) ListComponents(ctx _context.Context, pageId uuid.UUID, o ...ListComponentsOptionalParameters) (StatusPagesComponentArray, *_nethttp.Response, error) { +// WithFilterStatus sets the corresponding parameter name and returns the struct. +func (r *ListDegradationsOptionalParameters) WithFilterStatus(filterStatus string) *ListDegradationsOptionalParameters { + r.FilterStatus = &filterStatus + return r +} + +// WithSort sets the corresponding parameter name and returns the struct. +func (r *ListDegradationsOptionalParameters) WithSort(sort string) *ListDegradationsOptionalParameters { + r.Sort = &sort + return r +} + +// WithFilterSourceId sets the corresponding parameter name and returns the struct. +func (r *ListDegradationsOptionalParameters) WithFilterSourceId(filterSourceId string) *ListDegradationsOptionalParameters { + r.FilterSourceId = &filterSourceId + return r +} + +// ListDegradations List degradations. +// Lists all degradations for the organization. Optionally filter by status and page. +func (a *StatusPagesApi) ListDegradations(ctx _context.Context, o ...ListDegradationsOptionalParameters) (DegradationArray, *_nethttp.Response, error) { var ( localVarHTTPMethod = _nethttp.MethodGet localVarPostBody interface{} - localVarReturnValue StatusPagesComponentArray - optionalParams ListComponentsOptionalParameters + localVarReturnValue DegradationArray + optionalParams ListDegradationsOptionalParameters ) if len(o) > 1 { - return localVarReturnValue, nil, datadog.ReportError("only one argument of type ListComponentsOptionalParameters is allowed") + return localVarReturnValue, nil, datadog.ReportError("only one argument of type ListDegradationsOptionalParameters is allowed") } if len(o) == 1 { optionalParams = o[0] } - localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.StatusPagesApi.ListComponents") + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.StatusPagesApi.ListDegradations") if err != nil { return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} } - localVarPath := localBasePath + "/api/v2/statuspages/{page_id}/components" - localVarPath = datadog.ReplacePathParameter(localVarPath, "{page_id}", _neturl.PathEscape(datadog.ParameterToString(pageId, ""))) + localVarPath := localBasePath + "/api/v2/statuspages/degradations" localVarHeaderParams := make(map[string]string) localVarQueryParams := _neturl.Values{} localVarFormParams := _neturl.Values{} + if optionalParams.FilterPageId != nil { + localVarQueryParams.Add("filter[page_id]", datadog.ParameterToString(*optionalParams.FilterPageId, "")) + } + if optionalParams.PageOffset != nil { + localVarQueryParams.Add("page[offset]", datadog.ParameterToString(*optionalParams.PageOffset, "")) + } + if optionalParams.PageLimit != nil { + localVarQueryParams.Add("page[limit]", datadog.ParameterToString(*optionalParams.PageLimit, "")) + } if optionalParams.Include != nil { localVarQueryParams.Add("include", datadog.ParameterToString(*optionalParams.Include, "")) } + if optionalParams.FilterStatus != nil { + localVarQueryParams.Add("filter[status]", datadog.ParameterToString(*optionalParams.FilterStatus, "")) + } + if optionalParams.Sort != nil { + localVarQueryParams.Add("sort", datadog.ParameterToString(*optionalParams.Sort, "")) + } + if optionalParams.FilterSourceId != nil { + localVarQueryParams.Add("filter[source_id]", datadog.ParameterToString(*optionalParams.FilterSourceId, "")) + } localVarHeaderParams["Accept"] = "application/json" if a.Client.Cfg.DelegatedTokenConfig != nil { @@ -1525,117 +2366,68 @@ func (a *StatusPagesApi) ListComponents(ctx _context.Context, pageId uuid.UUID, 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 -} - -// ListDegradationsOptionalParameters holds optional parameters for ListDegradations. -type ListDegradationsOptionalParameters struct { - FilterPageId *string - PageOffset *int64 - PageLimit *int64 - Include *string - FilterStatus *string - Sort *string -} + } -// NewListDegradationsOptionalParameters creates an empty struct for parameters. -func NewListDegradationsOptionalParameters() *ListDegradationsOptionalParameters { - this := ListDegradationsOptionalParameters{} - return &this -} + 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 + } -// WithFilterPageId sets the corresponding parameter name and returns the struct. -func (r *ListDegradationsOptionalParameters) WithFilterPageId(filterPageId string) *ListDegradationsOptionalParameters { - r.FilterPageId = &filterPageId - return r + return localVarReturnValue, localVarHTTPResponse, nil } -// WithPageOffset sets the corresponding parameter name and returns the struct. -func (r *ListDegradationsOptionalParameters) WithPageOffset(pageOffset int64) *ListDegradationsOptionalParameters { - r.PageOffset = &pageOffset - return r +// ListMaintenanceTemplatesOptionalParameters holds optional parameters for ListMaintenanceTemplates. +type ListMaintenanceTemplatesOptionalParameters struct { + Include *string } -// WithPageLimit sets the corresponding parameter name and returns the struct. -func (r *ListDegradationsOptionalParameters) WithPageLimit(pageLimit int64) *ListDegradationsOptionalParameters { - r.PageLimit = &pageLimit - return r +// NewListMaintenanceTemplatesOptionalParameters creates an empty struct for parameters. +func NewListMaintenanceTemplatesOptionalParameters() *ListMaintenanceTemplatesOptionalParameters { + this := ListMaintenanceTemplatesOptionalParameters{} + return &this } // WithInclude sets the corresponding parameter name and returns the struct. -func (r *ListDegradationsOptionalParameters) WithInclude(include string) *ListDegradationsOptionalParameters { +func (r *ListMaintenanceTemplatesOptionalParameters) WithInclude(include string) *ListMaintenanceTemplatesOptionalParameters { r.Include = &include return r } -// WithFilterStatus sets the corresponding parameter name and returns the struct. -func (r *ListDegradationsOptionalParameters) WithFilterStatus(filterStatus string) *ListDegradationsOptionalParameters { - r.FilterStatus = &filterStatus - return r -} - -// WithSort sets the corresponding parameter name and returns the struct. -func (r *ListDegradationsOptionalParameters) WithSort(sort string) *ListDegradationsOptionalParameters { - r.Sort = &sort - return r -} - -// ListDegradations List degradations. -// Lists all degradations for the organization. Optionally filter by status and page. -func (a *StatusPagesApi) ListDegradations(ctx _context.Context, o ...ListDegradationsOptionalParameters) (DegradationArray, *_nethttp.Response, error) { +// ListMaintenanceTemplates List maintenance templates. +// Lists all maintenance templates for a status page. +func (a *StatusPagesApi) ListMaintenanceTemplates(ctx _context.Context, pageId uuid.UUID, o ...ListMaintenanceTemplatesOptionalParameters) (MaintenanceTemplateArray, *_nethttp.Response, error) { var ( localVarHTTPMethod = _nethttp.MethodGet localVarPostBody interface{} - localVarReturnValue DegradationArray - optionalParams ListDegradationsOptionalParameters + localVarReturnValue MaintenanceTemplateArray + optionalParams ListMaintenanceTemplatesOptionalParameters ) if len(o) > 1 { - return localVarReturnValue, nil, datadog.ReportError("only one argument of type ListDegradationsOptionalParameters is allowed") + return localVarReturnValue, nil, datadog.ReportError("only one argument of type ListMaintenanceTemplatesOptionalParameters is allowed") } if len(o) == 1 { optionalParams = o[0] } - localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.StatusPagesApi.ListDegradations") + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.StatusPagesApi.ListMaintenanceTemplates") if err != nil { return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} } - localVarPath := localBasePath + "/api/v2/statuspages/degradations" + localVarPath := localBasePath + "/api/v2/statuspages/{page_id}/maintenance_templates" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{page_id}", _neturl.PathEscape(datadog.ParameterToString(pageId, ""))) localVarHeaderParams := make(map[string]string) localVarQueryParams := _neturl.Values{} localVarFormParams := _neturl.Values{} - if optionalParams.FilterPageId != nil { - localVarQueryParams.Add("filter[page_id]", datadog.ParameterToString(*optionalParams.FilterPageId, "")) - } - if optionalParams.PageOffset != nil { - localVarQueryParams.Add("page[offset]", datadog.ParameterToString(*optionalParams.PageOffset, "")) - } - if optionalParams.PageLimit != nil { - localVarQueryParams.Add("page[limit]", datadog.ParameterToString(*optionalParams.PageLimit, "")) - } if optionalParams.Include != nil { localVarQueryParams.Add("include", datadog.ParameterToString(*optionalParams.Include, "")) } - if optionalParams.FilterStatus != nil { - localVarQueryParams.Add("filter[status]", datadog.ParameterToString(*optionalParams.FilterStatus, "")) - } - if optionalParams.Sort != nil { - localVarQueryParams.Add("sort", datadog.ParameterToString(*optionalParams.Sort, "")) - } localVarHeaderParams["Accept"] = "application/json" if a.Client.Cfg.DelegatedTokenConfig != nil { @@ -2420,6 +3212,116 @@ func (a *StatusPagesApi) UpdateDegradation(ctx _context.Context, pageId uuid.UUI return localVarReturnValue, localVarHTTPResponse, nil } +// UpdateDegradationTemplateOptionalParameters holds optional parameters for UpdateDegradationTemplate. +type UpdateDegradationTemplateOptionalParameters struct { + Include *string +} + +// NewUpdateDegradationTemplateOptionalParameters creates an empty struct for parameters. +func NewUpdateDegradationTemplateOptionalParameters() *UpdateDegradationTemplateOptionalParameters { + this := UpdateDegradationTemplateOptionalParameters{} + return &this +} + +// WithInclude sets the corresponding parameter name and returns the struct. +func (r *UpdateDegradationTemplateOptionalParameters) WithInclude(include string) *UpdateDegradationTemplateOptionalParameters { + r.Include = &include + return r +} + +// UpdateDegradationTemplate Update degradation template. +// Updates an existing degradation template's attributes. +func (a *StatusPagesApi) UpdateDegradationTemplate(ctx _context.Context, templateId uuid.UUID, pageId uuid.UUID, body PatchDegradationTemplateRequest, o ...UpdateDegradationTemplateOptionalParameters) (DegradationTemplate, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPatch + localVarPostBody interface{} + localVarReturnValue DegradationTemplate + optionalParams UpdateDegradationTemplateOptionalParameters + ) + + if len(o) > 1 { + return localVarReturnValue, nil, datadog.ReportError("only one argument of type UpdateDegradationTemplateOptionalParameters is allowed") + } + if len(o) == 1 { + optionalParams = o[0] + } + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.StatusPagesApi.UpdateDegradationTemplate") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/statuspages/{page_id}/degradation_templates/{template_id}" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{template_id}", _neturl.PathEscape(datadog.ParameterToString(templateId, ""))) + localVarPath = datadog.ReplacePathParameter(localVarPath, "{page_id}", _neturl.PathEscape(datadog.ParameterToString(pageId, ""))) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + if optionalParams.Include != nil { + localVarQueryParams.Add("include", datadog.ParameterToString(*optionalParams.Include, "")) + } + 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 == 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 +} + // UpdateMaintenanceOptionalParameters holds optional parameters for UpdateMaintenance. type UpdateMaintenanceOptionalParameters struct { NotifySubscribers *bool @@ -2540,6 +3442,116 @@ func (a *StatusPagesApi) UpdateMaintenance(ctx _context.Context, pageId uuid.UUI return localVarReturnValue, localVarHTTPResponse, nil } +// UpdateMaintenanceTemplateOptionalParameters holds optional parameters for UpdateMaintenanceTemplate. +type UpdateMaintenanceTemplateOptionalParameters struct { + Include *string +} + +// NewUpdateMaintenanceTemplateOptionalParameters creates an empty struct for parameters. +func NewUpdateMaintenanceTemplateOptionalParameters() *UpdateMaintenanceTemplateOptionalParameters { + this := UpdateMaintenanceTemplateOptionalParameters{} + return &this +} + +// WithInclude sets the corresponding parameter name and returns the struct. +func (r *UpdateMaintenanceTemplateOptionalParameters) WithInclude(include string) *UpdateMaintenanceTemplateOptionalParameters { + r.Include = &include + return r +} + +// UpdateMaintenanceTemplate Update maintenance template. +// Updates an existing maintenance template's attributes. +func (a *StatusPagesApi) UpdateMaintenanceTemplate(ctx _context.Context, pageId uuid.UUID, templateId uuid.UUID, body PatchMaintenanceTemplateRequest, o ...UpdateMaintenanceTemplateOptionalParameters) (MaintenanceTemplate, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPatch + localVarPostBody interface{} + localVarReturnValue MaintenanceTemplate + optionalParams UpdateMaintenanceTemplateOptionalParameters + ) + + if len(o) > 1 { + return localVarReturnValue, nil, datadog.ReportError("only one argument of type UpdateMaintenanceTemplateOptionalParameters is allowed") + } + if len(o) == 1 { + optionalParams = o[0] + } + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.StatusPagesApi.UpdateMaintenanceTemplate") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/statuspages/{page_id}/maintenance_templates/{template_id}" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{page_id}", _neturl.PathEscape(datadog.ParameterToString(pageId, ""))) + localVarPath = datadog.ReplacePathParameter(localVarPath, "{template_id}", _neturl.PathEscape(datadog.ParameterToString(templateId, ""))) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + if optionalParams.Include != nil { + localVarQueryParams.Add("include", datadog.ParameterToString(*optionalParams.Include, "")) + } + 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 == 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 +} + // UpdateStatusPageOptionalParameters holds optional parameters for UpdateStatusPage. type UpdateStatusPageOptionalParameters struct { DeleteSubscribers *bool diff --git a/api/datadogV2/doc.go b/api/datadogV2/doc.go index 75ee96ab80d..4aff559702b 100644 --- a/api/datadogV2/doc.go +++ b/api/datadogV2/doc.go @@ -1265,18 +1265,26 @@ // - [StatusPagesApi.CreateBackfilledMaintenance] // - [StatusPagesApi.CreateComponent] // - [StatusPagesApi.CreateDegradation] +// - [StatusPagesApi.CreateDegradationTemplate] // - [StatusPagesApi.CreateMaintenance] +// - [StatusPagesApi.CreateMaintenanceTemplate] // - [StatusPagesApi.CreateStatusPage] // - [StatusPagesApi.DeleteComponent] // - [StatusPagesApi.DeleteDegradation] +// - [StatusPagesApi.DeleteDegradationTemplate] +// - [StatusPagesApi.DeleteMaintenanceTemplate] // - [StatusPagesApi.DeleteStatusPage] // - [StatusPagesApi.EditDegradationUpdate] // - [StatusPagesApi.GetComponent] // - [StatusPagesApi.GetDegradation] +// - [StatusPagesApi.GetDegradationTemplate] // - [StatusPagesApi.GetMaintenance] +// - [StatusPagesApi.GetMaintenanceTemplate] // - [StatusPagesApi.GetStatusPage] // - [StatusPagesApi.ListComponents] +// - [StatusPagesApi.ListDegradationTemplates] // - [StatusPagesApi.ListDegradations] +// - [StatusPagesApi.ListMaintenanceTemplates] // - [StatusPagesApi.ListMaintenances] // - [StatusPagesApi.ListStatusPages] // - [StatusPagesApi.PublishStatusPage] @@ -1284,7 +1292,9 @@ // - [StatusPagesApi.UnpublishStatusPage] // - [StatusPagesApi.UpdateComponent] // - [StatusPagesApi.UpdateDegradation] +// - [StatusPagesApi.UpdateDegradationTemplate] // - [StatusPagesApi.UpdateMaintenance] +// - [StatusPagesApi.UpdateMaintenanceTemplate] // - [StatusPagesApi.UpdateStatusPage] // - [StatuspageIntegrationApi.CreateStatuspageAccount] // - [StatuspageIntegrationApi.CreateStatuspageUrlSetting] diff --git a/api/datadogV2/model_create_backfilled_degradation_request_data.go b/api/datadogV2/model_create_backfilled_degradation_request_data.go index 550c7c839cd..7cb78973d20 100644 --- a/api/datadogV2/model_create_backfilled_degradation_request_data.go +++ b/api/datadogV2/model_create_backfilled_degradation_request_data.go @@ -14,6 +14,8 @@ import ( type CreateBackfilledDegradationRequestData struct { // The supported attributes for creating a backfilled degradation. Attributes *CreateBackfilledDegradationRequestDataAttributes `json:"attributes,omitempty"` + // The supported relationships for creating a backfilled degradation. + Relationships *CreateBackfilledDegradationRequestDataRelationships `json:"relationships,omitempty"` // Degradations resource type. Type PatchDegradationRequestDataType `json:"type"` // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct @@ -69,6 +71,34 @@ func (o *CreateBackfilledDegradationRequestData) SetAttributes(v CreateBackfille o.Attributes = &v } +// GetRelationships returns the Relationships field value if set, zero value otherwise. +func (o *CreateBackfilledDegradationRequestData) GetRelationships() CreateBackfilledDegradationRequestDataRelationships { + if o == nil || o.Relationships == nil { + var ret CreateBackfilledDegradationRequestDataRelationships + return ret + } + return *o.Relationships +} + +// GetRelationshipsOk returns a tuple with the Relationships field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CreateBackfilledDegradationRequestData) GetRelationshipsOk() (*CreateBackfilledDegradationRequestDataRelationships, bool) { + if o == nil || o.Relationships == nil { + return nil, false + } + return o.Relationships, true +} + +// HasRelationships returns a boolean if a field has been set. +func (o *CreateBackfilledDegradationRequestData) HasRelationships() bool { + return o != nil && o.Relationships != nil +} + +// SetRelationships gets a reference to the given CreateBackfilledDegradationRequestDataRelationships and assigns it to the Relationships field. +func (o *CreateBackfilledDegradationRequestData) SetRelationships(v CreateBackfilledDegradationRequestDataRelationships) { + o.Relationships = &v +} + // GetType returns the Type field value. func (o *CreateBackfilledDegradationRequestData) GetType() PatchDegradationRequestDataType { if o == nil { @@ -101,6 +131,9 @@ func (o CreateBackfilledDegradationRequestData) MarshalJSON() ([]byte, error) { if o.Attributes != nil { toSerialize["attributes"] = o.Attributes } + if o.Relationships != nil { + toSerialize["relationships"] = o.Relationships + } toSerialize["type"] = o.Type for key, value := range o.AdditionalProperties { @@ -112,8 +145,9 @@ func (o CreateBackfilledDegradationRequestData) MarshalJSON() ([]byte, error) { // UnmarshalJSON deserializes the given payload. func (o *CreateBackfilledDegradationRequestData) UnmarshalJSON(bytes []byte) (err error) { all := struct { - Attributes *CreateBackfilledDegradationRequestDataAttributes `json:"attributes,omitempty"` - Type *PatchDegradationRequestDataType `json:"type"` + Attributes *CreateBackfilledDegradationRequestDataAttributes `json:"attributes,omitempty"` + Relationships *CreateBackfilledDegradationRequestDataRelationships `json:"relationships,omitempty"` + Type *PatchDegradationRequestDataType `json:"type"` }{} if err = datadog.Unmarshal(bytes, &all); err != nil { return datadog.Unmarshal(bytes, &o.UnparsedObject) @@ -123,7 +157,7 @@ func (o *CreateBackfilledDegradationRequestData) UnmarshalJSON(bytes []byte) (er } additionalProperties := make(map[string]interface{}) if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { - datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "type"}) + datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "relationships", "type"}) } else { return err } @@ -133,6 +167,10 @@ func (o *CreateBackfilledDegradationRequestData) UnmarshalJSON(bytes []byte) (er hasInvalidField = true } o.Attributes = all.Attributes + if all.Relationships != nil && all.Relationships.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Relationships = all.Relationships if !all.Type.IsValid() { hasInvalidField = true } else { diff --git a/api/datadogV2/model_create_backfilled_degradation_request_data_relationships.go b/api/datadogV2/model_create_backfilled_degradation_request_data_relationships.go new file mode 100644 index 00000000000..31d1d719822 --- /dev/null +++ b/api/datadogV2/model_create_backfilled_degradation_request_data_relationships.go @@ -0,0 +1,111 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// CreateBackfilledDegradationRequestDataRelationships The supported relationships for creating a backfilled degradation. +type CreateBackfilledDegradationRequestDataRelationships struct { + // The template used to create the backfilled degradation. + Template *CreateBackfilledDegradationRequestDataRelationshipsTemplate `json:"template,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:"-"` +} + +// NewCreateBackfilledDegradationRequestDataRelationships instantiates a new CreateBackfilledDegradationRequestDataRelationships 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 NewCreateBackfilledDegradationRequestDataRelationships() *CreateBackfilledDegradationRequestDataRelationships { + this := CreateBackfilledDegradationRequestDataRelationships{} + return &this +} + +// NewCreateBackfilledDegradationRequestDataRelationshipsWithDefaults instantiates a new CreateBackfilledDegradationRequestDataRelationships 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 NewCreateBackfilledDegradationRequestDataRelationshipsWithDefaults() *CreateBackfilledDegradationRequestDataRelationships { + this := CreateBackfilledDegradationRequestDataRelationships{} + return &this +} + +// GetTemplate returns the Template field value if set, zero value otherwise. +func (o *CreateBackfilledDegradationRequestDataRelationships) GetTemplate() CreateBackfilledDegradationRequestDataRelationshipsTemplate { + if o == nil || o.Template == nil { + var ret CreateBackfilledDegradationRequestDataRelationshipsTemplate + return ret + } + return *o.Template +} + +// GetTemplateOk returns a tuple with the Template field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CreateBackfilledDegradationRequestDataRelationships) GetTemplateOk() (*CreateBackfilledDegradationRequestDataRelationshipsTemplate, bool) { + if o == nil || o.Template == nil { + return nil, false + } + return o.Template, true +} + +// HasTemplate returns a boolean if a field has been set. +func (o *CreateBackfilledDegradationRequestDataRelationships) HasTemplate() bool { + return o != nil && o.Template != nil +} + +// SetTemplate gets a reference to the given CreateBackfilledDegradationRequestDataRelationshipsTemplate and assigns it to the Template field. +func (o *CreateBackfilledDegradationRequestDataRelationships) SetTemplate(v CreateBackfilledDegradationRequestDataRelationshipsTemplate) { + o.Template = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o CreateBackfilledDegradationRequestDataRelationships) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Template != nil { + toSerialize["template"] = o.Template + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *CreateBackfilledDegradationRequestDataRelationships) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Template *CreateBackfilledDegradationRequestDataRelationshipsTemplate `json:"template,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"template"}) + } else { + return err + } + + hasInvalidField := false + if all.Template != nil && all.Template.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Template = all.Template + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_create_backfilled_degradation_request_data_relationships_template.go b/api/datadogV2/model_create_backfilled_degradation_request_data_relationships_template.go new file mode 100644 index 00000000000..30f2d5a673c --- /dev/null +++ b/api/datadogV2/model_create_backfilled_degradation_request_data_relationships_template.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" +) + +// CreateBackfilledDegradationRequestDataRelationshipsTemplate The template used to create the backfilled degradation. +type CreateBackfilledDegradationRequestDataRelationshipsTemplate struct { + // The data object identifying the template used to create the backfilled degradation. + Data CreateBackfilledDegradationRequestDataRelationshipsTemplateData `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:"-"` +} + +// NewCreateBackfilledDegradationRequestDataRelationshipsTemplate instantiates a new CreateBackfilledDegradationRequestDataRelationshipsTemplate 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 NewCreateBackfilledDegradationRequestDataRelationshipsTemplate(data CreateBackfilledDegradationRequestDataRelationshipsTemplateData) *CreateBackfilledDegradationRequestDataRelationshipsTemplate { + this := CreateBackfilledDegradationRequestDataRelationshipsTemplate{} + this.Data = data + return &this +} + +// NewCreateBackfilledDegradationRequestDataRelationshipsTemplateWithDefaults instantiates a new CreateBackfilledDegradationRequestDataRelationshipsTemplate 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 NewCreateBackfilledDegradationRequestDataRelationshipsTemplateWithDefaults() *CreateBackfilledDegradationRequestDataRelationshipsTemplate { + this := CreateBackfilledDegradationRequestDataRelationshipsTemplate{} + return &this +} + +// GetData returns the Data field value. +func (o *CreateBackfilledDegradationRequestDataRelationshipsTemplate) GetData() CreateBackfilledDegradationRequestDataRelationshipsTemplateData { + if o == nil { + var ret CreateBackfilledDegradationRequestDataRelationshipsTemplateData + 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 *CreateBackfilledDegradationRequestDataRelationshipsTemplate) GetDataOk() (*CreateBackfilledDegradationRequestDataRelationshipsTemplateData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *CreateBackfilledDegradationRequestDataRelationshipsTemplate) SetData(v CreateBackfilledDegradationRequestDataRelationshipsTemplateData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o CreateBackfilledDegradationRequestDataRelationshipsTemplate) 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 *CreateBackfilledDegradationRequestDataRelationshipsTemplate) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *CreateBackfilledDegradationRequestDataRelationshipsTemplateData `json:"data"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Data == nil { + return fmt.Errorf("required field data missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + + hasInvalidField := false + if all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Data = *all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_create_backfilled_degradation_request_data_relationships_template_data.go b/api/datadogV2/model_create_backfilled_degradation_request_data_relationships_template_data.go new file mode 100644 index 00000000000..974a98c2967 --- /dev/null +++ b/api/datadogV2/model_create_backfilled_degradation_request_data_relationships_template_data.go @@ -0,0 +1,145 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// CreateBackfilledDegradationRequestDataRelationshipsTemplateData The data object identifying the template used to create the backfilled degradation. +type CreateBackfilledDegradationRequestDataRelationshipsTemplateData struct { + // The ID of the degradation template. + Id string `json:"id"` + // Degradation templates resource type. + Type PatchDegradationTemplateRequestDataType `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:"-"` +} + +// NewCreateBackfilledDegradationRequestDataRelationshipsTemplateData instantiates a new CreateBackfilledDegradationRequestDataRelationshipsTemplateData 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 NewCreateBackfilledDegradationRequestDataRelationshipsTemplateData(id string, typeVar PatchDegradationTemplateRequestDataType) *CreateBackfilledDegradationRequestDataRelationshipsTemplateData { + this := CreateBackfilledDegradationRequestDataRelationshipsTemplateData{} + this.Id = id + this.Type = typeVar + return &this +} + +// NewCreateBackfilledDegradationRequestDataRelationshipsTemplateDataWithDefaults instantiates a new CreateBackfilledDegradationRequestDataRelationshipsTemplateData 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 NewCreateBackfilledDegradationRequestDataRelationshipsTemplateDataWithDefaults() *CreateBackfilledDegradationRequestDataRelationshipsTemplateData { + this := CreateBackfilledDegradationRequestDataRelationshipsTemplateData{} + var typeVar PatchDegradationTemplateRequestDataType = PATCHDEGRADATIONTEMPLATEREQUESTDATATYPE_DEGRADATION_TEMPLATES + this.Type = typeVar + return &this +} + +// GetId returns the Id field value. +func (o *CreateBackfilledDegradationRequestDataRelationshipsTemplateData) GetId() string { + if o == nil { + var ret string + 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 *CreateBackfilledDegradationRequestDataRelationshipsTemplateData) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Id, true +} + +// SetId sets field value. +func (o *CreateBackfilledDegradationRequestDataRelationshipsTemplateData) SetId(v string) { + o.Id = v +} + +// GetType returns the Type field value. +func (o *CreateBackfilledDegradationRequestDataRelationshipsTemplateData) GetType() PatchDegradationTemplateRequestDataType { + if o == nil { + var ret PatchDegradationTemplateRequestDataType + 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 *CreateBackfilledDegradationRequestDataRelationshipsTemplateData) GetTypeOk() (*PatchDegradationTemplateRequestDataType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *CreateBackfilledDegradationRequestDataRelationshipsTemplateData) SetType(v PatchDegradationTemplateRequestDataType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o CreateBackfilledDegradationRequestDataRelationshipsTemplateData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["id"] = o.Id + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *CreateBackfilledDegradationRequestDataRelationshipsTemplateData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Id *string `json:"id"` + Type *PatchDegradationTemplateRequestDataType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Id == nil { + return fmt.Errorf("required field id missing") + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"id", "type"}) + } else { + return err + } + + hasInvalidField := false + o.Id = *all.Id + if !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = *all.Type + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_create_backfilled_maintenance_request_data.go b/api/datadogV2/model_create_backfilled_maintenance_request_data.go index 4de6bbc81ac..d1cca07ea75 100644 --- a/api/datadogV2/model_create_backfilled_maintenance_request_data.go +++ b/api/datadogV2/model_create_backfilled_maintenance_request_data.go @@ -14,6 +14,8 @@ import ( type CreateBackfilledMaintenanceRequestData struct { // The supported attributes for creating a backfilled maintenance. Attributes *CreateBackfilledMaintenanceRequestDataAttributes `json:"attributes,omitempty"` + // The supported relationships for creating a backfilled maintenance. + Relationships *CreateBackfilledMaintenanceRequestDataRelationships `json:"relationships,omitempty"` // Maintenances resource type. Type PatchMaintenanceRequestDataType `json:"type"` // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct @@ -69,6 +71,34 @@ func (o *CreateBackfilledMaintenanceRequestData) SetAttributes(v CreateBackfille o.Attributes = &v } +// GetRelationships returns the Relationships field value if set, zero value otherwise. +func (o *CreateBackfilledMaintenanceRequestData) GetRelationships() CreateBackfilledMaintenanceRequestDataRelationships { + if o == nil || o.Relationships == nil { + var ret CreateBackfilledMaintenanceRequestDataRelationships + return ret + } + return *o.Relationships +} + +// GetRelationshipsOk returns a tuple with the Relationships field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CreateBackfilledMaintenanceRequestData) GetRelationshipsOk() (*CreateBackfilledMaintenanceRequestDataRelationships, bool) { + if o == nil || o.Relationships == nil { + return nil, false + } + return o.Relationships, true +} + +// HasRelationships returns a boolean if a field has been set. +func (o *CreateBackfilledMaintenanceRequestData) HasRelationships() bool { + return o != nil && o.Relationships != nil +} + +// SetRelationships gets a reference to the given CreateBackfilledMaintenanceRequestDataRelationships and assigns it to the Relationships field. +func (o *CreateBackfilledMaintenanceRequestData) SetRelationships(v CreateBackfilledMaintenanceRequestDataRelationships) { + o.Relationships = &v +} + // GetType returns the Type field value. func (o *CreateBackfilledMaintenanceRequestData) GetType() PatchMaintenanceRequestDataType { if o == nil { @@ -101,6 +131,9 @@ func (o CreateBackfilledMaintenanceRequestData) MarshalJSON() ([]byte, error) { if o.Attributes != nil { toSerialize["attributes"] = o.Attributes } + if o.Relationships != nil { + toSerialize["relationships"] = o.Relationships + } toSerialize["type"] = o.Type for key, value := range o.AdditionalProperties { @@ -112,8 +145,9 @@ func (o CreateBackfilledMaintenanceRequestData) MarshalJSON() ([]byte, error) { // UnmarshalJSON deserializes the given payload. func (o *CreateBackfilledMaintenanceRequestData) UnmarshalJSON(bytes []byte) (err error) { all := struct { - Attributes *CreateBackfilledMaintenanceRequestDataAttributes `json:"attributes,omitempty"` - Type *PatchMaintenanceRequestDataType `json:"type"` + Attributes *CreateBackfilledMaintenanceRequestDataAttributes `json:"attributes,omitempty"` + Relationships *CreateBackfilledMaintenanceRequestDataRelationships `json:"relationships,omitempty"` + Type *PatchMaintenanceRequestDataType `json:"type"` }{} if err = datadog.Unmarshal(bytes, &all); err != nil { return datadog.Unmarshal(bytes, &o.UnparsedObject) @@ -123,7 +157,7 @@ func (o *CreateBackfilledMaintenanceRequestData) UnmarshalJSON(bytes []byte) (er } additionalProperties := make(map[string]interface{}) if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { - datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "type"}) + datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "relationships", "type"}) } else { return err } @@ -133,6 +167,10 @@ func (o *CreateBackfilledMaintenanceRequestData) UnmarshalJSON(bytes []byte) (er hasInvalidField = true } o.Attributes = all.Attributes + if all.Relationships != nil && all.Relationships.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Relationships = all.Relationships if !all.Type.IsValid() { hasInvalidField = true } else { diff --git a/api/datadogV2/model_create_backfilled_maintenance_request_data_relationships.go b/api/datadogV2/model_create_backfilled_maintenance_request_data_relationships.go new file mode 100644 index 00000000000..352693b5068 --- /dev/null +++ b/api/datadogV2/model_create_backfilled_maintenance_request_data_relationships.go @@ -0,0 +1,111 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// CreateBackfilledMaintenanceRequestDataRelationships The supported relationships for creating a backfilled maintenance. +type CreateBackfilledMaintenanceRequestDataRelationships struct { + // The template used to create the backfilled maintenance. + Template *CreateBackfilledMaintenanceRequestDataRelationshipsTemplate `json:"template,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:"-"` +} + +// NewCreateBackfilledMaintenanceRequestDataRelationships instantiates a new CreateBackfilledMaintenanceRequestDataRelationships 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 NewCreateBackfilledMaintenanceRequestDataRelationships() *CreateBackfilledMaintenanceRequestDataRelationships { + this := CreateBackfilledMaintenanceRequestDataRelationships{} + return &this +} + +// NewCreateBackfilledMaintenanceRequestDataRelationshipsWithDefaults instantiates a new CreateBackfilledMaintenanceRequestDataRelationships 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 NewCreateBackfilledMaintenanceRequestDataRelationshipsWithDefaults() *CreateBackfilledMaintenanceRequestDataRelationships { + this := CreateBackfilledMaintenanceRequestDataRelationships{} + return &this +} + +// GetTemplate returns the Template field value if set, zero value otherwise. +func (o *CreateBackfilledMaintenanceRequestDataRelationships) GetTemplate() CreateBackfilledMaintenanceRequestDataRelationshipsTemplate { + if o == nil || o.Template == nil { + var ret CreateBackfilledMaintenanceRequestDataRelationshipsTemplate + return ret + } + return *o.Template +} + +// GetTemplateOk returns a tuple with the Template field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CreateBackfilledMaintenanceRequestDataRelationships) GetTemplateOk() (*CreateBackfilledMaintenanceRequestDataRelationshipsTemplate, bool) { + if o == nil || o.Template == nil { + return nil, false + } + return o.Template, true +} + +// HasTemplate returns a boolean if a field has been set. +func (o *CreateBackfilledMaintenanceRequestDataRelationships) HasTemplate() bool { + return o != nil && o.Template != nil +} + +// SetTemplate gets a reference to the given CreateBackfilledMaintenanceRequestDataRelationshipsTemplate and assigns it to the Template field. +func (o *CreateBackfilledMaintenanceRequestDataRelationships) SetTemplate(v CreateBackfilledMaintenanceRequestDataRelationshipsTemplate) { + o.Template = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o CreateBackfilledMaintenanceRequestDataRelationships) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Template != nil { + toSerialize["template"] = o.Template + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *CreateBackfilledMaintenanceRequestDataRelationships) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Template *CreateBackfilledMaintenanceRequestDataRelationshipsTemplate `json:"template,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"template"}) + } else { + return err + } + + hasInvalidField := false + if all.Template != nil && all.Template.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Template = all.Template + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_create_backfilled_maintenance_request_data_relationships_template.go b/api/datadogV2/model_create_backfilled_maintenance_request_data_relationships_template.go new file mode 100644 index 00000000000..4a95bb3cf1d --- /dev/null +++ b/api/datadogV2/model_create_backfilled_maintenance_request_data_relationships_template.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" +) + +// CreateBackfilledMaintenanceRequestDataRelationshipsTemplate The template used to create the backfilled maintenance. +type CreateBackfilledMaintenanceRequestDataRelationshipsTemplate struct { + // The data object identifying the template used to create the backfilled maintenance. + Data CreateBackfilledMaintenanceRequestDataRelationshipsTemplateData `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:"-"` +} + +// NewCreateBackfilledMaintenanceRequestDataRelationshipsTemplate instantiates a new CreateBackfilledMaintenanceRequestDataRelationshipsTemplate 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 NewCreateBackfilledMaintenanceRequestDataRelationshipsTemplate(data CreateBackfilledMaintenanceRequestDataRelationshipsTemplateData) *CreateBackfilledMaintenanceRequestDataRelationshipsTemplate { + this := CreateBackfilledMaintenanceRequestDataRelationshipsTemplate{} + this.Data = data + return &this +} + +// NewCreateBackfilledMaintenanceRequestDataRelationshipsTemplateWithDefaults instantiates a new CreateBackfilledMaintenanceRequestDataRelationshipsTemplate 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 NewCreateBackfilledMaintenanceRequestDataRelationshipsTemplateWithDefaults() *CreateBackfilledMaintenanceRequestDataRelationshipsTemplate { + this := CreateBackfilledMaintenanceRequestDataRelationshipsTemplate{} + return &this +} + +// GetData returns the Data field value. +func (o *CreateBackfilledMaintenanceRequestDataRelationshipsTemplate) GetData() CreateBackfilledMaintenanceRequestDataRelationshipsTemplateData { + if o == nil { + var ret CreateBackfilledMaintenanceRequestDataRelationshipsTemplateData + 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 *CreateBackfilledMaintenanceRequestDataRelationshipsTemplate) GetDataOk() (*CreateBackfilledMaintenanceRequestDataRelationshipsTemplateData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *CreateBackfilledMaintenanceRequestDataRelationshipsTemplate) SetData(v CreateBackfilledMaintenanceRequestDataRelationshipsTemplateData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o CreateBackfilledMaintenanceRequestDataRelationshipsTemplate) 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 *CreateBackfilledMaintenanceRequestDataRelationshipsTemplate) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *CreateBackfilledMaintenanceRequestDataRelationshipsTemplateData `json:"data"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Data == nil { + return fmt.Errorf("required field data missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + + hasInvalidField := false + if all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Data = *all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_create_backfilled_maintenance_request_data_relationships_template_data.go b/api/datadogV2/model_create_backfilled_maintenance_request_data_relationships_template_data.go new file mode 100644 index 00000000000..4b54b45c80a --- /dev/null +++ b/api/datadogV2/model_create_backfilled_maintenance_request_data_relationships_template_data.go @@ -0,0 +1,145 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// CreateBackfilledMaintenanceRequestDataRelationshipsTemplateData The data object identifying the template used to create the backfilled maintenance. +type CreateBackfilledMaintenanceRequestDataRelationshipsTemplateData struct { + // The ID of the maintenance template. + Id string `json:"id"` + // Maintenance templates resource type. + Type PatchMaintenanceTemplateRequestDataType `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:"-"` +} + +// NewCreateBackfilledMaintenanceRequestDataRelationshipsTemplateData instantiates a new CreateBackfilledMaintenanceRequestDataRelationshipsTemplateData 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 NewCreateBackfilledMaintenanceRequestDataRelationshipsTemplateData(id string, typeVar PatchMaintenanceTemplateRequestDataType) *CreateBackfilledMaintenanceRequestDataRelationshipsTemplateData { + this := CreateBackfilledMaintenanceRequestDataRelationshipsTemplateData{} + this.Id = id + this.Type = typeVar + return &this +} + +// NewCreateBackfilledMaintenanceRequestDataRelationshipsTemplateDataWithDefaults instantiates a new CreateBackfilledMaintenanceRequestDataRelationshipsTemplateData 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 NewCreateBackfilledMaintenanceRequestDataRelationshipsTemplateDataWithDefaults() *CreateBackfilledMaintenanceRequestDataRelationshipsTemplateData { + this := CreateBackfilledMaintenanceRequestDataRelationshipsTemplateData{} + var typeVar PatchMaintenanceTemplateRequestDataType = PATCHMAINTENANCETEMPLATEREQUESTDATATYPE_MAINTENANCE_TEMPLATES + this.Type = typeVar + return &this +} + +// GetId returns the Id field value. +func (o *CreateBackfilledMaintenanceRequestDataRelationshipsTemplateData) GetId() string { + if o == nil { + var ret string + 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 *CreateBackfilledMaintenanceRequestDataRelationshipsTemplateData) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Id, true +} + +// SetId sets field value. +func (o *CreateBackfilledMaintenanceRequestDataRelationshipsTemplateData) SetId(v string) { + o.Id = v +} + +// GetType returns the Type field value. +func (o *CreateBackfilledMaintenanceRequestDataRelationshipsTemplateData) GetType() PatchMaintenanceTemplateRequestDataType { + if o == nil { + var ret PatchMaintenanceTemplateRequestDataType + 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 *CreateBackfilledMaintenanceRequestDataRelationshipsTemplateData) GetTypeOk() (*PatchMaintenanceTemplateRequestDataType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *CreateBackfilledMaintenanceRequestDataRelationshipsTemplateData) SetType(v PatchMaintenanceTemplateRequestDataType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o CreateBackfilledMaintenanceRequestDataRelationshipsTemplateData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["id"] = o.Id + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *CreateBackfilledMaintenanceRequestDataRelationshipsTemplateData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Id *string `json:"id"` + Type *PatchMaintenanceTemplateRequestDataType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Id == nil { + return fmt.Errorf("required field id missing") + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"id", "type"}) + } else { + return err + } + + hasInvalidField := false + o.Id = *all.Id + if !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = *all.Type + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_create_degradation_request_data.go b/api/datadogV2/model_create_degradation_request_data.go index 5de711ab39e..321c1d2f535 100644 --- a/api/datadogV2/model_create_degradation_request_data.go +++ b/api/datadogV2/model_create_degradation_request_data.go @@ -14,6 +14,8 @@ import ( type CreateDegradationRequestData struct { // The supported attributes for creating a degradation. Attributes CreateDegradationRequestDataAttributes `json:"attributes"` + // The supported relationships for creating a degradation. + Relationships *CreateDegradationRequestDataRelationships `json:"relationships,omitempty"` // Degradations resource type. Type PatchDegradationRequestDataType `json:"type"` // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct @@ -65,6 +67,34 @@ func (o *CreateDegradationRequestData) SetAttributes(v CreateDegradationRequestD o.Attributes = v } +// GetRelationships returns the Relationships field value if set, zero value otherwise. +func (o *CreateDegradationRequestData) GetRelationships() CreateDegradationRequestDataRelationships { + if o == nil || o.Relationships == nil { + var ret CreateDegradationRequestDataRelationships + return ret + } + return *o.Relationships +} + +// GetRelationshipsOk returns a tuple with the Relationships field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CreateDegradationRequestData) GetRelationshipsOk() (*CreateDegradationRequestDataRelationships, bool) { + if o == nil || o.Relationships == nil { + return nil, false + } + return o.Relationships, true +} + +// HasRelationships returns a boolean if a field has been set. +func (o *CreateDegradationRequestData) HasRelationships() bool { + return o != nil && o.Relationships != nil +} + +// SetRelationships gets a reference to the given CreateDegradationRequestDataRelationships and assigns it to the Relationships field. +func (o *CreateDegradationRequestData) SetRelationships(v CreateDegradationRequestDataRelationships) { + o.Relationships = &v +} + // GetType returns the Type field value. func (o *CreateDegradationRequestData) GetType() PatchDegradationRequestDataType { if o == nil { @@ -95,6 +125,9 @@ func (o CreateDegradationRequestData) MarshalJSON() ([]byte, error) { return datadog.Marshal(o.UnparsedObject) } toSerialize["attributes"] = o.Attributes + if o.Relationships != nil { + toSerialize["relationships"] = o.Relationships + } toSerialize["type"] = o.Type for key, value := range o.AdditionalProperties { @@ -106,8 +139,9 @@ func (o CreateDegradationRequestData) MarshalJSON() ([]byte, error) { // UnmarshalJSON deserializes the given payload. func (o *CreateDegradationRequestData) UnmarshalJSON(bytes []byte) (err error) { all := struct { - Attributes *CreateDegradationRequestDataAttributes `json:"attributes"` - Type *PatchDegradationRequestDataType `json:"type"` + Attributes *CreateDegradationRequestDataAttributes `json:"attributes"` + Relationships *CreateDegradationRequestDataRelationships `json:"relationships,omitempty"` + Type *PatchDegradationRequestDataType `json:"type"` }{} if err = datadog.Unmarshal(bytes, &all); err != nil { return datadog.Unmarshal(bytes, &o.UnparsedObject) @@ -120,7 +154,7 @@ func (o *CreateDegradationRequestData) UnmarshalJSON(bytes []byte) (err error) { } additionalProperties := make(map[string]interface{}) if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { - datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "type"}) + datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "relationships", "type"}) } else { return err } @@ -130,6 +164,10 @@ func (o *CreateDegradationRequestData) UnmarshalJSON(bytes []byte) (err error) { hasInvalidField = true } o.Attributes = *all.Attributes + if all.Relationships != nil && all.Relationships.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Relationships = all.Relationships if !all.Type.IsValid() { hasInvalidField = true } else { diff --git a/api/datadogV2/model_create_degradation_request_data_relationships.go b/api/datadogV2/model_create_degradation_request_data_relationships.go new file mode 100644 index 00000000000..06e75b6b06b --- /dev/null +++ b/api/datadogV2/model_create_degradation_request_data_relationships.go @@ -0,0 +1,111 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// CreateDegradationRequestDataRelationships The supported relationships for creating a degradation. +type CreateDegradationRequestDataRelationships struct { + // The template used to create the degradation. + Template *CreateDegradationRequestDataRelationshipsTemplate `json:"template,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:"-"` +} + +// NewCreateDegradationRequestDataRelationships instantiates a new CreateDegradationRequestDataRelationships 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 NewCreateDegradationRequestDataRelationships() *CreateDegradationRequestDataRelationships { + this := CreateDegradationRequestDataRelationships{} + return &this +} + +// NewCreateDegradationRequestDataRelationshipsWithDefaults instantiates a new CreateDegradationRequestDataRelationships 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 NewCreateDegradationRequestDataRelationshipsWithDefaults() *CreateDegradationRequestDataRelationships { + this := CreateDegradationRequestDataRelationships{} + return &this +} + +// GetTemplate returns the Template field value if set, zero value otherwise. +func (o *CreateDegradationRequestDataRelationships) GetTemplate() CreateDegradationRequestDataRelationshipsTemplate { + if o == nil || o.Template == nil { + var ret CreateDegradationRequestDataRelationshipsTemplate + return ret + } + return *o.Template +} + +// GetTemplateOk returns a tuple with the Template field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CreateDegradationRequestDataRelationships) GetTemplateOk() (*CreateDegradationRequestDataRelationshipsTemplate, bool) { + if o == nil || o.Template == nil { + return nil, false + } + return o.Template, true +} + +// HasTemplate returns a boolean if a field has been set. +func (o *CreateDegradationRequestDataRelationships) HasTemplate() bool { + return o != nil && o.Template != nil +} + +// SetTemplate gets a reference to the given CreateDegradationRequestDataRelationshipsTemplate and assigns it to the Template field. +func (o *CreateDegradationRequestDataRelationships) SetTemplate(v CreateDegradationRequestDataRelationshipsTemplate) { + o.Template = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o CreateDegradationRequestDataRelationships) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Template != nil { + toSerialize["template"] = o.Template + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *CreateDegradationRequestDataRelationships) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Template *CreateDegradationRequestDataRelationshipsTemplate `json:"template,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"template"}) + } else { + return err + } + + hasInvalidField := false + if all.Template != nil && all.Template.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Template = all.Template + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_create_degradation_request_data_relationships_template.go b/api/datadogV2/model_create_degradation_request_data_relationships_template.go new file mode 100644 index 00000000000..661a2fc2d3b --- /dev/null +++ b/api/datadogV2/model_create_degradation_request_data_relationships_template.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" +) + +// CreateDegradationRequestDataRelationshipsTemplate The template used to create the degradation. +type CreateDegradationRequestDataRelationshipsTemplate struct { + // The data object identifying the template used to create the degradation. + Data CreateDegradationRequestDataRelationshipsTemplateData `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:"-"` +} + +// NewCreateDegradationRequestDataRelationshipsTemplate instantiates a new CreateDegradationRequestDataRelationshipsTemplate 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 NewCreateDegradationRequestDataRelationshipsTemplate(data CreateDegradationRequestDataRelationshipsTemplateData) *CreateDegradationRequestDataRelationshipsTemplate { + this := CreateDegradationRequestDataRelationshipsTemplate{} + this.Data = data + return &this +} + +// NewCreateDegradationRequestDataRelationshipsTemplateWithDefaults instantiates a new CreateDegradationRequestDataRelationshipsTemplate 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 NewCreateDegradationRequestDataRelationshipsTemplateWithDefaults() *CreateDegradationRequestDataRelationshipsTemplate { + this := CreateDegradationRequestDataRelationshipsTemplate{} + return &this +} + +// GetData returns the Data field value. +func (o *CreateDegradationRequestDataRelationshipsTemplate) GetData() CreateDegradationRequestDataRelationshipsTemplateData { + if o == nil { + var ret CreateDegradationRequestDataRelationshipsTemplateData + 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 *CreateDegradationRequestDataRelationshipsTemplate) GetDataOk() (*CreateDegradationRequestDataRelationshipsTemplateData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *CreateDegradationRequestDataRelationshipsTemplate) SetData(v CreateDegradationRequestDataRelationshipsTemplateData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o CreateDegradationRequestDataRelationshipsTemplate) 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 *CreateDegradationRequestDataRelationshipsTemplate) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *CreateDegradationRequestDataRelationshipsTemplateData `json:"data"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Data == nil { + return fmt.Errorf("required field data missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + + hasInvalidField := false + if all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Data = *all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_create_degradation_request_data_relationships_template_data.go b/api/datadogV2/model_create_degradation_request_data_relationships_template_data.go new file mode 100644 index 00000000000..c147b0794da --- /dev/null +++ b/api/datadogV2/model_create_degradation_request_data_relationships_template_data.go @@ -0,0 +1,145 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// CreateDegradationRequestDataRelationshipsTemplateData The data object identifying the template used to create the degradation. +type CreateDegradationRequestDataRelationshipsTemplateData struct { + // The ID of the degradation template. + Id string `json:"id"` + // Degradation templates resource type. + Type PatchDegradationTemplateRequestDataType `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:"-"` +} + +// NewCreateDegradationRequestDataRelationshipsTemplateData instantiates a new CreateDegradationRequestDataRelationshipsTemplateData 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 NewCreateDegradationRequestDataRelationshipsTemplateData(id string, typeVar PatchDegradationTemplateRequestDataType) *CreateDegradationRequestDataRelationshipsTemplateData { + this := CreateDegradationRequestDataRelationshipsTemplateData{} + this.Id = id + this.Type = typeVar + return &this +} + +// NewCreateDegradationRequestDataRelationshipsTemplateDataWithDefaults instantiates a new CreateDegradationRequestDataRelationshipsTemplateData 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 NewCreateDegradationRequestDataRelationshipsTemplateDataWithDefaults() *CreateDegradationRequestDataRelationshipsTemplateData { + this := CreateDegradationRequestDataRelationshipsTemplateData{} + var typeVar PatchDegradationTemplateRequestDataType = PATCHDEGRADATIONTEMPLATEREQUESTDATATYPE_DEGRADATION_TEMPLATES + this.Type = typeVar + return &this +} + +// GetId returns the Id field value. +func (o *CreateDegradationRequestDataRelationshipsTemplateData) GetId() string { + if o == nil { + var ret string + 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 *CreateDegradationRequestDataRelationshipsTemplateData) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Id, true +} + +// SetId sets field value. +func (o *CreateDegradationRequestDataRelationshipsTemplateData) SetId(v string) { + o.Id = v +} + +// GetType returns the Type field value. +func (o *CreateDegradationRequestDataRelationshipsTemplateData) GetType() PatchDegradationTemplateRequestDataType { + if o == nil { + var ret PatchDegradationTemplateRequestDataType + 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 *CreateDegradationRequestDataRelationshipsTemplateData) GetTypeOk() (*PatchDegradationTemplateRequestDataType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *CreateDegradationRequestDataRelationshipsTemplateData) SetType(v PatchDegradationTemplateRequestDataType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o CreateDegradationRequestDataRelationshipsTemplateData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["id"] = o.Id + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *CreateDegradationRequestDataRelationshipsTemplateData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Id *string `json:"id"` + Type *PatchDegradationTemplateRequestDataType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Id == nil { + return fmt.Errorf("required field id missing") + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"id", "type"}) + } else { + return err + } + + hasInvalidField := false + o.Id = *all.Id + if !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = *all.Type + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_create_degradation_template_request.go b/api/datadogV2/model_create_degradation_template_request.go new file mode 100644 index 00000000000..999ad6f25b3 --- /dev/null +++ b/api/datadogV2/model_create_degradation_template_request.go @@ -0,0 +1,111 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// CreateDegradationTemplateRequest Request object for creating a degradation template. +type CreateDegradationTemplateRequest struct { + // The data object for creating a degradation template. + Data *CreateDegradationTemplateRequestData `json:"data,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewCreateDegradationTemplateRequest instantiates a new CreateDegradationTemplateRequest 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 NewCreateDegradationTemplateRequest() *CreateDegradationTemplateRequest { + this := CreateDegradationTemplateRequest{} + return &this +} + +// NewCreateDegradationTemplateRequestWithDefaults instantiates a new CreateDegradationTemplateRequest 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 NewCreateDegradationTemplateRequestWithDefaults() *CreateDegradationTemplateRequest { + this := CreateDegradationTemplateRequest{} + return &this +} + +// GetData returns the Data field value if set, zero value otherwise. +func (o *CreateDegradationTemplateRequest) GetData() CreateDegradationTemplateRequestData { + if o == nil || o.Data == nil { + var ret CreateDegradationTemplateRequestData + return ret + } + return *o.Data +} + +// GetDataOk returns a tuple with the Data field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CreateDegradationTemplateRequest) GetDataOk() (*CreateDegradationTemplateRequestData, bool) { + if o == nil || o.Data == nil { + return nil, false + } + return o.Data, true +} + +// HasData returns a boolean if a field has been set. +func (o *CreateDegradationTemplateRequest) HasData() bool { + return o != nil && o.Data != nil +} + +// SetData gets a reference to the given CreateDegradationTemplateRequestData and assigns it to the Data field. +func (o *CreateDegradationTemplateRequest) SetData(v CreateDegradationTemplateRequestData) { + o.Data = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o CreateDegradationTemplateRequest) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Data != nil { + toSerialize["data"] = o.Data + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *CreateDegradationTemplateRequest) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *CreateDegradationTemplateRequestData `json:"data,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + + hasInvalidField := false + if all.Data != nil && all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Data = all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_create_degradation_template_request_data.go b/api/datadogV2/model_create_degradation_template_request_data.go new file mode 100644 index 00000000000..7cfde2ae034 --- /dev/null +++ b/api/datadogV2/model_create_degradation_template_request_data.go @@ -0,0 +1,151 @@ +// 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" +) + +// CreateDegradationTemplateRequestData The data object for creating a degradation template. +type CreateDegradationTemplateRequestData struct { + // The attributes for creating a degradation template. + Attributes *CreateDegradationTemplateRequestDataAttributes `json:"attributes,omitempty"` + // Degradation templates resource type. + Type PatchDegradationTemplateRequestDataType `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:"-"` +} + +// NewCreateDegradationTemplateRequestData instantiates a new CreateDegradationTemplateRequestData 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 NewCreateDegradationTemplateRequestData(typeVar PatchDegradationTemplateRequestDataType) *CreateDegradationTemplateRequestData { + this := CreateDegradationTemplateRequestData{} + this.Type = typeVar + return &this +} + +// NewCreateDegradationTemplateRequestDataWithDefaults instantiates a new CreateDegradationTemplateRequestData 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 NewCreateDegradationTemplateRequestDataWithDefaults() *CreateDegradationTemplateRequestData { + this := CreateDegradationTemplateRequestData{} + var typeVar PatchDegradationTemplateRequestDataType = PATCHDEGRADATIONTEMPLATEREQUESTDATATYPE_DEGRADATION_TEMPLATES + this.Type = typeVar + return &this +} + +// GetAttributes returns the Attributes field value if set, zero value otherwise. +func (o *CreateDegradationTemplateRequestData) GetAttributes() CreateDegradationTemplateRequestDataAttributes { + if o == nil || o.Attributes == nil { + var ret CreateDegradationTemplateRequestDataAttributes + return ret + } + return *o.Attributes +} + +// GetAttributesOk returns a tuple with the Attributes field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CreateDegradationTemplateRequestData) GetAttributesOk() (*CreateDegradationTemplateRequestDataAttributes, bool) { + if o == nil || o.Attributes == nil { + return nil, false + } + return o.Attributes, true +} + +// HasAttributes returns a boolean if a field has been set. +func (o *CreateDegradationTemplateRequestData) HasAttributes() bool { + return o != nil && o.Attributes != nil +} + +// SetAttributes gets a reference to the given CreateDegradationTemplateRequestDataAttributes and assigns it to the Attributes field. +func (o *CreateDegradationTemplateRequestData) SetAttributes(v CreateDegradationTemplateRequestDataAttributes) { + o.Attributes = &v +} + +// GetType returns the Type field value. +func (o *CreateDegradationTemplateRequestData) GetType() PatchDegradationTemplateRequestDataType { + if o == nil { + var ret PatchDegradationTemplateRequestDataType + 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 *CreateDegradationTemplateRequestData) GetTypeOk() (*PatchDegradationTemplateRequestDataType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *CreateDegradationTemplateRequestData) SetType(v PatchDegradationTemplateRequestDataType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o CreateDegradationTemplateRequestData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Attributes != nil { + 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 *CreateDegradationTemplateRequestData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *CreateDegradationTemplateRequestDataAttributes `json:"attributes,omitempty"` + Type *PatchDegradationTemplateRequestDataType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "type"}) + } else { + return err + } + + hasInvalidField := false + if all.Attributes != nil && all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Attributes = all.Attributes + if !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = *all.Type + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_create_degradation_template_request_data_attributes.go b/api/datadogV2/model_create_degradation_template_request_data_attributes.go new file mode 100644 index 00000000000..fa9288daae9 --- /dev/null +++ b/api/datadogV2/model_create_degradation_template_request_data_attributes.go @@ -0,0 +1,206 @@ +// 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" +) + +// CreateDegradationTemplateRequestDataAttributes The attributes for creating a degradation template. +type CreateDegradationTemplateRequestDataAttributes struct { + // The components affected by a degradation created from this template. + ComponentsAffected []CreateDegradationTemplateRequestDataAttributesComponentsAffectedItems `json:"components_affected,omitempty"` + // The title used for a degradation created from this template. + DegradationTitle *string `json:"degradation_title,omitempty"` + // The name of the degradation template. + Name string `json:"name"` + // The pre-filled updates for a degradation created from this template. + Updates []CreateDegradationTemplateRequestDataAttributesUpdatesItems `json:"updates,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:"-"` +} + +// NewCreateDegradationTemplateRequestDataAttributes instantiates a new CreateDegradationTemplateRequestDataAttributes 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 NewCreateDegradationTemplateRequestDataAttributes(name string) *CreateDegradationTemplateRequestDataAttributes { + this := CreateDegradationTemplateRequestDataAttributes{} + this.Name = name + return &this +} + +// NewCreateDegradationTemplateRequestDataAttributesWithDefaults instantiates a new CreateDegradationTemplateRequestDataAttributes 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 NewCreateDegradationTemplateRequestDataAttributesWithDefaults() *CreateDegradationTemplateRequestDataAttributes { + this := CreateDegradationTemplateRequestDataAttributes{} + return &this +} + +// GetComponentsAffected returns the ComponentsAffected field value if set, zero value otherwise. +func (o *CreateDegradationTemplateRequestDataAttributes) GetComponentsAffected() []CreateDegradationTemplateRequestDataAttributesComponentsAffectedItems { + if o == nil || o.ComponentsAffected == nil { + var ret []CreateDegradationTemplateRequestDataAttributesComponentsAffectedItems + return ret + } + return o.ComponentsAffected +} + +// GetComponentsAffectedOk returns a tuple with the ComponentsAffected field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CreateDegradationTemplateRequestDataAttributes) GetComponentsAffectedOk() (*[]CreateDegradationTemplateRequestDataAttributesComponentsAffectedItems, bool) { + if o == nil || o.ComponentsAffected == nil { + return nil, false + } + return &o.ComponentsAffected, true +} + +// HasComponentsAffected returns a boolean if a field has been set. +func (o *CreateDegradationTemplateRequestDataAttributes) HasComponentsAffected() bool { + return o != nil && o.ComponentsAffected != nil +} + +// SetComponentsAffected gets a reference to the given []CreateDegradationTemplateRequestDataAttributesComponentsAffectedItems and assigns it to the ComponentsAffected field. +func (o *CreateDegradationTemplateRequestDataAttributes) SetComponentsAffected(v []CreateDegradationTemplateRequestDataAttributesComponentsAffectedItems) { + o.ComponentsAffected = v +} + +// GetDegradationTitle returns the DegradationTitle field value if set, zero value otherwise. +func (o *CreateDegradationTemplateRequestDataAttributes) GetDegradationTitle() string { + if o == nil || o.DegradationTitle == nil { + var ret string + return ret + } + return *o.DegradationTitle +} + +// GetDegradationTitleOk returns a tuple with the DegradationTitle field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CreateDegradationTemplateRequestDataAttributes) GetDegradationTitleOk() (*string, bool) { + if o == nil || o.DegradationTitle == nil { + return nil, false + } + return o.DegradationTitle, true +} + +// HasDegradationTitle returns a boolean if a field has been set. +func (o *CreateDegradationTemplateRequestDataAttributes) HasDegradationTitle() bool { + return o != nil && o.DegradationTitle != nil +} + +// SetDegradationTitle gets a reference to the given string and assigns it to the DegradationTitle field. +func (o *CreateDegradationTemplateRequestDataAttributes) SetDegradationTitle(v string) { + o.DegradationTitle = &v +} + +// GetName returns the Name field value. +func (o *CreateDegradationTemplateRequestDataAttributes) GetName() string { + if o == nil { + var ret string + return ret + } + return o.Name +} + +// GetNameOk returns a tuple with the Name field value +// and a boolean to check if the value has been set. +func (o *CreateDegradationTemplateRequestDataAttributes) GetNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Name, true +} + +// SetName sets field value. +func (o *CreateDegradationTemplateRequestDataAttributes) SetName(v string) { + o.Name = v +} + +// GetUpdates returns the Updates field value if set, zero value otherwise. +func (o *CreateDegradationTemplateRequestDataAttributes) GetUpdates() []CreateDegradationTemplateRequestDataAttributesUpdatesItems { + if o == nil || o.Updates == nil { + var ret []CreateDegradationTemplateRequestDataAttributesUpdatesItems + return ret + } + return o.Updates +} + +// GetUpdatesOk returns a tuple with the Updates field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CreateDegradationTemplateRequestDataAttributes) GetUpdatesOk() (*[]CreateDegradationTemplateRequestDataAttributesUpdatesItems, bool) { + if o == nil || o.Updates == nil { + return nil, false + } + return &o.Updates, true +} + +// HasUpdates returns a boolean if a field has been set. +func (o *CreateDegradationTemplateRequestDataAttributes) HasUpdates() bool { + return o != nil && o.Updates != nil +} + +// SetUpdates gets a reference to the given []CreateDegradationTemplateRequestDataAttributesUpdatesItems and assigns it to the Updates field. +func (o *CreateDegradationTemplateRequestDataAttributes) SetUpdates(v []CreateDegradationTemplateRequestDataAttributesUpdatesItems) { + o.Updates = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o CreateDegradationTemplateRequestDataAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.ComponentsAffected != nil { + toSerialize["components_affected"] = o.ComponentsAffected + } + if o.DegradationTitle != nil { + toSerialize["degradation_title"] = o.DegradationTitle + } + toSerialize["name"] = o.Name + if o.Updates != nil { + toSerialize["updates"] = o.Updates + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *CreateDegradationTemplateRequestDataAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + ComponentsAffected []CreateDegradationTemplateRequestDataAttributesComponentsAffectedItems `json:"components_affected,omitempty"` + DegradationTitle *string `json:"degradation_title,omitempty"` + Name *string `json:"name"` + Updates []CreateDegradationTemplateRequestDataAttributesUpdatesItems `json:"updates,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Name == nil { + return fmt.Errorf("required field name missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"components_affected", "degradation_title", "name", "updates"}) + } else { + return err + } + o.ComponentsAffected = all.ComponentsAffected + o.DegradationTitle = all.DegradationTitle + o.Name = *all.Name + o.Updates = all.Updates + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_create_degradation_template_request_data_attributes_components_affected_items.go b/api/datadogV2/model_create_degradation_template_request_data_attributes_components_affected_items.go new file mode 100644 index 00000000000..9551409ca22 --- /dev/null +++ b/api/datadogV2/model_create_degradation_template_request_data_attributes_components_affected_items.go @@ -0,0 +1,178 @@ +// 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" +) + +// CreateDegradationTemplateRequestDataAttributesComponentsAffectedItems A component affected by a degradation created from this template. +type CreateDegradationTemplateRequestDataAttributesComponentsAffectedItems struct { + // The ID of the component. Must be a component of type `component`. + Id string `json:"id"` + // The name of the component. + Name *string `json:"name,omitempty"` + // The status of the component. + Status PatchDegradationTemplateRequestDataAttributesComponentsAffectedItemsStatus `json:"status"` + // 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:"-"` +} + +// NewCreateDegradationTemplateRequestDataAttributesComponentsAffectedItems instantiates a new CreateDegradationTemplateRequestDataAttributesComponentsAffectedItems 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 NewCreateDegradationTemplateRequestDataAttributesComponentsAffectedItems(id string, status PatchDegradationTemplateRequestDataAttributesComponentsAffectedItemsStatus) *CreateDegradationTemplateRequestDataAttributesComponentsAffectedItems { + this := CreateDegradationTemplateRequestDataAttributesComponentsAffectedItems{} + this.Id = id + this.Status = status + return &this +} + +// NewCreateDegradationTemplateRequestDataAttributesComponentsAffectedItemsWithDefaults instantiates a new CreateDegradationTemplateRequestDataAttributesComponentsAffectedItems 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 NewCreateDegradationTemplateRequestDataAttributesComponentsAffectedItemsWithDefaults() *CreateDegradationTemplateRequestDataAttributesComponentsAffectedItems { + this := CreateDegradationTemplateRequestDataAttributesComponentsAffectedItems{} + return &this +} + +// GetId returns the Id field value. +func (o *CreateDegradationTemplateRequestDataAttributesComponentsAffectedItems) GetId() string { + if o == nil { + var ret string + 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 *CreateDegradationTemplateRequestDataAttributesComponentsAffectedItems) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Id, true +} + +// SetId sets field value. +func (o *CreateDegradationTemplateRequestDataAttributesComponentsAffectedItems) SetId(v string) { + o.Id = v +} + +// GetName returns the Name field value if set, zero value otherwise. +func (o *CreateDegradationTemplateRequestDataAttributesComponentsAffectedItems) GetName() string { + if o == nil || o.Name == nil { + var ret string + return ret + } + return *o.Name +} + +// GetNameOk returns a tuple with the Name field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CreateDegradationTemplateRequestDataAttributesComponentsAffectedItems) GetNameOk() (*string, bool) { + if o == nil || o.Name == nil { + return nil, false + } + return o.Name, true +} + +// HasName returns a boolean if a field has been set. +func (o *CreateDegradationTemplateRequestDataAttributesComponentsAffectedItems) HasName() bool { + return o != nil && o.Name != nil +} + +// SetName gets a reference to the given string and assigns it to the Name field. +func (o *CreateDegradationTemplateRequestDataAttributesComponentsAffectedItems) SetName(v string) { + o.Name = &v +} + +// GetStatus returns the Status field value. +func (o *CreateDegradationTemplateRequestDataAttributesComponentsAffectedItems) GetStatus() PatchDegradationTemplateRequestDataAttributesComponentsAffectedItemsStatus { + if o == nil { + var ret PatchDegradationTemplateRequestDataAttributesComponentsAffectedItemsStatus + return ret + } + return o.Status +} + +// GetStatusOk returns a tuple with the Status field value +// and a boolean to check if the value has been set. +func (o *CreateDegradationTemplateRequestDataAttributesComponentsAffectedItems) GetStatusOk() (*PatchDegradationTemplateRequestDataAttributesComponentsAffectedItemsStatus, bool) { + if o == nil { + return nil, false + } + return &o.Status, true +} + +// SetStatus sets field value. +func (o *CreateDegradationTemplateRequestDataAttributesComponentsAffectedItems) SetStatus(v PatchDegradationTemplateRequestDataAttributesComponentsAffectedItemsStatus) { + o.Status = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o CreateDegradationTemplateRequestDataAttributesComponentsAffectedItems) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["id"] = o.Id + if o.Name != nil { + toSerialize["name"] = o.Name + } + toSerialize["status"] = o.Status + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *CreateDegradationTemplateRequestDataAttributesComponentsAffectedItems) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Id *string `json:"id"` + Name *string `json:"name,omitempty"` + Status *PatchDegradationTemplateRequestDataAttributesComponentsAffectedItemsStatus `json:"status"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Id == nil { + return fmt.Errorf("required field id missing") + } + if all.Status == nil { + return fmt.Errorf("required field status missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"id", "name", "status"}) + } else { + return err + } + + hasInvalidField := false + o.Id = *all.Id + o.Name = all.Name + if !all.Status.IsValid() { + hasInvalidField = true + } else { + o.Status = *all.Status + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_create_degradation_template_request_data_attributes_updates_items.go b/api/datadogV2/model_create_degradation_template_request_data_attributes_updates_items.go new file mode 100644 index 00000000000..b8e08f0b691 --- /dev/null +++ b/api/datadogV2/model_create_degradation_template_request_data_attributes_updates_items.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" +) + +// CreateDegradationTemplateRequestDataAttributesUpdatesItems A pre-filled update for a degradation created from this template. +type CreateDegradationTemplateRequestDataAttributesUpdatesItems struct { + // The message of the update. + Message *string `json:"message,omitempty"` + // The status of the degradation. + Status CreateDegradationRequestDataAttributesStatus `json:"status"` + // 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:"-"` +} + +// NewCreateDegradationTemplateRequestDataAttributesUpdatesItems instantiates a new CreateDegradationTemplateRequestDataAttributesUpdatesItems 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 NewCreateDegradationTemplateRequestDataAttributesUpdatesItems(status CreateDegradationRequestDataAttributesStatus) *CreateDegradationTemplateRequestDataAttributesUpdatesItems { + this := CreateDegradationTemplateRequestDataAttributesUpdatesItems{} + this.Status = status + return &this +} + +// NewCreateDegradationTemplateRequestDataAttributesUpdatesItemsWithDefaults instantiates a new CreateDegradationTemplateRequestDataAttributesUpdatesItems 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 NewCreateDegradationTemplateRequestDataAttributesUpdatesItemsWithDefaults() *CreateDegradationTemplateRequestDataAttributesUpdatesItems { + this := CreateDegradationTemplateRequestDataAttributesUpdatesItems{} + return &this +} + +// GetMessage returns the Message field value if set, zero value otherwise. +func (o *CreateDegradationTemplateRequestDataAttributesUpdatesItems) GetMessage() string { + if o == nil || o.Message == nil { + var ret string + return ret + } + return *o.Message +} + +// GetMessageOk returns a tuple with the Message field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CreateDegradationTemplateRequestDataAttributesUpdatesItems) GetMessageOk() (*string, bool) { + if o == nil || o.Message == nil { + return nil, false + } + return o.Message, true +} + +// HasMessage returns a boolean if a field has been set. +func (o *CreateDegradationTemplateRequestDataAttributesUpdatesItems) HasMessage() bool { + return o != nil && o.Message != nil +} + +// SetMessage gets a reference to the given string and assigns it to the Message field. +func (o *CreateDegradationTemplateRequestDataAttributesUpdatesItems) SetMessage(v string) { + o.Message = &v +} + +// GetStatus returns the Status field value. +func (o *CreateDegradationTemplateRequestDataAttributesUpdatesItems) GetStatus() CreateDegradationRequestDataAttributesStatus { + if o == nil { + var ret CreateDegradationRequestDataAttributesStatus + return ret + } + return o.Status +} + +// GetStatusOk returns a tuple with the Status field value +// and a boolean to check if the value has been set. +func (o *CreateDegradationTemplateRequestDataAttributesUpdatesItems) GetStatusOk() (*CreateDegradationRequestDataAttributesStatus, bool) { + if o == nil { + return nil, false + } + return &o.Status, true +} + +// SetStatus sets field value. +func (o *CreateDegradationTemplateRequestDataAttributesUpdatesItems) SetStatus(v CreateDegradationRequestDataAttributesStatus) { + o.Status = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o CreateDegradationTemplateRequestDataAttributesUpdatesItems) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Message != nil { + toSerialize["message"] = o.Message + } + toSerialize["status"] = o.Status + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *CreateDegradationTemplateRequestDataAttributesUpdatesItems) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Message *string `json:"message,omitempty"` + Status *CreateDegradationRequestDataAttributesStatus `json:"status"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Status == nil { + return fmt.Errorf("required field status missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"message", "status"}) + } else { + return err + } + + hasInvalidField := false + o.Message = all.Message + if !all.Status.IsValid() { + hasInvalidField = true + } else { + o.Status = *all.Status + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_create_maintenance_request_data.go b/api/datadogV2/model_create_maintenance_request_data.go index acd4b8c58ec..13bdf21242e 100644 --- a/api/datadogV2/model_create_maintenance_request_data.go +++ b/api/datadogV2/model_create_maintenance_request_data.go @@ -14,6 +14,8 @@ import ( type CreateMaintenanceRequestData struct { // The supported attributes for creating a maintenance. Attributes CreateMaintenanceRequestDataAttributes `json:"attributes"` + // The supported relationships for creating a maintenance. + Relationships *CreateMaintenanceRequestDataRelationships `json:"relationships,omitempty"` // Maintenances resource type. Type PatchMaintenanceRequestDataType `json:"type"` // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct @@ -65,6 +67,34 @@ func (o *CreateMaintenanceRequestData) SetAttributes(v CreateMaintenanceRequestD o.Attributes = v } +// GetRelationships returns the Relationships field value if set, zero value otherwise. +func (o *CreateMaintenanceRequestData) GetRelationships() CreateMaintenanceRequestDataRelationships { + if o == nil || o.Relationships == nil { + var ret CreateMaintenanceRequestDataRelationships + return ret + } + return *o.Relationships +} + +// GetRelationshipsOk returns a tuple with the Relationships field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CreateMaintenanceRequestData) GetRelationshipsOk() (*CreateMaintenanceRequestDataRelationships, bool) { + if o == nil || o.Relationships == nil { + return nil, false + } + return o.Relationships, true +} + +// HasRelationships returns a boolean if a field has been set. +func (o *CreateMaintenanceRequestData) HasRelationships() bool { + return o != nil && o.Relationships != nil +} + +// SetRelationships gets a reference to the given CreateMaintenanceRequestDataRelationships and assigns it to the Relationships field. +func (o *CreateMaintenanceRequestData) SetRelationships(v CreateMaintenanceRequestDataRelationships) { + o.Relationships = &v +} + // GetType returns the Type field value. func (o *CreateMaintenanceRequestData) GetType() PatchMaintenanceRequestDataType { if o == nil { @@ -95,6 +125,9 @@ func (o CreateMaintenanceRequestData) MarshalJSON() ([]byte, error) { return datadog.Marshal(o.UnparsedObject) } toSerialize["attributes"] = o.Attributes + if o.Relationships != nil { + toSerialize["relationships"] = o.Relationships + } toSerialize["type"] = o.Type for key, value := range o.AdditionalProperties { @@ -106,8 +139,9 @@ func (o CreateMaintenanceRequestData) MarshalJSON() ([]byte, error) { // UnmarshalJSON deserializes the given payload. func (o *CreateMaintenanceRequestData) UnmarshalJSON(bytes []byte) (err error) { all := struct { - Attributes *CreateMaintenanceRequestDataAttributes `json:"attributes"` - Type *PatchMaintenanceRequestDataType `json:"type"` + Attributes *CreateMaintenanceRequestDataAttributes `json:"attributes"` + Relationships *CreateMaintenanceRequestDataRelationships `json:"relationships,omitempty"` + Type *PatchMaintenanceRequestDataType `json:"type"` }{} if err = datadog.Unmarshal(bytes, &all); err != nil { return datadog.Unmarshal(bytes, &o.UnparsedObject) @@ -120,7 +154,7 @@ func (o *CreateMaintenanceRequestData) UnmarshalJSON(bytes []byte) (err error) { } additionalProperties := make(map[string]interface{}) if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { - datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "type"}) + datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "relationships", "type"}) } else { return err } @@ -130,6 +164,10 @@ func (o *CreateMaintenanceRequestData) UnmarshalJSON(bytes []byte) (err error) { hasInvalidField = true } o.Attributes = *all.Attributes + if all.Relationships != nil && all.Relationships.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Relationships = all.Relationships if !all.Type.IsValid() { hasInvalidField = true } else { diff --git a/api/datadogV2/model_create_maintenance_request_data_relationships.go b/api/datadogV2/model_create_maintenance_request_data_relationships.go new file mode 100644 index 00000000000..cc3784756ef --- /dev/null +++ b/api/datadogV2/model_create_maintenance_request_data_relationships.go @@ -0,0 +1,111 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// CreateMaintenanceRequestDataRelationships The supported relationships for creating a maintenance. +type CreateMaintenanceRequestDataRelationships struct { + // The template used to create the maintenance. + Template *CreateMaintenanceRequestDataRelationshipsTemplate `json:"template,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:"-"` +} + +// NewCreateMaintenanceRequestDataRelationships instantiates a new CreateMaintenanceRequestDataRelationships 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 NewCreateMaintenanceRequestDataRelationships() *CreateMaintenanceRequestDataRelationships { + this := CreateMaintenanceRequestDataRelationships{} + return &this +} + +// NewCreateMaintenanceRequestDataRelationshipsWithDefaults instantiates a new CreateMaintenanceRequestDataRelationships 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 NewCreateMaintenanceRequestDataRelationshipsWithDefaults() *CreateMaintenanceRequestDataRelationships { + this := CreateMaintenanceRequestDataRelationships{} + return &this +} + +// GetTemplate returns the Template field value if set, zero value otherwise. +func (o *CreateMaintenanceRequestDataRelationships) GetTemplate() CreateMaintenanceRequestDataRelationshipsTemplate { + if o == nil || o.Template == nil { + var ret CreateMaintenanceRequestDataRelationshipsTemplate + return ret + } + return *o.Template +} + +// GetTemplateOk returns a tuple with the Template field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CreateMaintenanceRequestDataRelationships) GetTemplateOk() (*CreateMaintenanceRequestDataRelationshipsTemplate, bool) { + if o == nil || o.Template == nil { + return nil, false + } + return o.Template, true +} + +// HasTemplate returns a boolean if a field has been set. +func (o *CreateMaintenanceRequestDataRelationships) HasTemplate() bool { + return o != nil && o.Template != nil +} + +// SetTemplate gets a reference to the given CreateMaintenanceRequestDataRelationshipsTemplate and assigns it to the Template field. +func (o *CreateMaintenanceRequestDataRelationships) SetTemplate(v CreateMaintenanceRequestDataRelationshipsTemplate) { + o.Template = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o CreateMaintenanceRequestDataRelationships) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Template != nil { + toSerialize["template"] = o.Template + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *CreateMaintenanceRequestDataRelationships) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Template *CreateMaintenanceRequestDataRelationshipsTemplate `json:"template,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"template"}) + } else { + return err + } + + hasInvalidField := false + if all.Template != nil && all.Template.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Template = all.Template + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_create_maintenance_request_data_relationships_template.go b/api/datadogV2/model_create_maintenance_request_data_relationships_template.go new file mode 100644 index 00000000000..e246a5d20d8 --- /dev/null +++ b/api/datadogV2/model_create_maintenance_request_data_relationships_template.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" +) + +// CreateMaintenanceRequestDataRelationshipsTemplate The template used to create the maintenance. +type CreateMaintenanceRequestDataRelationshipsTemplate struct { + // The data object identifying the template used to create the maintenance. + Data CreateMaintenanceRequestDataRelationshipsTemplateData `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:"-"` +} + +// NewCreateMaintenanceRequestDataRelationshipsTemplate instantiates a new CreateMaintenanceRequestDataRelationshipsTemplate 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 NewCreateMaintenanceRequestDataRelationshipsTemplate(data CreateMaintenanceRequestDataRelationshipsTemplateData) *CreateMaintenanceRequestDataRelationshipsTemplate { + this := CreateMaintenanceRequestDataRelationshipsTemplate{} + this.Data = data + return &this +} + +// NewCreateMaintenanceRequestDataRelationshipsTemplateWithDefaults instantiates a new CreateMaintenanceRequestDataRelationshipsTemplate 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 NewCreateMaintenanceRequestDataRelationshipsTemplateWithDefaults() *CreateMaintenanceRequestDataRelationshipsTemplate { + this := CreateMaintenanceRequestDataRelationshipsTemplate{} + return &this +} + +// GetData returns the Data field value. +func (o *CreateMaintenanceRequestDataRelationshipsTemplate) GetData() CreateMaintenanceRequestDataRelationshipsTemplateData { + if o == nil { + var ret CreateMaintenanceRequestDataRelationshipsTemplateData + 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 *CreateMaintenanceRequestDataRelationshipsTemplate) GetDataOk() (*CreateMaintenanceRequestDataRelationshipsTemplateData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *CreateMaintenanceRequestDataRelationshipsTemplate) SetData(v CreateMaintenanceRequestDataRelationshipsTemplateData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o CreateMaintenanceRequestDataRelationshipsTemplate) 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 *CreateMaintenanceRequestDataRelationshipsTemplate) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *CreateMaintenanceRequestDataRelationshipsTemplateData `json:"data"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Data == nil { + return fmt.Errorf("required field data missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + + hasInvalidField := false + if all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Data = *all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_create_maintenance_request_data_relationships_template_data.go b/api/datadogV2/model_create_maintenance_request_data_relationships_template_data.go new file mode 100644 index 00000000000..6b2f4f5e416 --- /dev/null +++ b/api/datadogV2/model_create_maintenance_request_data_relationships_template_data.go @@ -0,0 +1,145 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// CreateMaintenanceRequestDataRelationshipsTemplateData The data object identifying the template used to create the maintenance. +type CreateMaintenanceRequestDataRelationshipsTemplateData struct { + // The ID of the maintenance template. + Id string `json:"id"` + // Maintenance templates resource type. + Type PatchMaintenanceTemplateRequestDataType `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:"-"` +} + +// NewCreateMaintenanceRequestDataRelationshipsTemplateData instantiates a new CreateMaintenanceRequestDataRelationshipsTemplateData 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 NewCreateMaintenanceRequestDataRelationshipsTemplateData(id string, typeVar PatchMaintenanceTemplateRequestDataType) *CreateMaintenanceRequestDataRelationshipsTemplateData { + this := CreateMaintenanceRequestDataRelationshipsTemplateData{} + this.Id = id + this.Type = typeVar + return &this +} + +// NewCreateMaintenanceRequestDataRelationshipsTemplateDataWithDefaults instantiates a new CreateMaintenanceRequestDataRelationshipsTemplateData 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 NewCreateMaintenanceRequestDataRelationshipsTemplateDataWithDefaults() *CreateMaintenanceRequestDataRelationshipsTemplateData { + this := CreateMaintenanceRequestDataRelationshipsTemplateData{} + var typeVar PatchMaintenanceTemplateRequestDataType = PATCHMAINTENANCETEMPLATEREQUESTDATATYPE_MAINTENANCE_TEMPLATES + this.Type = typeVar + return &this +} + +// GetId returns the Id field value. +func (o *CreateMaintenanceRequestDataRelationshipsTemplateData) GetId() string { + if o == nil { + var ret string + 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 *CreateMaintenanceRequestDataRelationshipsTemplateData) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Id, true +} + +// SetId sets field value. +func (o *CreateMaintenanceRequestDataRelationshipsTemplateData) SetId(v string) { + o.Id = v +} + +// GetType returns the Type field value. +func (o *CreateMaintenanceRequestDataRelationshipsTemplateData) GetType() PatchMaintenanceTemplateRequestDataType { + if o == nil { + var ret PatchMaintenanceTemplateRequestDataType + 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 *CreateMaintenanceRequestDataRelationshipsTemplateData) GetTypeOk() (*PatchMaintenanceTemplateRequestDataType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *CreateMaintenanceRequestDataRelationshipsTemplateData) SetType(v PatchMaintenanceTemplateRequestDataType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o CreateMaintenanceRequestDataRelationshipsTemplateData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["id"] = o.Id + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *CreateMaintenanceRequestDataRelationshipsTemplateData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Id *string `json:"id"` + Type *PatchMaintenanceTemplateRequestDataType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Id == nil { + return fmt.Errorf("required field id missing") + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"id", "type"}) + } else { + return err + } + + hasInvalidField := false + o.Id = *all.Id + if !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = *all.Type + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_create_maintenance_template_request.go b/api/datadogV2/model_create_maintenance_template_request.go new file mode 100644 index 00000000000..e1c37dd993e --- /dev/null +++ b/api/datadogV2/model_create_maintenance_template_request.go @@ -0,0 +1,111 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// CreateMaintenanceTemplateRequest Request object for creating a maintenance template. +type CreateMaintenanceTemplateRequest struct { + // The data object for creating a maintenance template. + Data *CreateMaintenanceTemplateRequestData `json:"data,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewCreateMaintenanceTemplateRequest instantiates a new CreateMaintenanceTemplateRequest 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 NewCreateMaintenanceTemplateRequest() *CreateMaintenanceTemplateRequest { + this := CreateMaintenanceTemplateRequest{} + return &this +} + +// NewCreateMaintenanceTemplateRequestWithDefaults instantiates a new CreateMaintenanceTemplateRequest 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 NewCreateMaintenanceTemplateRequestWithDefaults() *CreateMaintenanceTemplateRequest { + this := CreateMaintenanceTemplateRequest{} + return &this +} + +// GetData returns the Data field value if set, zero value otherwise. +func (o *CreateMaintenanceTemplateRequest) GetData() CreateMaintenanceTemplateRequestData { + if o == nil || o.Data == nil { + var ret CreateMaintenanceTemplateRequestData + return ret + } + return *o.Data +} + +// GetDataOk returns a tuple with the Data field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CreateMaintenanceTemplateRequest) GetDataOk() (*CreateMaintenanceTemplateRequestData, bool) { + if o == nil || o.Data == nil { + return nil, false + } + return o.Data, true +} + +// HasData returns a boolean if a field has been set. +func (o *CreateMaintenanceTemplateRequest) HasData() bool { + return o != nil && o.Data != nil +} + +// SetData gets a reference to the given CreateMaintenanceTemplateRequestData and assigns it to the Data field. +func (o *CreateMaintenanceTemplateRequest) SetData(v CreateMaintenanceTemplateRequestData) { + o.Data = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o CreateMaintenanceTemplateRequest) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Data != nil { + toSerialize["data"] = o.Data + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *CreateMaintenanceTemplateRequest) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *CreateMaintenanceTemplateRequestData `json:"data,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + + hasInvalidField := false + if all.Data != nil && all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Data = all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_create_maintenance_template_request_data.go b/api/datadogV2/model_create_maintenance_template_request_data.go new file mode 100644 index 00000000000..e46fc69ddd2 --- /dev/null +++ b/api/datadogV2/model_create_maintenance_template_request_data.go @@ -0,0 +1,151 @@ +// 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" +) + +// CreateMaintenanceTemplateRequestData The data object for creating a maintenance template. +type CreateMaintenanceTemplateRequestData struct { + // The attributes for creating a maintenance template. + Attributes *CreateMaintenanceTemplateRequestDataAttributes `json:"attributes,omitempty"` + // Maintenance templates resource type. + Type PatchMaintenanceTemplateRequestDataType `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:"-"` +} + +// NewCreateMaintenanceTemplateRequestData instantiates a new CreateMaintenanceTemplateRequestData 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 NewCreateMaintenanceTemplateRequestData(typeVar PatchMaintenanceTemplateRequestDataType) *CreateMaintenanceTemplateRequestData { + this := CreateMaintenanceTemplateRequestData{} + this.Type = typeVar + return &this +} + +// NewCreateMaintenanceTemplateRequestDataWithDefaults instantiates a new CreateMaintenanceTemplateRequestData 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 NewCreateMaintenanceTemplateRequestDataWithDefaults() *CreateMaintenanceTemplateRequestData { + this := CreateMaintenanceTemplateRequestData{} + var typeVar PatchMaintenanceTemplateRequestDataType = PATCHMAINTENANCETEMPLATEREQUESTDATATYPE_MAINTENANCE_TEMPLATES + this.Type = typeVar + return &this +} + +// GetAttributes returns the Attributes field value if set, zero value otherwise. +func (o *CreateMaintenanceTemplateRequestData) GetAttributes() CreateMaintenanceTemplateRequestDataAttributes { + if o == nil || o.Attributes == nil { + var ret CreateMaintenanceTemplateRequestDataAttributes + return ret + } + return *o.Attributes +} + +// GetAttributesOk returns a tuple with the Attributes field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CreateMaintenanceTemplateRequestData) GetAttributesOk() (*CreateMaintenanceTemplateRequestDataAttributes, bool) { + if o == nil || o.Attributes == nil { + return nil, false + } + return o.Attributes, true +} + +// HasAttributes returns a boolean if a field has been set. +func (o *CreateMaintenanceTemplateRequestData) HasAttributes() bool { + return o != nil && o.Attributes != nil +} + +// SetAttributes gets a reference to the given CreateMaintenanceTemplateRequestDataAttributes and assigns it to the Attributes field. +func (o *CreateMaintenanceTemplateRequestData) SetAttributes(v CreateMaintenanceTemplateRequestDataAttributes) { + o.Attributes = &v +} + +// GetType returns the Type field value. +func (o *CreateMaintenanceTemplateRequestData) GetType() PatchMaintenanceTemplateRequestDataType { + if o == nil { + var ret PatchMaintenanceTemplateRequestDataType + 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 *CreateMaintenanceTemplateRequestData) GetTypeOk() (*PatchMaintenanceTemplateRequestDataType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *CreateMaintenanceTemplateRequestData) SetType(v PatchMaintenanceTemplateRequestDataType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o CreateMaintenanceTemplateRequestData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Attributes != nil { + 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 *CreateMaintenanceTemplateRequestData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *CreateMaintenanceTemplateRequestDataAttributes `json:"attributes,omitempty"` + Type *PatchMaintenanceTemplateRequestDataType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "type"}) + } else { + return err + } + + hasInvalidField := false + if all.Attributes != nil && all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Attributes = all.Attributes + if !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = *all.Type + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_create_maintenance_template_request_data_attributes.go b/api/datadogV2/model_create_maintenance_template_request_data_attributes.go new file mode 100644 index 00000000000..f1e56b0a5e2 --- /dev/null +++ b/api/datadogV2/model_create_maintenance_template_request_data_attributes.go @@ -0,0 +1,276 @@ +// 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" +) + +// CreateMaintenanceTemplateRequestDataAttributes The attributes for creating a maintenance template. +type CreateMaintenanceTemplateRequestDataAttributes struct { + // The description shown when a maintenance created from this template is completed. + CompletedDescription *string `json:"completed_description,omitempty"` + // The IDs of the components affected by a maintenance created from this template. + ComponentIds []string `json:"component_ids,omitempty"` + // The description shown while a maintenance created from this template is in progress. + InProgressDescription *string `json:"in_progress_description,omitempty"` + // The title used for a maintenance created from this template. + MaintenanceTitle *string `json:"maintenance_title,omitempty"` + // The name of the maintenance template. + Name string `json:"name"` + // The description shown when a maintenance created from this template is scheduled. + ScheduledDescription *string `json:"scheduled_description,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:"-"` +} + +// NewCreateMaintenanceTemplateRequestDataAttributes instantiates a new CreateMaintenanceTemplateRequestDataAttributes 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 NewCreateMaintenanceTemplateRequestDataAttributes(name string) *CreateMaintenanceTemplateRequestDataAttributes { + this := CreateMaintenanceTemplateRequestDataAttributes{} + this.Name = name + return &this +} + +// NewCreateMaintenanceTemplateRequestDataAttributesWithDefaults instantiates a new CreateMaintenanceTemplateRequestDataAttributes 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 NewCreateMaintenanceTemplateRequestDataAttributesWithDefaults() *CreateMaintenanceTemplateRequestDataAttributes { + this := CreateMaintenanceTemplateRequestDataAttributes{} + return &this +} + +// GetCompletedDescription returns the CompletedDescription field value if set, zero value otherwise. +func (o *CreateMaintenanceTemplateRequestDataAttributes) GetCompletedDescription() string { + if o == nil || o.CompletedDescription == nil { + var ret string + return ret + } + return *o.CompletedDescription +} + +// GetCompletedDescriptionOk returns a tuple with the CompletedDescription field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CreateMaintenanceTemplateRequestDataAttributes) GetCompletedDescriptionOk() (*string, bool) { + if o == nil || o.CompletedDescription == nil { + return nil, false + } + return o.CompletedDescription, true +} + +// HasCompletedDescription returns a boolean if a field has been set. +func (o *CreateMaintenanceTemplateRequestDataAttributes) HasCompletedDescription() bool { + return o != nil && o.CompletedDescription != nil +} + +// SetCompletedDescription gets a reference to the given string and assigns it to the CompletedDescription field. +func (o *CreateMaintenanceTemplateRequestDataAttributes) SetCompletedDescription(v string) { + o.CompletedDescription = &v +} + +// GetComponentIds returns the ComponentIds field value if set, zero value otherwise. +func (o *CreateMaintenanceTemplateRequestDataAttributes) GetComponentIds() []string { + if o == nil || o.ComponentIds == nil { + var ret []string + return ret + } + return o.ComponentIds +} + +// GetComponentIdsOk returns a tuple with the ComponentIds field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CreateMaintenanceTemplateRequestDataAttributes) GetComponentIdsOk() (*[]string, bool) { + if o == nil || o.ComponentIds == nil { + return nil, false + } + return &o.ComponentIds, true +} + +// HasComponentIds returns a boolean if a field has been set. +func (o *CreateMaintenanceTemplateRequestDataAttributes) HasComponentIds() bool { + return o != nil && o.ComponentIds != nil +} + +// SetComponentIds gets a reference to the given []string and assigns it to the ComponentIds field. +func (o *CreateMaintenanceTemplateRequestDataAttributes) SetComponentIds(v []string) { + o.ComponentIds = v +} + +// GetInProgressDescription returns the InProgressDescription field value if set, zero value otherwise. +func (o *CreateMaintenanceTemplateRequestDataAttributes) GetInProgressDescription() string { + if o == nil || o.InProgressDescription == nil { + var ret string + return ret + } + return *o.InProgressDescription +} + +// GetInProgressDescriptionOk returns a tuple with the InProgressDescription field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CreateMaintenanceTemplateRequestDataAttributes) GetInProgressDescriptionOk() (*string, bool) { + if o == nil || o.InProgressDescription == nil { + return nil, false + } + return o.InProgressDescription, true +} + +// HasInProgressDescription returns a boolean if a field has been set. +func (o *CreateMaintenanceTemplateRequestDataAttributes) HasInProgressDescription() bool { + return o != nil && o.InProgressDescription != nil +} + +// SetInProgressDescription gets a reference to the given string and assigns it to the InProgressDescription field. +func (o *CreateMaintenanceTemplateRequestDataAttributes) SetInProgressDescription(v string) { + o.InProgressDescription = &v +} + +// GetMaintenanceTitle returns the MaintenanceTitle field value if set, zero value otherwise. +func (o *CreateMaintenanceTemplateRequestDataAttributes) GetMaintenanceTitle() string { + if o == nil || o.MaintenanceTitle == nil { + var ret string + return ret + } + return *o.MaintenanceTitle +} + +// GetMaintenanceTitleOk returns a tuple with the MaintenanceTitle field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CreateMaintenanceTemplateRequestDataAttributes) GetMaintenanceTitleOk() (*string, bool) { + if o == nil || o.MaintenanceTitle == nil { + return nil, false + } + return o.MaintenanceTitle, true +} + +// HasMaintenanceTitle returns a boolean if a field has been set. +func (o *CreateMaintenanceTemplateRequestDataAttributes) HasMaintenanceTitle() bool { + return o != nil && o.MaintenanceTitle != nil +} + +// SetMaintenanceTitle gets a reference to the given string and assigns it to the MaintenanceTitle field. +func (o *CreateMaintenanceTemplateRequestDataAttributes) SetMaintenanceTitle(v string) { + o.MaintenanceTitle = &v +} + +// GetName returns the Name field value. +func (o *CreateMaintenanceTemplateRequestDataAttributes) GetName() string { + if o == nil { + var ret string + return ret + } + return o.Name +} + +// GetNameOk returns a tuple with the Name field value +// and a boolean to check if the value has been set. +func (o *CreateMaintenanceTemplateRequestDataAttributes) GetNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Name, true +} + +// SetName sets field value. +func (o *CreateMaintenanceTemplateRequestDataAttributes) SetName(v string) { + o.Name = v +} + +// GetScheduledDescription returns the ScheduledDescription field value if set, zero value otherwise. +func (o *CreateMaintenanceTemplateRequestDataAttributes) GetScheduledDescription() string { + if o == nil || o.ScheduledDescription == nil { + var ret string + return ret + } + return *o.ScheduledDescription +} + +// GetScheduledDescriptionOk returns a tuple with the ScheduledDescription field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CreateMaintenanceTemplateRequestDataAttributes) GetScheduledDescriptionOk() (*string, bool) { + if o == nil || o.ScheduledDescription == nil { + return nil, false + } + return o.ScheduledDescription, true +} + +// HasScheduledDescription returns a boolean if a field has been set. +func (o *CreateMaintenanceTemplateRequestDataAttributes) HasScheduledDescription() bool { + return o != nil && o.ScheduledDescription != nil +} + +// SetScheduledDescription gets a reference to the given string and assigns it to the ScheduledDescription field. +func (o *CreateMaintenanceTemplateRequestDataAttributes) SetScheduledDescription(v string) { + o.ScheduledDescription = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o CreateMaintenanceTemplateRequestDataAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.CompletedDescription != nil { + toSerialize["completed_description"] = o.CompletedDescription + } + if o.ComponentIds != nil { + toSerialize["component_ids"] = o.ComponentIds + } + if o.InProgressDescription != nil { + toSerialize["in_progress_description"] = o.InProgressDescription + } + if o.MaintenanceTitle != nil { + toSerialize["maintenance_title"] = o.MaintenanceTitle + } + toSerialize["name"] = o.Name + if o.ScheduledDescription != nil { + toSerialize["scheduled_description"] = o.ScheduledDescription + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *CreateMaintenanceTemplateRequestDataAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + CompletedDescription *string `json:"completed_description,omitempty"` + ComponentIds []string `json:"component_ids,omitempty"` + InProgressDescription *string `json:"in_progress_description,omitempty"` + MaintenanceTitle *string `json:"maintenance_title,omitempty"` + Name *string `json:"name"` + ScheduledDescription *string `json:"scheduled_description,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Name == nil { + return fmt.Errorf("required field name missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"completed_description", "component_ids", "in_progress_description", "maintenance_title", "name", "scheduled_description"}) + } else { + return err + } + o.CompletedDescription = all.CompletedDescription + o.ComponentIds = all.ComponentIds + o.InProgressDescription = all.InProgressDescription + o.MaintenanceTitle = all.MaintenanceTitle + o.Name = *all.Name + o.ScheduledDescription = all.ScheduledDescription + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_degradation_data_relationships.go b/api/datadogV2/model_degradation_data_relationships.go index ad0c76b32ab..2d4abca6f15 100644 --- a/api/datadogV2/model_degradation_data_relationships.go +++ b/api/datadogV2/model_degradation_data_relationships.go @@ -16,6 +16,8 @@ type DegradationDataRelationships struct { LastModifiedByUser *DegradationDataRelationshipsLastModifiedByUser `json:"last_modified_by_user,omitempty"` // The status page the degradation belongs to. StatusPage *DegradationDataRelationshipsStatusPage `json:"status_page,omitempty"` + // The template the degradation was created from. + Template *DegradationDataRelationshipsTemplate `json:"template,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:"-"` @@ -122,6 +124,34 @@ func (o *DegradationDataRelationships) SetStatusPage(v DegradationDataRelationsh o.StatusPage = &v } +// GetTemplate returns the Template field value if set, zero value otherwise. +func (o *DegradationDataRelationships) GetTemplate() DegradationDataRelationshipsTemplate { + if o == nil || o.Template == nil { + var ret DegradationDataRelationshipsTemplate + return ret + } + return *o.Template +} + +// GetTemplateOk returns a tuple with the Template field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *DegradationDataRelationships) GetTemplateOk() (*DegradationDataRelationshipsTemplate, bool) { + if o == nil || o.Template == nil { + return nil, false + } + return o.Template, true +} + +// HasTemplate returns a boolean if a field has been set. +func (o *DegradationDataRelationships) HasTemplate() bool { + return o != nil && o.Template != nil +} + +// SetTemplate gets a reference to the given DegradationDataRelationshipsTemplate and assigns it to the Template field. +func (o *DegradationDataRelationships) SetTemplate(v DegradationDataRelationshipsTemplate) { + o.Template = &v +} + // MarshalJSON serializes the struct using spec logic. func (o DegradationDataRelationships) MarshalJSON() ([]byte, error) { toSerialize := map[string]interface{}{} @@ -137,6 +167,9 @@ func (o DegradationDataRelationships) MarshalJSON() ([]byte, error) { if o.StatusPage != nil { toSerialize["status_page"] = o.StatusPage } + if o.Template != nil { + toSerialize["template"] = o.Template + } for key, value := range o.AdditionalProperties { toSerialize[key] = value @@ -150,13 +183,14 @@ func (o *DegradationDataRelationships) UnmarshalJSON(bytes []byte) (err error) { CreatedByUser *DegradationDataRelationshipsCreatedByUser `json:"created_by_user,omitempty"` LastModifiedByUser *DegradationDataRelationshipsLastModifiedByUser `json:"last_modified_by_user,omitempty"` StatusPage *DegradationDataRelationshipsStatusPage `json:"status_page,omitempty"` + Template *DegradationDataRelationshipsTemplate `json:"template,omitempty"` }{} if err = datadog.Unmarshal(bytes, &all); err != nil { return datadog.Unmarshal(bytes, &o.UnparsedObject) } additionalProperties := make(map[string]interface{}) if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { - datadog.DeleteKeys(additionalProperties, &[]string{"created_by_user", "last_modified_by_user", "status_page"}) + datadog.DeleteKeys(additionalProperties, &[]string{"created_by_user", "last_modified_by_user", "status_page", "template"}) } else { return err } @@ -174,6 +208,10 @@ func (o *DegradationDataRelationships) UnmarshalJSON(bytes []byte) (err error) { hasInvalidField = true } o.StatusPage = all.StatusPage + if all.Template != nil && all.Template.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Template = all.Template if len(additionalProperties) > 0 { o.AdditionalProperties = additionalProperties diff --git a/api/datadogV2/model_degradation_data_relationships_template.go b/api/datadogV2/model_degradation_data_relationships_template.go new file mode 100644 index 00000000000..7325296df13 --- /dev/null +++ b/api/datadogV2/model_degradation_data_relationships_template.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" +) + +// DegradationDataRelationshipsTemplate The template the degradation was created from. +type DegradationDataRelationshipsTemplate struct { + // The data object identifying the template the degradation was created from. + Data DegradationDataRelationshipsTemplateData `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:"-"` +} + +// NewDegradationDataRelationshipsTemplate instantiates a new DegradationDataRelationshipsTemplate 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 NewDegradationDataRelationshipsTemplate(data DegradationDataRelationshipsTemplateData) *DegradationDataRelationshipsTemplate { + this := DegradationDataRelationshipsTemplate{} + this.Data = data + return &this +} + +// NewDegradationDataRelationshipsTemplateWithDefaults instantiates a new DegradationDataRelationshipsTemplate 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 NewDegradationDataRelationshipsTemplateWithDefaults() *DegradationDataRelationshipsTemplate { + this := DegradationDataRelationshipsTemplate{} + return &this +} + +// GetData returns the Data field value. +func (o *DegradationDataRelationshipsTemplate) GetData() DegradationDataRelationshipsTemplateData { + if o == nil { + var ret DegradationDataRelationshipsTemplateData + 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 *DegradationDataRelationshipsTemplate) GetDataOk() (*DegradationDataRelationshipsTemplateData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *DegradationDataRelationshipsTemplate) SetData(v DegradationDataRelationshipsTemplateData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o DegradationDataRelationshipsTemplate) 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 *DegradationDataRelationshipsTemplate) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *DegradationDataRelationshipsTemplateData `json:"data"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Data == nil { + return fmt.Errorf("required field data missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + + hasInvalidField := false + if all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Data = *all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_degradation_data_relationships_template_data.go b/api/datadogV2/model_degradation_data_relationships_template_data.go new file mode 100644 index 00000000000..495e91665a3 --- /dev/null +++ b/api/datadogV2/model_degradation_data_relationships_template_data.go @@ -0,0 +1,145 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// DegradationDataRelationshipsTemplateData The data object identifying the template the degradation was created from. +type DegradationDataRelationshipsTemplateData struct { + // The ID of the degradation template. + Id string `json:"id"` + // Degradation templates resource type. + Type PatchDegradationTemplateRequestDataType `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:"-"` +} + +// NewDegradationDataRelationshipsTemplateData instantiates a new DegradationDataRelationshipsTemplateData 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 NewDegradationDataRelationshipsTemplateData(id string, typeVar PatchDegradationTemplateRequestDataType) *DegradationDataRelationshipsTemplateData { + this := DegradationDataRelationshipsTemplateData{} + this.Id = id + this.Type = typeVar + return &this +} + +// NewDegradationDataRelationshipsTemplateDataWithDefaults instantiates a new DegradationDataRelationshipsTemplateData 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 NewDegradationDataRelationshipsTemplateDataWithDefaults() *DegradationDataRelationshipsTemplateData { + this := DegradationDataRelationshipsTemplateData{} + var typeVar PatchDegradationTemplateRequestDataType = PATCHDEGRADATIONTEMPLATEREQUESTDATATYPE_DEGRADATION_TEMPLATES + this.Type = typeVar + return &this +} + +// GetId returns the Id field value. +func (o *DegradationDataRelationshipsTemplateData) GetId() string { + if o == nil { + var ret string + 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 *DegradationDataRelationshipsTemplateData) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Id, true +} + +// SetId sets field value. +func (o *DegradationDataRelationshipsTemplateData) SetId(v string) { + o.Id = v +} + +// GetType returns the Type field value. +func (o *DegradationDataRelationshipsTemplateData) GetType() PatchDegradationTemplateRequestDataType { + if o == nil { + var ret PatchDegradationTemplateRequestDataType + 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 *DegradationDataRelationshipsTemplateData) GetTypeOk() (*PatchDegradationTemplateRequestDataType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *DegradationDataRelationshipsTemplateData) SetType(v PatchDegradationTemplateRequestDataType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o DegradationDataRelationshipsTemplateData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["id"] = o.Id + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *DegradationDataRelationshipsTemplateData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Id *string `json:"id"` + Type *PatchDegradationTemplateRequestDataType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Id == nil { + return fmt.Errorf("required field id missing") + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"id", "type"}) + } else { + return err + } + + hasInvalidField := false + o.Id = *all.Id + if !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = *all.Type + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_degradation_template.go b/api/datadogV2/model_degradation_template.go new file mode 100644 index 00000000000..111fa42e5b6 --- /dev/null +++ b/api/datadogV2/model_degradation_template.go @@ -0,0 +1,146 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// DegradationTemplate Response object for a single degradation template. +type DegradationTemplate struct { + // The data object for a degradation template. + Data *DegradationTemplateData `json:"data,omitempty"` + // The included related resources of a degradation template. Client must explicitly request these resources by name in the `include` query parameter. + Included []DegradationIncluded `json:"included,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:"-"` +} + +// NewDegradationTemplate instantiates a new DegradationTemplate 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 NewDegradationTemplate() *DegradationTemplate { + this := DegradationTemplate{} + return &this +} + +// NewDegradationTemplateWithDefaults instantiates a new DegradationTemplate 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 NewDegradationTemplateWithDefaults() *DegradationTemplate { + this := DegradationTemplate{} + return &this +} + +// GetData returns the Data field value if set, zero value otherwise. +func (o *DegradationTemplate) GetData() DegradationTemplateData { + if o == nil || o.Data == nil { + var ret DegradationTemplateData + return ret + } + return *o.Data +} + +// GetDataOk returns a tuple with the Data field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *DegradationTemplate) GetDataOk() (*DegradationTemplateData, bool) { + if o == nil || o.Data == nil { + return nil, false + } + return o.Data, true +} + +// HasData returns a boolean if a field has been set. +func (o *DegradationTemplate) HasData() bool { + return o != nil && o.Data != nil +} + +// SetData gets a reference to the given DegradationTemplateData and assigns it to the Data field. +func (o *DegradationTemplate) SetData(v DegradationTemplateData) { + o.Data = &v +} + +// GetIncluded returns the Included field value if set, zero value otherwise. +func (o *DegradationTemplate) GetIncluded() []DegradationIncluded { + if o == nil || o.Included == nil { + var ret []DegradationIncluded + return ret + } + return o.Included +} + +// GetIncludedOk returns a tuple with the Included field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *DegradationTemplate) GetIncludedOk() (*[]DegradationIncluded, bool) { + if o == nil || o.Included == nil { + return nil, false + } + return &o.Included, true +} + +// HasIncluded returns a boolean if a field has been set. +func (o *DegradationTemplate) HasIncluded() bool { + return o != nil && o.Included != nil +} + +// SetIncluded gets a reference to the given []DegradationIncluded and assigns it to the Included field. +func (o *DegradationTemplate) SetIncluded(v []DegradationIncluded) { + o.Included = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o DegradationTemplate) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Data != nil { + toSerialize["data"] = o.Data + } + if o.Included != nil { + toSerialize["included"] = o.Included + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *DegradationTemplate) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *DegradationTemplateData `json:"data,omitempty"` + Included []DegradationIncluded `json:"included,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data", "included"}) + } else { + return err + } + + hasInvalidField := false + if all.Data != nil && all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Data = all.Data + o.Included = all.Included + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_degradation_template_array.go b/api/datadogV2/model_degradation_template_array.go new file mode 100644 index 00000000000..94cbf95ec14 --- /dev/null +++ b/api/datadogV2/model_degradation_template_array.go @@ -0,0 +1,136 @@ +// 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" +) + +// DegradationTemplateArray Response object for a list of degradation templates. +type DegradationTemplateArray struct { + // A list of degradation template data objects. + Data []DegradationTemplateData `json:"data"` + // The included related resources of a degradation template. Client must explicitly request these resources by name in the `include` query parameter. + Included []DegradationIncluded `json:"included,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:"-"` +} + +// NewDegradationTemplateArray instantiates a new DegradationTemplateArray 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 NewDegradationTemplateArray(data []DegradationTemplateData) *DegradationTemplateArray { + this := DegradationTemplateArray{} + this.Data = data + return &this +} + +// NewDegradationTemplateArrayWithDefaults instantiates a new DegradationTemplateArray 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 NewDegradationTemplateArrayWithDefaults() *DegradationTemplateArray { + this := DegradationTemplateArray{} + return &this +} + +// GetData returns the Data field value. +func (o *DegradationTemplateArray) GetData() []DegradationTemplateData { + if o == nil { + var ret []DegradationTemplateData + 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 *DegradationTemplateArray) GetDataOk() (*[]DegradationTemplateData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *DegradationTemplateArray) SetData(v []DegradationTemplateData) { + o.Data = v +} + +// GetIncluded returns the Included field value if set, zero value otherwise. +func (o *DegradationTemplateArray) GetIncluded() []DegradationIncluded { + if o == nil || o.Included == nil { + var ret []DegradationIncluded + return ret + } + return o.Included +} + +// GetIncludedOk returns a tuple with the Included field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *DegradationTemplateArray) GetIncludedOk() (*[]DegradationIncluded, bool) { + if o == nil || o.Included == nil { + return nil, false + } + return &o.Included, true +} + +// HasIncluded returns a boolean if a field has been set. +func (o *DegradationTemplateArray) HasIncluded() bool { + return o != nil && o.Included != nil +} + +// SetIncluded gets a reference to the given []DegradationIncluded and assigns it to the Included field. +func (o *DegradationTemplateArray) SetIncluded(v []DegradationIncluded) { + o.Included = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o DegradationTemplateArray) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["data"] = o.Data + if o.Included != nil { + toSerialize["included"] = o.Included + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *DegradationTemplateArray) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *[]DegradationTemplateData `json:"data"` + Included []DegradationIncluded `json:"included,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Data == nil { + return fmt.Errorf("required field data missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data", "included"}) + } else { + return err + } + o.Data = *all.Data + o.Included = all.Included + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_degradation_template_data.go b/api/datadogV2/model_degradation_template_data.go new file mode 100644 index 00000000000..66c8b623e07 --- /dev/null +++ b/api/datadogV2/model_degradation_template_data.go @@ -0,0 +1,224 @@ +// 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" +) + +// DegradationTemplateData The data object for a degradation template. +type DegradationTemplateData struct { + // The attributes of a degradation template. + Attributes *DegradationTemplateDataAttributes `json:"attributes,omitempty"` + // The ID of the degradation template. + Id *string `json:"id,omitempty"` + // The relationships of a degradation template. + Relationships *DegradationTemplateDataRelationships `json:"relationships,omitempty"` + // Degradation templates resource type. + Type PatchDegradationTemplateRequestDataType `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:"-"` +} + +// NewDegradationTemplateData instantiates a new DegradationTemplateData 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 NewDegradationTemplateData(typeVar PatchDegradationTemplateRequestDataType) *DegradationTemplateData { + this := DegradationTemplateData{} + this.Type = typeVar + return &this +} + +// NewDegradationTemplateDataWithDefaults instantiates a new DegradationTemplateData 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 NewDegradationTemplateDataWithDefaults() *DegradationTemplateData { + this := DegradationTemplateData{} + var typeVar PatchDegradationTemplateRequestDataType = PATCHDEGRADATIONTEMPLATEREQUESTDATATYPE_DEGRADATION_TEMPLATES + this.Type = typeVar + return &this +} + +// GetAttributes returns the Attributes field value if set, zero value otherwise. +func (o *DegradationTemplateData) GetAttributes() DegradationTemplateDataAttributes { + if o == nil || o.Attributes == nil { + var ret DegradationTemplateDataAttributes + return ret + } + return *o.Attributes +} + +// GetAttributesOk returns a tuple with the Attributes field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *DegradationTemplateData) GetAttributesOk() (*DegradationTemplateDataAttributes, bool) { + if o == nil || o.Attributes == nil { + return nil, false + } + return o.Attributes, true +} + +// HasAttributes returns a boolean if a field has been set. +func (o *DegradationTemplateData) HasAttributes() bool { + return o != nil && o.Attributes != nil +} + +// SetAttributes gets a reference to the given DegradationTemplateDataAttributes and assigns it to the Attributes field. +func (o *DegradationTemplateData) SetAttributes(v DegradationTemplateDataAttributes) { + o.Attributes = &v +} + +// GetId returns the Id field value if set, zero value otherwise. +func (o *DegradationTemplateData) GetId() string { + if o == nil || o.Id == nil { + var ret string + return ret + } + return *o.Id +} + +// GetIdOk returns a tuple with the Id field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *DegradationTemplateData) GetIdOk() (*string, bool) { + if o == nil || o.Id == nil { + return nil, false + } + return o.Id, true +} + +// HasId returns a boolean if a field has been set. +func (o *DegradationTemplateData) HasId() bool { + return o != nil && o.Id != nil +} + +// SetId gets a reference to the given string and assigns it to the Id field. +func (o *DegradationTemplateData) SetId(v string) { + o.Id = &v +} + +// GetRelationships returns the Relationships field value if set, zero value otherwise. +func (o *DegradationTemplateData) GetRelationships() DegradationTemplateDataRelationships { + if o == nil || o.Relationships == nil { + var ret DegradationTemplateDataRelationships + return ret + } + return *o.Relationships +} + +// GetRelationshipsOk returns a tuple with the Relationships field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *DegradationTemplateData) GetRelationshipsOk() (*DegradationTemplateDataRelationships, bool) { + if o == nil || o.Relationships == nil { + return nil, false + } + return o.Relationships, true +} + +// HasRelationships returns a boolean if a field has been set. +func (o *DegradationTemplateData) HasRelationships() bool { + return o != nil && o.Relationships != nil +} + +// SetRelationships gets a reference to the given DegradationTemplateDataRelationships and assigns it to the Relationships field. +func (o *DegradationTemplateData) SetRelationships(v DegradationTemplateDataRelationships) { + o.Relationships = &v +} + +// GetType returns the Type field value. +func (o *DegradationTemplateData) GetType() PatchDegradationTemplateRequestDataType { + if o == nil { + var ret PatchDegradationTemplateRequestDataType + 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 *DegradationTemplateData) GetTypeOk() (*PatchDegradationTemplateRequestDataType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *DegradationTemplateData) SetType(v PatchDegradationTemplateRequestDataType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o DegradationTemplateData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Attributes != nil { + toSerialize["attributes"] = o.Attributes + } + if o.Id != nil { + toSerialize["id"] = o.Id + } + if o.Relationships != nil { + toSerialize["relationships"] = o.Relationships + } + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *DegradationTemplateData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *DegradationTemplateDataAttributes `json:"attributes,omitempty"` + Id *string `json:"id,omitempty"` + Relationships *DegradationTemplateDataRelationships `json:"relationships,omitempty"` + Type *PatchDegradationTemplateRequestDataType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "id", "relationships", "type"}) + } else { + return err + } + + hasInvalidField := false + if all.Attributes != nil && all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Attributes = all.Attributes + o.Id = all.Id + if all.Relationships != nil && all.Relationships.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Relationships = all.Relationships + 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_degradation_template_data_attributes.go b/api/datadogV2/model_degradation_template_data_attributes.go new file mode 100644 index 00000000000..f75539e331f --- /dev/null +++ b/api/datadogV2/model_degradation_template_data_attributes.go @@ -0,0 +1,287 @@ +// 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 ( + "time" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// DegradationTemplateDataAttributes The attributes of a degradation template. +type DegradationTemplateDataAttributes struct { + // The components affected by a degradation created from this template. + ComponentsAffected []DegradationTemplateDataAttributesComponentsAffectedItems `json:"components_affected,omitempty"` + // Timestamp of when the degradation template was created. + CreatedAt *time.Time `json:"created_at,omitempty"` + // The title used for a degradation created from this template. + DegradationTitle *string `json:"degradation_title,omitempty"` + // Timestamp of when the degradation template was last modified. + ModifiedAt *time.Time `json:"modified_at,omitempty"` + // The name of the degradation template. + Name *string `json:"name,omitempty"` + // The pre-filled updates for a degradation created from this template. + Updates []DegradationTemplateDataAttributesUpdatesItems `json:"updates,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:"-"` +} + +// NewDegradationTemplateDataAttributes instantiates a new DegradationTemplateDataAttributes 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 NewDegradationTemplateDataAttributes() *DegradationTemplateDataAttributes { + this := DegradationTemplateDataAttributes{} + return &this +} + +// NewDegradationTemplateDataAttributesWithDefaults instantiates a new DegradationTemplateDataAttributes 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 NewDegradationTemplateDataAttributesWithDefaults() *DegradationTemplateDataAttributes { + this := DegradationTemplateDataAttributes{} + return &this +} + +// GetComponentsAffected returns the ComponentsAffected field value if set, zero value otherwise. +func (o *DegradationTemplateDataAttributes) GetComponentsAffected() []DegradationTemplateDataAttributesComponentsAffectedItems { + if o == nil || o.ComponentsAffected == nil { + var ret []DegradationTemplateDataAttributesComponentsAffectedItems + return ret + } + return o.ComponentsAffected +} + +// GetComponentsAffectedOk returns a tuple with the ComponentsAffected field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *DegradationTemplateDataAttributes) GetComponentsAffectedOk() (*[]DegradationTemplateDataAttributesComponentsAffectedItems, bool) { + if o == nil || o.ComponentsAffected == nil { + return nil, false + } + return &o.ComponentsAffected, true +} + +// HasComponentsAffected returns a boolean if a field has been set. +func (o *DegradationTemplateDataAttributes) HasComponentsAffected() bool { + return o != nil && o.ComponentsAffected != nil +} + +// SetComponentsAffected gets a reference to the given []DegradationTemplateDataAttributesComponentsAffectedItems and assigns it to the ComponentsAffected field. +func (o *DegradationTemplateDataAttributes) SetComponentsAffected(v []DegradationTemplateDataAttributesComponentsAffectedItems) { + o.ComponentsAffected = v +} + +// GetCreatedAt returns the CreatedAt field value if set, zero value otherwise. +func (o *DegradationTemplateDataAttributes) GetCreatedAt() time.Time { + if o == nil || o.CreatedAt == nil { + var ret time.Time + return ret + } + return *o.CreatedAt +} + +// GetCreatedAtOk returns a tuple with the CreatedAt field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *DegradationTemplateDataAttributes) GetCreatedAtOk() (*time.Time, bool) { + if o == nil || o.CreatedAt == nil { + return nil, false + } + return o.CreatedAt, true +} + +// HasCreatedAt returns a boolean if a field has been set. +func (o *DegradationTemplateDataAttributes) HasCreatedAt() bool { + return o != nil && o.CreatedAt != nil +} + +// SetCreatedAt gets a reference to the given time.Time and assigns it to the CreatedAt field. +func (o *DegradationTemplateDataAttributes) SetCreatedAt(v time.Time) { + o.CreatedAt = &v +} + +// GetDegradationTitle returns the DegradationTitle field value if set, zero value otherwise. +func (o *DegradationTemplateDataAttributes) GetDegradationTitle() string { + if o == nil || o.DegradationTitle == nil { + var ret string + return ret + } + return *o.DegradationTitle +} + +// GetDegradationTitleOk returns a tuple with the DegradationTitle field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *DegradationTemplateDataAttributes) GetDegradationTitleOk() (*string, bool) { + if o == nil || o.DegradationTitle == nil { + return nil, false + } + return o.DegradationTitle, true +} + +// HasDegradationTitle returns a boolean if a field has been set. +func (o *DegradationTemplateDataAttributes) HasDegradationTitle() bool { + return o != nil && o.DegradationTitle != nil +} + +// SetDegradationTitle gets a reference to the given string and assigns it to the DegradationTitle field. +func (o *DegradationTemplateDataAttributes) SetDegradationTitle(v string) { + o.DegradationTitle = &v +} + +// GetModifiedAt returns the ModifiedAt field value if set, zero value otherwise. +func (o *DegradationTemplateDataAttributes) GetModifiedAt() time.Time { + if o == nil || o.ModifiedAt == nil { + var ret time.Time + return ret + } + return *o.ModifiedAt +} + +// GetModifiedAtOk returns a tuple with the ModifiedAt field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *DegradationTemplateDataAttributes) GetModifiedAtOk() (*time.Time, bool) { + if o == nil || o.ModifiedAt == nil { + return nil, false + } + return o.ModifiedAt, true +} + +// HasModifiedAt returns a boolean if a field has been set. +func (o *DegradationTemplateDataAttributes) HasModifiedAt() bool { + return o != nil && o.ModifiedAt != nil +} + +// SetModifiedAt gets a reference to the given time.Time and assigns it to the ModifiedAt field. +func (o *DegradationTemplateDataAttributes) SetModifiedAt(v time.Time) { + o.ModifiedAt = &v +} + +// GetName returns the Name field value if set, zero value otherwise. +func (o *DegradationTemplateDataAttributes) GetName() string { + if o == nil || o.Name == nil { + var ret string + return ret + } + return *o.Name +} + +// GetNameOk returns a tuple with the Name field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *DegradationTemplateDataAttributes) GetNameOk() (*string, bool) { + if o == nil || o.Name == nil { + return nil, false + } + return o.Name, true +} + +// HasName returns a boolean if a field has been set. +func (o *DegradationTemplateDataAttributes) HasName() bool { + return o != nil && o.Name != nil +} + +// SetName gets a reference to the given string and assigns it to the Name field. +func (o *DegradationTemplateDataAttributes) SetName(v string) { + o.Name = &v +} + +// GetUpdates returns the Updates field value if set, zero value otherwise. +func (o *DegradationTemplateDataAttributes) GetUpdates() []DegradationTemplateDataAttributesUpdatesItems { + if o == nil || o.Updates == nil { + var ret []DegradationTemplateDataAttributesUpdatesItems + return ret + } + return o.Updates +} + +// GetUpdatesOk returns a tuple with the Updates field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *DegradationTemplateDataAttributes) GetUpdatesOk() (*[]DegradationTemplateDataAttributesUpdatesItems, bool) { + if o == nil || o.Updates == nil { + return nil, false + } + return &o.Updates, true +} + +// HasUpdates returns a boolean if a field has been set. +func (o *DegradationTemplateDataAttributes) HasUpdates() bool { + return o != nil && o.Updates != nil +} + +// SetUpdates gets a reference to the given []DegradationTemplateDataAttributesUpdatesItems and assigns it to the Updates field. +func (o *DegradationTemplateDataAttributes) SetUpdates(v []DegradationTemplateDataAttributesUpdatesItems) { + o.Updates = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o DegradationTemplateDataAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.ComponentsAffected != nil { + toSerialize["components_affected"] = o.ComponentsAffected + } + if o.CreatedAt != nil { + if o.CreatedAt.Nanosecond() == 0 { + toSerialize["created_at"] = o.CreatedAt.Format("2006-01-02T15:04:05Z07:00") + } else { + toSerialize["created_at"] = o.CreatedAt.Format("2006-01-02T15:04:05.000Z07:00") + } + } + if o.DegradationTitle != nil { + toSerialize["degradation_title"] = o.DegradationTitle + } + if o.ModifiedAt != nil { + if o.ModifiedAt.Nanosecond() == 0 { + toSerialize["modified_at"] = o.ModifiedAt.Format("2006-01-02T15:04:05Z07:00") + } else { + toSerialize["modified_at"] = o.ModifiedAt.Format("2006-01-02T15:04:05.000Z07:00") + } + } + if o.Name != nil { + toSerialize["name"] = o.Name + } + if o.Updates != nil { + toSerialize["updates"] = o.Updates + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *DegradationTemplateDataAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + ComponentsAffected []DegradationTemplateDataAttributesComponentsAffectedItems `json:"components_affected,omitempty"` + CreatedAt *time.Time `json:"created_at,omitempty"` + DegradationTitle *string `json:"degradation_title,omitempty"` + ModifiedAt *time.Time `json:"modified_at,omitempty"` + Name *string `json:"name,omitempty"` + Updates []DegradationTemplateDataAttributesUpdatesItems `json:"updates,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"components_affected", "created_at", "degradation_title", "modified_at", "name", "updates"}) + } else { + return err + } + o.ComponentsAffected = all.ComponentsAffected + o.CreatedAt = all.CreatedAt + o.DegradationTitle = all.DegradationTitle + o.ModifiedAt = all.ModifiedAt + o.Name = all.Name + o.Updates = all.Updates + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_degradation_template_data_attributes_components_affected_items.go b/api/datadogV2/model_degradation_template_data_attributes_components_affected_items.go new file mode 100644 index 00000000000..868f4daef80 --- /dev/null +++ b/api/datadogV2/model_degradation_template_data_attributes_components_affected_items.go @@ -0,0 +1,178 @@ +// 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" +) + +// DegradationTemplateDataAttributesComponentsAffectedItems A component affected by a degradation created from this template. +type DegradationTemplateDataAttributesComponentsAffectedItems struct { + // The ID of the component. + Id string `json:"id"` + // The name of the component. + Name *string `json:"name,omitempty"` + // The status of the component. + Status PatchDegradationTemplateRequestDataAttributesComponentsAffectedItemsStatus `json:"status"` + // 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:"-"` +} + +// NewDegradationTemplateDataAttributesComponentsAffectedItems instantiates a new DegradationTemplateDataAttributesComponentsAffectedItems 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 NewDegradationTemplateDataAttributesComponentsAffectedItems(id string, status PatchDegradationTemplateRequestDataAttributesComponentsAffectedItemsStatus) *DegradationTemplateDataAttributesComponentsAffectedItems { + this := DegradationTemplateDataAttributesComponentsAffectedItems{} + this.Id = id + this.Status = status + return &this +} + +// NewDegradationTemplateDataAttributesComponentsAffectedItemsWithDefaults instantiates a new DegradationTemplateDataAttributesComponentsAffectedItems 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 NewDegradationTemplateDataAttributesComponentsAffectedItemsWithDefaults() *DegradationTemplateDataAttributesComponentsAffectedItems { + this := DegradationTemplateDataAttributesComponentsAffectedItems{} + return &this +} + +// GetId returns the Id field value. +func (o *DegradationTemplateDataAttributesComponentsAffectedItems) GetId() string { + if o == nil { + var ret string + 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 *DegradationTemplateDataAttributesComponentsAffectedItems) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Id, true +} + +// SetId sets field value. +func (o *DegradationTemplateDataAttributesComponentsAffectedItems) SetId(v string) { + o.Id = v +} + +// GetName returns the Name field value if set, zero value otherwise. +func (o *DegradationTemplateDataAttributesComponentsAffectedItems) GetName() string { + if o == nil || o.Name == nil { + var ret string + return ret + } + return *o.Name +} + +// GetNameOk returns a tuple with the Name field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *DegradationTemplateDataAttributesComponentsAffectedItems) GetNameOk() (*string, bool) { + if o == nil || o.Name == nil { + return nil, false + } + return o.Name, true +} + +// HasName returns a boolean if a field has been set. +func (o *DegradationTemplateDataAttributesComponentsAffectedItems) HasName() bool { + return o != nil && o.Name != nil +} + +// SetName gets a reference to the given string and assigns it to the Name field. +func (o *DegradationTemplateDataAttributesComponentsAffectedItems) SetName(v string) { + o.Name = &v +} + +// GetStatus returns the Status field value. +func (o *DegradationTemplateDataAttributesComponentsAffectedItems) GetStatus() PatchDegradationTemplateRequestDataAttributesComponentsAffectedItemsStatus { + if o == nil { + var ret PatchDegradationTemplateRequestDataAttributesComponentsAffectedItemsStatus + return ret + } + return o.Status +} + +// GetStatusOk returns a tuple with the Status field value +// and a boolean to check if the value has been set. +func (o *DegradationTemplateDataAttributesComponentsAffectedItems) GetStatusOk() (*PatchDegradationTemplateRequestDataAttributesComponentsAffectedItemsStatus, bool) { + if o == nil { + return nil, false + } + return &o.Status, true +} + +// SetStatus sets field value. +func (o *DegradationTemplateDataAttributesComponentsAffectedItems) SetStatus(v PatchDegradationTemplateRequestDataAttributesComponentsAffectedItemsStatus) { + o.Status = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o DegradationTemplateDataAttributesComponentsAffectedItems) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["id"] = o.Id + if o.Name != nil { + toSerialize["name"] = o.Name + } + toSerialize["status"] = o.Status + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *DegradationTemplateDataAttributesComponentsAffectedItems) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Id *string `json:"id"` + Name *string `json:"name,omitempty"` + Status *PatchDegradationTemplateRequestDataAttributesComponentsAffectedItemsStatus `json:"status"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Id == nil { + return fmt.Errorf("required field id missing") + } + if all.Status == nil { + return fmt.Errorf("required field status missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"id", "name", "status"}) + } else { + return err + } + + hasInvalidField := false + o.Id = *all.Id + o.Name = all.Name + if !all.Status.IsValid() { + hasInvalidField = true + } else { + o.Status = *all.Status + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_degradation_template_data_attributes_updates_items.go b/api/datadogV2/model_degradation_template_data_attributes_updates_items.go new file mode 100644 index 00000000000..fad10cb0755 --- /dev/null +++ b/api/datadogV2/model_degradation_template_data_attributes_updates_items.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" +) + +// DegradationTemplateDataAttributesUpdatesItems A pre-filled update for a degradation created from this template. +type DegradationTemplateDataAttributesUpdatesItems struct { + // The message of the update. + Message *string `json:"message,omitempty"` + // The status of the degradation. + Status CreateDegradationRequestDataAttributesStatus `json:"status"` + // 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:"-"` +} + +// NewDegradationTemplateDataAttributesUpdatesItems instantiates a new DegradationTemplateDataAttributesUpdatesItems 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 NewDegradationTemplateDataAttributesUpdatesItems(status CreateDegradationRequestDataAttributesStatus) *DegradationTemplateDataAttributesUpdatesItems { + this := DegradationTemplateDataAttributesUpdatesItems{} + this.Status = status + return &this +} + +// NewDegradationTemplateDataAttributesUpdatesItemsWithDefaults instantiates a new DegradationTemplateDataAttributesUpdatesItems 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 NewDegradationTemplateDataAttributesUpdatesItemsWithDefaults() *DegradationTemplateDataAttributesUpdatesItems { + this := DegradationTemplateDataAttributesUpdatesItems{} + return &this +} + +// GetMessage returns the Message field value if set, zero value otherwise. +func (o *DegradationTemplateDataAttributesUpdatesItems) GetMessage() string { + if o == nil || o.Message == nil { + var ret string + return ret + } + return *o.Message +} + +// GetMessageOk returns a tuple with the Message field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *DegradationTemplateDataAttributesUpdatesItems) GetMessageOk() (*string, bool) { + if o == nil || o.Message == nil { + return nil, false + } + return o.Message, true +} + +// HasMessage returns a boolean if a field has been set. +func (o *DegradationTemplateDataAttributesUpdatesItems) HasMessage() bool { + return o != nil && o.Message != nil +} + +// SetMessage gets a reference to the given string and assigns it to the Message field. +func (o *DegradationTemplateDataAttributesUpdatesItems) SetMessage(v string) { + o.Message = &v +} + +// GetStatus returns the Status field value. +func (o *DegradationTemplateDataAttributesUpdatesItems) GetStatus() CreateDegradationRequestDataAttributesStatus { + if o == nil { + var ret CreateDegradationRequestDataAttributesStatus + return ret + } + return o.Status +} + +// GetStatusOk returns a tuple with the Status field value +// and a boolean to check if the value has been set. +func (o *DegradationTemplateDataAttributesUpdatesItems) GetStatusOk() (*CreateDegradationRequestDataAttributesStatus, bool) { + if o == nil { + return nil, false + } + return &o.Status, true +} + +// SetStatus sets field value. +func (o *DegradationTemplateDataAttributesUpdatesItems) SetStatus(v CreateDegradationRequestDataAttributesStatus) { + o.Status = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o DegradationTemplateDataAttributesUpdatesItems) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Message != nil { + toSerialize["message"] = o.Message + } + toSerialize["status"] = o.Status + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *DegradationTemplateDataAttributesUpdatesItems) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Message *string `json:"message,omitempty"` + Status *CreateDegradationRequestDataAttributesStatus `json:"status"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Status == nil { + return fmt.Errorf("required field status missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"message", "status"}) + } else { + return err + } + + hasInvalidField := false + o.Message = all.Message + if !all.Status.IsValid() { + hasInvalidField = true + } else { + o.Status = *all.Status + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_degradation_template_data_relationships.go b/api/datadogV2/model_degradation_template_data_relationships.go new file mode 100644 index 00000000000..64ad519a9a3 --- /dev/null +++ b/api/datadogV2/model_degradation_template_data_relationships.go @@ -0,0 +1,187 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// DegradationTemplateDataRelationships The relationships of a degradation template. +type DegradationTemplateDataRelationships struct { + // The Datadog user who created the degradation template. + CreatedByUser *DegradationTemplateDataRelationshipsCreatedByUser `json:"created_by_user,omitempty"` + // The Datadog user who last modified the degradation template. + LastModifiedByUser *DegradationTemplateDataRelationshipsLastModifiedByUser `json:"last_modified_by_user,omitempty"` + // The status page the degradation template belongs to. + StatusPage *DegradationTemplateDataRelationshipsStatusPage `json:"status_page,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:"-"` +} + +// NewDegradationTemplateDataRelationships instantiates a new DegradationTemplateDataRelationships 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 NewDegradationTemplateDataRelationships() *DegradationTemplateDataRelationships { + this := DegradationTemplateDataRelationships{} + return &this +} + +// NewDegradationTemplateDataRelationshipsWithDefaults instantiates a new DegradationTemplateDataRelationships 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 NewDegradationTemplateDataRelationshipsWithDefaults() *DegradationTemplateDataRelationships { + this := DegradationTemplateDataRelationships{} + return &this +} + +// GetCreatedByUser returns the CreatedByUser field value if set, zero value otherwise. +func (o *DegradationTemplateDataRelationships) GetCreatedByUser() DegradationTemplateDataRelationshipsCreatedByUser { + if o == nil || o.CreatedByUser == nil { + var ret DegradationTemplateDataRelationshipsCreatedByUser + return ret + } + return *o.CreatedByUser +} + +// GetCreatedByUserOk returns a tuple with the CreatedByUser field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *DegradationTemplateDataRelationships) GetCreatedByUserOk() (*DegradationTemplateDataRelationshipsCreatedByUser, bool) { + if o == nil || o.CreatedByUser == nil { + return nil, false + } + return o.CreatedByUser, true +} + +// HasCreatedByUser returns a boolean if a field has been set. +func (o *DegradationTemplateDataRelationships) HasCreatedByUser() bool { + return o != nil && o.CreatedByUser != nil +} + +// SetCreatedByUser gets a reference to the given DegradationTemplateDataRelationshipsCreatedByUser and assigns it to the CreatedByUser field. +func (o *DegradationTemplateDataRelationships) SetCreatedByUser(v DegradationTemplateDataRelationshipsCreatedByUser) { + o.CreatedByUser = &v +} + +// GetLastModifiedByUser returns the LastModifiedByUser field value if set, zero value otherwise. +func (o *DegradationTemplateDataRelationships) GetLastModifiedByUser() DegradationTemplateDataRelationshipsLastModifiedByUser { + if o == nil || o.LastModifiedByUser == nil { + var ret DegradationTemplateDataRelationshipsLastModifiedByUser + return ret + } + return *o.LastModifiedByUser +} + +// GetLastModifiedByUserOk returns a tuple with the LastModifiedByUser field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *DegradationTemplateDataRelationships) GetLastModifiedByUserOk() (*DegradationTemplateDataRelationshipsLastModifiedByUser, bool) { + if o == nil || o.LastModifiedByUser == nil { + return nil, false + } + return o.LastModifiedByUser, true +} + +// HasLastModifiedByUser returns a boolean if a field has been set. +func (o *DegradationTemplateDataRelationships) HasLastModifiedByUser() bool { + return o != nil && o.LastModifiedByUser != nil +} + +// SetLastModifiedByUser gets a reference to the given DegradationTemplateDataRelationshipsLastModifiedByUser and assigns it to the LastModifiedByUser field. +func (o *DegradationTemplateDataRelationships) SetLastModifiedByUser(v DegradationTemplateDataRelationshipsLastModifiedByUser) { + o.LastModifiedByUser = &v +} + +// GetStatusPage returns the StatusPage field value if set, zero value otherwise. +func (o *DegradationTemplateDataRelationships) GetStatusPage() DegradationTemplateDataRelationshipsStatusPage { + if o == nil || o.StatusPage == nil { + var ret DegradationTemplateDataRelationshipsStatusPage + return ret + } + return *o.StatusPage +} + +// GetStatusPageOk returns a tuple with the StatusPage field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *DegradationTemplateDataRelationships) GetStatusPageOk() (*DegradationTemplateDataRelationshipsStatusPage, bool) { + if o == nil || o.StatusPage == nil { + return nil, false + } + return o.StatusPage, true +} + +// HasStatusPage returns a boolean if a field has been set. +func (o *DegradationTemplateDataRelationships) HasStatusPage() bool { + return o != nil && o.StatusPage != nil +} + +// SetStatusPage gets a reference to the given DegradationTemplateDataRelationshipsStatusPage and assigns it to the StatusPage field. +func (o *DegradationTemplateDataRelationships) SetStatusPage(v DegradationTemplateDataRelationshipsStatusPage) { + o.StatusPage = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o DegradationTemplateDataRelationships) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.CreatedByUser != nil { + toSerialize["created_by_user"] = o.CreatedByUser + } + if o.LastModifiedByUser != nil { + toSerialize["last_modified_by_user"] = o.LastModifiedByUser + } + if o.StatusPage != nil { + toSerialize["status_page"] = o.StatusPage + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *DegradationTemplateDataRelationships) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + CreatedByUser *DegradationTemplateDataRelationshipsCreatedByUser `json:"created_by_user,omitempty"` + LastModifiedByUser *DegradationTemplateDataRelationshipsLastModifiedByUser `json:"last_modified_by_user,omitempty"` + StatusPage *DegradationTemplateDataRelationshipsStatusPage `json:"status_page,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"created_by_user", "last_modified_by_user", "status_page"}) + } else { + return err + } + + hasInvalidField := false + if all.CreatedByUser != nil && all.CreatedByUser.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.CreatedByUser = all.CreatedByUser + if all.LastModifiedByUser != nil && all.LastModifiedByUser.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.LastModifiedByUser = all.LastModifiedByUser + if all.StatusPage != nil && all.StatusPage.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.StatusPage = all.StatusPage + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_degradation_template_data_relationships_created_by_user.go b/api/datadogV2/model_degradation_template_data_relationships_created_by_user.go new file mode 100644 index 00000000000..f8e7d33acff --- /dev/null +++ b/api/datadogV2/model_degradation_template_data_relationships_created_by_user.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" +) + +// DegradationTemplateDataRelationshipsCreatedByUser The Datadog user who created the degradation template. +type DegradationTemplateDataRelationshipsCreatedByUser struct { + // The data object identifying the Datadog user who created the degradation template. + Data DegradationTemplateDataRelationshipsCreatedByUserData `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:"-"` +} + +// NewDegradationTemplateDataRelationshipsCreatedByUser instantiates a new DegradationTemplateDataRelationshipsCreatedByUser 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 NewDegradationTemplateDataRelationshipsCreatedByUser(data DegradationTemplateDataRelationshipsCreatedByUserData) *DegradationTemplateDataRelationshipsCreatedByUser { + this := DegradationTemplateDataRelationshipsCreatedByUser{} + this.Data = data + return &this +} + +// NewDegradationTemplateDataRelationshipsCreatedByUserWithDefaults instantiates a new DegradationTemplateDataRelationshipsCreatedByUser 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 NewDegradationTemplateDataRelationshipsCreatedByUserWithDefaults() *DegradationTemplateDataRelationshipsCreatedByUser { + this := DegradationTemplateDataRelationshipsCreatedByUser{} + return &this +} + +// GetData returns the Data field value. +func (o *DegradationTemplateDataRelationshipsCreatedByUser) GetData() DegradationTemplateDataRelationshipsCreatedByUserData { + if o == nil { + var ret DegradationTemplateDataRelationshipsCreatedByUserData + 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 *DegradationTemplateDataRelationshipsCreatedByUser) GetDataOk() (*DegradationTemplateDataRelationshipsCreatedByUserData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *DegradationTemplateDataRelationshipsCreatedByUser) SetData(v DegradationTemplateDataRelationshipsCreatedByUserData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o DegradationTemplateDataRelationshipsCreatedByUser) 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 *DegradationTemplateDataRelationshipsCreatedByUser) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *DegradationTemplateDataRelationshipsCreatedByUserData `json:"data"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Data == nil { + return fmt.Errorf("required field data missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + + hasInvalidField := false + if all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Data = *all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_degradation_template_data_relationships_created_by_user_data.go b/api/datadogV2/model_degradation_template_data_relationships_created_by_user_data.go new file mode 100644 index 00000000000..ff2b450f239 --- /dev/null +++ b/api/datadogV2/model_degradation_template_data_relationships_created_by_user_data.go @@ -0,0 +1,145 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// DegradationTemplateDataRelationshipsCreatedByUserData The data object identifying the Datadog user who created the degradation template. +type DegradationTemplateDataRelationshipsCreatedByUserData struct { + // The ID of the Datadog user who created the degradation template. + Id string `json:"id"` + // Users resource type. + Type StatusPagesUserType `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:"-"` +} + +// NewDegradationTemplateDataRelationshipsCreatedByUserData instantiates a new DegradationTemplateDataRelationshipsCreatedByUserData 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 NewDegradationTemplateDataRelationshipsCreatedByUserData(id string, typeVar StatusPagesUserType) *DegradationTemplateDataRelationshipsCreatedByUserData { + this := DegradationTemplateDataRelationshipsCreatedByUserData{} + this.Id = id + this.Type = typeVar + return &this +} + +// NewDegradationTemplateDataRelationshipsCreatedByUserDataWithDefaults instantiates a new DegradationTemplateDataRelationshipsCreatedByUserData 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 NewDegradationTemplateDataRelationshipsCreatedByUserDataWithDefaults() *DegradationTemplateDataRelationshipsCreatedByUserData { + this := DegradationTemplateDataRelationshipsCreatedByUserData{} + var typeVar StatusPagesUserType = STATUSPAGESUSERTYPE_USERS + this.Type = typeVar + return &this +} + +// GetId returns the Id field value. +func (o *DegradationTemplateDataRelationshipsCreatedByUserData) GetId() string { + if o == nil { + var ret string + 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 *DegradationTemplateDataRelationshipsCreatedByUserData) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Id, true +} + +// SetId sets field value. +func (o *DegradationTemplateDataRelationshipsCreatedByUserData) SetId(v string) { + o.Id = v +} + +// GetType returns the Type field value. +func (o *DegradationTemplateDataRelationshipsCreatedByUserData) GetType() StatusPagesUserType { + if o == nil { + var ret StatusPagesUserType + 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 *DegradationTemplateDataRelationshipsCreatedByUserData) GetTypeOk() (*StatusPagesUserType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *DegradationTemplateDataRelationshipsCreatedByUserData) SetType(v StatusPagesUserType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o DegradationTemplateDataRelationshipsCreatedByUserData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["id"] = o.Id + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *DegradationTemplateDataRelationshipsCreatedByUserData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Id *string `json:"id"` + Type *StatusPagesUserType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Id == nil { + return fmt.Errorf("required field id missing") + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"id", "type"}) + } else { + return err + } + + hasInvalidField := false + o.Id = *all.Id + if !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = *all.Type + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_degradation_template_data_relationships_last_modified_by_user.go b/api/datadogV2/model_degradation_template_data_relationships_last_modified_by_user.go new file mode 100644 index 00000000000..bc642fb0ecf --- /dev/null +++ b/api/datadogV2/model_degradation_template_data_relationships_last_modified_by_user.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" +) + +// DegradationTemplateDataRelationshipsLastModifiedByUser The Datadog user who last modified the degradation template. +type DegradationTemplateDataRelationshipsLastModifiedByUser struct { + // The data object identifying the Datadog user who last modified the degradation template. + Data DegradationTemplateDataRelationshipsLastModifiedByUserData `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:"-"` +} + +// NewDegradationTemplateDataRelationshipsLastModifiedByUser instantiates a new DegradationTemplateDataRelationshipsLastModifiedByUser 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 NewDegradationTemplateDataRelationshipsLastModifiedByUser(data DegradationTemplateDataRelationshipsLastModifiedByUserData) *DegradationTemplateDataRelationshipsLastModifiedByUser { + this := DegradationTemplateDataRelationshipsLastModifiedByUser{} + this.Data = data + return &this +} + +// NewDegradationTemplateDataRelationshipsLastModifiedByUserWithDefaults instantiates a new DegradationTemplateDataRelationshipsLastModifiedByUser 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 NewDegradationTemplateDataRelationshipsLastModifiedByUserWithDefaults() *DegradationTemplateDataRelationshipsLastModifiedByUser { + this := DegradationTemplateDataRelationshipsLastModifiedByUser{} + return &this +} + +// GetData returns the Data field value. +func (o *DegradationTemplateDataRelationshipsLastModifiedByUser) GetData() DegradationTemplateDataRelationshipsLastModifiedByUserData { + if o == nil { + var ret DegradationTemplateDataRelationshipsLastModifiedByUserData + 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 *DegradationTemplateDataRelationshipsLastModifiedByUser) GetDataOk() (*DegradationTemplateDataRelationshipsLastModifiedByUserData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *DegradationTemplateDataRelationshipsLastModifiedByUser) SetData(v DegradationTemplateDataRelationshipsLastModifiedByUserData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o DegradationTemplateDataRelationshipsLastModifiedByUser) 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 *DegradationTemplateDataRelationshipsLastModifiedByUser) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *DegradationTemplateDataRelationshipsLastModifiedByUserData `json:"data"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Data == nil { + return fmt.Errorf("required field data missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + + hasInvalidField := false + if all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Data = *all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_degradation_template_data_relationships_last_modified_by_user_data.go b/api/datadogV2/model_degradation_template_data_relationships_last_modified_by_user_data.go new file mode 100644 index 00000000000..a807038d6f2 --- /dev/null +++ b/api/datadogV2/model_degradation_template_data_relationships_last_modified_by_user_data.go @@ -0,0 +1,145 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// DegradationTemplateDataRelationshipsLastModifiedByUserData The data object identifying the Datadog user who last modified the degradation template. +type DegradationTemplateDataRelationshipsLastModifiedByUserData struct { + // The ID of the Datadog user who last modified the degradation template. + Id string `json:"id"` + // Users resource type. + Type StatusPagesUserType `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:"-"` +} + +// NewDegradationTemplateDataRelationshipsLastModifiedByUserData instantiates a new DegradationTemplateDataRelationshipsLastModifiedByUserData 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 NewDegradationTemplateDataRelationshipsLastModifiedByUserData(id string, typeVar StatusPagesUserType) *DegradationTemplateDataRelationshipsLastModifiedByUserData { + this := DegradationTemplateDataRelationshipsLastModifiedByUserData{} + this.Id = id + this.Type = typeVar + return &this +} + +// NewDegradationTemplateDataRelationshipsLastModifiedByUserDataWithDefaults instantiates a new DegradationTemplateDataRelationshipsLastModifiedByUserData 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 NewDegradationTemplateDataRelationshipsLastModifiedByUserDataWithDefaults() *DegradationTemplateDataRelationshipsLastModifiedByUserData { + this := DegradationTemplateDataRelationshipsLastModifiedByUserData{} + var typeVar StatusPagesUserType = STATUSPAGESUSERTYPE_USERS + this.Type = typeVar + return &this +} + +// GetId returns the Id field value. +func (o *DegradationTemplateDataRelationshipsLastModifiedByUserData) GetId() string { + if o == nil { + var ret string + 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 *DegradationTemplateDataRelationshipsLastModifiedByUserData) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Id, true +} + +// SetId sets field value. +func (o *DegradationTemplateDataRelationshipsLastModifiedByUserData) SetId(v string) { + o.Id = v +} + +// GetType returns the Type field value. +func (o *DegradationTemplateDataRelationshipsLastModifiedByUserData) GetType() StatusPagesUserType { + if o == nil { + var ret StatusPagesUserType + 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 *DegradationTemplateDataRelationshipsLastModifiedByUserData) GetTypeOk() (*StatusPagesUserType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *DegradationTemplateDataRelationshipsLastModifiedByUserData) SetType(v StatusPagesUserType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o DegradationTemplateDataRelationshipsLastModifiedByUserData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["id"] = o.Id + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *DegradationTemplateDataRelationshipsLastModifiedByUserData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Id *string `json:"id"` + Type *StatusPagesUserType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Id == nil { + return fmt.Errorf("required field id missing") + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"id", "type"}) + } else { + return err + } + + hasInvalidField := false + o.Id = *all.Id + if !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = *all.Type + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_degradation_template_data_relationships_status_page.go b/api/datadogV2/model_degradation_template_data_relationships_status_page.go new file mode 100644 index 00000000000..4dd43489a80 --- /dev/null +++ b/api/datadogV2/model_degradation_template_data_relationships_status_page.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" +) + +// DegradationTemplateDataRelationshipsStatusPage The status page the degradation template belongs to. +type DegradationTemplateDataRelationshipsStatusPage struct { + // The data object identifying the status page associated with a degradation template. + Data DegradationTemplateDataRelationshipsStatusPageData `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:"-"` +} + +// NewDegradationTemplateDataRelationshipsStatusPage instantiates a new DegradationTemplateDataRelationshipsStatusPage 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 NewDegradationTemplateDataRelationshipsStatusPage(data DegradationTemplateDataRelationshipsStatusPageData) *DegradationTemplateDataRelationshipsStatusPage { + this := DegradationTemplateDataRelationshipsStatusPage{} + this.Data = data + return &this +} + +// NewDegradationTemplateDataRelationshipsStatusPageWithDefaults instantiates a new DegradationTemplateDataRelationshipsStatusPage 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 NewDegradationTemplateDataRelationshipsStatusPageWithDefaults() *DegradationTemplateDataRelationshipsStatusPage { + this := DegradationTemplateDataRelationshipsStatusPage{} + return &this +} + +// GetData returns the Data field value. +func (o *DegradationTemplateDataRelationshipsStatusPage) GetData() DegradationTemplateDataRelationshipsStatusPageData { + if o == nil { + var ret DegradationTemplateDataRelationshipsStatusPageData + 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 *DegradationTemplateDataRelationshipsStatusPage) GetDataOk() (*DegradationTemplateDataRelationshipsStatusPageData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *DegradationTemplateDataRelationshipsStatusPage) SetData(v DegradationTemplateDataRelationshipsStatusPageData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o DegradationTemplateDataRelationshipsStatusPage) 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 *DegradationTemplateDataRelationshipsStatusPage) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *DegradationTemplateDataRelationshipsStatusPageData `json:"data"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Data == nil { + return fmt.Errorf("required field data missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + + hasInvalidField := false + if all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Data = *all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_degradation_template_data_relationships_status_page_data.go b/api/datadogV2/model_degradation_template_data_relationships_status_page_data.go new file mode 100644 index 00000000000..7725b0bb759 --- /dev/null +++ b/api/datadogV2/model_degradation_template_data_relationships_status_page_data.go @@ -0,0 +1,145 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// DegradationTemplateDataRelationshipsStatusPageData The data object identifying the status page associated with a degradation template. +type DegradationTemplateDataRelationshipsStatusPageData struct { + // The ID of the status page. + Id string `json:"id"` + // Status pages resource type. + Type StatusPageDataType `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:"-"` +} + +// NewDegradationTemplateDataRelationshipsStatusPageData instantiates a new DegradationTemplateDataRelationshipsStatusPageData 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 NewDegradationTemplateDataRelationshipsStatusPageData(id string, typeVar StatusPageDataType) *DegradationTemplateDataRelationshipsStatusPageData { + this := DegradationTemplateDataRelationshipsStatusPageData{} + this.Id = id + this.Type = typeVar + return &this +} + +// NewDegradationTemplateDataRelationshipsStatusPageDataWithDefaults instantiates a new DegradationTemplateDataRelationshipsStatusPageData 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 NewDegradationTemplateDataRelationshipsStatusPageDataWithDefaults() *DegradationTemplateDataRelationshipsStatusPageData { + this := DegradationTemplateDataRelationshipsStatusPageData{} + var typeVar StatusPageDataType = STATUSPAGEDATATYPE_STATUS_PAGES + this.Type = typeVar + return &this +} + +// GetId returns the Id field value. +func (o *DegradationTemplateDataRelationshipsStatusPageData) GetId() string { + if o == nil { + var ret string + 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 *DegradationTemplateDataRelationshipsStatusPageData) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Id, true +} + +// SetId sets field value. +func (o *DegradationTemplateDataRelationshipsStatusPageData) SetId(v string) { + o.Id = v +} + +// GetType returns the Type field value. +func (o *DegradationTemplateDataRelationshipsStatusPageData) GetType() StatusPageDataType { + if o == nil { + var ret StatusPageDataType + 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 *DegradationTemplateDataRelationshipsStatusPageData) GetTypeOk() (*StatusPageDataType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *DegradationTemplateDataRelationshipsStatusPageData) SetType(v StatusPageDataType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o DegradationTemplateDataRelationshipsStatusPageData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["id"] = o.Id + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *DegradationTemplateDataRelationshipsStatusPageData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Id *string `json:"id"` + Type *StatusPageDataType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Id == nil { + return fmt.Errorf("required field id missing") + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"id", "type"}) + } else { + return err + } + + hasInvalidField := false + o.Id = *all.Id + if !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = *all.Type + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_maintenance_data_relationships.go b/api/datadogV2/model_maintenance_data_relationships.go index bdb02a2a144..65a71d41673 100644 --- a/api/datadogV2/model_maintenance_data_relationships.go +++ b/api/datadogV2/model_maintenance_data_relationships.go @@ -16,6 +16,8 @@ type MaintenanceDataRelationships struct { LastModifiedByUser *MaintenanceDataRelationshipsLastModifiedByUser `json:"last_modified_by_user,omitempty"` // The status page the maintenance belongs to. StatusPage *MaintenanceDataRelationshipsStatusPage `json:"status_page,omitempty"` + // The template the maintenance was created from. + Template *MaintenanceDataRelationshipsTemplate `json:"template,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:"-"` @@ -122,6 +124,34 @@ func (o *MaintenanceDataRelationships) SetStatusPage(v MaintenanceDataRelationsh o.StatusPage = &v } +// GetTemplate returns the Template field value if set, zero value otherwise. +func (o *MaintenanceDataRelationships) GetTemplate() MaintenanceDataRelationshipsTemplate { + if o == nil || o.Template == nil { + var ret MaintenanceDataRelationshipsTemplate + return ret + } + return *o.Template +} + +// GetTemplateOk returns a tuple with the Template field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *MaintenanceDataRelationships) GetTemplateOk() (*MaintenanceDataRelationshipsTemplate, bool) { + if o == nil || o.Template == nil { + return nil, false + } + return o.Template, true +} + +// HasTemplate returns a boolean if a field has been set. +func (o *MaintenanceDataRelationships) HasTemplate() bool { + return o != nil && o.Template != nil +} + +// SetTemplate gets a reference to the given MaintenanceDataRelationshipsTemplate and assigns it to the Template field. +func (o *MaintenanceDataRelationships) SetTemplate(v MaintenanceDataRelationshipsTemplate) { + o.Template = &v +} + // MarshalJSON serializes the struct using spec logic. func (o MaintenanceDataRelationships) MarshalJSON() ([]byte, error) { toSerialize := map[string]interface{}{} @@ -137,6 +167,9 @@ func (o MaintenanceDataRelationships) MarshalJSON() ([]byte, error) { if o.StatusPage != nil { toSerialize["status_page"] = o.StatusPage } + if o.Template != nil { + toSerialize["template"] = o.Template + } for key, value := range o.AdditionalProperties { toSerialize[key] = value @@ -150,13 +183,14 @@ func (o *MaintenanceDataRelationships) UnmarshalJSON(bytes []byte) (err error) { CreatedByUser *MaintenanceDataRelationshipsCreatedByUser `json:"created_by_user,omitempty"` LastModifiedByUser *MaintenanceDataRelationshipsLastModifiedByUser `json:"last_modified_by_user,omitempty"` StatusPage *MaintenanceDataRelationshipsStatusPage `json:"status_page,omitempty"` + Template *MaintenanceDataRelationshipsTemplate `json:"template,omitempty"` }{} if err = datadog.Unmarshal(bytes, &all); err != nil { return datadog.Unmarshal(bytes, &o.UnparsedObject) } additionalProperties := make(map[string]interface{}) if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { - datadog.DeleteKeys(additionalProperties, &[]string{"created_by_user", "last_modified_by_user", "status_page"}) + datadog.DeleteKeys(additionalProperties, &[]string{"created_by_user", "last_modified_by_user", "status_page", "template"}) } else { return err } @@ -174,6 +208,10 @@ func (o *MaintenanceDataRelationships) UnmarshalJSON(bytes []byte) (err error) { hasInvalidField = true } o.StatusPage = all.StatusPage + if all.Template != nil && all.Template.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Template = all.Template if len(additionalProperties) > 0 { o.AdditionalProperties = additionalProperties diff --git a/api/datadogV2/model_maintenance_data_relationships_template.go b/api/datadogV2/model_maintenance_data_relationships_template.go new file mode 100644 index 00000000000..7ce546a5b0a --- /dev/null +++ b/api/datadogV2/model_maintenance_data_relationships_template.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" +) + +// MaintenanceDataRelationshipsTemplate The template the maintenance was created from. +type MaintenanceDataRelationshipsTemplate struct { + // The data object identifying the template the maintenance was created from. + Data MaintenanceDataRelationshipsTemplateData `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:"-"` +} + +// NewMaintenanceDataRelationshipsTemplate instantiates a new MaintenanceDataRelationshipsTemplate 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 NewMaintenanceDataRelationshipsTemplate(data MaintenanceDataRelationshipsTemplateData) *MaintenanceDataRelationshipsTemplate { + this := MaintenanceDataRelationshipsTemplate{} + this.Data = data + return &this +} + +// NewMaintenanceDataRelationshipsTemplateWithDefaults instantiates a new MaintenanceDataRelationshipsTemplate 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 NewMaintenanceDataRelationshipsTemplateWithDefaults() *MaintenanceDataRelationshipsTemplate { + this := MaintenanceDataRelationshipsTemplate{} + return &this +} + +// GetData returns the Data field value. +func (o *MaintenanceDataRelationshipsTemplate) GetData() MaintenanceDataRelationshipsTemplateData { + if o == nil { + var ret MaintenanceDataRelationshipsTemplateData + 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 *MaintenanceDataRelationshipsTemplate) GetDataOk() (*MaintenanceDataRelationshipsTemplateData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *MaintenanceDataRelationshipsTemplate) SetData(v MaintenanceDataRelationshipsTemplateData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o MaintenanceDataRelationshipsTemplate) 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 *MaintenanceDataRelationshipsTemplate) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *MaintenanceDataRelationshipsTemplateData `json:"data"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Data == nil { + return fmt.Errorf("required field data missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + + hasInvalidField := false + if all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Data = *all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_maintenance_data_relationships_template_data.go b/api/datadogV2/model_maintenance_data_relationships_template_data.go new file mode 100644 index 00000000000..d64892ccb78 --- /dev/null +++ b/api/datadogV2/model_maintenance_data_relationships_template_data.go @@ -0,0 +1,145 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// MaintenanceDataRelationshipsTemplateData The data object identifying the template the maintenance was created from. +type MaintenanceDataRelationshipsTemplateData struct { + // The ID of the maintenance template. + Id string `json:"id"` + // Maintenance templates resource type. + Type PatchMaintenanceTemplateRequestDataType `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:"-"` +} + +// NewMaintenanceDataRelationshipsTemplateData instantiates a new MaintenanceDataRelationshipsTemplateData 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 NewMaintenanceDataRelationshipsTemplateData(id string, typeVar PatchMaintenanceTemplateRequestDataType) *MaintenanceDataRelationshipsTemplateData { + this := MaintenanceDataRelationshipsTemplateData{} + this.Id = id + this.Type = typeVar + return &this +} + +// NewMaintenanceDataRelationshipsTemplateDataWithDefaults instantiates a new MaintenanceDataRelationshipsTemplateData 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 NewMaintenanceDataRelationshipsTemplateDataWithDefaults() *MaintenanceDataRelationshipsTemplateData { + this := MaintenanceDataRelationshipsTemplateData{} + var typeVar PatchMaintenanceTemplateRequestDataType = PATCHMAINTENANCETEMPLATEREQUESTDATATYPE_MAINTENANCE_TEMPLATES + this.Type = typeVar + return &this +} + +// GetId returns the Id field value. +func (o *MaintenanceDataRelationshipsTemplateData) GetId() string { + if o == nil { + var ret string + 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 *MaintenanceDataRelationshipsTemplateData) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Id, true +} + +// SetId sets field value. +func (o *MaintenanceDataRelationshipsTemplateData) SetId(v string) { + o.Id = v +} + +// GetType returns the Type field value. +func (o *MaintenanceDataRelationshipsTemplateData) GetType() PatchMaintenanceTemplateRequestDataType { + if o == nil { + var ret PatchMaintenanceTemplateRequestDataType + 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 *MaintenanceDataRelationshipsTemplateData) GetTypeOk() (*PatchMaintenanceTemplateRequestDataType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *MaintenanceDataRelationshipsTemplateData) SetType(v PatchMaintenanceTemplateRequestDataType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o MaintenanceDataRelationshipsTemplateData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["id"] = o.Id + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *MaintenanceDataRelationshipsTemplateData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Id *string `json:"id"` + Type *PatchMaintenanceTemplateRequestDataType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Id == nil { + return fmt.Errorf("required field id missing") + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"id", "type"}) + } else { + return err + } + + hasInvalidField := false + o.Id = *all.Id + if !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = *all.Type + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_maintenance_template.go b/api/datadogV2/model_maintenance_template.go new file mode 100644 index 00000000000..1e45e172640 --- /dev/null +++ b/api/datadogV2/model_maintenance_template.go @@ -0,0 +1,146 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// MaintenanceTemplate Response object for a single maintenance template. +type MaintenanceTemplate struct { + // The data object for a maintenance template. + Data *MaintenanceTemplateData `json:"data,omitempty"` + // The included related resources of a maintenance template. Client must explicitly request these resources by name in the `include` query parameter. + Included []DegradationIncluded `json:"included,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:"-"` +} + +// NewMaintenanceTemplate instantiates a new MaintenanceTemplate 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 NewMaintenanceTemplate() *MaintenanceTemplate { + this := MaintenanceTemplate{} + return &this +} + +// NewMaintenanceTemplateWithDefaults instantiates a new MaintenanceTemplate 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 NewMaintenanceTemplateWithDefaults() *MaintenanceTemplate { + this := MaintenanceTemplate{} + return &this +} + +// GetData returns the Data field value if set, zero value otherwise. +func (o *MaintenanceTemplate) GetData() MaintenanceTemplateData { + if o == nil || o.Data == nil { + var ret MaintenanceTemplateData + return ret + } + return *o.Data +} + +// GetDataOk returns a tuple with the Data field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *MaintenanceTemplate) GetDataOk() (*MaintenanceTemplateData, bool) { + if o == nil || o.Data == nil { + return nil, false + } + return o.Data, true +} + +// HasData returns a boolean if a field has been set. +func (o *MaintenanceTemplate) HasData() bool { + return o != nil && o.Data != nil +} + +// SetData gets a reference to the given MaintenanceTemplateData and assigns it to the Data field. +func (o *MaintenanceTemplate) SetData(v MaintenanceTemplateData) { + o.Data = &v +} + +// GetIncluded returns the Included field value if set, zero value otherwise. +func (o *MaintenanceTemplate) GetIncluded() []DegradationIncluded { + if o == nil || o.Included == nil { + var ret []DegradationIncluded + return ret + } + return o.Included +} + +// GetIncludedOk returns a tuple with the Included field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *MaintenanceTemplate) GetIncludedOk() (*[]DegradationIncluded, bool) { + if o == nil || o.Included == nil { + return nil, false + } + return &o.Included, true +} + +// HasIncluded returns a boolean if a field has been set. +func (o *MaintenanceTemplate) HasIncluded() bool { + return o != nil && o.Included != nil +} + +// SetIncluded gets a reference to the given []DegradationIncluded and assigns it to the Included field. +func (o *MaintenanceTemplate) SetIncluded(v []DegradationIncluded) { + o.Included = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o MaintenanceTemplate) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Data != nil { + toSerialize["data"] = o.Data + } + if o.Included != nil { + toSerialize["included"] = o.Included + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *MaintenanceTemplate) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *MaintenanceTemplateData `json:"data,omitempty"` + Included []DegradationIncluded `json:"included,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data", "included"}) + } else { + return err + } + + hasInvalidField := false + if all.Data != nil && all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Data = all.Data + o.Included = all.Included + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_maintenance_template_array.go b/api/datadogV2/model_maintenance_template_array.go new file mode 100644 index 00000000000..c3434fcf1fb --- /dev/null +++ b/api/datadogV2/model_maintenance_template_array.go @@ -0,0 +1,136 @@ +// 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" +) + +// MaintenanceTemplateArray Response object for a list of maintenance templates. +type MaintenanceTemplateArray struct { + // A list of maintenance template data objects. + Data []MaintenanceTemplateData `json:"data"` + // The included related resources of a maintenance template. Client must explicitly request these resources by name in the `include` query parameter. + Included []DegradationIncluded `json:"included,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:"-"` +} + +// NewMaintenanceTemplateArray instantiates a new MaintenanceTemplateArray 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 NewMaintenanceTemplateArray(data []MaintenanceTemplateData) *MaintenanceTemplateArray { + this := MaintenanceTemplateArray{} + this.Data = data + return &this +} + +// NewMaintenanceTemplateArrayWithDefaults instantiates a new MaintenanceTemplateArray 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 NewMaintenanceTemplateArrayWithDefaults() *MaintenanceTemplateArray { + this := MaintenanceTemplateArray{} + return &this +} + +// GetData returns the Data field value. +func (o *MaintenanceTemplateArray) GetData() []MaintenanceTemplateData { + if o == nil { + var ret []MaintenanceTemplateData + 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 *MaintenanceTemplateArray) GetDataOk() (*[]MaintenanceTemplateData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *MaintenanceTemplateArray) SetData(v []MaintenanceTemplateData) { + o.Data = v +} + +// GetIncluded returns the Included field value if set, zero value otherwise. +func (o *MaintenanceTemplateArray) GetIncluded() []DegradationIncluded { + if o == nil || o.Included == nil { + var ret []DegradationIncluded + return ret + } + return o.Included +} + +// GetIncludedOk returns a tuple with the Included field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *MaintenanceTemplateArray) GetIncludedOk() (*[]DegradationIncluded, bool) { + if o == nil || o.Included == nil { + return nil, false + } + return &o.Included, true +} + +// HasIncluded returns a boolean if a field has been set. +func (o *MaintenanceTemplateArray) HasIncluded() bool { + return o != nil && o.Included != nil +} + +// SetIncluded gets a reference to the given []DegradationIncluded and assigns it to the Included field. +func (o *MaintenanceTemplateArray) SetIncluded(v []DegradationIncluded) { + o.Included = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o MaintenanceTemplateArray) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["data"] = o.Data + if o.Included != nil { + toSerialize["included"] = o.Included + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *MaintenanceTemplateArray) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *[]MaintenanceTemplateData `json:"data"` + Included []DegradationIncluded `json:"included,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Data == nil { + return fmt.Errorf("required field data missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data", "included"}) + } else { + return err + } + o.Data = *all.Data + o.Included = all.Included + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_maintenance_template_data.go b/api/datadogV2/model_maintenance_template_data.go new file mode 100644 index 00000000000..e0bafff9370 --- /dev/null +++ b/api/datadogV2/model_maintenance_template_data.go @@ -0,0 +1,224 @@ +// 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" +) + +// MaintenanceTemplateData The data object for a maintenance template. +type MaintenanceTemplateData struct { + // The attributes of a maintenance template. + Attributes *MaintenanceTemplateDataAttributes `json:"attributes,omitempty"` + // The ID of the maintenance template. + Id *string `json:"id,omitempty"` + // The relationships of a maintenance template. + Relationships *MaintenanceTemplateDataRelationships `json:"relationships,omitempty"` + // Maintenance templates resource type. + Type PatchMaintenanceTemplateRequestDataType `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:"-"` +} + +// NewMaintenanceTemplateData instantiates a new MaintenanceTemplateData 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 NewMaintenanceTemplateData(typeVar PatchMaintenanceTemplateRequestDataType) *MaintenanceTemplateData { + this := MaintenanceTemplateData{} + this.Type = typeVar + return &this +} + +// NewMaintenanceTemplateDataWithDefaults instantiates a new MaintenanceTemplateData 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 NewMaintenanceTemplateDataWithDefaults() *MaintenanceTemplateData { + this := MaintenanceTemplateData{} + var typeVar PatchMaintenanceTemplateRequestDataType = PATCHMAINTENANCETEMPLATEREQUESTDATATYPE_MAINTENANCE_TEMPLATES + this.Type = typeVar + return &this +} + +// GetAttributes returns the Attributes field value if set, zero value otherwise. +func (o *MaintenanceTemplateData) GetAttributes() MaintenanceTemplateDataAttributes { + if o == nil || o.Attributes == nil { + var ret MaintenanceTemplateDataAttributes + return ret + } + return *o.Attributes +} + +// GetAttributesOk returns a tuple with the Attributes field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *MaintenanceTemplateData) GetAttributesOk() (*MaintenanceTemplateDataAttributes, bool) { + if o == nil || o.Attributes == nil { + return nil, false + } + return o.Attributes, true +} + +// HasAttributes returns a boolean if a field has been set. +func (o *MaintenanceTemplateData) HasAttributes() bool { + return o != nil && o.Attributes != nil +} + +// SetAttributes gets a reference to the given MaintenanceTemplateDataAttributes and assigns it to the Attributes field. +func (o *MaintenanceTemplateData) SetAttributes(v MaintenanceTemplateDataAttributes) { + o.Attributes = &v +} + +// GetId returns the Id field value if set, zero value otherwise. +func (o *MaintenanceTemplateData) GetId() string { + if o == nil || o.Id == nil { + var ret string + return ret + } + return *o.Id +} + +// GetIdOk returns a tuple with the Id field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *MaintenanceTemplateData) GetIdOk() (*string, bool) { + if o == nil || o.Id == nil { + return nil, false + } + return o.Id, true +} + +// HasId returns a boolean if a field has been set. +func (o *MaintenanceTemplateData) HasId() bool { + return o != nil && o.Id != nil +} + +// SetId gets a reference to the given string and assigns it to the Id field. +func (o *MaintenanceTemplateData) SetId(v string) { + o.Id = &v +} + +// GetRelationships returns the Relationships field value if set, zero value otherwise. +func (o *MaintenanceTemplateData) GetRelationships() MaintenanceTemplateDataRelationships { + if o == nil || o.Relationships == nil { + var ret MaintenanceTemplateDataRelationships + return ret + } + return *o.Relationships +} + +// GetRelationshipsOk returns a tuple with the Relationships field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *MaintenanceTemplateData) GetRelationshipsOk() (*MaintenanceTemplateDataRelationships, bool) { + if o == nil || o.Relationships == nil { + return nil, false + } + return o.Relationships, true +} + +// HasRelationships returns a boolean if a field has been set. +func (o *MaintenanceTemplateData) HasRelationships() bool { + return o != nil && o.Relationships != nil +} + +// SetRelationships gets a reference to the given MaintenanceTemplateDataRelationships and assigns it to the Relationships field. +func (o *MaintenanceTemplateData) SetRelationships(v MaintenanceTemplateDataRelationships) { + o.Relationships = &v +} + +// GetType returns the Type field value. +func (o *MaintenanceTemplateData) GetType() PatchMaintenanceTemplateRequestDataType { + if o == nil { + var ret PatchMaintenanceTemplateRequestDataType + 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 *MaintenanceTemplateData) GetTypeOk() (*PatchMaintenanceTemplateRequestDataType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *MaintenanceTemplateData) SetType(v PatchMaintenanceTemplateRequestDataType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o MaintenanceTemplateData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Attributes != nil { + toSerialize["attributes"] = o.Attributes + } + if o.Id != nil { + toSerialize["id"] = o.Id + } + if o.Relationships != nil { + toSerialize["relationships"] = o.Relationships + } + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *MaintenanceTemplateData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *MaintenanceTemplateDataAttributes `json:"attributes,omitempty"` + Id *string `json:"id,omitempty"` + Relationships *MaintenanceTemplateDataRelationships `json:"relationships,omitempty"` + Type *PatchMaintenanceTemplateRequestDataType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "id", "relationships", "type"}) + } else { + return err + } + + hasInvalidField := false + if all.Attributes != nil && all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Attributes = all.Attributes + o.Id = all.Id + if all.Relationships != nil && all.Relationships.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Relationships = all.Relationships + 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_maintenance_template_data_attributes.go b/api/datadogV2/model_maintenance_template_data_attributes.go new file mode 100644 index 00000000000..197d69e6c62 --- /dev/null +++ b/api/datadogV2/model_maintenance_template_data_attributes.go @@ -0,0 +1,357 @@ +// 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 ( + "time" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// MaintenanceTemplateDataAttributes The attributes of a maintenance template. +type MaintenanceTemplateDataAttributes struct { + // The description shown when a maintenance created from this template is completed. + CompletedDescription *string `json:"completed_description,omitempty"` + // The IDs of the components affected by a maintenance created from this template. + ComponentIds []string `json:"component_ids,omitempty"` + // Timestamp of when the maintenance template was created. + CreatedAt *time.Time `json:"created_at,omitempty"` + // The description shown while a maintenance created from this template is in progress. + InProgressDescription *string `json:"in_progress_description,omitempty"` + // The title used for a maintenance created from this template. + MaintenanceTitle *string `json:"maintenance_title,omitempty"` + // Timestamp of when the maintenance template was last modified. + ModifiedAt *time.Time `json:"modified_at,omitempty"` + // The name of the maintenance template. + Name *string `json:"name,omitempty"` + // The description shown when a maintenance created from this template is scheduled. + ScheduledDescription *string `json:"scheduled_description,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:"-"` +} + +// NewMaintenanceTemplateDataAttributes instantiates a new MaintenanceTemplateDataAttributes 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 NewMaintenanceTemplateDataAttributes() *MaintenanceTemplateDataAttributes { + this := MaintenanceTemplateDataAttributes{} + return &this +} + +// NewMaintenanceTemplateDataAttributesWithDefaults instantiates a new MaintenanceTemplateDataAttributes 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 NewMaintenanceTemplateDataAttributesWithDefaults() *MaintenanceTemplateDataAttributes { + this := MaintenanceTemplateDataAttributes{} + return &this +} + +// GetCompletedDescription returns the CompletedDescription field value if set, zero value otherwise. +func (o *MaintenanceTemplateDataAttributes) GetCompletedDescription() string { + if o == nil || o.CompletedDescription == nil { + var ret string + return ret + } + return *o.CompletedDescription +} + +// GetCompletedDescriptionOk returns a tuple with the CompletedDescription field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *MaintenanceTemplateDataAttributes) GetCompletedDescriptionOk() (*string, bool) { + if o == nil || o.CompletedDescription == nil { + return nil, false + } + return o.CompletedDescription, true +} + +// HasCompletedDescription returns a boolean if a field has been set. +func (o *MaintenanceTemplateDataAttributes) HasCompletedDescription() bool { + return o != nil && o.CompletedDescription != nil +} + +// SetCompletedDescription gets a reference to the given string and assigns it to the CompletedDescription field. +func (o *MaintenanceTemplateDataAttributes) SetCompletedDescription(v string) { + o.CompletedDescription = &v +} + +// GetComponentIds returns the ComponentIds field value if set, zero value otherwise. +func (o *MaintenanceTemplateDataAttributes) GetComponentIds() []string { + if o == nil || o.ComponentIds == nil { + var ret []string + return ret + } + return o.ComponentIds +} + +// GetComponentIdsOk returns a tuple with the ComponentIds field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *MaintenanceTemplateDataAttributes) GetComponentIdsOk() (*[]string, bool) { + if o == nil || o.ComponentIds == nil { + return nil, false + } + return &o.ComponentIds, true +} + +// HasComponentIds returns a boolean if a field has been set. +func (o *MaintenanceTemplateDataAttributes) HasComponentIds() bool { + return o != nil && o.ComponentIds != nil +} + +// SetComponentIds gets a reference to the given []string and assigns it to the ComponentIds field. +func (o *MaintenanceTemplateDataAttributes) SetComponentIds(v []string) { + o.ComponentIds = v +} + +// GetCreatedAt returns the CreatedAt field value if set, zero value otherwise. +func (o *MaintenanceTemplateDataAttributes) GetCreatedAt() time.Time { + if o == nil || o.CreatedAt == nil { + var ret time.Time + return ret + } + return *o.CreatedAt +} + +// GetCreatedAtOk returns a tuple with the CreatedAt field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *MaintenanceTemplateDataAttributes) GetCreatedAtOk() (*time.Time, bool) { + if o == nil || o.CreatedAt == nil { + return nil, false + } + return o.CreatedAt, true +} + +// HasCreatedAt returns a boolean if a field has been set. +func (o *MaintenanceTemplateDataAttributes) HasCreatedAt() bool { + return o != nil && o.CreatedAt != nil +} + +// SetCreatedAt gets a reference to the given time.Time and assigns it to the CreatedAt field. +func (o *MaintenanceTemplateDataAttributes) SetCreatedAt(v time.Time) { + o.CreatedAt = &v +} + +// GetInProgressDescription returns the InProgressDescription field value if set, zero value otherwise. +func (o *MaintenanceTemplateDataAttributes) GetInProgressDescription() string { + if o == nil || o.InProgressDescription == nil { + var ret string + return ret + } + return *o.InProgressDescription +} + +// GetInProgressDescriptionOk returns a tuple with the InProgressDescription field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *MaintenanceTemplateDataAttributes) GetInProgressDescriptionOk() (*string, bool) { + if o == nil || o.InProgressDescription == nil { + return nil, false + } + return o.InProgressDescription, true +} + +// HasInProgressDescription returns a boolean if a field has been set. +func (o *MaintenanceTemplateDataAttributes) HasInProgressDescription() bool { + return o != nil && o.InProgressDescription != nil +} + +// SetInProgressDescription gets a reference to the given string and assigns it to the InProgressDescription field. +func (o *MaintenanceTemplateDataAttributes) SetInProgressDescription(v string) { + o.InProgressDescription = &v +} + +// GetMaintenanceTitle returns the MaintenanceTitle field value if set, zero value otherwise. +func (o *MaintenanceTemplateDataAttributes) GetMaintenanceTitle() string { + if o == nil || o.MaintenanceTitle == nil { + var ret string + return ret + } + return *o.MaintenanceTitle +} + +// GetMaintenanceTitleOk returns a tuple with the MaintenanceTitle field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *MaintenanceTemplateDataAttributes) GetMaintenanceTitleOk() (*string, bool) { + if o == nil || o.MaintenanceTitle == nil { + return nil, false + } + return o.MaintenanceTitle, true +} + +// HasMaintenanceTitle returns a boolean if a field has been set. +func (o *MaintenanceTemplateDataAttributes) HasMaintenanceTitle() bool { + return o != nil && o.MaintenanceTitle != nil +} + +// SetMaintenanceTitle gets a reference to the given string and assigns it to the MaintenanceTitle field. +func (o *MaintenanceTemplateDataAttributes) SetMaintenanceTitle(v string) { + o.MaintenanceTitle = &v +} + +// GetModifiedAt returns the ModifiedAt field value if set, zero value otherwise. +func (o *MaintenanceTemplateDataAttributes) GetModifiedAt() time.Time { + if o == nil || o.ModifiedAt == nil { + var ret time.Time + return ret + } + return *o.ModifiedAt +} + +// GetModifiedAtOk returns a tuple with the ModifiedAt field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *MaintenanceTemplateDataAttributes) GetModifiedAtOk() (*time.Time, bool) { + if o == nil || o.ModifiedAt == nil { + return nil, false + } + return o.ModifiedAt, true +} + +// HasModifiedAt returns a boolean if a field has been set. +func (o *MaintenanceTemplateDataAttributes) HasModifiedAt() bool { + return o != nil && o.ModifiedAt != nil +} + +// SetModifiedAt gets a reference to the given time.Time and assigns it to the ModifiedAt field. +func (o *MaintenanceTemplateDataAttributes) SetModifiedAt(v time.Time) { + o.ModifiedAt = &v +} + +// GetName returns the Name field value if set, zero value otherwise. +func (o *MaintenanceTemplateDataAttributes) GetName() string { + if o == nil || o.Name == nil { + var ret string + return ret + } + return *o.Name +} + +// GetNameOk returns a tuple with the Name field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *MaintenanceTemplateDataAttributes) GetNameOk() (*string, bool) { + if o == nil || o.Name == nil { + return nil, false + } + return o.Name, true +} + +// HasName returns a boolean if a field has been set. +func (o *MaintenanceTemplateDataAttributes) HasName() bool { + return o != nil && o.Name != nil +} + +// SetName gets a reference to the given string and assigns it to the Name field. +func (o *MaintenanceTemplateDataAttributes) SetName(v string) { + o.Name = &v +} + +// GetScheduledDescription returns the ScheduledDescription field value if set, zero value otherwise. +func (o *MaintenanceTemplateDataAttributes) GetScheduledDescription() string { + if o == nil || o.ScheduledDescription == nil { + var ret string + return ret + } + return *o.ScheduledDescription +} + +// GetScheduledDescriptionOk returns a tuple with the ScheduledDescription field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *MaintenanceTemplateDataAttributes) GetScheduledDescriptionOk() (*string, bool) { + if o == nil || o.ScheduledDescription == nil { + return nil, false + } + return o.ScheduledDescription, true +} + +// HasScheduledDescription returns a boolean if a field has been set. +func (o *MaintenanceTemplateDataAttributes) HasScheduledDescription() bool { + return o != nil && o.ScheduledDescription != nil +} + +// SetScheduledDescription gets a reference to the given string and assigns it to the ScheduledDescription field. +func (o *MaintenanceTemplateDataAttributes) SetScheduledDescription(v string) { + o.ScheduledDescription = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o MaintenanceTemplateDataAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.CompletedDescription != nil { + toSerialize["completed_description"] = o.CompletedDescription + } + if o.ComponentIds != nil { + toSerialize["component_ids"] = o.ComponentIds + } + if o.CreatedAt != nil { + if o.CreatedAt.Nanosecond() == 0 { + toSerialize["created_at"] = o.CreatedAt.Format("2006-01-02T15:04:05Z07:00") + } else { + toSerialize["created_at"] = o.CreatedAt.Format("2006-01-02T15:04:05.000Z07:00") + } + } + if o.InProgressDescription != nil { + toSerialize["in_progress_description"] = o.InProgressDescription + } + if o.MaintenanceTitle != nil { + toSerialize["maintenance_title"] = o.MaintenanceTitle + } + if o.ModifiedAt != nil { + if o.ModifiedAt.Nanosecond() == 0 { + toSerialize["modified_at"] = o.ModifiedAt.Format("2006-01-02T15:04:05Z07:00") + } else { + toSerialize["modified_at"] = o.ModifiedAt.Format("2006-01-02T15:04:05.000Z07:00") + } + } + if o.Name != nil { + toSerialize["name"] = o.Name + } + if o.ScheduledDescription != nil { + toSerialize["scheduled_description"] = o.ScheduledDescription + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *MaintenanceTemplateDataAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + CompletedDescription *string `json:"completed_description,omitempty"` + ComponentIds []string `json:"component_ids,omitempty"` + CreatedAt *time.Time `json:"created_at,omitempty"` + InProgressDescription *string `json:"in_progress_description,omitempty"` + MaintenanceTitle *string `json:"maintenance_title,omitempty"` + ModifiedAt *time.Time `json:"modified_at,omitempty"` + Name *string `json:"name,omitempty"` + ScheduledDescription *string `json:"scheduled_description,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"completed_description", "component_ids", "created_at", "in_progress_description", "maintenance_title", "modified_at", "name", "scheduled_description"}) + } else { + return err + } + o.CompletedDescription = all.CompletedDescription + o.ComponentIds = all.ComponentIds + o.CreatedAt = all.CreatedAt + o.InProgressDescription = all.InProgressDescription + o.MaintenanceTitle = all.MaintenanceTitle + o.ModifiedAt = all.ModifiedAt + o.Name = all.Name + o.ScheduledDescription = all.ScheduledDescription + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_maintenance_template_data_relationships.go b/api/datadogV2/model_maintenance_template_data_relationships.go new file mode 100644 index 00000000000..58ae4b2ed46 --- /dev/null +++ b/api/datadogV2/model_maintenance_template_data_relationships.go @@ -0,0 +1,187 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// MaintenanceTemplateDataRelationships The relationships of a maintenance template. +type MaintenanceTemplateDataRelationships struct { + // The Datadog user who created the maintenance template. + CreatedByUser *MaintenanceTemplateDataRelationshipsCreatedByUser `json:"created_by_user,omitempty"` + // The Datadog user who last modified the maintenance template. + LastModifiedByUser *MaintenanceTemplateDataRelationshipsLastModifiedByUser `json:"last_modified_by_user,omitempty"` + // The status page the maintenance template belongs to. + StatusPage *MaintenanceTemplateDataRelationshipsStatusPage `json:"status_page,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:"-"` +} + +// NewMaintenanceTemplateDataRelationships instantiates a new MaintenanceTemplateDataRelationships 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 NewMaintenanceTemplateDataRelationships() *MaintenanceTemplateDataRelationships { + this := MaintenanceTemplateDataRelationships{} + return &this +} + +// NewMaintenanceTemplateDataRelationshipsWithDefaults instantiates a new MaintenanceTemplateDataRelationships 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 NewMaintenanceTemplateDataRelationshipsWithDefaults() *MaintenanceTemplateDataRelationships { + this := MaintenanceTemplateDataRelationships{} + return &this +} + +// GetCreatedByUser returns the CreatedByUser field value if set, zero value otherwise. +func (o *MaintenanceTemplateDataRelationships) GetCreatedByUser() MaintenanceTemplateDataRelationshipsCreatedByUser { + if o == nil || o.CreatedByUser == nil { + var ret MaintenanceTemplateDataRelationshipsCreatedByUser + return ret + } + return *o.CreatedByUser +} + +// GetCreatedByUserOk returns a tuple with the CreatedByUser field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *MaintenanceTemplateDataRelationships) GetCreatedByUserOk() (*MaintenanceTemplateDataRelationshipsCreatedByUser, bool) { + if o == nil || o.CreatedByUser == nil { + return nil, false + } + return o.CreatedByUser, true +} + +// HasCreatedByUser returns a boolean if a field has been set. +func (o *MaintenanceTemplateDataRelationships) HasCreatedByUser() bool { + return o != nil && o.CreatedByUser != nil +} + +// SetCreatedByUser gets a reference to the given MaintenanceTemplateDataRelationshipsCreatedByUser and assigns it to the CreatedByUser field. +func (o *MaintenanceTemplateDataRelationships) SetCreatedByUser(v MaintenanceTemplateDataRelationshipsCreatedByUser) { + o.CreatedByUser = &v +} + +// GetLastModifiedByUser returns the LastModifiedByUser field value if set, zero value otherwise. +func (o *MaintenanceTemplateDataRelationships) GetLastModifiedByUser() MaintenanceTemplateDataRelationshipsLastModifiedByUser { + if o == nil || o.LastModifiedByUser == nil { + var ret MaintenanceTemplateDataRelationshipsLastModifiedByUser + return ret + } + return *o.LastModifiedByUser +} + +// GetLastModifiedByUserOk returns a tuple with the LastModifiedByUser field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *MaintenanceTemplateDataRelationships) GetLastModifiedByUserOk() (*MaintenanceTemplateDataRelationshipsLastModifiedByUser, bool) { + if o == nil || o.LastModifiedByUser == nil { + return nil, false + } + return o.LastModifiedByUser, true +} + +// HasLastModifiedByUser returns a boolean if a field has been set. +func (o *MaintenanceTemplateDataRelationships) HasLastModifiedByUser() bool { + return o != nil && o.LastModifiedByUser != nil +} + +// SetLastModifiedByUser gets a reference to the given MaintenanceTemplateDataRelationshipsLastModifiedByUser and assigns it to the LastModifiedByUser field. +func (o *MaintenanceTemplateDataRelationships) SetLastModifiedByUser(v MaintenanceTemplateDataRelationshipsLastModifiedByUser) { + o.LastModifiedByUser = &v +} + +// GetStatusPage returns the StatusPage field value if set, zero value otherwise. +func (o *MaintenanceTemplateDataRelationships) GetStatusPage() MaintenanceTemplateDataRelationshipsStatusPage { + if o == nil || o.StatusPage == nil { + var ret MaintenanceTemplateDataRelationshipsStatusPage + return ret + } + return *o.StatusPage +} + +// GetStatusPageOk returns a tuple with the StatusPage field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *MaintenanceTemplateDataRelationships) GetStatusPageOk() (*MaintenanceTemplateDataRelationshipsStatusPage, bool) { + if o == nil || o.StatusPage == nil { + return nil, false + } + return o.StatusPage, true +} + +// HasStatusPage returns a boolean if a field has been set. +func (o *MaintenanceTemplateDataRelationships) HasStatusPage() bool { + return o != nil && o.StatusPage != nil +} + +// SetStatusPage gets a reference to the given MaintenanceTemplateDataRelationshipsStatusPage and assigns it to the StatusPage field. +func (o *MaintenanceTemplateDataRelationships) SetStatusPage(v MaintenanceTemplateDataRelationshipsStatusPage) { + o.StatusPage = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o MaintenanceTemplateDataRelationships) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.CreatedByUser != nil { + toSerialize["created_by_user"] = o.CreatedByUser + } + if o.LastModifiedByUser != nil { + toSerialize["last_modified_by_user"] = o.LastModifiedByUser + } + if o.StatusPage != nil { + toSerialize["status_page"] = o.StatusPage + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *MaintenanceTemplateDataRelationships) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + CreatedByUser *MaintenanceTemplateDataRelationshipsCreatedByUser `json:"created_by_user,omitempty"` + LastModifiedByUser *MaintenanceTemplateDataRelationshipsLastModifiedByUser `json:"last_modified_by_user,omitempty"` + StatusPage *MaintenanceTemplateDataRelationshipsStatusPage `json:"status_page,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"created_by_user", "last_modified_by_user", "status_page"}) + } else { + return err + } + + hasInvalidField := false + if all.CreatedByUser != nil && all.CreatedByUser.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.CreatedByUser = all.CreatedByUser + if all.LastModifiedByUser != nil && all.LastModifiedByUser.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.LastModifiedByUser = all.LastModifiedByUser + if all.StatusPage != nil && all.StatusPage.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.StatusPage = all.StatusPage + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_maintenance_template_data_relationships_created_by_user.go b/api/datadogV2/model_maintenance_template_data_relationships_created_by_user.go new file mode 100644 index 00000000000..2d7abb3f9be --- /dev/null +++ b/api/datadogV2/model_maintenance_template_data_relationships_created_by_user.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" +) + +// MaintenanceTemplateDataRelationshipsCreatedByUser The Datadog user who created the maintenance template. +type MaintenanceTemplateDataRelationshipsCreatedByUser struct { + // The data object identifying the Datadog user who created the maintenance template. + Data MaintenanceTemplateDataRelationshipsCreatedByUserData `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:"-"` +} + +// NewMaintenanceTemplateDataRelationshipsCreatedByUser instantiates a new MaintenanceTemplateDataRelationshipsCreatedByUser 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 NewMaintenanceTemplateDataRelationshipsCreatedByUser(data MaintenanceTemplateDataRelationshipsCreatedByUserData) *MaintenanceTemplateDataRelationshipsCreatedByUser { + this := MaintenanceTemplateDataRelationshipsCreatedByUser{} + this.Data = data + return &this +} + +// NewMaintenanceTemplateDataRelationshipsCreatedByUserWithDefaults instantiates a new MaintenanceTemplateDataRelationshipsCreatedByUser 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 NewMaintenanceTemplateDataRelationshipsCreatedByUserWithDefaults() *MaintenanceTemplateDataRelationshipsCreatedByUser { + this := MaintenanceTemplateDataRelationshipsCreatedByUser{} + return &this +} + +// GetData returns the Data field value. +func (o *MaintenanceTemplateDataRelationshipsCreatedByUser) GetData() MaintenanceTemplateDataRelationshipsCreatedByUserData { + if o == nil { + var ret MaintenanceTemplateDataRelationshipsCreatedByUserData + 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 *MaintenanceTemplateDataRelationshipsCreatedByUser) GetDataOk() (*MaintenanceTemplateDataRelationshipsCreatedByUserData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *MaintenanceTemplateDataRelationshipsCreatedByUser) SetData(v MaintenanceTemplateDataRelationshipsCreatedByUserData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o MaintenanceTemplateDataRelationshipsCreatedByUser) 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 *MaintenanceTemplateDataRelationshipsCreatedByUser) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *MaintenanceTemplateDataRelationshipsCreatedByUserData `json:"data"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Data == nil { + return fmt.Errorf("required field data missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + + hasInvalidField := false + if all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Data = *all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_maintenance_template_data_relationships_created_by_user_data.go b/api/datadogV2/model_maintenance_template_data_relationships_created_by_user_data.go new file mode 100644 index 00000000000..be50ad24b3a --- /dev/null +++ b/api/datadogV2/model_maintenance_template_data_relationships_created_by_user_data.go @@ -0,0 +1,145 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// MaintenanceTemplateDataRelationshipsCreatedByUserData The data object identifying the Datadog user who created the maintenance template. +type MaintenanceTemplateDataRelationshipsCreatedByUserData struct { + // The ID of the Datadog user who created the maintenance template. + Id string `json:"id"` + // Users resource type. + Type StatusPagesUserType `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:"-"` +} + +// NewMaintenanceTemplateDataRelationshipsCreatedByUserData instantiates a new MaintenanceTemplateDataRelationshipsCreatedByUserData 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 NewMaintenanceTemplateDataRelationshipsCreatedByUserData(id string, typeVar StatusPagesUserType) *MaintenanceTemplateDataRelationshipsCreatedByUserData { + this := MaintenanceTemplateDataRelationshipsCreatedByUserData{} + this.Id = id + this.Type = typeVar + return &this +} + +// NewMaintenanceTemplateDataRelationshipsCreatedByUserDataWithDefaults instantiates a new MaintenanceTemplateDataRelationshipsCreatedByUserData 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 NewMaintenanceTemplateDataRelationshipsCreatedByUserDataWithDefaults() *MaintenanceTemplateDataRelationshipsCreatedByUserData { + this := MaintenanceTemplateDataRelationshipsCreatedByUserData{} + var typeVar StatusPagesUserType = STATUSPAGESUSERTYPE_USERS + this.Type = typeVar + return &this +} + +// GetId returns the Id field value. +func (o *MaintenanceTemplateDataRelationshipsCreatedByUserData) GetId() string { + if o == nil { + var ret string + 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 *MaintenanceTemplateDataRelationshipsCreatedByUserData) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Id, true +} + +// SetId sets field value. +func (o *MaintenanceTemplateDataRelationshipsCreatedByUserData) SetId(v string) { + o.Id = v +} + +// GetType returns the Type field value. +func (o *MaintenanceTemplateDataRelationshipsCreatedByUserData) GetType() StatusPagesUserType { + if o == nil { + var ret StatusPagesUserType + 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 *MaintenanceTemplateDataRelationshipsCreatedByUserData) GetTypeOk() (*StatusPagesUserType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *MaintenanceTemplateDataRelationshipsCreatedByUserData) SetType(v StatusPagesUserType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o MaintenanceTemplateDataRelationshipsCreatedByUserData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["id"] = o.Id + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *MaintenanceTemplateDataRelationshipsCreatedByUserData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Id *string `json:"id"` + Type *StatusPagesUserType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Id == nil { + return fmt.Errorf("required field id missing") + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"id", "type"}) + } else { + return err + } + + hasInvalidField := false + o.Id = *all.Id + if !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = *all.Type + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_maintenance_template_data_relationships_last_modified_by_user.go b/api/datadogV2/model_maintenance_template_data_relationships_last_modified_by_user.go new file mode 100644 index 00000000000..011984b3e30 --- /dev/null +++ b/api/datadogV2/model_maintenance_template_data_relationships_last_modified_by_user.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" +) + +// MaintenanceTemplateDataRelationshipsLastModifiedByUser The Datadog user who last modified the maintenance template. +type MaintenanceTemplateDataRelationshipsLastModifiedByUser struct { + // The data object identifying the Datadog user who last modified the maintenance template. + Data MaintenanceTemplateDataRelationshipsLastModifiedByUserData `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:"-"` +} + +// NewMaintenanceTemplateDataRelationshipsLastModifiedByUser instantiates a new MaintenanceTemplateDataRelationshipsLastModifiedByUser 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 NewMaintenanceTemplateDataRelationshipsLastModifiedByUser(data MaintenanceTemplateDataRelationshipsLastModifiedByUserData) *MaintenanceTemplateDataRelationshipsLastModifiedByUser { + this := MaintenanceTemplateDataRelationshipsLastModifiedByUser{} + this.Data = data + return &this +} + +// NewMaintenanceTemplateDataRelationshipsLastModifiedByUserWithDefaults instantiates a new MaintenanceTemplateDataRelationshipsLastModifiedByUser 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 NewMaintenanceTemplateDataRelationshipsLastModifiedByUserWithDefaults() *MaintenanceTemplateDataRelationshipsLastModifiedByUser { + this := MaintenanceTemplateDataRelationshipsLastModifiedByUser{} + return &this +} + +// GetData returns the Data field value. +func (o *MaintenanceTemplateDataRelationshipsLastModifiedByUser) GetData() MaintenanceTemplateDataRelationshipsLastModifiedByUserData { + if o == nil { + var ret MaintenanceTemplateDataRelationshipsLastModifiedByUserData + 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 *MaintenanceTemplateDataRelationshipsLastModifiedByUser) GetDataOk() (*MaintenanceTemplateDataRelationshipsLastModifiedByUserData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *MaintenanceTemplateDataRelationshipsLastModifiedByUser) SetData(v MaintenanceTemplateDataRelationshipsLastModifiedByUserData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o MaintenanceTemplateDataRelationshipsLastModifiedByUser) 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 *MaintenanceTemplateDataRelationshipsLastModifiedByUser) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *MaintenanceTemplateDataRelationshipsLastModifiedByUserData `json:"data"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Data == nil { + return fmt.Errorf("required field data missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + + hasInvalidField := false + if all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Data = *all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_maintenance_template_data_relationships_last_modified_by_user_data.go b/api/datadogV2/model_maintenance_template_data_relationships_last_modified_by_user_data.go new file mode 100644 index 00000000000..73b477661e8 --- /dev/null +++ b/api/datadogV2/model_maintenance_template_data_relationships_last_modified_by_user_data.go @@ -0,0 +1,145 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// MaintenanceTemplateDataRelationshipsLastModifiedByUserData The data object identifying the Datadog user who last modified the maintenance template. +type MaintenanceTemplateDataRelationshipsLastModifiedByUserData struct { + // The ID of the Datadog user who last modified the maintenance template. + Id string `json:"id"` + // Users resource type. + Type StatusPagesUserType `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:"-"` +} + +// NewMaintenanceTemplateDataRelationshipsLastModifiedByUserData instantiates a new MaintenanceTemplateDataRelationshipsLastModifiedByUserData 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 NewMaintenanceTemplateDataRelationshipsLastModifiedByUserData(id string, typeVar StatusPagesUserType) *MaintenanceTemplateDataRelationshipsLastModifiedByUserData { + this := MaintenanceTemplateDataRelationshipsLastModifiedByUserData{} + this.Id = id + this.Type = typeVar + return &this +} + +// NewMaintenanceTemplateDataRelationshipsLastModifiedByUserDataWithDefaults instantiates a new MaintenanceTemplateDataRelationshipsLastModifiedByUserData 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 NewMaintenanceTemplateDataRelationshipsLastModifiedByUserDataWithDefaults() *MaintenanceTemplateDataRelationshipsLastModifiedByUserData { + this := MaintenanceTemplateDataRelationshipsLastModifiedByUserData{} + var typeVar StatusPagesUserType = STATUSPAGESUSERTYPE_USERS + this.Type = typeVar + return &this +} + +// GetId returns the Id field value. +func (o *MaintenanceTemplateDataRelationshipsLastModifiedByUserData) GetId() string { + if o == nil { + var ret string + 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 *MaintenanceTemplateDataRelationshipsLastModifiedByUserData) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Id, true +} + +// SetId sets field value. +func (o *MaintenanceTemplateDataRelationshipsLastModifiedByUserData) SetId(v string) { + o.Id = v +} + +// GetType returns the Type field value. +func (o *MaintenanceTemplateDataRelationshipsLastModifiedByUserData) GetType() StatusPagesUserType { + if o == nil { + var ret StatusPagesUserType + 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 *MaintenanceTemplateDataRelationshipsLastModifiedByUserData) GetTypeOk() (*StatusPagesUserType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *MaintenanceTemplateDataRelationshipsLastModifiedByUserData) SetType(v StatusPagesUserType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o MaintenanceTemplateDataRelationshipsLastModifiedByUserData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["id"] = o.Id + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *MaintenanceTemplateDataRelationshipsLastModifiedByUserData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Id *string `json:"id"` + Type *StatusPagesUserType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Id == nil { + return fmt.Errorf("required field id missing") + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"id", "type"}) + } else { + return err + } + + hasInvalidField := false + o.Id = *all.Id + if !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = *all.Type + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_maintenance_template_data_relationships_status_page.go b/api/datadogV2/model_maintenance_template_data_relationships_status_page.go new file mode 100644 index 00000000000..1736bbef012 --- /dev/null +++ b/api/datadogV2/model_maintenance_template_data_relationships_status_page.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" +) + +// MaintenanceTemplateDataRelationshipsStatusPage The status page the maintenance template belongs to. +type MaintenanceTemplateDataRelationshipsStatusPage struct { + // The data object identifying the status page associated with a maintenance template. + Data MaintenanceTemplateDataRelationshipsStatusPageData `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:"-"` +} + +// NewMaintenanceTemplateDataRelationshipsStatusPage instantiates a new MaintenanceTemplateDataRelationshipsStatusPage 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 NewMaintenanceTemplateDataRelationshipsStatusPage(data MaintenanceTemplateDataRelationshipsStatusPageData) *MaintenanceTemplateDataRelationshipsStatusPage { + this := MaintenanceTemplateDataRelationshipsStatusPage{} + this.Data = data + return &this +} + +// NewMaintenanceTemplateDataRelationshipsStatusPageWithDefaults instantiates a new MaintenanceTemplateDataRelationshipsStatusPage 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 NewMaintenanceTemplateDataRelationshipsStatusPageWithDefaults() *MaintenanceTemplateDataRelationshipsStatusPage { + this := MaintenanceTemplateDataRelationshipsStatusPage{} + return &this +} + +// GetData returns the Data field value. +func (o *MaintenanceTemplateDataRelationshipsStatusPage) GetData() MaintenanceTemplateDataRelationshipsStatusPageData { + if o == nil { + var ret MaintenanceTemplateDataRelationshipsStatusPageData + 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 *MaintenanceTemplateDataRelationshipsStatusPage) GetDataOk() (*MaintenanceTemplateDataRelationshipsStatusPageData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *MaintenanceTemplateDataRelationshipsStatusPage) SetData(v MaintenanceTemplateDataRelationshipsStatusPageData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o MaintenanceTemplateDataRelationshipsStatusPage) 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 *MaintenanceTemplateDataRelationshipsStatusPage) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *MaintenanceTemplateDataRelationshipsStatusPageData `json:"data"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Data == nil { + return fmt.Errorf("required field data missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + + hasInvalidField := false + if all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Data = *all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_maintenance_template_data_relationships_status_page_data.go b/api/datadogV2/model_maintenance_template_data_relationships_status_page_data.go new file mode 100644 index 00000000000..d7cdde1a56e --- /dev/null +++ b/api/datadogV2/model_maintenance_template_data_relationships_status_page_data.go @@ -0,0 +1,145 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// MaintenanceTemplateDataRelationshipsStatusPageData The data object identifying the status page associated with a maintenance template. +type MaintenanceTemplateDataRelationshipsStatusPageData struct { + // The ID of the status page. + Id string `json:"id"` + // Status pages resource type. + Type StatusPageDataType `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:"-"` +} + +// NewMaintenanceTemplateDataRelationshipsStatusPageData instantiates a new MaintenanceTemplateDataRelationshipsStatusPageData 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 NewMaintenanceTemplateDataRelationshipsStatusPageData(id string, typeVar StatusPageDataType) *MaintenanceTemplateDataRelationshipsStatusPageData { + this := MaintenanceTemplateDataRelationshipsStatusPageData{} + this.Id = id + this.Type = typeVar + return &this +} + +// NewMaintenanceTemplateDataRelationshipsStatusPageDataWithDefaults instantiates a new MaintenanceTemplateDataRelationshipsStatusPageData 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 NewMaintenanceTemplateDataRelationshipsStatusPageDataWithDefaults() *MaintenanceTemplateDataRelationshipsStatusPageData { + this := MaintenanceTemplateDataRelationshipsStatusPageData{} + var typeVar StatusPageDataType = STATUSPAGEDATATYPE_STATUS_PAGES + this.Type = typeVar + return &this +} + +// GetId returns the Id field value. +func (o *MaintenanceTemplateDataRelationshipsStatusPageData) GetId() string { + if o == nil { + var ret string + 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 *MaintenanceTemplateDataRelationshipsStatusPageData) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Id, true +} + +// SetId sets field value. +func (o *MaintenanceTemplateDataRelationshipsStatusPageData) SetId(v string) { + o.Id = v +} + +// GetType returns the Type field value. +func (o *MaintenanceTemplateDataRelationshipsStatusPageData) GetType() StatusPageDataType { + if o == nil { + var ret StatusPageDataType + 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 *MaintenanceTemplateDataRelationshipsStatusPageData) GetTypeOk() (*StatusPageDataType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *MaintenanceTemplateDataRelationshipsStatusPageData) SetType(v StatusPageDataType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o MaintenanceTemplateDataRelationshipsStatusPageData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["id"] = o.Id + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *MaintenanceTemplateDataRelationshipsStatusPageData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Id *string `json:"id"` + Type *StatusPageDataType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Id == nil { + return fmt.Errorf("required field id missing") + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"id", "type"}) + } else { + return err + } + + hasInvalidField := false + o.Id = *all.Id + if !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = *all.Type + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_patch_degradation_request_data.go b/api/datadogV2/model_patch_degradation_request_data.go index eb083e594b8..43837141558 100644 --- a/api/datadogV2/model_patch_degradation_request_data.go +++ b/api/datadogV2/model_patch_degradation_request_data.go @@ -18,6 +18,8 @@ type PatchDegradationRequestData struct { Attributes PatchDegradationRequestDataAttributes `json:"attributes"` // The ID of the degradation. Id uuid.UUID `json:"id"` + // The supported relationships for updating a degradation. + Relationships *PatchDegradationRequestDataRelationships `json:"relationships,omitempty"` // Degradations resource type. Type PatchDegradationRequestDataType `json:"type"` // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct @@ -93,6 +95,34 @@ func (o *PatchDegradationRequestData) SetId(v uuid.UUID) { o.Id = v } +// GetRelationships returns the Relationships field value if set, zero value otherwise. +func (o *PatchDegradationRequestData) GetRelationships() PatchDegradationRequestDataRelationships { + if o == nil || o.Relationships == nil { + var ret PatchDegradationRequestDataRelationships + return ret + } + return *o.Relationships +} + +// GetRelationshipsOk returns a tuple with the Relationships field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *PatchDegradationRequestData) GetRelationshipsOk() (*PatchDegradationRequestDataRelationships, bool) { + if o == nil || o.Relationships == nil { + return nil, false + } + return o.Relationships, true +} + +// HasRelationships returns a boolean if a field has been set. +func (o *PatchDegradationRequestData) HasRelationships() bool { + return o != nil && o.Relationships != nil +} + +// SetRelationships gets a reference to the given PatchDegradationRequestDataRelationships and assigns it to the Relationships field. +func (o *PatchDegradationRequestData) SetRelationships(v PatchDegradationRequestDataRelationships) { + o.Relationships = &v +} + // GetType returns the Type field value. func (o *PatchDegradationRequestData) GetType() PatchDegradationRequestDataType { if o == nil { @@ -124,6 +154,9 @@ func (o PatchDegradationRequestData) MarshalJSON() ([]byte, error) { } toSerialize["attributes"] = o.Attributes toSerialize["id"] = o.Id + if o.Relationships != nil { + toSerialize["relationships"] = o.Relationships + } toSerialize["type"] = o.Type for key, value := range o.AdditionalProperties { @@ -135,9 +168,10 @@ func (o PatchDegradationRequestData) MarshalJSON() ([]byte, error) { // UnmarshalJSON deserializes the given payload. func (o *PatchDegradationRequestData) UnmarshalJSON(bytes []byte) (err error) { all := struct { - Attributes *PatchDegradationRequestDataAttributes `json:"attributes"` - Id *uuid.UUID `json:"id"` - Type *PatchDegradationRequestDataType `json:"type"` + Attributes *PatchDegradationRequestDataAttributes `json:"attributes"` + Id *uuid.UUID `json:"id"` + Relationships *PatchDegradationRequestDataRelationships `json:"relationships,omitempty"` + Type *PatchDegradationRequestDataType `json:"type"` }{} if err = datadog.Unmarshal(bytes, &all); err != nil { return datadog.Unmarshal(bytes, &o.UnparsedObject) @@ -153,7 +187,7 @@ func (o *PatchDegradationRequestData) UnmarshalJSON(bytes []byte) (err error) { } additionalProperties := make(map[string]interface{}) if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { - datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "id", "type"}) + datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "id", "relationships", "type"}) } else { return err } @@ -164,6 +198,10 @@ func (o *PatchDegradationRequestData) UnmarshalJSON(bytes []byte) (err error) { } o.Attributes = *all.Attributes o.Id = *all.Id + if all.Relationships != nil && all.Relationships.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Relationships = all.Relationships if !all.Type.IsValid() { hasInvalidField = true } else { diff --git a/api/datadogV2/model_patch_degradation_request_data_relationships.go b/api/datadogV2/model_patch_degradation_request_data_relationships.go new file mode 100644 index 00000000000..c1fd505056d --- /dev/null +++ b/api/datadogV2/model_patch_degradation_request_data_relationships.go @@ -0,0 +1,111 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// PatchDegradationRequestDataRelationships The supported relationships for updating a degradation. +type PatchDegradationRequestDataRelationships struct { + // The template used to create the degradation. + Template *PatchDegradationRequestDataRelationshipsTemplate `json:"template,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:"-"` +} + +// NewPatchDegradationRequestDataRelationships instantiates a new PatchDegradationRequestDataRelationships 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 NewPatchDegradationRequestDataRelationships() *PatchDegradationRequestDataRelationships { + this := PatchDegradationRequestDataRelationships{} + return &this +} + +// NewPatchDegradationRequestDataRelationshipsWithDefaults instantiates a new PatchDegradationRequestDataRelationships 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 NewPatchDegradationRequestDataRelationshipsWithDefaults() *PatchDegradationRequestDataRelationships { + this := PatchDegradationRequestDataRelationships{} + return &this +} + +// GetTemplate returns the Template field value if set, zero value otherwise. +func (o *PatchDegradationRequestDataRelationships) GetTemplate() PatchDegradationRequestDataRelationshipsTemplate { + if o == nil || o.Template == nil { + var ret PatchDegradationRequestDataRelationshipsTemplate + return ret + } + return *o.Template +} + +// GetTemplateOk returns a tuple with the Template field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *PatchDegradationRequestDataRelationships) GetTemplateOk() (*PatchDegradationRequestDataRelationshipsTemplate, bool) { + if o == nil || o.Template == nil { + return nil, false + } + return o.Template, true +} + +// HasTemplate returns a boolean if a field has been set. +func (o *PatchDegradationRequestDataRelationships) HasTemplate() bool { + return o != nil && o.Template != nil +} + +// SetTemplate gets a reference to the given PatchDegradationRequestDataRelationshipsTemplate and assigns it to the Template field. +func (o *PatchDegradationRequestDataRelationships) SetTemplate(v PatchDegradationRequestDataRelationshipsTemplate) { + o.Template = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o PatchDegradationRequestDataRelationships) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Template != nil { + toSerialize["template"] = o.Template + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *PatchDegradationRequestDataRelationships) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Template *PatchDegradationRequestDataRelationshipsTemplate `json:"template,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"template"}) + } else { + return err + } + + hasInvalidField := false + if all.Template != nil && all.Template.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Template = all.Template + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_patch_degradation_request_data_relationships_template.go b/api/datadogV2/model_patch_degradation_request_data_relationships_template.go new file mode 100644 index 00000000000..3d9df4dc1d4 --- /dev/null +++ b/api/datadogV2/model_patch_degradation_request_data_relationships_template.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" +) + +// PatchDegradationRequestDataRelationshipsTemplate The template used to create the degradation. +type PatchDegradationRequestDataRelationshipsTemplate struct { + // The data object identifying the template used to create the degradation. + Data PatchDegradationRequestDataRelationshipsTemplateData `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:"-"` +} + +// NewPatchDegradationRequestDataRelationshipsTemplate instantiates a new PatchDegradationRequestDataRelationshipsTemplate 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 NewPatchDegradationRequestDataRelationshipsTemplate(data PatchDegradationRequestDataRelationshipsTemplateData) *PatchDegradationRequestDataRelationshipsTemplate { + this := PatchDegradationRequestDataRelationshipsTemplate{} + this.Data = data + return &this +} + +// NewPatchDegradationRequestDataRelationshipsTemplateWithDefaults instantiates a new PatchDegradationRequestDataRelationshipsTemplate 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 NewPatchDegradationRequestDataRelationshipsTemplateWithDefaults() *PatchDegradationRequestDataRelationshipsTemplate { + this := PatchDegradationRequestDataRelationshipsTemplate{} + return &this +} + +// GetData returns the Data field value. +func (o *PatchDegradationRequestDataRelationshipsTemplate) GetData() PatchDegradationRequestDataRelationshipsTemplateData { + if o == nil { + var ret PatchDegradationRequestDataRelationshipsTemplateData + 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 *PatchDegradationRequestDataRelationshipsTemplate) GetDataOk() (*PatchDegradationRequestDataRelationshipsTemplateData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *PatchDegradationRequestDataRelationshipsTemplate) SetData(v PatchDegradationRequestDataRelationshipsTemplateData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o PatchDegradationRequestDataRelationshipsTemplate) 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 *PatchDegradationRequestDataRelationshipsTemplate) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *PatchDegradationRequestDataRelationshipsTemplateData `json:"data"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Data == nil { + return fmt.Errorf("required field data missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + + hasInvalidField := false + if all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Data = *all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_patch_degradation_request_data_relationships_template_data.go b/api/datadogV2/model_patch_degradation_request_data_relationships_template_data.go new file mode 100644 index 00000000000..37273db1e29 --- /dev/null +++ b/api/datadogV2/model_patch_degradation_request_data_relationships_template_data.go @@ -0,0 +1,145 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// PatchDegradationRequestDataRelationshipsTemplateData The data object identifying the template used to create the degradation. +type PatchDegradationRequestDataRelationshipsTemplateData struct { + // The ID of the degradation template. + Id string `json:"id"` + // Degradation templates resource type. + Type PatchDegradationTemplateRequestDataType `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:"-"` +} + +// NewPatchDegradationRequestDataRelationshipsTemplateData instantiates a new PatchDegradationRequestDataRelationshipsTemplateData 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 NewPatchDegradationRequestDataRelationshipsTemplateData(id string, typeVar PatchDegradationTemplateRequestDataType) *PatchDegradationRequestDataRelationshipsTemplateData { + this := PatchDegradationRequestDataRelationshipsTemplateData{} + this.Id = id + this.Type = typeVar + return &this +} + +// NewPatchDegradationRequestDataRelationshipsTemplateDataWithDefaults instantiates a new PatchDegradationRequestDataRelationshipsTemplateData 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 NewPatchDegradationRequestDataRelationshipsTemplateDataWithDefaults() *PatchDegradationRequestDataRelationshipsTemplateData { + this := PatchDegradationRequestDataRelationshipsTemplateData{} + var typeVar PatchDegradationTemplateRequestDataType = PATCHDEGRADATIONTEMPLATEREQUESTDATATYPE_DEGRADATION_TEMPLATES + this.Type = typeVar + return &this +} + +// GetId returns the Id field value. +func (o *PatchDegradationRequestDataRelationshipsTemplateData) GetId() string { + if o == nil { + var ret string + 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 *PatchDegradationRequestDataRelationshipsTemplateData) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Id, true +} + +// SetId sets field value. +func (o *PatchDegradationRequestDataRelationshipsTemplateData) SetId(v string) { + o.Id = v +} + +// GetType returns the Type field value. +func (o *PatchDegradationRequestDataRelationshipsTemplateData) GetType() PatchDegradationTemplateRequestDataType { + if o == nil { + var ret PatchDegradationTemplateRequestDataType + 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 *PatchDegradationRequestDataRelationshipsTemplateData) GetTypeOk() (*PatchDegradationTemplateRequestDataType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *PatchDegradationRequestDataRelationshipsTemplateData) SetType(v PatchDegradationTemplateRequestDataType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o PatchDegradationRequestDataRelationshipsTemplateData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["id"] = o.Id + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *PatchDegradationRequestDataRelationshipsTemplateData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Id *string `json:"id"` + Type *PatchDegradationTemplateRequestDataType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Id == nil { + return fmt.Errorf("required field id missing") + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"id", "type"}) + } else { + return err + } + + hasInvalidField := false + o.Id = *all.Id + if !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = *all.Type + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_patch_degradation_template_request.go b/api/datadogV2/model_patch_degradation_template_request.go new file mode 100644 index 00000000000..eb74c6ac09a --- /dev/null +++ b/api/datadogV2/model_patch_degradation_template_request.go @@ -0,0 +1,111 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// PatchDegradationTemplateRequest Request object for updating a degradation template. +type PatchDegradationTemplateRequest struct { + // The data object for updating a degradation template. + Data *PatchDegradationTemplateRequestData `json:"data,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewPatchDegradationTemplateRequest instantiates a new PatchDegradationTemplateRequest 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 NewPatchDegradationTemplateRequest() *PatchDegradationTemplateRequest { + this := PatchDegradationTemplateRequest{} + return &this +} + +// NewPatchDegradationTemplateRequestWithDefaults instantiates a new PatchDegradationTemplateRequest 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 NewPatchDegradationTemplateRequestWithDefaults() *PatchDegradationTemplateRequest { + this := PatchDegradationTemplateRequest{} + return &this +} + +// GetData returns the Data field value if set, zero value otherwise. +func (o *PatchDegradationTemplateRequest) GetData() PatchDegradationTemplateRequestData { + if o == nil || o.Data == nil { + var ret PatchDegradationTemplateRequestData + return ret + } + return *o.Data +} + +// GetDataOk returns a tuple with the Data field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *PatchDegradationTemplateRequest) GetDataOk() (*PatchDegradationTemplateRequestData, bool) { + if o == nil || o.Data == nil { + return nil, false + } + return o.Data, true +} + +// HasData returns a boolean if a field has been set. +func (o *PatchDegradationTemplateRequest) HasData() bool { + return o != nil && o.Data != nil +} + +// SetData gets a reference to the given PatchDegradationTemplateRequestData and assigns it to the Data field. +func (o *PatchDegradationTemplateRequest) SetData(v PatchDegradationTemplateRequestData) { + o.Data = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o PatchDegradationTemplateRequest) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Data != nil { + toSerialize["data"] = o.Data + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *PatchDegradationTemplateRequest) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *PatchDegradationTemplateRequestData `json:"data,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + + hasInvalidField := false + if all.Data != nil && all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Data = all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_patch_degradation_template_request_data.go b/api/datadogV2/model_patch_degradation_template_request_data.go new file mode 100644 index 00000000000..6e36c9781bd --- /dev/null +++ b/api/datadogV2/model_patch_degradation_template_request_data.go @@ -0,0 +1,183 @@ +// 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" +) + +// PatchDegradationTemplateRequestData The data object for updating a degradation template. +type PatchDegradationTemplateRequestData struct { + // The supported attributes for updating a degradation template. + Attributes *PatchDegradationTemplateRequestDataAttributes `json:"attributes,omitempty"` + // The ID of the degradation template. + Id string `json:"id"` + // Degradation templates resource type. + Type PatchDegradationTemplateRequestDataType `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:"-"` +} + +// NewPatchDegradationTemplateRequestData instantiates a new PatchDegradationTemplateRequestData 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 NewPatchDegradationTemplateRequestData(id string, typeVar PatchDegradationTemplateRequestDataType) *PatchDegradationTemplateRequestData { + this := PatchDegradationTemplateRequestData{} + this.Id = id + this.Type = typeVar + return &this +} + +// NewPatchDegradationTemplateRequestDataWithDefaults instantiates a new PatchDegradationTemplateRequestData 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 NewPatchDegradationTemplateRequestDataWithDefaults() *PatchDegradationTemplateRequestData { + this := PatchDegradationTemplateRequestData{} + var typeVar PatchDegradationTemplateRequestDataType = PATCHDEGRADATIONTEMPLATEREQUESTDATATYPE_DEGRADATION_TEMPLATES + this.Type = typeVar + return &this +} + +// GetAttributes returns the Attributes field value if set, zero value otherwise. +func (o *PatchDegradationTemplateRequestData) GetAttributes() PatchDegradationTemplateRequestDataAttributes { + if o == nil || o.Attributes == nil { + var ret PatchDegradationTemplateRequestDataAttributes + return ret + } + return *o.Attributes +} + +// GetAttributesOk returns a tuple with the Attributes field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *PatchDegradationTemplateRequestData) GetAttributesOk() (*PatchDegradationTemplateRequestDataAttributes, bool) { + if o == nil || o.Attributes == nil { + return nil, false + } + return o.Attributes, true +} + +// HasAttributes returns a boolean if a field has been set. +func (o *PatchDegradationTemplateRequestData) HasAttributes() bool { + return o != nil && o.Attributes != nil +} + +// SetAttributes gets a reference to the given PatchDegradationTemplateRequestDataAttributes and assigns it to the Attributes field. +func (o *PatchDegradationTemplateRequestData) SetAttributes(v PatchDegradationTemplateRequestDataAttributes) { + o.Attributes = &v +} + +// GetId returns the Id field value. +func (o *PatchDegradationTemplateRequestData) GetId() string { + if o == nil { + var ret string + 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 *PatchDegradationTemplateRequestData) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Id, true +} + +// SetId sets field value. +func (o *PatchDegradationTemplateRequestData) SetId(v string) { + o.Id = v +} + +// GetType returns the Type field value. +func (o *PatchDegradationTemplateRequestData) GetType() PatchDegradationTemplateRequestDataType { + if o == nil { + var ret PatchDegradationTemplateRequestDataType + 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 *PatchDegradationTemplateRequestData) GetTypeOk() (*PatchDegradationTemplateRequestDataType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *PatchDegradationTemplateRequestData) SetType(v PatchDegradationTemplateRequestDataType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o PatchDegradationTemplateRequestData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Attributes != nil { + 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 *PatchDegradationTemplateRequestData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *PatchDegradationTemplateRequestDataAttributes `json:"attributes,omitempty"` + Id *string `json:"id"` + Type *PatchDegradationTemplateRequestDataType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Id == nil { + return fmt.Errorf("required field id missing") + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "id", "type"}) + } else { + return err + } + + hasInvalidField := false + if all.Attributes != nil && 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_patch_degradation_template_request_data_attributes.go b/api/datadogV2/model_patch_degradation_template_request_data_attributes.go new file mode 100644 index 00000000000..bbd1d5c71cc --- /dev/null +++ b/api/datadogV2/model_patch_degradation_template_request_data_attributes.go @@ -0,0 +1,207 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// PatchDegradationTemplateRequestDataAttributes The supported attributes for updating a degradation template. +type PatchDegradationTemplateRequestDataAttributes struct { + // The components affected by a degradation created from this template. + ComponentsAffected []PatchDegradationTemplateRequestDataAttributesComponentsAffectedItems `json:"components_affected,omitempty"` + // The title used for a degradation created from this template. + DegradationTitle *string `json:"degradation_title,omitempty"` + // The name of the degradation template. + Name *string `json:"name,omitempty"` + // The pre-filled updates for a degradation created from this template. + Updates []PatchDegradationTemplateRequestDataAttributesUpdatesItems `json:"updates,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:"-"` +} + +// NewPatchDegradationTemplateRequestDataAttributes instantiates a new PatchDegradationTemplateRequestDataAttributes 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 NewPatchDegradationTemplateRequestDataAttributes() *PatchDegradationTemplateRequestDataAttributes { + this := PatchDegradationTemplateRequestDataAttributes{} + return &this +} + +// NewPatchDegradationTemplateRequestDataAttributesWithDefaults instantiates a new PatchDegradationTemplateRequestDataAttributes 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 NewPatchDegradationTemplateRequestDataAttributesWithDefaults() *PatchDegradationTemplateRequestDataAttributes { + this := PatchDegradationTemplateRequestDataAttributes{} + return &this +} + +// GetComponentsAffected returns the ComponentsAffected field value if set, zero value otherwise. +func (o *PatchDegradationTemplateRequestDataAttributes) GetComponentsAffected() []PatchDegradationTemplateRequestDataAttributesComponentsAffectedItems { + if o == nil || o.ComponentsAffected == nil { + var ret []PatchDegradationTemplateRequestDataAttributesComponentsAffectedItems + return ret + } + return o.ComponentsAffected +} + +// GetComponentsAffectedOk returns a tuple with the ComponentsAffected field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *PatchDegradationTemplateRequestDataAttributes) GetComponentsAffectedOk() (*[]PatchDegradationTemplateRequestDataAttributesComponentsAffectedItems, bool) { + if o == nil || o.ComponentsAffected == nil { + return nil, false + } + return &o.ComponentsAffected, true +} + +// HasComponentsAffected returns a boolean if a field has been set. +func (o *PatchDegradationTemplateRequestDataAttributes) HasComponentsAffected() bool { + return o != nil && o.ComponentsAffected != nil +} + +// SetComponentsAffected gets a reference to the given []PatchDegradationTemplateRequestDataAttributesComponentsAffectedItems and assigns it to the ComponentsAffected field. +func (o *PatchDegradationTemplateRequestDataAttributes) SetComponentsAffected(v []PatchDegradationTemplateRequestDataAttributesComponentsAffectedItems) { + o.ComponentsAffected = v +} + +// GetDegradationTitle returns the DegradationTitle field value if set, zero value otherwise. +func (o *PatchDegradationTemplateRequestDataAttributes) GetDegradationTitle() string { + if o == nil || o.DegradationTitle == nil { + var ret string + return ret + } + return *o.DegradationTitle +} + +// GetDegradationTitleOk returns a tuple with the DegradationTitle field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *PatchDegradationTemplateRequestDataAttributes) GetDegradationTitleOk() (*string, bool) { + if o == nil || o.DegradationTitle == nil { + return nil, false + } + return o.DegradationTitle, true +} + +// HasDegradationTitle returns a boolean if a field has been set. +func (o *PatchDegradationTemplateRequestDataAttributes) HasDegradationTitle() bool { + return o != nil && o.DegradationTitle != nil +} + +// SetDegradationTitle gets a reference to the given string and assigns it to the DegradationTitle field. +func (o *PatchDegradationTemplateRequestDataAttributes) SetDegradationTitle(v string) { + o.DegradationTitle = &v +} + +// GetName returns the Name field value if set, zero value otherwise. +func (o *PatchDegradationTemplateRequestDataAttributes) GetName() string { + if o == nil || o.Name == nil { + var ret string + return ret + } + return *o.Name +} + +// GetNameOk returns a tuple with the Name field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *PatchDegradationTemplateRequestDataAttributes) GetNameOk() (*string, bool) { + if o == nil || o.Name == nil { + return nil, false + } + return o.Name, true +} + +// HasName returns a boolean if a field has been set. +func (o *PatchDegradationTemplateRequestDataAttributes) HasName() bool { + return o != nil && o.Name != nil +} + +// SetName gets a reference to the given string and assigns it to the Name field. +func (o *PatchDegradationTemplateRequestDataAttributes) SetName(v string) { + o.Name = &v +} + +// GetUpdates returns the Updates field value if set, zero value otherwise. +func (o *PatchDegradationTemplateRequestDataAttributes) GetUpdates() []PatchDegradationTemplateRequestDataAttributesUpdatesItems { + if o == nil || o.Updates == nil { + var ret []PatchDegradationTemplateRequestDataAttributesUpdatesItems + return ret + } + return o.Updates +} + +// GetUpdatesOk returns a tuple with the Updates field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *PatchDegradationTemplateRequestDataAttributes) GetUpdatesOk() (*[]PatchDegradationTemplateRequestDataAttributesUpdatesItems, bool) { + if o == nil || o.Updates == nil { + return nil, false + } + return &o.Updates, true +} + +// HasUpdates returns a boolean if a field has been set. +func (o *PatchDegradationTemplateRequestDataAttributes) HasUpdates() bool { + return o != nil && o.Updates != nil +} + +// SetUpdates gets a reference to the given []PatchDegradationTemplateRequestDataAttributesUpdatesItems and assigns it to the Updates field. +func (o *PatchDegradationTemplateRequestDataAttributes) SetUpdates(v []PatchDegradationTemplateRequestDataAttributesUpdatesItems) { + o.Updates = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o PatchDegradationTemplateRequestDataAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.ComponentsAffected != nil { + toSerialize["components_affected"] = o.ComponentsAffected + } + if o.DegradationTitle != nil { + toSerialize["degradation_title"] = o.DegradationTitle + } + if o.Name != nil { + toSerialize["name"] = o.Name + } + if o.Updates != nil { + toSerialize["updates"] = o.Updates + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *PatchDegradationTemplateRequestDataAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + ComponentsAffected []PatchDegradationTemplateRequestDataAttributesComponentsAffectedItems `json:"components_affected,omitempty"` + DegradationTitle *string `json:"degradation_title,omitempty"` + Name *string `json:"name,omitempty"` + Updates []PatchDegradationTemplateRequestDataAttributesUpdatesItems `json:"updates,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"components_affected", "degradation_title", "name", "updates"}) + } else { + return err + } + o.ComponentsAffected = all.ComponentsAffected + o.DegradationTitle = all.DegradationTitle + o.Name = all.Name + o.Updates = all.Updates + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_patch_degradation_template_request_data_attributes_components_affected_items.go b/api/datadogV2/model_patch_degradation_template_request_data_attributes_components_affected_items.go new file mode 100644 index 00000000000..ebfc7fe9a86 --- /dev/null +++ b/api/datadogV2/model_patch_degradation_template_request_data_attributes_components_affected_items.go @@ -0,0 +1,178 @@ +// 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" +) + +// PatchDegradationTemplateRequestDataAttributesComponentsAffectedItems A component affected by a degradation created from this template. +type PatchDegradationTemplateRequestDataAttributesComponentsAffectedItems struct { + // The ID of the component. Must be a component of type `component`. + Id string `json:"id"` + // The name of the component. + Name *string `json:"name,omitempty"` + // The status of the component. + Status PatchDegradationTemplateRequestDataAttributesComponentsAffectedItemsStatus `json:"status"` + // 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:"-"` +} + +// NewPatchDegradationTemplateRequestDataAttributesComponentsAffectedItems instantiates a new PatchDegradationTemplateRequestDataAttributesComponentsAffectedItems 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 NewPatchDegradationTemplateRequestDataAttributesComponentsAffectedItems(id string, status PatchDegradationTemplateRequestDataAttributesComponentsAffectedItemsStatus) *PatchDegradationTemplateRequestDataAttributesComponentsAffectedItems { + this := PatchDegradationTemplateRequestDataAttributesComponentsAffectedItems{} + this.Id = id + this.Status = status + return &this +} + +// NewPatchDegradationTemplateRequestDataAttributesComponentsAffectedItemsWithDefaults instantiates a new PatchDegradationTemplateRequestDataAttributesComponentsAffectedItems 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 NewPatchDegradationTemplateRequestDataAttributesComponentsAffectedItemsWithDefaults() *PatchDegradationTemplateRequestDataAttributesComponentsAffectedItems { + this := PatchDegradationTemplateRequestDataAttributesComponentsAffectedItems{} + return &this +} + +// GetId returns the Id field value. +func (o *PatchDegradationTemplateRequestDataAttributesComponentsAffectedItems) GetId() string { + if o == nil { + var ret string + 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 *PatchDegradationTemplateRequestDataAttributesComponentsAffectedItems) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Id, true +} + +// SetId sets field value. +func (o *PatchDegradationTemplateRequestDataAttributesComponentsAffectedItems) SetId(v string) { + o.Id = v +} + +// GetName returns the Name field value if set, zero value otherwise. +func (o *PatchDegradationTemplateRequestDataAttributesComponentsAffectedItems) GetName() string { + if o == nil || o.Name == nil { + var ret string + return ret + } + return *o.Name +} + +// GetNameOk returns a tuple with the Name field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *PatchDegradationTemplateRequestDataAttributesComponentsAffectedItems) GetNameOk() (*string, bool) { + if o == nil || o.Name == nil { + return nil, false + } + return o.Name, true +} + +// HasName returns a boolean if a field has been set. +func (o *PatchDegradationTemplateRequestDataAttributesComponentsAffectedItems) HasName() bool { + return o != nil && o.Name != nil +} + +// SetName gets a reference to the given string and assigns it to the Name field. +func (o *PatchDegradationTemplateRequestDataAttributesComponentsAffectedItems) SetName(v string) { + o.Name = &v +} + +// GetStatus returns the Status field value. +func (o *PatchDegradationTemplateRequestDataAttributesComponentsAffectedItems) GetStatus() PatchDegradationTemplateRequestDataAttributesComponentsAffectedItemsStatus { + if o == nil { + var ret PatchDegradationTemplateRequestDataAttributesComponentsAffectedItemsStatus + return ret + } + return o.Status +} + +// GetStatusOk returns a tuple with the Status field value +// and a boolean to check if the value has been set. +func (o *PatchDegradationTemplateRequestDataAttributesComponentsAffectedItems) GetStatusOk() (*PatchDegradationTemplateRequestDataAttributesComponentsAffectedItemsStatus, bool) { + if o == nil { + return nil, false + } + return &o.Status, true +} + +// SetStatus sets field value. +func (o *PatchDegradationTemplateRequestDataAttributesComponentsAffectedItems) SetStatus(v PatchDegradationTemplateRequestDataAttributesComponentsAffectedItemsStatus) { + o.Status = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o PatchDegradationTemplateRequestDataAttributesComponentsAffectedItems) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["id"] = o.Id + if o.Name != nil { + toSerialize["name"] = o.Name + } + toSerialize["status"] = o.Status + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *PatchDegradationTemplateRequestDataAttributesComponentsAffectedItems) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Id *string `json:"id"` + Name *string `json:"name,omitempty"` + Status *PatchDegradationTemplateRequestDataAttributesComponentsAffectedItemsStatus `json:"status"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Id == nil { + return fmt.Errorf("required field id missing") + } + if all.Status == nil { + return fmt.Errorf("required field status missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"id", "name", "status"}) + } else { + return err + } + + hasInvalidField := false + o.Id = *all.Id + o.Name = all.Name + if !all.Status.IsValid() { + hasInvalidField = true + } else { + o.Status = *all.Status + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_patch_degradation_template_request_data_attributes_components_affected_items_status.go b/api/datadogV2/model_patch_degradation_template_request_data_attributes_components_affected_items_status.go new file mode 100644 index 00000000000..067ab4b887a --- /dev/null +++ b/api/datadogV2/model_patch_degradation_template_request_data_attributes_components_affected_items_status.go @@ -0,0 +1,70 @@ +// 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" +) + +// PatchDegradationTemplateRequestDataAttributesComponentsAffectedItemsStatus The status of the component. +type PatchDegradationTemplateRequestDataAttributesComponentsAffectedItemsStatus string + +// List of PatchDegradationTemplateRequestDataAttributesComponentsAffectedItemsStatus. +const ( + PATCHDEGRADATIONTEMPLATEREQUESTDATAATTRIBUTESCOMPONENTSAFFECTEDITEMSSTATUS_OPERATIONAL PatchDegradationTemplateRequestDataAttributesComponentsAffectedItemsStatus = "operational" + PATCHDEGRADATIONTEMPLATEREQUESTDATAATTRIBUTESCOMPONENTSAFFECTEDITEMSSTATUS_DEGRADED PatchDegradationTemplateRequestDataAttributesComponentsAffectedItemsStatus = "degraded" + PATCHDEGRADATIONTEMPLATEREQUESTDATAATTRIBUTESCOMPONENTSAFFECTEDITEMSSTATUS_PARTIAL_OUTAGE PatchDegradationTemplateRequestDataAttributesComponentsAffectedItemsStatus = "partial_outage" + PATCHDEGRADATIONTEMPLATEREQUESTDATAATTRIBUTESCOMPONENTSAFFECTEDITEMSSTATUS_MAJOR_OUTAGE PatchDegradationTemplateRequestDataAttributesComponentsAffectedItemsStatus = "major_outage" +) + +var allowedPatchDegradationTemplateRequestDataAttributesComponentsAffectedItemsStatusEnumValues = []PatchDegradationTemplateRequestDataAttributesComponentsAffectedItemsStatus{ + PATCHDEGRADATIONTEMPLATEREQUESTDATAATTRIBUTESCOMPONENTSAFFECTEDITEMSSTATUS_OPERATIONAL, + PATCHDEGRADATIONTEMPLATEREQUESTDATAATTRIBUTESCOMPONENTSAFFECTEDITEMSSTATUS_DEGRADED, + PATCHDEGRADATIONTEMPLATEREQUESTDATAATTRIBUTESCOMPONENTSAFFECTEDITEMSSTATUS_PARTIAL_OUTAGE, + PATCHDEGRADATIONTEMPLATEREQUESTDATAATTRIBUTESCOMPONENTSAFFECTEDITEMSSTATUS_MAJOR_OUTAGE, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *PatchDegradationTemplateRequestDataAttributesComponentsAffectedItemsStatus) GetAllowedValues() []PatchDegradationTemplateRequestDataAttributesComponentsAffectedItemsStatus { + return allowedPatchDegradationTemplateRequestDataAttributesComponentsAffectedItemsStatusEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *PatchDegradationTemplateRequestDataAttributesComponentsAffectedItemsStatus) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = PatchDegradationTemplateRequestDataAttributesComponentsAffectedItemsStatus(value) + return nil +} + +// NewPatchDegradationTemplateRequestDataAttributesComponentsAffectedItemsStatusFromValue returns a pointer to a valid PatchDegradationTemplateRequestDataAttributesComponentsAffectedItemsStatus +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewPatchDegradationTemplateRequestDataAttributesComponentsAffectedItemsStatusFromValue(v string) (*PatchDegradationTemplateRequestDataAttributesComponentsAffectedItemsStatus, error) { + ev := PatchDegradationTemplateRequestDataAttributesComponentsAffectedItemsStatus(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for PatchDegradationTemplateRequestDataAttributesComponentsAffectedItemsStatus: valid values are %v", v, allowedPatchDegradationTemplateRequestDataAttributesComponentsAffectedItemsStatusEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v PatchDegradationTemplateRequestDataAttributesComponentsAffectedItemsStatus) IsValid() bool { + for _, existing := range allowedPatchDegradationTemplateRequestDataAttributesComponentsAffectedItemsStatusEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to PatchDegradationTemplateRequestDataAttributesComponentsAffectedItemsStatus value. +func (v PatchDegradationTemplateRequestDataAttributesComponentsAffectedItemsStatus) Ptr() *PatchDegradationTemplateRequestDataAttributesComponentsAffectedItemsStatus { + return &v +} diff --git a/api/datadogV2/model_patch_degradation_template_request_data_attributes_updates_items.go b/api/datadogV2/model_patch_degradation_template_request_data_attributes_updates_items.go new file mode 100644 index 00000000000..74e54e99409 --- /dev/null +++ b/api/datadogV2/model_patch_degradation_template_request_data_attributes_updates_items.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" +) + +// PatchDegradationTemplateRequestDataAttributesUpdatesItems A pre-filled update for a degradation created from this template. +type PatchDegradationTemplateRequestDataAttributesUpdatesItems struct { + // The message of the update. + Message *string `json:"message,omitempty"` + // The status of the degradation. + Status CreateDegradationRequestDataAttributesStatus `json:"status"` + // 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:"-"` +} + +// NewPatchDegradationTemplateRequestDataAttributesUpdatesItems instantiates a new PatchDegradationTemplateRequestDataAttributesUpdatesItems 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 NewPatchDegradationTemplateRequestDataAttributesUpdatesItems(status CreateDegradationRequestDataAttributesStatus) *PatchDegradationTemplateRequestDataAttributesUpdatesItems { + this := PatchDegradationTemplateRequestDataAttributesUpdatesItems{} + this.Status = status + return &this +} + +// NewPatchDegradationTemplateRequestDataAttributesUpdatesItemsWithDefaults instantiates a new PatchDegradationTemplateRequestDataAttributesUpdatesItems 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 NewPatchDegradationTemplateRequestDataAttributesUpdatesItemsWithDefaults() *PatchDegradationTemplateRequestDataAttributesUpdatesItems { + this := PatchDegradationTemplateRequestDataAttributesUpdatesItems{} + return &this +} + +// GetMessage returns the Message field value if set, zero value otherwise. +func (o *PatchDegradationTemplateRequestDataAttributesUpdatesItems) GetMessage() string { + if o == nil || o.Message == nil { + var ret string + return ret + } + return *o.Message +} + +// GetMessageOk returns a tuple with the Message field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *PatchDegradationTemplateRequestDataAttributesUpdatesItems) GetMessageOk() (*string, bool) { + if o == nil || o.Message == nil { + return nil, false + } + return o.Message, true +} + +// HasMessage returns a boolean if a field has been set. +func (o *PatchDegradationTemplateRequestDataAttributesUpdatesItems) HasMessage() bool { + return o != nil && o.Message != nil +} + +// SetMessage gets a reference to the given string and assigns it to the Message field. +func (o *PatchDegradationTemplateRequestDataAttributesUpdatesItems) SetMessage(v string) { + o.Message = &v +} + +// GetStatus returns the Status field value. +func (o *PatchDegradationTemplateRequestDataAttributesUpdatesItems) GetStatus() CreateDegradationRequestDataAttributesStatus { + if o == nil { + var ret CreateDegradationRequestDataAttributesStatus + return ret + } + return o.Status +} + +// GetStatusOk returns a tuple with the Status field value +// and a boolean to check if the value has been set. +func (o *PatchDegradationTemplateRequestDataAttributesUpdatesItems) GetStatusOk() (*CreateDegradationRequestDataAttributesStatus, bool) { + if o == nil { + return nil, false + } + return &o.Status, true +} + +// SetStatus sets field value. +func (o *PatchDegradationTemplateRequestDataAttributesUpdatesItems) SetStatus(v CreateDegradationRequestDataAttributesStatus) { + o.Status = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o PatchDegradationTemplateRequestDataAttributesUpdatesItems) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Message != nil { + toSerialize["message"] = o.Message + } + toSerialize["status"] = o.Status + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *PatchDegradationTemplateRequestDataAttributesUpdatesItems) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Message *string `json:"message,omitempty"` + Status *CreateDegradationRequestDataAttributesStatus `json:"status"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Status == nil { + return fmt.Errorf("required field status missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"message", "status"}) + } else { + return err + } + + hasInvalidField := false + o.Message = all.Message + if !all.Status.IsValid() { + hasInvalidField = true + } else { + o.Status = *all.Status + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_patch_degradation_template_request_data_type.go b/api/datadogV2/model_patch_degradation_template_request_data_type.go new file mode 100644 index 00000000000..0ea7e2faba6 --- /dev/null +++ b/api/datadogV2/model_patch_degradation_template_request_data_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" +) + +// PatchDegradationTemplateRequestDataType Degradation templates resource type. +type PatchDegradationTemplateRequestDataType string + +// List of PatchDegradationTemplateRequestDataType. +const ( + PATCHDEGRADATIONTEMPLATEREQUESTDATATYPE_DEGRADATION_TEMPLATES PatchDegradationTemplateRequestDataType = "degradation_templates" +) + +var allowedPatchDegradationTemplateRequestDataTypeEnumValues = []PatchDegradationTemplateRequestDataType{ + PATCHDEGRADATIONTEMPLATEREQUESTDATATYPE_DEGRADATION_TEMPLATES, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *PatchDegradationTemplateRequestDataType) GetAllowedValues() []PatchDegradationTemplateRequestDataType { + return allowedPatchDegradationTemplateRequestDataTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *PatchDegradationTemplateRequestDataType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = PatchDegradationTemplateRequestDataType(value) + return nil +} + +// NewPatchDegradationTemplateRequestDataTypeFromValue returns a pointer to a valid PatchDegradationTemplateRequestDataType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewPatchDegradationTemplateRequestDataTypeFromValue(v string) (*PatchDegradationTemplateRequestDataType, error) { + ev := PatchDegradationTemplateRequestDataType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for PatchDegradationTemplateRequestDataType: valid values are %v", v, allowedPatchDegradationTemplateRequestDataTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v PatchDegradationTemplateRequestDataType) IsValid() bool { + for _, existing := range allowedPatchDegradationTemplateRequestDataTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to PatchDegradationTemplateRequestDataType value. +func (v PatchDegradationTemplateRequestDataType) Ptr() *PatchDegradationTemplateRequestDataType { + return &v +} diff --git a/api/datadogV2/model_patch_maintenance_request_data.go b/api/datadogV2/model_patch_maintenance_request_data.go index a3b8cbf28d4..3468e29b61e 100644 --- a/api/datadogV2/model_patch_maintenance_request_data.go +++ b/api/datadogV2/model_patch_maintenance_request_data.go @@ -18,6 +18,8 @@ type PatchMaintenanceRequestData struct { Attributes PatchMaintenanceRequestDataAttributes `json:"attributes"` // The ID of the maintenance. Id uuid.UUID `json:"id"` + // The supported relationships for updating a maintenance. + Relationships *PatchMaintenanceRequestDataRelationships `json:"relationships,omitempty"` // Maintenances resource type. Type PatchMaintenanceRequestDataType `json:"type"` // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct @@ -93,6 +95,34 @@ func (o *PatchMaintenanceRequestData) SetId(v uuid.UUID) { o.Id = v } +// GetRelationships returns the Relationships field value if set, zero value otherwise. +func (o *PatchMaintenanceRequestData) GetRelationships() PatchMaintenanceRequestDataRelationships { + if o == nil || o.Relationships == nil { + var ret PatchMaintenanceRequestDataRelationships + return ret + } + return *o.Relationships +} + +// GetRelationshipsOk returns a tuple with the Relationships field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *PatchMaintenanceRequestData) GetRelationshipsOk() (*PatchMaintenanceRequestDataRelationships, bool) { + if o == nil || o.Relationships == nil { + return nil, false + } + return o.Relationships, true +} + +// HasRelationships returns a boolean if a field has been set. +func (o *PatchMaintenanceRequestData) HasRelationships() bool { + return o != nil && o.Relationships != nil +} + +// SetRelationships gets a reference to the given PatchMaintenanceRequestDataRelationships and assigns it to the Relationships field. +func (o *PatchMaintenanceRequestData) SetRelationships(v PatchMaintenanceRequestDataRelationships) { + o.Relationships = &v +} + // GetType returns the Type field value. func (o *PatchMaintenanceRequestData) GetType() PatchMaintenanceRequestDataType { if o == nil { @@ -124,6 +154,9 @@ func (o PatchMaintenanceRequestData) MarshalJSON() ([]byte, error) { } toSerialize["attributes"] = o.Attributes toSerialize["id"] = o.Id + if o.Relationships != nil { + toSerialize["relationships"] = o.Relationships + } toSerialize["type"] = o.Type for key, value := range o.AdditionalProperties { @@ -135,9 +168,10 @@ func (o PatchMaintenanceRequestData) MarshalJSON() ([]byte, error) { // UnmarshalJSON deserializes the given payload. func (o *PatchMaintenanceRequestData) UnmarshalJSON(bytes []byte) (err error) { all := struct { - Attributes *PatchMaintenanceRequestDataAttributes `json:"attributes"` - Id *uuid.UUID `json:"id"` - Type *PatchMaintenanceRequestDataType `json:"type"` + Attributes *PatchMaintenanceRequestDataAttributes `json:"attributes"` + Id *uuid.UUID `json:"id"` + Relationships *PatchMaintenanceRequestDataRelationships `json:"relationships,omitempty"` + Type *PatchMaintenanceRequestDataType `json:"type"` }{} if err = datadog.Unmarshal(bytes, &all); err != nil { return datadog.Unmarshal(bytes, &o.UnparsedObject) @@ -153,7 +187,7 @@ func (o *PatchMaintenanceRequestData) UnmarshalJSON(bytes []byte) (err error) { } additionalProperties := make(map[string]interface{}) if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { - datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "id", "type"}) + datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "id", "relationships", "type"}) } else { return err } @@ -164,6 +198,10 @@ func (o *PatchMaintenanceRequestData) UnmarshalJSON(bytes []byte) (err error) { } o.Attributes = *all.Attributes o.Id = *all.Id + if all.Relationships != nil && all.Relationships.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Relationships = all.Relationships if !all.Type.IsValid() { hasInvalidField = true } else { diff --git a/api/datadogV2/model_patch_maintenance_request_data_relationships.go b/api/datadogV2/model_patch_maintenance_request_data_relationships.go new file mode 100644 index 00000000000..0a7153ddecf --- /dev/null +++ b/api/datadogV2/model_patch_maintenance_request_data_relationships.go @@ -0,0 +1,111 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// PatchMaintenanceRequestDataRelationships The supported relationships for updating a maintenance. +type PatchMaintenanceRequestDataRelationships struct { + // The template used to create the maintenance. + Template *PatchMaintenanceRequestDataRelationshipsTemplate `json:"template,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:"-"` +} + +// NewPatchMaintenanceRequestDataRelationships instantiates a new PatchMaintenanceRequestDataRelationships 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 NewPatchMaintenanceRequestDataRelationships() *PatchMaintenanceRequestDataRelationships { + this := PatchMaintenanceRequestDataRelationships{} + return &this +} + +// NewPatchMaintenanceRequestDataRelationshipsWithDefaults instantiates a new PatchMaintenanceRequestDataRelationships 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 NewPatchMaintenanceRequestDataRelationshipsWithDefaults() *PatchMaintenanceRequestDataRelationships { + this := PatchMaintenanceRequestDataRelationships{} + return &this +} + +// GetTemplate returns the Template field value if set, zero value otherwise. +func (o *PatchMaintenanceRequestDataRelationships) GetTemplate() PatchMaintenanceRequestDataRelationshipsTemplate { + if o == nil || o.Template == nil { + var ret PatchMaintenanceRequestDataRelationshipsTemplate + return ret + } + return *o.Template +} + +// GetTemplateOk returns a tuple with the Template field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *PatchMaintenanceRequestDataRelationships) GetTemplateOk() (*PatchMaintenanceRequestDataRelationshipsTemplate, bool) { + if o == nil || o.Template == nil { + return nil, false + } + return o.Template, true +} + +// HasTemplate returns a boolean if a field has been set. +func (o *PatchMaintenanceRequestDataRelationships) HasTemplate() bool { + return o != nil && o.Template != nil +} + +// SetTemplate gets a reference to the given PatchMaintenanceRequestDataRelationshipsTemplate and assigns it to the Template field. +func (o *PatchMaintenanceRequestDataRelationships) SetTemplate(v PatchMaintenanceRequestDataRelationshipsTemplate) { + o.Template = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o PatchMaintenanceRequestDataRelationships) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Template != nil { + toSerialize["template"] = o.Template + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *PatchMaintenanceRequestDataRelationships) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Template *PatchMaintenanceRequestDataRelationshipsTemplate `json:"template,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"template"}) + } else { + return err + } + + hasInvalidField := false + if all.Template != nil && all.Template.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Template = all.Template + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_patch_maintenance_request_data_relationships_template.go b/api/datadogV2/model_patch_maintenance_request_data_relationships_template.go new file mode 100644 index 00000000000..2922fb0d30d --- /dev/null +++ b/api/datadogV2/model_patch_maintenance_request_data_relationships_template.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" +) + +// PatchMaintenanceRequestDataRelationshipsTemplate The template used to create the maintenance. +type PatchMaintenanceRequestDataRelationshipsTemplate struct { + // The data object identifying the template used to create the maintenance. + Data PatchMaintenanceRequestDataRelationshipsTemplateData `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:"-"` +} + +// NewPatchMaintenanceRequestDataRelationshipsTemplate instantiates a new PatchMaintenanceRequestDataRelationshipsTemplate 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 NewPatchMaintenanceRequestDataRelationshipsTemplate(data PatchMaintenanceRequestDataRelationshipsTemplateData) *PatchMaintenanceRequestDataRelationshipsTemplate { + this := PatchMaintenanceRequestDataRelationshipsTemplate{} + this.Data = data + return &this +} + +// NewPatchMaintenanceRequestDataRelationshipsTemplateWithDefaults instantiates a new PatchMaintenanceRequestDataRelationshipsTemplate 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 NewPatchMaintenanceRequestDataRelationshipsTemplateWithDefaults() *PatchMaintenanceRequestDataRelationshipsTemplate { + this := PatchMaintenanceRequestDataRelationshipsTemplate{} + return &this +} + +// GetData returns the Data field value. +func (o *PatchMaintenanceRequestDataRelationshipsTemplate) GetData() PatchMaintenanceRequestDataRelationshipsTemplateData { + if o == nil { + var ret PatchMaintenanceRequestDataRelationshipsTemplateData + 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 *PatchMaintenanceRequestDataRelationshipsTemplate) GetDataOk() (*PatchMaintenanceRequestDataRelationshipsTemplateData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *PatchMaintenanceRequestDataRelationshipsTemplate) SetData(v PatchMaintenanceRequestDataRelationshipsTemplateData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o PatchMaintenanceRequestDataRelationshipsTemplate) 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 *PatchMaintenanceRequestDataRelationshipsTemplate) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *PatchMaintenanceRequestDataRelationshipsTemplateData `json:"data"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Data == nil { + return fmt.Errorf("required field data missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + + hasInvalidField := false + if all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Data = *all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_patch_maintenance_request_data_relationships_template_data.go b/api/datadogV2/model_patch_maintenance_request_data_relationships_template_data.go new file mode 100644 index 00000000000..0fd0631225b --- /dev/null +++ b/api/datadogV2/model_patch_maintenance_request_data_relationships_template_data.go @@ -0,0 +1,145 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// PatchMaintenanceRequestDataRelationshipsTemplateData The data object identifying the template used to create the maintenance. +type PatchMaintenanceRequestDataRelationshipsTemplateData struct { + // The ID of the maintenance template. + Id string `json:"id"` + // Maintenance templates resource type. + Type PatchMaintenanceTemplateRequestDataType `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:"-"` +} + +// NewPatchMaintenanceRequestDataRelationshipsTemplateData instantiates a new PatchMaintenanceRequestDataRelationshipsTemplateData 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 NewPatchMaintenanceRequestDataRelationshipsTemplateData(id string, typeVar PatchMaintenanceTemplateRequestDataType) *PatchMaintenanceRequestDataRelationshipsTemplateData { + this := PatchMaintenanceRequestDataRelationshipsTemplateData{} + this.Id = id + this.Type = typeVar + return &this +} + +// NewPatchMaintenanceRequestDataRelationshipsTemplateDataWithDefaults instantiates a new PatchMaintenanceRequestDataRelationshipsTemplateData 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 NewPatchMaintenanceRequestDataRelationshipsTemplateDataWithDefaults() *PatchMaintenanceRequestDataRelationshipsTemplateData { + this := PatchMaintenanceRequestDataRelationshipsTemplateData{} + var typeVar PatchMaintenanceTemplateRequestDataType = PATCHMAINTENANCETEMPLATEREQUESTDATATYPE_MAINTENANCE_TEMPLATES + this.Type = typeVar + return &this +} + +// GetId returns the Id field value. +func (o *PatchMaintenanceRequestDataRelationshipsTemplateData) GetId() string { + if o == nil { + var ret string + 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 *PatchMaintenanceRequestDataRelationshipsTemplateData) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Id, true +} + +// SetId sets field value. +func (o *PatchMaintenanceRequestDataRelationshipsTemplateData) SetId(v string) { + o.Id = v +} + +// GetType returns the Type field value. +func (o *PatchMaintenanceRequestDataRelationshipsTemplateData) GetType() PatchMaintenanceTemplateRequestDataType { + if o == nil { + var ret PatchMaintenanceTemplateRequestDataType + 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 *PatchMaintenanceRequestDataRelationshipsTemplateData) GetTypeOk() (*PatchMaintenanceTemplateRequestDataType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *PatchMaintenanceRequestDataRelationshipsTemplateData) SetType(v PatchMaintenanceTemplateRequestDataType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o PatchMaintenanceRequestDataRelationshipsTemplateData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["id"] = o.Id + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *PatchMaintenanceRequestDataRelationshipsTemplateData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Id *string `json:"id"` + Type *PatchMaintenanceTemplateRequestDataType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Id == nil { + return fmt.Errorf("required field id missing") + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"id", "type"}) + } else { + return err + } + + hasInvalidField := false + o.Id = *all.Id + if !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = *all.Type + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_patch_maintenance_template_request.go b/api/datadogV2/model_patch_maintenance_template_request.go new file mode 100644 index 00000000000..b240392ed44 --- /dev/null +++ b/api/datadogV2/model_patch_maintenance_template_request.go @@ -0,0 +1,111 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// PatchMaintenanceTemplateRequest Request object for updating a maintenance template. +type PatchMaintenanceTemplateRequest struct { + // The data object for updating a maintenance template. + Data *PatchMaintenanceTemplateRequestData `json:"data,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewPatchMaintenanceTemplateRequest instantiates a new PatchMaintenanceTemplateRequest 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 NewPatchMaintenanceTemplateRequest() *PatchMaintenanceTemplateRequest { + this := PatchMaintenanceTemplateRequest{} + return &this +} + +// NewPatchMaintenanceTemplateRequestWithDefaults instantiates a new PatchMaintenanceTemplateRequest 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 NewPatchMaintenanceTemplateRequestWithDefaults() *PatchMaintenanceTemplateRequest { + this := PatchMaintenanceTemplateRequest{} + return &this +} + +// GetData returns the Data field value if set, zero value otherwise. +func (o *PatchMaintenanceTemplateRequest) GetData() PatchMaintenanceTemplateRequestData { + if o == nil || o.Data == nil { + var ret PatchMaintenanceTemplateRequestData + return ret + } + return *o.Data +} + +// GetDataOk returns a tuple with the Data field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *PatchMaintenanceTemplateRequest) GetDataOk() (*PatchMaintenanceTemplateRequestData, bool) { + if o == nil || o.Data == nil { + return nil, false + } + return o.Data, true +} + +// HasData returns a boolean if a field has been set. +func (o *PatchMaintenanceTemplateRequest) HasData() bool { + return o != nil && o.Data != nil +} + +// SetData gets a reference to the given PatchMaintenanceTemplateRequestData and assigns it to the Data field. +func (o *PatchMaintenanceTemplateRequest) SetData(v PatchMaintenanceTemplateRequestData) { + o.Data = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o PatchMaintenanceTemplateRequest) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Data != nil { + toSerialize["data"] = o.Data + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *PatchMaintenanceTemplateRequest) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *PatchMaintenanceTemplateRequestData `json:"data,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + + hasInvalidField := false + if all.Data != nil && all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Data = all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_patch_maintenance_template_request_data.go b/api/datadogV2/model_patch_maintenance_template_request_data.go new file mode 100644 index 00000000000..5954bc00b70 --- /dev/null +++ b/api/datadogV2/model_patch_maintenance_template_request_data.go @@ -0,0 +1,183 @@ +// 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" +) + +// PatchMaintenanceTemplateRequestData The data object for updating a maintenance template. +type PatchMaintenanceTemplateRequestData struct { + // The supported attributes for updating a maintenance template. + Attributes *PatchMaintenanceTemplateRequestDataAttributes `json:"attributes,omitempty"` + // The ID of the maintenance template. + Id string `json:"id"` + // Maintenance templates resource type. + Type PatchMaintenanceTemplateRequestDataType `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:"-"` +} + +// NewPatchMaintenanceTemplateRequestData instantiates a new PatchMaintenanceTemplateRequestData 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 NewPatchMaintenanceTemplateRequestData(id string, typeVar PatchMaintenanceTemplateRequestDataType) *PatchMaintenanceTemplateRequestData { + this := PatchMaintenanceTemplateRequestData{} + this.Id = id + this.Type = typeVar + return &this +} + +// NewPatchMaintenanceTemplateRequestDataWithDefaults instantiates a new PatchMaintenanceTemplateRequestData 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 NewPatchMaintenanceTemplateRequestDataWithDefaults() *PatchMaintenanceTemplateRequestData { + this := PatchMaintenanceTemplateRequestData{} + var typeVar PatchMaintenanceTemplateRequestDataType = PATCHMAINTENANCETEMPLATEREQUESTDATATYPE_MAINTENANCE_TEMPLATES + this.Type = typeVar + return &this +} + +// GetAttributes returns the Attributes field value if set, zero value otherwise. +func (o *PatchMaintenanceTemplateRequestData) GetAttributes() PatchMaintenanceTemplateRequestDataAttributes { + if o == nil || o.Attributes == nil { + var ret PatchMaintenanceTemplateRequestDataAttributes + return ret + } + return *o.Attributes +} + +// GetAttributesOk returns a tuple with the Attributes field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *PatchMaintenanceTemplateRequestData) GetAttributesOk() (*PatchMaintenanceTemplateRequestDataAttributes, bool) { + if o == nil || o.Attributes == nil { + return nil, false + } + return o.Attributes, true +} + +// HasAttributes returns a boolean if a field has been set. +func (o *PatchMaintenanceTemplateRequestData) HasAttributes() bool { + return o != nil && o.Attributes != nil +} + +// SetAttributes gets a reference to the given PatchMaintenanceTemplateRequestDataAttributes and assigns it to the Attributes field. +func (o *PatchMaintenanceTemplateRequestData) SetAttributes(v PatchMaintenanceTemplateRequestDataAttributes) { + o.Attributes = &v +} + +// GetId returns the Id field value. +func (o *PatchMaintenanceTemplateRequestData) GetId() string { + if o == nil { + var ret string + 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 *PatchMaintenanceTemplateRequestData) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Id, true +} + +// SetId sets field value. +func (o *PatchMaintenanceTemplateRequestData) SetId(v string) { + o.Id = v +} + +// GetType returns the Type field value. +func (o *PatchMaintenanceTemplateRequestData) GetType() PatchMaintenanceTemplateRequestDataType { + if o == nil { + var ret PatchMaintenanceTemplateRequestDataType + 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 *PatchMaintenanceTemplateRequestData) GetTypeOk() (*PatchMaintenanceTemplateRequestDataType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *PatchMaintenanceTemplateRequestData) SetType(v PatchMaintenanceTemplateRequestDataType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o PatchMaintenanceTemplateRequestData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Attributes != nil { + 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 *PatchMaintenanceTemplateRequestData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *PatchMaintenanceTemplateRequestDataAttributes `json:"attributes,omitempty"` + Id *string `json:"id"` + Type *PatchMaintenanceTemplateRequestDataType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Id == nil { + return fmt.Errorf("required field id missing") + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "id", "type"}) + } else { + return err + } + + hasInvalidField := false + if all.Attributes != nil && 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_patch_maintenance_template_request_data_attributes.go b/api/datadogV2/model_patch_maintenance_template_request_data_attributes.go new file mode 100644 index 00000000000..9cfffb24bae --- /dev/null +++ b/api/datadogV2/model_patch_maintenance_template_request_data_attributes.go @@ -0,0 +1,277 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// PatchMaintenanceTemplateRequestDataAttributes The supported attributes for updating a maintenance template. +type PatchMaintenanceTemplateRequestDataAttributes struct { + // The description shown when a maintenance created from this template is completed. + CompletedDescription *string `json:"completed_description,omitempty"` + // The IDs of the components affected by a maintenance created from this template. + ComponentIds []string `json:"component_ids,omitempty"` + // The description shown while a maintenance created from this template is in progress. + InProgressDescription *string `json:"in_progress_description,omitempty"` + // The title used for a maintenance created from this template. + MaintenanceTitle *string `json:"maintenance_title,omitempty"` + // The name of the maintenance template. + Name *string `json:"name,omitempty"` + // The description shown when a maintenance created from this template is scheduled. + ScheduledDescription *string `json:"scheduled_description,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:"-"` +} + +// NewPatchMaintenanceTemplateRequestDataAttributes instantiates a new PatchMaintenanceTemplateRequestDataAttributes 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 NewPatchMaintenanceTemplateRequestDataAttributes() *PatchMaintenanceTemplateRequestDataAttributes { + this := PatchMaintenanceTemplateRequestDataAttributes{} + return &this +} + +// NewPatchMaintenanceTemplateRequestDataAttributesWithDefaults instantiates a new PatchMaintenanceTemplateRequestDataAttributes 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 NewPatchMaintenanceTemplateRequestDataAttributesWithDefaults() *PatchMaintenanceTemplateRequestDataAttributes { + this := PatchMaintenanceTemplateRequestDataAttributes{} + return &this +} + +// GetCompletedDescription returns the CompletedDescription field value if set, zero value otherwise. +func (o *PatchMaintenanceTemplateRequestDataAttributes) GetCompletedDescription() string { + if o == nil || o.CompletedDescription == nil { + var ret string + return ret + } + return *o.CompletedDescription +} + +// GetCompletedDescriptionOk returns a tuple with the CompletedDescription field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *PatchMaintenanceTemplateRequestDataAttributes) GetCompletedDescriptionOk() (*string, bool) { + if o == nil || o.CompletedDescription == nil { + return nil, false + } + return o.CompletedDescription, true +} + +// HasCompletedDescription returns a boolean if a field has been set. +func (o *PatchMaintenanceTemplateRequestDataAttributes) HasCompletedDescription() bool { + return o != nil && o.CompletedDescription != nil +} + +// SetCompletedDescription gets a reference to the given string and assigns it to the CompletedDescription field. +func (o *PatchMaintenanceTemplateRequestDataAttributes) SetCompletedDescription(v string) { + o.CompletedDescription = &v +} + +// GetComponentIds returns the ComponentIds field value if set, zero value otherwise. +func (o *PatchMaintenanceTemplateRequestDataAttributes) GetComponentIds() []string { + if o == nil || o.ComponentIds == nil { + var ret []string + return ret + } + return o.ComponentIds +} + +// GetComponentIdsOk returns a tuple with the ComponentIds field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *PatchMaintenanceTemplateRequestDataAttributes) GetComponentIdsOk() (*[]string, bool) { + if o == nil || o.ComponentIds == nil { + return nil, false + } + return &o.ComponentIds, true +} + +// HasComponentIds returns a boolean if a field has been set. +func (o *PatchMaintenanceTemplateRequestDataAttributes) HasComponentIds() bool { + return o != nil && o.ComponentIds != nil +} + +// SetComponentIds gets a reference to the given []string and assigns it to the ComponentIds field. +func (o *PatchMaintenanceTemplateRequestDataAttributes) SetComponentIds(v []string) { + o.ComponentIds = v +} + +// GetInProgressDescription returns the InProgressDescription field value if set, zero value otherwise. +func (o *PatchMaintenanceTemplateRequestDataAttributes) GetInProgressDescription() string { + if o == nil || o.InProgressDescription == nil { + var ret string + return ret + } + return *o.InProgressDescription +} + +// GetInProgressDescriptionOk returns a tuple with the InProgressDescription field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *PatchMaintenanceTemplateRequestDataAttributes) GetInProgressDescriptionOk() (*string, bool) { + if o == nil || o.InProgressDescription == nil { + return nil, false + } + return o.InProgressDescription, true +} + +// HasInProgressDescription returns a boolean if a field has been set. +func (o *PatchMaintenanceTemplateRequestDataAttributes) HasInProgressDescription() bool { + return o != nil && o.InProgressDescription != nil +} + +// SetInProgressDescription gets a reference to the given string and assigns it to the InProgressDescription field. +func (o *PatchMaintenanceTemplateRequestDataAttributes) SetInProgressDescription(v string) { + o.InProgressDescription = &v +} + +// GetMaintenanceTitle returns the MaintenanceTitle field value if set, zero value otherwise. +func (o *PatchMaintenanceTemplateRequestDataAttributes) GetMaintenanceTitle() string { + if o == nil || o.MaintenanceTitle == nil { + var ret string + return ret + } + return *o.MaintenanceTitle +} + +// GetMaintenanceTitleOk returns a tuple with the MaintenanceTitle field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *PatchMaintenanceTemplateRequestDataAttributes) GetMaintenanceTitleOk() (*string, bool) { + if o == nil || o.MaintenanceTitle == nil { + return nil, false + } + return o.MaintenanceTitle, true +} + +// HasMaintenanceTitle returns a boolean if a field has been set. +func (o *PatchMaintenanceTemplateRequestDataAttributes) HasMaintenanceTitle() bool { + return o != nil && o.MaintenanceTitle != nil +} + +// SetMaintenanceTitle gets a reference to the given string and assigns it to the MaintenanceTitle field. +func (o *PatchMaintenanceTemplateRequestDataAttributes) SetMaintenanceTitle(v string) { + o.MaintenanceTitle = &v +} + +// GetName returns the Name field value if set, zero value otherwise. +func (o *PatchMaintenanceTemplateRequestDataAttributes) GetName() string { + if o == nil || o.Name == nil { + var ret string + return ret + } + return *o.Name +} + +// GetNameOk returns a tuple with the Name field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *PatchMaintenanceTemplateRequestDataAttributes) GetNameOk() (*string, bool) { + if o == nil || o.Name == nil { + return nil, false + } + return o.Name, true +} + +// HasName returns a boolean if a field has been set. +func (o *PatchMaintenanceTemplateRequestDataAttributes) HasName() bool { + return o != nil && o.Name != nil +} + +// SetName gets a reference to the given string and assigns it to the Name field. +func (o *PatchMaintenanceTemplateRequestDataAttributes) SetName(v string) { + o.Name = &v +} + +// GetScheduledDescription returns the ScheduledDescription field value if set, zero value otherwise. +func (o *PatchMaintenanceTemplateRequestDataAttributes) GetScheduledDescription() string { + if o == nil || o.ScheduledDescription == nil { + var ret string + return ret + } + return *o.ScheduledDescription +} + +// GetScheduledDescriptionOk returns a tuple with the ScheduledDescription field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *PatchMaintenanceTemplateRequestDataAttributes) GetScheduledDescriptionOk() (*string, bool) { + if o == nil || o.ScheduledDescription == nil { + return nil, false + } + return o.ScheduledDescription, true +} + +// HasScheduledDescription returns a boolean if a field has been set. +func (o *PatchMaintenanceTemplateRequestDataAttributes) HasScheduledDescription() bool { + return o != nil && o.ScheduledDescription != nil +} + +// SetScheduledDescription gets a reference to the given string and assigns it to the ScheduledDescription field. +func (o *PatchMaintenanceTemplateRequestDataAttributes) SetScheduledDescription(v string) { + o.ScheduledDescription = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o PatchMaintenanceTemplateRequestDataAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.CompletedDescription != nil { + toSerialize["completed_description"] = o.CompletedDescription + } + if o.ComponentIds != nil { + toSerialize["component_ids"] = o.ComponentIds + } + if o.InProgressDescription != nil { + toSerialize["in_progress_description"] = o.InProgressDescription + } + if o.MaintenanceTitle != nil { + toSerialize["maintenance_title"] = o.MaintenanceTitle + } + if o.Name != nil { + toSerialize["name"] = o.Name + } + if o.ScheduledDescription != nil { + toSerialize["scheduled_description"] = o.ScheduledDescription + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *PatchMaintenanceTemplateRequestDataAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + CompletedDescription *string `json:"completed_description,omitempty"` + ComponentIds []string `json:"component_ids,omitempty"` + InProgressDescription *string `json:"in_progress_description,omitempty"` + MaintenanceTitle *string `json:"maintenance_title,omitempty"` + Name *string `json:"name,omitempty"` + ScheduledDescription *string `json:"scheduled_description,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.UnmarshalUseNumber(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"completed_description", "component_ids", "in_progress_description", "maintenance_title", "name", "scheduled_description"}) + } else { + return err + } + o.CompletedDescription = all.CompletedDescription + o.ComponentIds = all.ComponentIds + o.InProgressDescription = all.InProgressDescription + o.MaintenanceTitle = all.MaintenanceTitle + o.Name = all.Name + o.ScheduledDescription = all.ScheduledDescription + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_patch_maintenance_template_request_data_type.go b/api/datadogV2/model_patch_maintenance_template_request_data_type.go new file mode 100644 index 00000000000..dcfa05d6ba7 --- /dev/null +++ b/api/datadogV2/model_patch_maintenance_template_request_data_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" +) + +// PatchMaintenanceTemplateRequestDataType Maintenance templates resource type. +type PatchMaintenanceTemplateRequestDataType string + +// List of PatchMaintenanceTemplateRequestDataType. +const ( + PATCHMAINTENANCETEMPLATEREQUESTDATATYPE_MAINTENANCE_TEMPLATES PatchMaintenanceTemplateRequestDataType = "maintenance_templates" +) + +var allowedPatchMaintenanceTemplateRequestDataTypeEnumValues = []PatchMaintenanceTemplateRequestDataType{ + PATCHMAINTENANCETEMPLATEREQUESTDATATYPE_MAINTENANCE_TEMPLATES, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *PatchMaintenanceTemplateRequestDataType) GetAllowedValues() []PatchMaintenanceTemplateRequestDataType { + return allowedPatchMaintenanceTemplateRequestDataTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *PatchMaintenanceTemplateRequestDataType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = PatchMaintenanceTemplateRequestDataType(value) + return nil +} + +// NewPatchMaintenanceTemplateRequestDataTypeFromValue returns a pointer to a valid PatchMaintenanceTemplateRequestDataType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewPatchMaintenanceTemplateRequestDataTypeFromValue(v string) (*PatchMaintenanceTemplateRequestDataType, error) { + ev := PatchMaintenanceTemplateRequestDataType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for PatchMaintenanceTemplateRequestDataType: valid values are %v", v, allowedPatchMaintenanceTemplateRequestDataTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v PatchMaintenanceTemplateRequestDataType) IsValid() bool { + for _, existing := range allowedPatchMaintenanceTemplateRequestDataTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to PatchMaintenanceTemplateRequestDataType value. +func (v PatchMaintenanceTemplateRequestDataType) Ptr() *PatchMaintenanceTemplateRequestDataType { + return &v +} diff --git a/examples/v2/status-pages/CreateDegradationTemplate.go b/examples/v2/status-pages/CreateDegradationTemplate.go new file mode 100644 index 00000000000..bfd462951b8 --- /dev/null +++ b/examples/v2/status-pages/CreateDegradationTemplate.go @@ -0,0 +1,49 @@ +// Create degradation 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.CreateDegradationTemplateRequest{ + Data: &datadogV2.CreateDegradationTemplateRequestData{ + Attributes: &datadogV2.CreateDegradationTemplateRequestDataAttributes{ + ComponentsAffected: []datadogV2.CreateDegradationTemplateRequestDataAttributesComponentsAffectedItems{ + { + Id: "", + Status: datadogV2.PATCHDEGRADATIONTEMPLATEREQUESTDATAATTRIBUTESCOMPONENTSAFFECTEDITEMSSTATUS_OPERATIONAL, + }, + }, + Name: "", + Updates: []datadogV2.CreateDegradationTemplateRequestDataAttributesUpdatesItems{ + { + Status: datadogV2.CREATEDEGRADATIONREQUESTDATAATTRIBUTESSTATUS_INVESTIGATING, + }, + }, + }, + Type: datadogV2.PATCHDEGRADATIONTEMPLATEREQUESTDATATYPE_DEGRADATION_TEMPLATES, + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewStatusPagesApi(apiClient) + resp, r, err := api.CreateDegradationTemplate(ctx, uuid.MustParse("9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d"), body, *datadogV2.NewCreateDegradationTemplateOptionalParameters()) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `StatusPagesApi.CreateDegradationTemplate`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `StatusPagesApi.CreateDegradationTemplate`:\n%s\n", responseContent) +} diff --git a/examples/v2/status-pages/CreateMaintenanceTemplate.go b/examples/v2/status-pages/CreateMaintenanceTemplate.go new file mode 100644 index 00000000000..482260eb855 --- /dev/null +++ b/examples/v2/status-pages/CreateMaintenanceTemplate.go @@ -0,0 +1,39 @@ +// Create maintenance 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.CreateMaintenanceTemplateRequest{ + Data: &datadogV2.CreateMaintenanceTemplateRequestData{ + Attributes: &datadogV2.CreateMaintenanceTemplateRequestDataAttributes{ + ComponentIds: []string{}, + Name: "", + }, + Type: datadogV2.PATCHMAINTENANCETEMPLATEREQUESTDATATYPE_MAINTENANCE_TEMPLATES, + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewStatusPagesApi(apiClient) + resp, r, err := api.CreateMaintenanceTemplate(ctx, uuid.MustParse("9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d"), body, *datadogV2.NewCreateMaintenanceTemplateOptionalParameters()) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `StatusPagesApi.CreateMaintenanceTemplate`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `StatusPagesApi.CreateMaintenanceTemplate`:\n%s\n", responseContent) +} diff --git a/examples/v2/status-pages/DeleteDegradationTemplate.go b/examples/v2/status-pages/DeleteDegradationTemplate.go new file mode 100644 index 00000000000..812851a0aa0 --- /dev/null +++ b/examples/v2/status-pages/DeleteDegradationTemplate.go @@ -0,0 +1,26 @@ +// Delete degradation template returns "No Content" 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() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewStatusPagesApi(apiClient) + r, err := api.DeleteDegradationTemplate(ctx, uuid.MustParse("9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d"), uuid.MustParse("9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d")) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `StatusPagesApi.DeleteDegradationTemplate`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } +} diff --git a/examples/v2/status-pages/DeleteMaintenanceTemplate.go b/examples/v2/status-pages/DeleteMaintenanceTemplate.go new file mode 100644 index 00000000000..b6759c2d249 --- /dev/null +++ b/examples/v2/status-pages/DeleteMaintenanceTemplate.go @@ -0,0 +1,26 @@ +// Delete maintenance template returns "No Content" 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() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewStatusPagesApi(apiClient) + r, err := api.DeleteMaintenanceTemplate(ctx, uuid.MustParse("9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d"), uuid.MustParse("9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d")) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `StatusPagesApi.DeleteMaintenanceTemplate`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } +} diff --git a/examples/v2/status-pages/GetDegradationTemplate.go b/examples/v2/status-pages/GetDegradationTemplate.go new file mode 100644 index 00000000000..e2c982143e7 --- /dev/null +++ b/examples/v2/status-pages/GetDegradationTemplate.go @@ -0,0 +1,30 @@ +// Get degradation 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() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewStatusPagesApi(apiClient) + resp, r, err := api.GetDegradationTemplate(ctx, uuid.MustParse("9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d"), uuid.MustParse("9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d"), *datadogV2.NewGetDegradationTemplateOptionalParameters()) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `StatusPagesApi.GetDegradationTemplate`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `StatusPagesApi.GetDegradationTemplate`:\n%s\n", responseContent) +} diff --git a/examples/v2/status-pages/GetMaintenanceTemplate.go b/examples/v2/status-pages/GetMaintenanceTemplate.go new file mode 100644 index 00000000000..eadcda84e4e --- /dev/null +++ b/examples/v2/status-pages/GetMaintenanceTemplate.go @@ -0,0 +1,30 @@ +// Get maintenance 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() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewStatusPagesApi(apiClient) + resp, r, err := api.GetMaintenanceTemplate(ctx, uuid.MustParse("9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d"), uuid.MustParse("9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d"), *datadogV2.NewGetMaintenanceTemplateOptionalParameters()) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `StatusPagesApi.GetMaintenanceTemplate`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `StatusPagesApi.GetMaintenanceTemplate`:\n%s\n", responseContent) +} diff --git a/examples/v2/status-pages/ListDegradationTemplates.go b/examples/v2/status-pages/ListDegradationTemplates.go new file mode 100644 index 00000000000..48465f08fa2 --- /dev/null +++ b/examples/v2/status-pages/ListDegradationTemplates.go @@ -0,0 +1,30 @@ +// List degradation 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" + "github.com/google/uuid" +) + +func main() { + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewStatusPagesApi(apiClient) + resp, r, err := api.ListDegradationTemplates(ctx, uuid.MustParse("9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d"), *datadogV2.NewListDegradationTemplatesOptionalParameters()) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `StatusPagesApi.ListDegradationTemplates`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `StatusPagesApi.ListDegradationTemplates`:\n%s\n", responseContent) +} diff --git a/examples/v2/status-pages/ListMaintenanceTemplates.go b/examples/v2/status-pages/ListMaintenanceTemplates.go new file mode 100644 index 00000000000..ffee3485cf9 --- /dev/null +++ b/examples/v2/status-pages/ListMaintenanceTemplates.go @@ -0,0 +1,30 @@ +// List maintenance 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" + "github.com/google/uuid" +) + +func main() { + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewStatusPagesApi(apiClient) + resp, r, err := api.ListMaintenanceTemplates(ctx, uuid.MustParse("9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d"), *datadogV2.NewListMaintenanceTemplatesOptionalParameters()) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `StatusPagesApi.ListMaintenanceTemplates`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `StatusPagesApi.ListMaintenanceTemplates`:\n%s\n", responseContent) +} diff --git a/examples/v2/status-pages/UpdateDegradationTemplate.go b/examples/v2/status-pages/UpdateDegradationTemplate.go new file mode 100644 index 00000000000..c8f29f724c4 --- /dev/null +++ b/examples/v2/status-pages/UpdateDegradationTemplate.go @@ -0,0 +1,49 @@ +// Update degradation 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.PatchDegradationTemplateRequest{ + Data: &datadogV2.PatchDegradationTemplateRequestData{ + Attributes: &datadogV2.PatchDegradationTemplateRequestDataAttributes{ + ComponentsAffected: []datadogV2.PatchDegradationTemplateRequestDataAttributesComponentsAffectedItems{ + { + Id: "", + Status: datadogV2.PATCHDEGRADATIONTEMPLATEREQUESTDATAATTRIBUTESCOMPONENTSAFFECTEDITEMSSTATUS_OPERATIONAL, + }, + }, + Updates: []datadogV2.PatchDegradationTemplateRequestDataAttributesUpdatesItems{ + { + Status: datadogV2.CREATEDEGRADATIONREQUESTDATAATTRIBUTESSTATUS_INVESTIGATING, + }, + }, + }, + Id: "", + Type: datadogV2.PATCHDEGRADATIONTEMPLATEREQUESTDATATYPE_DEGRADATION_TEMPLATES, + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewStatusPagesApi(apiClient) + resp, r, err := api.UpdateDegradationTemplate(ctx, uuid.MustParse("9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d"), uuid.MustParse("9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d"), body, *datadogV2.NewUpdateDegradationTemplateOptionalParameters()) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `StatusPagesApi.UpdateDegradationTemplate`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `StatusPagesApi.UpdateDegradationTemplate`:\n%s\n", responseContent) +} diff --git a/examples/v2/status-pages/UpdateMaintenanceTemplate.go b/examples/v2/status-pages/UpdateMaintenanceTemplate.go new file mode 100644 index 00000000000..ada7448bda1 --- /dev/null +++ b/examples/v2/status-pages/UpdateMaintenanceTemplate.go @@ -0,0 +1,39 @@ +// Update maintenance 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.PatchMaintenanceTemplateRequest{ + Data: &datadogV2.PatchMaintenanceTemplateRequestData{ + Attributes: &datadogV2.PatchMaintenanceTemplateRequestDataAttributes{ + ComponentIds: []string{}, + }, + Id: "", + Type: datadogV2.PATCHMAINTENANCETEMPLATEREQUESTDATATYPE_MAINTENANCE_TEMPLATES, + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewStatusPagesApi(apiClient) + resp, r, err := api.UpdateMaintenanceTemplate(ctx, uuid.MustParse("9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d"), uuid.MustParse("9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d"), body, *datadogV2.NewUpdateMaintenanceTemplateOptionalParameters()) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `StatusPagesApi.UpdateMaintenanceTemplate`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `StatusPagesApi.UpdateMaintenanceTemplate`:\n%s\n", responseContent) +} diff --git a/tests/scenarios/features/v2/status_pages.feature b/tests/scenarios/features/v2/status_pages.feature index 99cb8e3ed61..c7f922bf6ca 100644 --- a/tests/scenarios/features/v2/status_pages.feature +++ b/tests/scenarios/features/v2/status_pages.feature @@ -50,6 +50,14 @@ Feature: Status Pages Then the response status is 201 Created And the response "data.attributes.updates" has length 1 + @generated @skip @team:DataDog/incident-app + Scenario: Create degradation template returns "Created" response + Given new "CreateDegradationTemplate" request + And request contains "page_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"components_affected": [{"id": "", "status": "operational"}], "name": "", "updates": [{"status": "investigating"}]}, "type": "degradation_templates"}} + When the request is sent + Then the response status is 201 Created + @team:DataDog/incident-app Scenario: Create maintenance returns "Created" response Given there is a valid "status_page" in the system @@ -60,6 +68,14 @@ Feature: Status Pages Then the response status is 201 Created And the response "data.attributes.updates" has length 1 + @generated @skip @team:DataDog/incident-app + Scenario: Create maintenance template returns "Created" response + Given new "CreateMaintenanceTemplate" request + And request contains "page_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"component_ids": [], "name": ""}, "type": "maintenance_templates"}} + When the request is sent + Then the response status is 201 Created + @team:DataDog/incident-app Scenario: Create status page returns "Created" response Given new "CreateStatusPage" request @@ -86,6 +102,22 @@ Feature: Status Pages When the request is sent Then the response status is 204 No Content + @generated @skip @team:DataDog/incident-app + Scenario: Delete degradation template returns "No Content" response + Given new "DeleteDegradationTemplate" request + And request contains "page_id" parameter from "REPLACE.ME" + And request contains "template_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 204 No Content + + @generated @skip @team:DataDog/incident-app + Scenario: Delete maintenance template returns "No Content" response + Given new "DeleteMaintenanceTemplate" request + And request contains "page_id" parameter from "REPLACE.ME" + And request contains "template_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 204 No Content + @team:DataDog/incident-app Scenario: Delete status page returns "No Content" response Given new "DeleteStatusPage" request @@ -123,6 +155,14 @@ Feature: Status Pages When the request is sent Then the response status is 200 OK + @generated @skip @team:DataDog/incident-app + Scenario: Get degradation template returns "OK" response + Given new "GetDegradationTemplate" request + And request contains "page_id" parameter from "REPLACE.ME" + And request contains "template_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK + @team:DataDog/incident-app Scenario: Get maintenance returns "OK" response Given there is a valid "status_page" in the system @@ -133,6 +173,14 @@ Feature: Status Pages When the request is sent Then the response status is 200 OK + @generated @skip @team:DataDog/incident-app + Scenario: Get maintenance template returns "OK" response + Given new "GetMaintenanceTemplate" request + And request contains "page_id" parameter from "REPLACE.ME" + And request contains "template_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK + @team:DataDog/incident-app Scenario: Get status page returns "OK" response Given new "GetStatusPage" request @@ -149,6 +197,13 @@ Feature: Status Pages When the request is sent Then the response status is 200 OK + @generated @skip @team:DataDog/incident-app + Scenario: List degradation templates returns "OK" response + Given new "ListDegradationTemplates" request + And request contains "page_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK + @team:DataDog/incident-app Scenario: List degradations returns "OK" response Given new "ListDegradations" request @@ -157,6 +212,13 @@ Feature: Status Pages When the request is sent Then the response status is 200 OK + @generated @skip @team:DataDog/incident-app + Scenario: List maintenance templates returns "OK" response + Given new "ListMaintenanceTemplates" request + And request contains "page_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK + @team:DataDog/incident-app Scenario: List maintenances returns "OK" response Given there is a valid "status_page" in the system @@ -227,6 +289,15 @@ Feature: Status Pages Then the response status is 200 OK And the response "data.attributes.title" is equal to "Elevated API Latency in US1" + @generated @skip @team:DataDog/incident-app + Scenario: Update degradation template returns "OK" response + Given new "UpdateDegradationTemplate" request + And request contains "template_id" parameter from "REPLACE.ME" + And request contains "page_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"components_affected": [{"id": "", "status": "operational"}], "updates": [{"status": "investigating"}]}, "id": "", "type": "degradation_templates"}} + When the request is sent + Then the response status is 200 OK + @team:DataDog/incident-app Scenario: Update maintenance returns "OK" response Given there is a valid "status_page" in the system @@ -238,6 +309,15 @@ Feature: Status Pages When the request is sent Then the response status is 200 OK + @generated @skip @team:DataDog/incident-app + Scenario: Update maintenance template returns "OK" response + Given new "UpdateMaintenanceTemplate" request + And request contains "page_id" parameter from "REPLACE.ME" + And request contains "template_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"component_ids": []}, "id": "", "type": "maintenance_templates"}} + When the request is sent + Then the response status is 200 OK + @team:DataDog/incident-app Scenario: Update status page returns "OK" response Given new "UpdateStatusPage" request diff --git a/tests/scenarios/features/v2/undo.json b/tests/scenarios/features/v2/undo.json index 10ae8ac71d4..499944b1511 100644 --- a/tests/scenarios/features/v2/undo.json +++ b/tests/scenarios/features/v2/undo.json @@ -8846,6 +8846,47 @@ "type": "idempotent" } }, + "ListDegradationTemplates": { + "tag": "Status Pages", + "undo": { + "type": "safe" + } + }, + "CreateDegradationTemplate": { + "tag": "Status Pages", + "undo": { + "operationId": "DeleteDegradationTemplate", + "parameters": [ + { + "name": "page_id", + "source": "" + }, + { + "name": "template_id", + "source": "" + } + ], + "type": "unsafe" + } + }, + "DeleteDegradationTemplate": { + "tag": "Status Pages", + "undo": { + "type": "idempotent" + } + }, + "GetDegradationTemplate": { + "tag": "Status Pages", + "undo": { + "type": "safe" + } + }, + "UpdateDegradationTemplate": { + "tag": "Status Pages", + "undo": { + "type": "idempotent" + } + }, "CreateDegradation": { "tag": "Status Pages", "undo": { @@ -8910,6 +8951,47 @@ "type": "idempotent" } }, + "ListMaintenanceTemplates": { + "tag": "Status Pages", + "undo": { + "type": "safe" + } + }, + "CreateMaintenanceTemplate": { + "tag": "Status Pages", + "undo": { + "operationId": "DeleteMaintenanceTemplate", + "parameters": [ + { + "name": "page_id", + "source": "" + }, + { + "name": "template_id", + "source": "" + } + ], + "type": "unsafe" + } + }, + "DeleteMaintenanceTemplate": { + "tag": "Status Pages", + "undo": { + "type": "idempotent" + } + }, + "GetMaintenanceTemplate": { + "tag": "Status Pages", + "undo": { + "type": "safe" + } + }, + "UpdateMaintenanceTemplate": { + "tag": "Status Pages", + "undo": { + "type": "idempotent" + } + }, "CreateMaintenance": { "tag": "Status Pages", "undo": {