diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 90e119682..1b908d9be 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: @@ -76039,6 +76641,8 @@ components: example: "1234abcd-12ab-34cd-56ef-123456abcdef" format: uuid type: string + relationships: + $ref: "#/components/schemas/PatchDegradationRequestDataRelationships" type: $ref: "#/components/schemas/PatchDegradationRequestDataType" required: @@ -76100,6 +76704,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. @@ -76109,6 +76741,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: @@ -76198,6 +76922,8 @@ components: example: "1234abcd-12ab-34cd-56ef-123456abcdef" format: uuid type: string + relationships: + $ref: "#/components/schemas/PatchMaintenanceRequestDataRelationships" type: $ref: "#/components/schemas/PatchMaintenanceRequestDataType" required: @@ -76265,6 +76991,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. @@ -76274,6 +77028,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: @@ -193140,6 +193948,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: @@ -193696,6 +194509,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. @@ -194152,6 +195239,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/examples/v2_status-pages_CreateDegradationTemplate.rs b/examples/v2_status-pages_CreateDegradationTemplate.rs new file mode 100644 index 000000000..3d90c2626 --- /dev/null +++ b/examples/v2_status-pages_CreateDegradationTemplate.rs @@ -0,0 +1,56 @@ +// Create degradation template returns "Created" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_status_pages::CreateDegradationTemplateOptionalParams; +use datadog_api_client::datadogV2::api_status_pages::StatusPagesAPI; +use datadog_api_client::datadogV2::model::CreateDegradationRequestDataAttributesStatus; +use datadog_api_client::datadogV2::model::CreateDegradationTemplateRequest; +use datadog_api_client::datadogV2::model::CreateDegradationTemplateRequestData; +use datadog_api_client::datadogV2::model::CreateDegradationTemplateRequestDataAttributes; +use datadog_api_client::datadogV2::model::CreateDegradationTemplateRequestDataAttributesComponentsAffectedItems; +use datadog_api_client::datadogV2::model::CreateDegradationTemplateRequestDataAttributesUpdatesItems; +use datadog_api_client::datadogV2::model::PatchDegradationTemplateRequestDataAttributesComponentsAffectedItemsStatus; +use datadog_api_client::datadogV2::model::PatchDegradationTemplateRequestDataType; +use uuid::Uuid; + +#[tokio::main] +async fn main() { + let body = + CreateDegradationTemplateRequest + ::new().data( + CreateDegradationTemplateRequestData::new( + PatchDegradationTemplateRequestDataType::DEGRADATION_TEMPLATES, + ).attributes( + CreateDegradationTemplateRequestDataAttributes::new("".to_string()) + .components_affected( + vec![ + CreateDegradationTemplateRequestDataAttributesComponentsAffectedItems::new( + "".to_string(), + PatchDegradationTemplateRequestDataAttributesComponentsAffectedItemsStatus + ::OPERATIONAL, + ) + ], + ) + .updates( + vec![ + CreateDegradationTemplateRequestDataAttributesUpdatesItems::new( + CreateDegradationRequestDataAttributesStatus::INVESTIGATING, + ) + ], + ), + ), + ); + let configuration = datadog::Configuration::new(); + let api = StatusPagesAPI::with_config(configuration); + let resp = api + .create_degradation_template( + Uuid::parse_str("00000000-0000-0000-0000-000000000000").expect("invalid UUID"), + body, + CreateDegradationTemplateOptionalParams::default(), + ) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_status-pages_CreateMaintenanceTemplate.rs b/examples/v2_status-pages_CreateMaintenanceTemplate.rs new file mode 100644 index 000000000..f28200768 --- /dev/null +++ b/examples/v2_status-pages_CreateMaintenanceTemplate.rs @@ -0,0 +1,36 @@ +// Create maintenance template returns "Created" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_status_pages::CreateMaintenanceTemplateOptionalParams; +use datadog_api_client::datadogV2::api_status_pages::StatusPagesAPI; +use datadog_api_client::datadogV2::model::CreateMaintenanceTemplateRequest; +use datadog_api_client::datadogV2::model::CreateMaintenanceTemplateRequestData; +use datadog_api_client::datadogV2::model::CreateMaintenanceTemplateRequestDataAttributes; +use datadog_api_client::datadogV2::model::PatchMaintenanceTemplateRequestDataType; +use uuid::Uuid; + +#[tokio::main] +async fn main() { + let body = CreateMaintenanceTemplateRequest::new().data( + CreateMaintenanceTemplateRequestData::new( + PatchMaintenanceTemplateRequestDataType::MAINTENANCE_TEMPLATES, + ) + .attributes( + CreateMaintenanceTemplateRequestDataAttributes::new("".to_string()) + .component_ids(vec![]), + ), + ); + let configuration = datadog::Configuration::new(); + let api = StatusPagesAPI::with_config(configuration); + let resp = api + .create_maintenance_template( + Uuid::parse_str("00000000-0000-0000-0000-000000000000").expect("invalid UUID"), + body, + CreateMaintenanceTemplateOptionalParams::default(), + ) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_status-pages_DeleteDegradationTemplate.rs b/examples/v2_status-pages_DeleteDegradationTemplate.rs new file mode 100644 index 000000000..a85f40f48 --- /dev/null +++ b/examples/v2_status-pages_DeleteDegradationTemplate.rs @@ -0,0 +1,21 @@ +// Delete degradation template returns "No Content" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_status_pages::StatusPagesAPI; +use uuid::Uuid; + +#[tokio::main] +async fn main() { + let configuration = datadog::Configuration::new(); + let api = StatusPagesAPI::with_config(configuration); + let resp = api + .delete_degradation_template( + Uuid::parse_str("00000000-0000-0000-0000-000000000000").expect("invalid UUID"), + Uuid::parse_str("00000000-0000-0000-0000-000000000000").expect("invalid UUID"), + ) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_status-pages_DeleteMaintenanceTemplate.rs b/examples/v2_status-pages_DeleteMaintenanceTemplate.rs new file mode 100644 index 000000000..b703e0db8 --- /dev/null +++ b/examples/v2_status-pages_DeleteMaintenanceTemplate.rs @@ -0,0 +1,21 @@ +// Delete maintenance template returns "No Content" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_status_pages::StatusPagesAPI; +use uuid::Uuid; + +#[tokio::main] +async fn main() { + let configuration = datadog::Configuration::new(); + let api = StatusPagesAPI::with_config(configuration); + let resp = api + .delete_maintenance_template( + Uuid::parse_str("00000000-0000-0000-0000-000000000000").expect("invalid UUID"), + Uuid::parse_str("00000000-0000-0000-0000-000000000000").expect("invalid UUID"), + ) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_status-pages_GetDegradationTemplate.rs b/examples/v2_status-pages_GetDegradationTemplate.rs new file mode 100644 index 000000000..b97cf31a1 --- /dev/null +++ b/examples/v2_status-pages_GetDegradationTemplate.rs @@ -0,0 +1,23 @@ +// Get degradation template returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_status_pages::GetDegradationTemplateOptionalParams; +use datadog_api_client::datadogV2::api_status_pages::StatusPagesAPI; +use uuid::Uuid; + +#[tokio::main] +async fn main() { + let configuration = datadog::Configuration::new(); + let api = StatusPagesAPI::with_config(configuration); + let resp = api + .get_degradation_template( + Uuid::parse_str("00000000-0000-0000-0000-000000000000").expect("invalid UUID"), + Uuid::parse_str("00000000-0000-0000-0000-000000000000").expect("invalid UUID"), + GetDegradationTemplateOptionalParams::default(), + ) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_status-pages_GetMaintenanceTemplate.rs b/examples/v2_status-pages_GetMaintenanceTemplate.rs new file mode 100644 index 000000000..daa436b76 --- /dev/null +++ b/examples/v2_status-pages_GetMaintenanceTemplate.rs @@ -0,0 +1,23 @@ +// Get maintenance template returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_status_pages::GetMaintenanceTemplateOptionalParams; +use datadog_api_client::datadogV2::api_status_pages::StatusPagesAPI; +use uuid::Uuid; + +#[tokio::main] +async fn main() { + let configuration = datadog::Configuration::new(); + let api = StatusPagesAPI::with_config(configuration); + let resp = api + .get_maintenance_template( + Uuid::parse_str("00000000-0000-0000-0000-000000000000").expect("invalid UUID"), + Uuid::parse_str("00000000-0000-0000-0000-000000000000").expect("invalid UUID"), + GetMaintenanceTemplateOptionalParams::default(), + ) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_status-pages_ListDegradationTemplates.rs b/examples/v2_status-pages_ListDegradationTemplates.rs new file mode 100644 index 000000000..6f3a152a5 --- /dev/null +++ b/examples/v2_status-pages_ListDegradationTemplates.rs @@ -0,0 +1,22 @@ +// List degradation templates returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_status_pages::ListDegradationTemplatesOptionalParams; +use datadog_api_client::datadogV2::api_status_pages::StatusPagesAPI; +use uuid::Uuid; + +#[tokio::main] +async fn main() { + let configuration = datadog::Configuration::new(); + let api = StatusPagesAPI::with_config(configuration); + let resp = api + .list_degradation_templates( + Uuid::parse_str("00000000-0000-0000-0000-000000000000").expect("invalid UUID"), + ListDegradationTemplatesOptionalParams::default(), + ) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_status-pages_ListMaintenanceTemplates.rs b/examples/v2_status-pages_ListMaintenanceTemplates.rs new file mode 100644 index 000000000..bb03f32c8 --- /dev/null +++ b/examples/v2_status-pages_ListMaintenanceTemplates.rs @@ -0,0 +1,22 @@ +// List maintenance templates returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_status_pages::ListMaintenanceTemplatesOptionalParams; +use datadog_api_client::datadogV2::api_status_pages::StatusPagesAPI; +use uuid::Uuid; + +#[tokio::main] +async fn main() { + let configuration = datadog::Configuration::new(); + let api = StatusPagesAPI::with_config(configuration); + let resp = api + .list_maintenance_templates( + Uuid::parse_str("00000000-0000-0000-0000-000000000000").expect("invalid UUID"), + ListMaintenanceTemplatesOptionalParams::default(), + ) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_status-pages_UpdateDegradationTemplate.rs b/examples/v2_status-pages_UpdateDegradationTemplate.rs new file mode 100644 index 000000000..e509fd9b0 --- /dev/null +++ b/examples/v2_status-pages_UpdateDegradationTemplate.rs @@ -0,0 +1,58 @@ +// Update degradation template returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_status_pages::StatusPagesAPI; +use datadog_api_client::datadogV2::api_status_pages::UpdateDegradationTemplateOptionalParams; +use datadog_api_client::datadogV2::model::CreateDegradationRequestDataAttributesStatus; +use datadog_api_client::datadogV2::model::PatchDegradationTemplateRequest; +use datadog_api_client::datadogV2::model::PatchDegradationTemplateRequestData; +use datadog_api_client::datadogV2::model::PatchDegradationTemplateRequestDataAttributes; +use datadog_api_client::datadogV2::model::PatchDegradationTemplateRequestDataAttributesComponentsAffectedItems; +use datadog_api_client::datadogV2::model::PatchDegradationTemplateRequestDataAttributesComponentsAffectedItemsStatus; +use datadog_api_client::datadogV2::model::PatchDegradationTemplateRequestDataAttributesUpdatesItems; +use datadog_api_client::datadogV2::model::PatchDegradationTemplateRequestDataType; +use uuid::Uuid; + +#[tokio::main] +async fn main() { + let body = + PatchDegradationTemplateRequest + ::new().data( + PatchDegradationTemplateRequestData::new( + "".to_string(), + PatchDegradationTemplateRequestDataType::DEGRADATION_TEMPLATES, + ).attributes( + PatchDegradationTemplateRequestDataAttributes::new() + .components_affected( + vec![ + PatchDegradationTemplateRequestDataAttributesComponentsAffectedItems::new( + "".to_string(), + PatchDegradationTemplateRequestDataAttributesComponentsAffectedItemsStatus + ::OPERATIONAL, + ) + ], + ) + .updates( + vec![ + PatchDegradationTemplateRequestDataAttributesUpdatesItems::new( + CreateDegradationRequestDataAttributesStatus::INVESTIGATING, + ) + ], + ), + ), + ); + let configuration = datadog::Configuration::new(); + let api = StatusPagesAPI::with_config(configuration); + let resp = api + .update_degradation_template( + Uuid::parse_str("00000000-0000-0000-0000-000000000000").expect("invalid UUID"), + Uuid::parse_str("00000000-0000-0000-0000-000000000000").expect("invalid UUID"), + body, + UpdateDegradationTemplateOptionalParams::default(), + ) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_status-pages_UpdateMaintenanceTemplate.rs b/examples/v2_status-pages_UpdateMaintenanceTemplate.rs new file mode 100644 index 000000000..2630081f0 --- /dev/null +++ b/examples/v2_status-pages_UpdateMaintenanceTemplate.rs @@ -0,0 +1,35 @@ +// Update maintenance template returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_status_pages::StatusPagesAPI; +use datadog_api_client::datadogV2::api_status_pages::UpdateMaintenanceTemplateOptionalParams; +use datadog_api_client::datadogV2::model::PatchMaintenanceTemplateRequest; +use datadog_api_client::datadogV2::model::PatchMaintenanceTemplateRequestData; +use datadog_api_client::datadogV2::model::PatchMaintenanceTemplateRequestDataAttributes; +use datadog_api_client::datadogV2::model::PatchMaintenanceTemplateRequestDataType; +use uuid::Uuid; + +#[tokio::main] +async fn main() { + let body = PatchMaintenanceTemplateRequest::new().data( + PatchMaintenanceTemplateRequestData::new( + "".to_string(), + PatchMaintenanceTemplateRequestDataType::MAINTENANCE_TEMPLATES, + ) + .attributes(PatchMaintenanceTemplateRequestDataAttributes::new().component_ids(vec![])), + ); + let configuration = datadog::Configuration::new(); + let api = StatusPagesAPI::with_config(configuration); + let resp = api + .update_maintenance_template( + Uuid::parse_str("00000000-0000-0000-0000-000000000000").expect("invalid UUID"), + Uuid::parse_str("00000000-0000-0000-0000-000000000000").expect("invalid UUID"), + body, + UpdateMaintenanceTemplateOptionalParams::default(), + ) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/src/datadogV2/api/api_status_pages.rs b/src/datadogV2/api/api_status_pages.rs index 01a2a1f33..dd7c07c8c 100644 --- a/src/datadogV2/api/api_status_pages.rs +++ b/src/datadogV2/api/api_status_pages.rs @@ -81,6 +81,22 @@ impl CreateDegradationOptionalParams { } } +/// CreateDegradationTemplateOptionalParams is a struct for passing parameters to the method [`StatusPagesAPI::create_degradation_template`] +#[non_exhaustive] +#[derive(Clone, Default, Debug)] +pub struct CreateDegradationTemplateOptionalParams { + /// Comma-separated list of resources to include. Supported values: created_by_user, last_modified_by_user, status_page. + pub include: Option, +} + +impl CreateDegradationTemplateOptionalParams { + /// Comma-separated list of resources to include. Supported values: created_by_user, last_modified_by_user, status_page. + pub fn include(mut self, value: String) -> Self { + self.include = Some(value); + self + } +} + /// CreateMaintenanceOptionalParams is a struct for passing parameters to the method [`StatusPagesAPI::create_maintenance`] #[non_exhaustive] #[derive(Clone, Default, Debug)] @@ -104,6 +120,22 @@ impl CreateMaintenanceOptionalParams { } } +/// CreateMaintenanceTemplateOptionalParams is a struct for passing parameters to the method [`StatusPagesAPI::create_maintenance_template`] +#[non_exhaustive] +#[derive(Clone, Default, Debug)] +pub struct CreateMaintenanceTemplateOptionalParams { + /// Comma-separated list of resources to include. Supported values: created_by_user, last_modified_by_user, status_page. + pub include: Option, +} + +impl CreateMaintenanceTemplateOptionalParams { + /// Comma-separated list of resources to include. Supported values: created_by_user, last_modified_by_user, status_page. + pub fn include(mut self, value: String) -> Self { + self.include = Some(value); + self + } +} + /// CreateStatusPageOptionalParams is a struct for passing parameters to the method [`StatusPagesAPI::create_status_page`] #[non_exhaustive] #[derive(Clone, Default, Debug)] @@ -168,6 +200,22 @@ impl GetDegradationOptionalParams { } } +/// GetDegradationTemplateOptionalParams is a struct for passing parameters to the method [`StatusPagesAPI::get_degradation_template`] +#[non_exhaustive] +#[derive(Clone, Default, Debug)] +pub struct GetDegradationTemplateOptionalParams { + /// Comma-separated list of resources to include. Supported values: created_by_user, last_modified_by_user, status_page. + pub include: Option, +} + +impl GetDegradationTemplateOptionalParams { + /// Comma-separated list of resources to include. Supported values: created_by_user, last_modified_by_user, status_page. + pub fn include(mut self, value: String) -> Self { + self.include = Some(value); + self + } +} + /// GetMaintenanceOptionalParams is a struct for passing parameters to the method [`StatusPagesAPI::get_maintenance`] #[non_exhaustive] #[derive(Clone, Default, Debug)] @@ -184,6 +232,22 @@ impl GetMaintenanceOptionalParams { } } +/// GetMaintenanceTemplateOptionalParams is a struct for passing parameters to the method [`StatusPagesAPI::get_maintenance_template`] +#[non_exhaustive] +#[derive(Clone, Default, Debug)] +pub struct GetMaintenanceTemplateOptionalParams { + /// Comma-separated list of resources to include. Supported values: created_by_user, last_modified_by_user, status_page. + pub include: Option, +} + +impl GetMaintenanceTemplateOptionalParams { + /// Comma-separated list of resources to include. Supported values: created_by_user, last_modified_by_user, status_page. + pub fn include(mut self, value: String) -> Self { + self.include = Some(value); + self + } +} + /// GetStatusPageOptionalParams is a struct for passing parameters to the method [`StatusPagesAPI::get_status_page`] #[non_exhaustive] #[derive(Clone, Default, Debug)] @@ -216,6 +280,22 @@ impl ListComponentsOptionalParams { } } +/// ListDegradationTemplatesOptionalParams is a struct for passing parameters to the method [`StatusPagesAPI::list_degradation_templates`] +#[non_exhaustive] +#[derive(Clone, Default, Debug)] +pub struct ListDegradationTemplatesOptionalParams { + /// Comma-separated list of resources to include. Supported values: created_by_user, last_modified_by_user, status_page. + pub include: Option, +} + +impl ListDegradationTemplatesOptionalParams { + /// Comma-separated list of resources to include. Supported values: created_by_user, last_modified_by_user, status_page. + pub fn include(mut self, value: String) -> Self { + self.include = Some(value); + self + } +} + /// ListDegradationsOptionalParams is a struct for passing parameters to the method [`StatusPagesAPI::list_degradations`] #[non_exhaustive] #[derive(Clone, Default, Debug)] @@ -232,6 +312,8 @@ pub struct ListDegradationsOptionalParams { pub filter_status: Option, /// Sort order. Prefix with '-' for descending. Supported values: created_at, -created_at, modified_at, -modified_at. pub sort: Option, + /// Optional source ID filter. Returns only degradations whose source matches this ID (for example, an incident ID). + pub filter_source_id: Option, } impl ListDegradationsOptionalParams { @@ -265,6 +347,27 @@ impl ListDegradationsOptionalParams { self.sort = Some(value); self } + /// Optional source ID filter. Returns only degradations whose source matches this ID (for example, an incident ID). + pub fn filter_source_id(mut self, value: String) -> Self { + self.filter_source_id = Some(value); + self + } +} + +/// ListMaintenanceTemplatesOptionalParams is a struct for passing parameters to the method [`StatusPagesAPI::list_maintenance_templates`] +#[non_exhaustive] +#[derive(Clone, Default, Debug)] +pub struct ListMaintenanceTemplatesOptionalParams { + /// Comma-separated list of resources to include. Supported values: created_by_user, last_modified_by_user, status_page. + pub include: Option, +} + +impl ListMaintenanceTemplatesOptionalParams { + /// Comma-separated list of resources to include. Supported values: created_by_user, last_modified_by_user, status_page. + pub fn include(mut self, value: String) -> Self { + self.include = Some(value); + self + } } /// ListMaintenancesOptionalParams is a struct for passing parameters to the method [`StatusPagesAPI::list_maintenances`] @@ -394,6 +497,22 @@ impl UpdateDegradationOptionalParams { } } +/// UpdateDegradationTemplateOptionalParams is a struct for passing parameters to the method [`StatusPagesAPI::update_degradation_template`] +#[non_exhaustive] +#[derive(Clone, Default, Debug)] +pub struct UpdateDegradationTemplateOptionalParams { + /// Comma-separated list of resources to include. Supported values: created_by_user, last_modified_by_user, status_page. + pub include: Option, +} + +impl UpdateDegradationTemplateOptionalParams { + /// Comma-separated list of resources to include. Supported values: created_by_user, last_modified_by_user, status_page. + pub fn include(mut self, value: String) -> Self { + self.include = Some(value); + self + } +} + /// UpdateMaintenanceOptionalParams is a struct for passing parameters to the method [`StatusPagesAPI::update_maintenance`] #[non_exhaustive] #[derive(Clone, Default, Debug)] @@ -417,6 +536,22 @@ impl UpdateMaintenanceOptionalParams { } } +/// UpdateMaintenanceTemplateOptionalParams is a struct for passing parameters to the method [`StatusPagesAPI::update_maintenance_template`] +#[non_exhaustive] +#[derive(Clone, Default, Debug)] +pub struct UpdateMaintenanceTemplateOptionalParams { + /// Comma-separated list of resources to include. Supported values: created_by_user, last_modified_by_user, status_page. + pub include: Option, +} + +impl UpdateMaintenanceTemplateOptionalParams { + /// Comma-separated list of resources to include. Supported values: created_by_user, last_modified_by_user, status_page. + pub fn include(mut self, value: String) -> Self { + self.include = Some(value); + self + } +} + /// UpdateStatusPageOptionalParams is a struct for passing parameters to the method [`StatusPagesAPI::update_status_page`] #[non_exhaustive] #[derive(Clone, Default, Debug)] @@ -472,6 +607,14 @@ pub enum CreateDegradationError { UnknownValue(serde_json::Value), } +/// CreateDegradationTemplateError is a struct for typed errors of method [`StatusPagesAPI::create_degradation_template`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CreateDegradationTemplateError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + /// CreateMaintenanceError is a struct for typed errors of method [`StatusPagesAPI::create_maintenance`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -480,6 +623,14 @@ pub enum CreateMaintenanceError { UnknownValue(serde_json::Value), } +/// CreateMaintenanceTemplateError is a struct for typed errors of method [`StatusPagesAPI::create_maintenance_template`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CreateMaintenanceTemplateError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + /// CreateStatusPageError is a struct for typed errors of method [`StatusPagesAPI::create_status_page`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -504,6 +655,22 @@ pub enum DeleteDegradationError { UnknownValue(serde_json::Value), } +/// DeleteDegradationTemplateError is a struct for typed errors of method [`StatusPagesAPI::delete_degradation_template`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum DeleteDegradationTemplateError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// DeleteMaintenanceTemplateError is a struct for typed errors of method [`StatusPagesAPI::delete_maintenance_template`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum DeleteMaintenanceTemplateError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + /// DeleteStatusPageError is a struct for typed errors of method [`StatusPagesAPI::delete_status_page`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -536,6 +703,14 @@ pub enum GetDegradationError { UnknownValue(serde_json::Value), } +/// GetDegradationTemplateError is a struct for typed errors of method [`StatusPagesAPI::get_degradation_template`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetDegradationTemplateError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + /// GetMaintenanceError is a struct for typed errors of method [`StatusPagesAPI::get_maintenance`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -544,6 +719,14 @@ pub enum GetMaintenanceError { UnknownValue(serde_json::Value), } +/// GetMaintenanceTemplateError is a struct for typed errors of method [`StatusPagesAPI::get_maintenance_template`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetMaintenanceTemplateError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + /// GetStatusPageError is a struct for typed errors of method [`StatusPagesAPI::get_status_page`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -560,6 +743,14 @@ pub enum ListComponentsError { UnknownValue(serde_json::Value), } +/// ListDegradationTemplatesError is a struct for typed errors of method [`StatusPagesAPI::list_degradation_templates`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ListDegradationTemplatesError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + /// ListDegradationsError is a struct for typed errors of method [`StatusPagesAPI::list_degradations`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -568,6 +759,14 @@ pub enum ListDegradationsError { UnknownValue(serde_json::Value), } +/// ListMaintenanceTemplatesError is a struct for typed errors of method [`StatusPagesAPI::list_maintenance_templates`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ListMaintenanceTemplatesError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + /// ListMaintenancesError is a struct for typed errors of method [`StatusPagesAPI::list_maintenances`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -624,6 +823,14 @@ pub enum UpdateDegradationError { UnknownValue(serde_json::Value), } +/// UpdateDegradationTemplateError is a struct for typed errors of method [`StatusPagesAPI::update_degradation_template`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum UpdateDegradationTemplateError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + /// UpdateMaintenanceError is a struct for typed errors of method [`StatusPagesAPI::update_maintenance`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -632,6 +839,14 @@ pub enum UpdateMaintenanceError { UnknownValue(serde_json::Value), } +/// UpdateMaintenanceTemplateError is a struct for typed errors of method [`StatusPagesAPI::update_maintenance_template`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum UpdateMaintenanceTemplateError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + /// UpdateStatusPageError is a struct for typed errors of method [`StatusPagesAPI::update_status_page`] #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(untagged)] @@ -1392,15 +1607,18 @@ impl StatusPagesAPI { } } - /// Schedules a new maintenance. - pub async fn create_maintenance( + /// Creates a new degradation template. + pub async fn create_degradation_template( &self, page_id: uuid::Uuid, - body: crate::datadogV2::model::CreateMaintenanceRequest, - params: CreateMaintenanceOptionalParams, - ) -> Result> { + body: crate::datadogV2::model::CreateDegradationTemplateRequest, + params: CreateDegradationTemplateOptionalParams, + ) -> Result< + crate::datadogV2::model::DegradationTemplate, + datadog::Error, + > { match self - .create_maintenance_with_http_info(page_id, body, params) + .create_degradation_template_with_http_info(page_id, body, params) .await { Ok(response_content) => { @@ -1416,37 +1634,32 @@ impl StatusPagesAPI { } } - /// Schedules a new maintenance. - pub async fn create_maintenance_with_http_info( + /// Creates a new degradation template. + pub async fn create_degradation_template_with_http_info( &self, page_id: uuid::Uuid, - body: crate::datadogV2::model::CreateMaintenanceRequest, - params: CreateMaintenanceOptionalParams, + body: crate::datadogV2::model::CreateDegradationTemplateRequest, + params: CreateDegradationTemplateOptionalParams, ) -> Result< - datadog::ResponseContent, - datadog::Error, + datadog::ResponseContent, + datadog::Error, > { let local_configuration = &self.config; - let operation_id = "v2.create_maintenance"; + let operation_id = "v2.create_degradation_template"; // unbox and build optional parameters - let notify_subscribers = params.notify_subscribers; let include = params.include; let local_client = &self.client; let local_uri_str = format!( - "{}/api/v2/statuspages/{page_id}/maintenances", + "{}/api/v2/statuspages/{page_id}/degradation_templates", local_configuration.get_operation_host(operation_id), page_id = datadog::urlencode(page_id.to_string()) ); let mut local_req_builder = local_client.request(reqwest::Method::POST, local_uri_str.as_str()); - if let Some(ref local_query_param) = notify_subscribers { - local_req_builder = - local_req_builder.query(&[("notify_subscribers", &local_query_param.to_string())]); - }; if let Some(ref local_query_param) = include { local_req_builder = local_req_builder.query(&[("include", &local_query_param.to_string())]); @@ -1541,7 +1754,9 @@ impl StatusPagesAPI { log::debug!("response content: {}", local_content); if !local_status.is_client_error() && !local_status.is_server_error() { - match serde_json::from_str::(&local_content) { + match serde_json::from_str::( + &local_content, + ) { Ok(e) => { return Ok(datadog::ResponseContent { status: local_status, @@ -1552,7 +1767,7 @@ impl StatusPagesAPI { Err(e) => return Err(datadog::Error::Serde(e)), }; } else { - let local_entity: Option = + let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = datadog::ResponseContent { status: local_status, @@ -1563,13 +1778,17 @@ impl StatusPagesAPI { } } - /// Creates a new status page in an unpublished state. Use the dedicated [publish](#publish-status-page) status page endpoint to publish the page after creation. - pub async fn create_status_page( + /// Schedules a new maintenance. + pub async fn create_maintenance( &self, - body: crate::datadogV2::model::CreateStatusPageRequest, - params: CreateStatusPageOptionalParams, - ) -> Result> { - match self.create_status_page_with_http_info(body, params).await { + page_id: uuid::Uuid, + body: crate::datadogV2::model::CreateMaintenanceRequest, + params: CreateMaintenanceOptionalParams, + ) -> Result> { + match self + .create_maintenance_with_http_info(page_id, body, params) + .await + { Ok(response_content) => { if let Some(e) = response_content.entity { Ok(e) @@ -1583,30 +1802,37 @@ impl StatusPagesAPI { } } - /// Creates a new status page in an unpublished state. Use the dedicated [publish](#publish-status-page) status page endpoint to publish the page after creation. - pub async fn create_status_page_with_http_info( + /// Schedules a new maintenance. + pub async fn create_maintenance_with_http_info( &self, - body: crate::datadogV2::model::CreateStatusPageRequest, - params: CreateStatusPageOptionalParams, + page_id: uuid::Uuid, + body: crate::datadogV2::model::CreateMaintenanceRequest, + params: CreateMaintenanceOptionalParams, ) -> Result< - datadog::ResponseContent, - datadog::Error, + datadog::ResponseContent, + datadog::Error, > { let local_configuration = &self.config; - let operation_id = "v2.create_status_page"; + let operation_id = "v2.create_maintenance"; // unbox and build optional parameters + let notify_subscribers = params.notify_subscribers; let include = params.include; let local_client = &self.client; let local_uri_str = format!( - "{}/api/v2/statuspages", - local_configuration.get_operation_host(operation_id) + "{}/api/v2/statuspages/{page_id}/maintenances", + local_configuration.get_operation_host(operation_id), + page_id = datadog::urlencode(page_id.to_string()) ); let mut local_req_builder = local_client.request(reqwest::Method::POST, local_uri_str.as_str()); + if let Some(ref local_query_param) = notify_subscribers { + local_req_builder = + local_req_builder.query(&[("notify_subscribers", &local_query_param.to_string())]); + }; if let Some(ref local_query_param) = include { local_req_builder = local_req_builder.query(&[("include", &local_query_param.to_string())]); @@ -1701,7 +1927,7 @@ impl StatusPagesAPI { log::debug!("response content: {}", local_content); if !local_status.is_client_error() && !local_status.is_server_error() { - match serde_json::from_str::(&local_content) { + match serde_json::from_str::(&local_content) { Ok(e) => { return Ok(datadog::ResponseContent { status: local_status, @@ -1712,7 +1938,7 @@ impl StatusPagesAPI { Err(e) => return Err(datadog::Error::Serde(e)), }; } else { - let local_entity: Option = + let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = datadog::ResponseContent { status: local_status, @@ -1723,29 +1949,1023 @@ impl StatusPagesAPI { } } - /// Deletes a component by its ID. - pub async fn delete_component( + /// Creates a new maintenance template. + pub async fn create_maintenance_template( &self, page_id: uuid::Uuid, - component_id: uuid::Uuid, - ) -> Result<(), datadog::Error> { + body: crate::datadogV2::model::CreateMaintenanceTemplateRequest, + params: CreateMaintenanceTemplateOptionalParams, + ) -> Result< + crate::datadogV2::model::MaintenanceTemplate, + datadog::Error, + > { match self - .delete_component_with_http_info(page_id, component_id) + .create_maintenance_template_with_http_info(page_id, body, params) .await { - Ok(_) => Ok(()), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(datadog::Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } - /// Deletes a component by its ID. - pub async fn delete_component_with_http_info( + /// Creates a new maintenance template. + pub async fn create_maintenance_template_with_http_info( &self, page_id: uuid::Uuid, - component_id: uuid::Uuid, + body: crate::datadogV2::model::CreateMaintenanceTemplateRequest, + params: CreateMaintenanceTemplateOptionalParams, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.create_maintenance_template"; + + // unbox and build optional parameters + let include = params.include; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/statuspages/{page_id}/maintenance_templates", + local_configuration.get_operation_host(operation_id), + page_id = datadog::urlencode(page_id.to_string()) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::POST, local_uri_str.as_str()); + + if let Some(ref local_query_param) = include { + local_req_builder = + local_req_builder.query(&[("include", &local_query_param.to_string())]); + }; + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Content-Type", HeaderValue::from_static("application/json")); + headers.insert("Accept", HeaderValue::from_static("application/json")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + // build body parameters + let output = Vec::new(); + let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter); + if body.serialize(&mut ser).is_ok() { + if let Some(content_encoding) = headers.get("Content-Encoding") { + match content_encoding.to_str().unwrap_or_default() { + "gzip" => { + let mut enc = GzEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + "deflate" => { + let mut enc = ZlibEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + #[cfg(feature = "zstd")] + "zstd1" => { + let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap(); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + _ => { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + } else { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + match serde_json::from_str::( + &local_content, + ) { + Ok(e) => { + return Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: Some(e), + }) + } + Err(e) => return Err(datadog::Error::Serde(e)), + }; + } else { + let local_entity: Option = + serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } + + /// Creates a new status page in an unpublished state. Use the dedicated [publish](#publish-status-page) status page endpoint to publish the page after creation. + pub async fn create_status_page( + &self, + body: crate::datadogV2::model::CreateStatusPageRequest, + params: CreateStatusPageOptionalParams, + ) -> Result> { + match self.create_status_page_with_http_info(body, params).await { + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(datadog::Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } + Err(err) => Err(err), + } + } + + /// Creates a new status page in an unpublished state. Use the dedicated [publish](#publish-status-page) status page endpoint to publish the page after creation. + pub async fn create_status_page_with_http_info( + &self, + body: crate::datadogV2::model::CreateStatusPageRequest, + params: CreateStatusPageOptionalParams, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.create_status_page"; + + // unbox and build optional parameters + let include = params.include; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/statuspages", + local_configuration.get_operation_host(operation_id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::POST, local_uri_str.as_str()); + + if let Some(ref local_query_param) = include { + local_req_builder = + local_req_builder.query(&[("include", &local_query_param.to_string())]); + }; + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Content-Type", HeaderValue::from_static("application/json")); + headers.insert("Accept", HeaderValue::from_static("application/json")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + // build body parameters + let output = Vec::new(); + let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter); + if body.serialize(&mut ser).is_ok() { + if let Some(content_encoding) = headers.get("Content-Encoding") { + match content_encoding.to_str().unwrap_or_default() { + "gzip" => { + let mut enc = GzEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + "deflate" => { + let mut enc = ZlibEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + #[cfg(feature = "zstd")] + "zstd1" => { + let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap(); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + _ => { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + } else { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + match serde_json::from_str::(&local_content) { + Ok(e) => { + return Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: Some(e), + }) + } + Err(e) => return Err(datadog::Error::Serde(e)), + }; + } else { + let local_entity: Option = + serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } + + /// Deletes a component by its ID. + pub async fn delete_component( + &self, + page_id: uuid::Uuid, + component_id: uuid::Uuid, + ) -> Result<(), datadog::Error> { + match self + .delete_component_with_http_info(page_id, component_id) + .await + { + Ok(_) => Ok(()), + Err(err) => Err(err), + } + } + + /// Deletes a component by its ID. + pub async fn delete_component_with_http_info( + &self, + page_id: uuid::Uuid, + component_id: uuid::Uuid, ) -> Result, datadog::Error> { let local_configuration = &self.config; - let operation_id = "v2.delete_component"; + let operation_id = "v2.delete_component"; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/statuspages/{page_id}/components/{component_id}", + local_configuration.get_operation_host(operation_id), + page_id = datadog::urlencode(page_id.to_string()), + component_id = datadog::urlencode(component_id.to_string()) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::DELETE, local_uri_str.as_str()); + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Accept", HeaderValue::from_static("*/*")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: None, + }) + } else { + let local_entity: Option = + serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } + + /// Deletes a degradation by its ID. + pub async fn delete_degradation( + &self, + page_id: uuid::Uuid, + degradation_id: uuid::Uuid, + ) -> Result<(), datadog::Error> { + match self + .delete_degradation_with_http_info(page_id, degradation_id) + .await + { + Ok(_) => Ok(()), + Err(err) => Err(err), + } + } + + /// Deletes a degradation by its ID. + pub async fn delete_degradation_with_http_info( + &self, + page_id: uuid::Uuid, + degradation_id: uuid::Uuid, + ) -> Result, datadog::Error> { + let local_configuration = &self.config; + let operation_id = "v2.delete_degradation"; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/statuspages/{page_id}/degradations/{degradation_id}", + local_configuration.get_operation_host(operation_id), + page_id = datadog::urlencode(page_id.to_string()), + degradation_id = datadog::urlencode(degradation_id.to_string()) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::DELETE, local_uri_str.as_str()); + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Accept", HeaderValue::from_static("*/*")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: None, + }) + } else { + let local_entity: Option = + serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } + + /// Deletes a degradation template by its ID (soft delete). + pub async fn delete_degradation_template( + &self, + page_id: uuid::Uuid, + template_id: uuid::Uuid, + ) -> Result<(), datadog::Error> { + match self + .delete_degradation_template_with_http_info(page_id, template_id) + .await + { + Ok(_) => Ok(()), + Err(err) => Err(err), + } + } + + /// Deletes a degradation template by its ID (soft delete). + pub async fn delete_degradation_template_with_http_info( + &self, + page_id: uuid::Uuid, + template_id: uuid::Uuid, + ) -> Result, datadog::Error> { + let local_configuration = &self.config; + let operation_id = "v2.delete_degradation_template"; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/statuspages/{page_id}/degradation_templates/{template_id}", + local_configuration.get_operation_host(operation_id), + page_id = datadog::urlencode(page_id.to_string()), + template_id = datadog::urlencode(template_id.to_string()) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::DELETE, local_uri_str.as_str()); + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Accept", HeaderValue::from_static("*/*")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: None, + }) + } else { + let local_entity: Option = + serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } + + /// Deletes a maintenance template by its ID (soft delete). + pub async fn delete_maintenance_template( + &self, + page_id: uuid::Uuid, + template_id: uuid::Uuid, + ) -> Result<(), datadog::Error> { + match self + .delete_maintenance_template_with_http_info(page_id, template_id) + .await + { + Ok(_) => Ok(()), + Err(err) => Err(err), + } + } + + /// Deletes a maintenance template by its ID (soft delete). + pub async fn delete_maintenance_template_with_http_info( + &self, + page_id: uuid::Uuid, + template_id: uuid::Uuid, + ) -> Result, datadog::Error> { + let local_configuration = &self.config; + let operation_id = "v2.delete_maintenance_template"; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/statuspages/{page_id}/maintenance_templates/{template_id}", + local_configuration.get_operation_host(operation_id), + page_id = datadog::urlencode(page_id.to_string()), + template_id = datadog::urlencode(template_id.to_string()) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::DELETE, local_uri_str.as_str()); + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Accept", HeaderValue::from_static("*/*")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: None, + }) + } else { + let local_entity: Option = + serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } + + /// Deletes a status page by its ID. + pub async fn delete_status_page( + &self, + page_id: uuid::Uuid, + ) -> Result<(), datadog::Error> { + match self.delete_status_page_with_http_info(page_id).await { + Ok(_) => Ok(()), + Err(err) => Err(err), + } + } + + /// Deletes a status page by its ID. + pub async fn delete_status_page_with_http_info( + &self, + page_id: uuid::Uuid, + ) -> Result, datadog::Error> { + let local_configuration = &self.config; + let operation_id = "v2.delete_status_page"; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/statuspages/{page_id}", + local_configuration.get_operation_host(operation_id), + page_id = datadog::urlencode(page_id.to_string()) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::DELETE, local_uri_str.as_str()); + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Accept", HeaderValue::from_static("*/*")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: None, + }) + } else { + let local_entity: Option = + serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } + + /// Edits a specific degradation update. + pub async fn edit_degradation_update( + &self, + degradation_id: uuid::Uuid, + page_id: uuid::Uuid, + update_id: uuid::Uuid, + body: crate::datadogV2::model::PatchDegradationUpdateRequest, + params: EditDegradationUpdateOptionalParams, + ) -> Result< + crate::datadogV2::model::DegradationUpdate, + datadog::Error, + > { + match self + .edit_degradation_update_with_http_info( + degradation_id, + page_id, + update_id, + body, + params, + ) + .await + { + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(datadog::Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } + Err(err) => Err(err), + } + } + + /// Edits a specific degradation update. + pub async fn edit_degradation_update_with_http_info( + &self, + degradation_id: uuid::Uuid, + page_id: uuid::Uuid, + update_id: uuid::Uuid, + body: crate::datadogV2::model::PatchDegradationUpdateRequest, + params: EditDegradationUpdateOptionalParams, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.edit_degradation_update"; + + // unbox and build optional parameters + let include = params.include; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/statuspages/{page_id}/degradations/{degradation_id}/updates/{update_id}", + local_configuration.get_operation_host(operation_id), + degradation_id = datadog::urlencode(degradation_id.to_string()), + page_id = datadog::urlencode(page_id.to_string()), + update_id = datadog::urlencode(update_id.to_string()) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::PATCH, local_uri_str.as_str()); + + if let Some(ref local_query_param) = include { + local_req_builder = + local_req_builder.query(&[("include", &local_query_param.to_string())]); + }; + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Content-Type", HeaderValue::from_static("application/json")); + headers.insert("Accept", HeaderValue::from_static("application/json")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + // build body parameters + let output = Vec::new(); + let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter); + if body.serialize(&mut ser).is_ok() { + if let Some(content_encoding) = headers.get("Content-Encoding") { + match content_encoding.to_str().unwrap_or_default() { + "gzip" => { + let mut enc = GzEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + "deflate" => { + let mut enc = ZlibEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + #[cfg(feature = "zstd")] + "zstd1" => { + let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap(); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + _ => { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + } else { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + match serde_json::from_str::(&local_content) + { + Ok(e) => { + return Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: Some(e), + }) + } + Err(e) => return Err(datadog::Error::Serde(e)), + }; + } else { + let local_entity: Option = + serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } + + /// Retrieves a specific component by its ID. + pub async fn get_component( + &self, + page_id: uuid::Uuid, + component_id: uuid::Uuid, + params: GetComponentOptionalParams, + ) -> Result> + { + match self + .get_component_with_http_info(page_id, component_id, params) + .await + { + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(datadog::Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } + Err(err) => Err(err), + } + } + + /// Retrieves a specific component by its ID. + pub async fn get_component_with_http_info( + &self, + page_id: uuid::Uuid, + component_id: uuid::Uuid, + params: GetComponentOptionalParams, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.get_component"; + + // unbox and build optional parameters + let include = params.include; let local_client = &self.client; @@ -1756,11 +2976,16 @@ impl StatusPagesAPI { component_id = datadog::urlencode(component_id.to_string()) ); let mut local_req_builder = - local_client.request(reqwest::Method::DELETE, local_uri_str.as_str()); + local_client.request(reqwest::Method::GET, local_uri_str.as_str()); + + if let Some(ref local_query_param) = include { + local_req_builder = + local_req_builder.query(&[("include", &local_query_param.to_string())]); + }; // build headers let mut headers = HeaderMap::new(); - headers.insert("Accept", HeaderValue::from_static("*/*")); + headers.insert("Accept", HeaderValue::from_static("application/json")); // build user agent match HeaderValue::from_str(local_configuration.user_agent.as_str()) { @@ -1800,14 +3025,20 @@ impl StatusPagesAPI { log::debug!("response content: {}", local_content); if !local_status.is_client_error() && !local_status.is_server_error() { - Ok(datadog::ResponseContent { - status: local_status, - content: local_content, - entity: None, - }) + match serde_json::from_str::( + &local_content, + ) { + Ok(e) => { + return Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: Some(e), + }) + } + Err(e) => return Err(datadog::Error::Serde(e)), + }; } else { - let local_entity: Option = - serde_json::from_str(&local_content).ok(); + let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = datadog::ResponseContent { status: local_status, content: local_content, @@ -1817,29 +3048,45 @@ impl StatusPagesAPI { } } - /// Deletes a degradation by its ID. - pub async fn delete_degradation( + /// Retrieves a specific degradation by its ID. + pub async fn get_degradation( &self, page_id: uuid::Uuid, degradation_id: uuid::Uuid, - ) -> Result<(), datadog::Error> { + params: GetDegradationOptionalParams, + ) -> Result> { match self - .delete_degradation_with_http_info(page_id, degradation_id) + .get_degradation_with_http_info(page_id, degradation_id, params) .await { - Ok(_) => Ok(()), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(datadog::Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } - /// Deletes a degradation by its ID. - pub async fn delete_degradation_with_http_info( + /// Retrieves a specific degradation by its ID. + pub async fn get_degradation_with_http_info( &self, page_id: uuid::Uuid, degradation_id: uuid::Uuid, - ) -> Result, datadog::Error> { + params: GetDegradationOptionalParams, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { let local_configuration = &self.config; - let operation_id = "v2.delete_degradation"; + let operation_id = "v2.get_degradation"; + + // unbox and build optional parameters + let include = params.include; let local_client = &self.client; @@ -1850,11 +3097,139 @@ impl StatusPagesAPI { degradation_id = datadog::urlencode(degradation_id.to_string()) ); let mut local_req_builder = - local_client.request(reqwest::Method::DELETE, local_uri_str.as_str()); + local_client.request(reqwest::Method::GET, local_uri_str.as_str()); + + if let Some(ref local_query_param) = include { + local_req_builder = + local_req_builder.query(&[("include", &local_query_param.to_string())]); + }; + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Accept", HeaderValue::from_static("application/json")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + match serde_json::from_str::(&local_content) { + Ok(e) => { + return Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: Some(e), + }) + } + Err(e) => return Err(datadog::Error::Serde(e)), + }; + } else { + let local_entity: Option = + serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } + + /// Retrieves a specific degradation template by its ID. + pub async fn get_degradation_template( + &self, + page_id: uuid::Uuid, + template_id: uuid::Uuid, + params: GetDegradationTemplateOptionalParams, + ) -> Result< + crate::datadogV2::model::DegradationTemplate, + datadog::Error, + > { + match self + .get_degradation_template_with_http_info(page_id, template_id, params) + .await + { + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(datadog::Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } + Err(err) => Err(err), + } + } + + /// Retrieves a specific degradation template by its ID. + pub async fn get_degradation_template_with_http_info( + &self, + page_id: uuid::Uuid, + template_id: uuid::Uuid, + params: GetDegradationTemplateOptionalParams, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.get_degradation_template"; + + // unbox and build optional parameters + let include = params.include; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/statuspages/{page_id}/degradation_templates/{template_id}", + local_configuration.get_operation_host(operation_id), + page_id = datadog::urlencode(page_id.to_string()), + template_id = datadog::urlencode(template_id.to_string()) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::GET, local_uri_str.as_str()); + + if let Some(ref local_query_param) = include { + local_req_builder = + local_req_builder.query(&[("include", &local_query_param.to_string())]); + }; // build headers let mut headers = HeaderMap::new(); - headers.insert("Accept", HeaderValue::from_static("*/*")); + headers.insert("Accept", HeaderValue::from_static("application/json")); // build user agent match HeaderValue::from_str(local_configuration.user_agent.as_str()) { @@ -1894,13 +3269,20 @@ impl StatusPagesAPI { log::debug!("response content: {}", local_content); if !local_status.is_client_error() && !local_status.is_server_error() { - Ok(datadog::ResponseContent { - status: local_status, - content: local_content, - entity: None, - }) + match serde_json::from_str::( + &local_content, + ) { + Ok(e) => { + return Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: Some(e), + }) + } + Err(e) => return Err(datadog::Error::Serde(e)), + }; } else { - let local_entity: Option = + let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = datadog::ResponseContent { status: local_status, @@ -1911,38 +3293,65 @@ impl StatusPagesAPI { } } - /// Deletes a status page by its ID. - pub async fn delete_status_page( + /// Retrieves a specific maintenance by its ID. + pub async fn get_maintenance( &self, page_id: uuid::Uuid, - ) -> Result<(), datadog::Error> { - match self.delete_status_page_with_http_info(page_id).await { - Ok(_) => Ok(()), + maintenance_id: uuid::Uuid, + params: GetMaintenanceOptionalParams, + ) -> Result> { + match self + .get_maintenance_with_http_info(page_id, maintenance_id, params) + .await + { + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(datadog::Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } - /// Deletes a status page by its ID. - pub async fn delete_status_page_with_http_info( + /// Retrieves a specific maintenance by its ID. + pub async fn get_maintenance_with_http_info( &self, page_id: uuid::Uuid, - ) -> Result, datadog::Error> { + maintenance_id: uuid::Uuid, + params: GetMaintenanceOptionalParams, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { let local_configuration = &self.config; - let operation_id = "v2.delete_status_page"; + let operation_id = "v2.get_maintenance"; + + // unbox and build optional parameters + let include = params.include; let local_client = &self.client; let local_uri_str = format!( - "{}/api/v2/statuspages/{page_id}", + "{}/api/v2/statuspages/{page_id}/maintenances/{maintenance_id}", local_configuration.get_operation_host(operation_id), - page_id = datadog::urlencode(page_id.to_string()) + page_id = datadog::urlencode(page_id.to_string()), + maintenance_id = datadog::urlencode(maintenance_id.to_string()) ); let mut local_req_builder = - local_client.request(reqwest::Method::DELETE, local_uri_str.as_str()); + local_client.request(reqwest::Method::GET, local_uri_str.as_str()); + + if let Some(ref local_query_param) = include { + local_req_builder = + local_req_builder.query(&[("include", &local_query_param.to_string())]); + }; // build headers let mut headers = HeaderMap::new(); - headers.insert("Accept", HeaderValue::from_static("*/*")); + headers.insert("Accept", HeaderValue::from_static("application/json")); // build user agent match HeaderValue::from_str(local_configuration.user_agent.as_str()) { @@ -1982,13 +3391,18 @@ impl StatusPagesAPI { log::debug!("response content: {}", local_content); if !local_status.is_client_error() && !local_status.is_server_error() { - Ok(datadog::ResponseContent { - status: local_status, - content: local_content, - entity: None, - }) + match serde_json::from_str::(&local_content) { + Ok(e) => { + return Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: Some(e), + }) + } + Err(e) => return Err(datadog::Error::Serde(e)), + }; } else { - let local_entity: Option = + let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = datadog::ResponseContent { status: local_status, @@ -1999,26 +3413,18 @@ impl StatusPagesAPI { } } - /// Edits a specific degradation update. - pub async fn edit_degradation_update( + /// Retrieves a specific maintenance template by its ID. + pub async fn get_maintenance_template( &self, - degradation_id: uuid::Uuid, page_id: uuid::Uuid, - update_id: uuid::Uuid, - body: crate::datadogV2::model::PatchDegradationUpdateRequest, - params: EditDegradationUpdateOptionalParams, + template_id: uuid::Uuid, + params: GetMaintenanceTemplateOptionalParams, ) -> Result< - crate::datadogV2::model::DegradationUpdate, - datadog::Error, + crate::datadogV2::model::MaintenanceTemplate, + datadog::Error, > { match self - .edit_degradation_update_with_http_info( - degradation_id, - page_id, - update_id, - body, - params, - ) + .get_maintenance_template_with_http_info(page_id, template_id, params) .await { Ok(response_content) => { @@ -2034,20 +3440,18 @@ impl StatusPagesAPI { } } - /// Edits a specific degradation update. - pub async fn edit_degradation_update_with_http_info( + /// Retrieves a specific maintenance template by its ID. + pub async fn get_maintenance_template_with_http_info( &self, - degradation_id: uuid::Uuid, page_id: uuid::Uuid, - update_id: uuid::Uuid, - body: crate::datadogV2::model::PatchDegradationUpdateRequest, - params: EditDegradationUpdateOptionalParams, + template_id: uuid::Uuid, + params: GetMaintenanceTemplateOptionalParams, ) -> Result< - datadog::ResponseContent, - datadog::Error, + datadog::ResponseContent, + datadog::Error, > { let local_configuration = &self.config; - let operation_id = "v2.edit_degradation_update"; + let operation_id = "v2.get_maintenance_template"; // unbox and build optional parameters let include = params.include; @@ -2055,14 +3459,13 @@ impl StatusPagesAPI { let local_client = &self.client; let local_uri_str = format!( - "{}/api/v2/statuspages/{page_id}/degradations/{degradation_id}/updates/{update_id}", + "{}/api/v2/statuspages/{page_id}/maintenance_templates/{template_id}", local_configuration.get_operation_host(operation_id), - degradation_id = datadog::urlencode(degradation_id.to_string()), page_id = datadog::urlencode(page_id.to_string()), - update_id = datadog::urlencode(update_id.to_string()) + template_id = datadog::urlencode(template_id.to_string()) ); let mut local_req_builder = - local_client.request(reqwest::Method::PATCH, local_uri_str.as_str()); + local_client.request(reqwest::Method::GET, local_uri_str.as_str()); if let Some(ref local_query_param) = include { local_req_builder = @@ -2071,7 +3474,6 @@ impl StatusPagesAPI { // build headers let mut headers = HeaderMap::new(); - headers.insert("Content-Type", HeaderValue::from_static("application/json")); headers.insert("Accept", HeaderValue::from_static("application/json")); // build user agent @@ -2102,52 +3504,6 @@ impl StatusPagesAPI { ); }; - // build body parameters - let output = Vec::new(); - let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter); - if body.serialize(&mut ser).is_ok() { - if let Some(content_encoding) = headers.get("Content-Encoding") { - match content_encoding.to_str().unwrap_or_default() { - "gzip" => { - let mut enc = GzEncoder::new(Vec::new(), Compression::default()); - let _ = enc.write_all(ser.into_inner().as_slice()); - match enc.finish() { - Ok(buf) => { - local_req_builder = local_req_builder.body(buf); - } - Err(e) => return Err(datadog::Error::Io(e)), - } - } - "deflate" => { - let mut enc = ZlibEncoder::new(Vec::new(), Compression::default()); - let _ = enc.write_all(ser.into_inner().as_slice()); - match enc.finish() { - Ok(buf) => { - local_req_builder = local_req_builder.body(buf); - } - Err(e) => return Err(datadog::Error::Io(e)), - } - } - #[cfg(feature = "zstd")] - "zstd1" => { - let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap(); - let _ = enc.write_all(ser.into_inner().as_slice()); - match enc.finish() { - Ok(buf) => { - local_req_builder = local_req_builder.body(buf); - } - Err(e) => return Err(datadog::Error::Io(e)), - } - } - _ => { - local_req_builder = local_req_builder.body(ser.into_inner()); - } - } - } else { - local_req_builder = local_req_builder.body(ser.into_inner()); - } - } - local_req_builder = local_req_builder.headers(headers); let local_req = local_req_builder.build()?; log::debug!("request content: {:?}", local_req.body()); @@ -2158,8 +3514,9 @@ impl StatusPagesAPI { log::debug!("response content: {}", local_content); if !local_status.is_client_error() && !local_status.is_server_error() { - match serde_json::from_str::(&local_content) - { + match serde_json::from_str::( + &local_content, + ) { Ok(e) => { return Ok(datadog::ResponseContent { status: local_status, @@ -2170,7 +3527,7 @@ impl StatusPagesAPI { Err(e) => return Err(datadog::Error::Serde(e)), }; } else { - let local_entity: Option = + let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = datadog::ResponseContent { status: local_status, @@ -2181,18 +3538,13 @@ impl StatusPagesAPI { } } - /// Retrieves a specific component by its ID. - pub async fn get_component( + /// Retrieves a specific status page by its ID. + pub async fn get_status_page( &self, page_id: uuid::Uuid, - component_id: uuid::Uuid, - params: GetComponentOptionalParams, - ) -> Result> - { - match self - .get_component_with_http_info(page_id, component_id, params) - .await - { + params: GetStatusPageOptionalParams, + ) -> Result> { + match self.get_status_page_with_http_info(page_id, params).await { Ok(response_content) => { if let Some(e) = response_content.entity { Ok(e) @@ -2206,18 +3558,17 @@ impl StatusPagesAPI { } } - /// Retrieves a specific component by its ID. - pub async fn get_component_with_http_info( + /// Retrieves a specific status page by its ID. + pub async fn get_status_page_with_http_info( &self, page_id: uuid::Uuid, - component_id: uuid::Uuid, - params: GetComponentOptionalParams, + params: GetStatusPageOptionalParams, ) -> Result< - datadog::ResponseContent, - datadog::Error, + datadog::ResponseContent, + datadog::Error, > { let local_configuration = &self.config; - let operation_id = "v2.get_component"; + let operation_id = "v2.get_status_page"; // unbox and build optional parameters let include = params.include; @@ -2225,10 +3576,9 @@ impl StatusPagesAPI { let local_client = &self.client; let local_uri_str = format!( - "{}/api/v2/statuspages/{page_id}/components/{component_id}", + "{}/api/v2/statuspages/{page_id}", local_configuration.get_operation_host(operation_id), - page_id = datadog::urlencode(page_id.to_string()), - component_id = datadog::urlencode(component_id.to_string()) + page_id = datadog::urlencode(page_id.to_string()) ); let mut local_req_builder = local_client.request(reqwest::Method::GET, local_uri_str.as_str()); @@ -2280,9 +3630,7 @@ impl StatusPagesAPI { log::debug!("response content: {}", local_content); if !local_status.is_client_error() && !local_status.is_server_error() { - match serde_json::from_str::( - &local_content, - ) { + match serde_json::from_str::(&local_content) { Ok(e) => { return Ok(datadog::ResponseContent { status: local_status, @@ -2293,7 +3641,8 @@ impl StatusPagesAPI { Err(e) => return Err(datadog::Error::Serde(e)), }; } else { - let local_entity: Option = serde_json::from_str(&local_content).ok(); + let local_entity: Option = + serde_json::from_str(&local_content).ok(); let local_error = datadog::ResponseContent { status: local_status, content: local_content, @@ -2303,17 +3652,16 @@ impl StatusPagesAPI { } } - /// Retrieves a specific degradation by its ID. - pub async fn get_degradation( + /// Lists all components for a status page. + pub async fn list_components( &self, page_id: uuid::Uuid, - degradation_id: uuid::Uuid, - params: GetDegradationOptionalParams, - ) -> Result> { - match self - .get_degradation_with_http_info(page_id, degradation_id, params) - .await - { + params: ListComponentsOptionalParams, + ) -> Result< + crate::datadogV2::model::StatusPagesComponentArray, + datadog::Error, + > { + match self.list_components_with_http_info(page_id, params).await { Ok(response_content) => { if let Some(e) = response_content.entity { Ok(e) @@ -2327,18 +3675,17 @@ impl StatusPagesAPI { } } - /// Retrieves a specific degradation by its ID. - pub async fn get_degradation_with_http_info( + /// Lists all components for a status page. + pub async fn list_components_with_http_info( &self, page_id: uuid::Uuid, - degradation_id: uuid::Uuid, - params: GetDegradationOptionalParams, + params: ListComponentsOptionalParams, ) -> Result< - datadog::ResponseContent, - datadog::Error, + datadog::ResponseContent, + datadog::Error, > { let local_configuration = &self.config; - let operation_id = "v2.get_degradation"; + let operation_id = "v2.list_components"; // unbox and build optional parameters let include = params.include; @@ -2346,10 +3693,9 @@ impl StatusPagesAPI { let local_client = &self.client; let local_uri_str = format!( - "{}/api/v2/statuspages/{page_id}/degradations/{degradation_id}", + "{}/api/v2/statuspages/{page_id}/components", local_configuration.get_operation_host(operation_id), - page_id = datadog::urlencode(page_id.to_string()), - degradation_id = datadog::urlencode(degradation_id.to_string()) + page_id = datadog::urlencode(page_id.to_string()) ); let mut local_req_builder = local_client.request(reqwest::Method::GET, local_uri_str.as_str()); @@ -2401,7 +3747,9 @@ impl StatusPagesAPI { log::debug!("response content: {}", local_content); if !local_status.is_client_error() && !local_status.is_server_error() { - match serde_json::from_str::(&local_content) { + match serde_json::from_str::( + &local_content, + ) { Ok(e) => { return Ok(datadog::ResponseContent { status: local_status, @@ -2412,7 +3760,7 @@ impl StatusPagesAPI { Err(e) => return Err(datadog::Error::Serde(e)), }; } else { - let local_entity: Option = + let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = datadog::ResponseContent { status: local_status, @@ -2422,16 +3770,18 @@ impl StatusPagesAPI { Err(datadog::Error::ResponseError(local_error)) } } - - /// Retrieves a specific maintenance by its ID. - pub async fn get_maintenance( + + /// Lists all degradation templates for a status page. + pub async fn list_degradation_templates( &self, page_id: uuid::Uuid, - maintenance_id: uuid::Uuid, - params: GetMaintenanceOptionalParams, - ) -> Result> { + params: ListDegradationTemplatesOptionalParams, + ) -> Result< + crate::datadogV2::model::DegradationTemplateArray, + datadog::Error, + > { match self - .get_maintenance_with_http_info(page_id, maintenance_id, params) + .list_degradation_templates_with_http_info(page_id, params) .await { Ok(response_content) => { @@ -2447,18 +3797,17 @@ impl StatusPagesAPI { } } - /// Retrieves a specific maintenance by its ID. - pub async fn get_maintenance_with_http_info( + /// Lists all degradation templates for a status page. + pub async fn list_degradation_templates_with_http_info( &self, page_id: uuid::Uuid, - maintenance_id: uuid::Uuid, - params: GetMaintenanceOptionalParams, + params: ListDegradationTemplatesOptionalParams, ) -> Result< - datadog::ResponseContent, - datadog::Error, + datadog::ResponseContent, + datadog::Error, > { let local_configuration = &self.config; - let operation_id = "v2.get_maintenance"; + let operation_id = "v2.list_degradation_templates"; // unbox and build optional parameters let include = params.include; @@ -2466,10 +3815,9 @@ impl StatusPagesAPI { let local_client = &self.client; let local_uri_str = format!( - "{}/api/v2/statuspages/{page_id}/maintenances/{maintenance_id}", + "{}/api/v2/statuspages/{page_id}/degradation_templates", local_configuration.get_operation_host(operation_id), - page_id = datadog::urlencode(page_id.to_string()), - maintenance_id = datadog::urlencode(maintenance_id.to_string()) + page_id = datadog::urlencode(page_id.to_string()) ); let mut local_req_builder = local_client.request(reqwest::Method::GET, local_uri_str.as_str()); @@ -2521,7 +3869,9 @@ impl StatusPagesAPI { log::debug!("response content: {}", local_content); if !local_status.is_client_error() && !local_status.is_server_error() { - match serde_json::from_str::(&local_content) { + match serde_json::from_str::( + &local_content, + ) { Ok(e) => { return Ok(datadog::ResponseContent { status: local_status, @@ -2532,7 +3882,7 @@ impl StatusPagesAPI { Err(e) => return Err(datadog::Error::Serde(e)), }; } else { - let local_entity: Option = + let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = datadog::ResponseContent { status: local_status, @@ -2543,13 +3893,13 @@ impl StatusPagesAPI { } } - /// Retrieves a specific status page by its ID. - pub async fn get_status_page( + /// Lists all degradations for the organization. Optionally filter by status and page. + pub async fn list_degradations( &self, - page_id: uuid::Uuid, - params: GetStatusPageOptionalParams, - ) -> Result> { - match self.get_status_page_with_http_info(page_id, params).await { + params: ListDegradationsOptionalParams, + ) -> Result> + { + match self.list_degradations_with_http_info(params).await { Ok(response_content) => { if let Some(e) = response_content.entity { Ok(e) @@ -2563,35 +3913,63 @@ impl StatusPagesAPI { } } - /// Retrieves a specific status page by its ID. - pub async fn get_status_page_with_http_info( + /// Lists all degradations for the organization. Optionally filter by status and page. + pub async fn list_degradations_with_http_info( &self, - page_id: uuid::Uuid, - params: GetStatusPageOptionalParams, + params: ListDegradationsOptionalParams, ) -> Result< - datadog::ResponseContent, - datadog::Error, + datadog::ResponseContent, + datadog::Error, > { let local_configuration = &self.config; - let operation_id = "v2.get_status_page"; + let operation_id = "v2.list_degradations"; // unbox and build optional parameters + let filter_page_id = params.filter_page_id; + let page_offset = params.page_offset; + let page_limit = params.page_limit; let include = params.include; + let filter_status = params.filter_status; + let sort = params.sort; + let filter_source_id = params.filter_source_id; let local_client = &self.client; let local_uri_str = format!( - "{}/api/v2/statuspages/{page_id}", - local_configuration.get_operation_host(operation_id), - page_id = datadog::urlencode(page_id.to_string()) + "{}/api/v2/statuspages/degradations", + local_configuration.get_operation_host(operation_id) ); let mut local_req_builder = local_client.request(reqwest::Method::GET, local_uri_str.as_str()); + if let Some(ref local_query_param) = filter_page_id { + local_req_builder = + local_req_builder.query(&[("filter[page_id]", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = page_offset { + local_req_builder = + local_req_builder.query(&[("page[offset]", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = page_limit { + local_req_builder = + local_req_builder.query(&[("page[limit]", &local_query_param.to_string())]); + }; if let Some(ref local_query_param) = include { local_req_builder = local_req_builder.query(&[("include", &local_query_param.to_string())]); }; + if let Some(ref local_query_param) = filter_status { + local_req_builder = + local_req_builder.query(&[("filter[status]", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = sort { + local_req_builder = + local_req_builder.query(&[("sort", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = filter_source_id { + local_req_builder = + local_req_builder.query(&[("filter[source_id]", &local_query_param.to_string())]); + }; // build headers let mut headers = HeaderMap::new(); @@ -2635,7 +4013,8 @@ impl StatusPagesAPI { log::debug!("response content: {}", local_content); if !local_status.is_client_error() && !local_status.is_server_error() { - match serde_json::from_str::(&local_content) { + match serde_json::from_str::(&local_content) + { Ok(e) => { return Ok(datadog::ResponseContent { status: local_status, @@ -2646,7 +4025,7 @@ impl StatusPagesAPI { Err(e) => return Err(datadog::Error::Serde(e)), }; } else { - let local_entity: Option = + let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = datadog::ResponseContent { status: local_status, @@ -2657,16 +4036,19 @@ impl StatusPagesAPI { } } - /// Lists all components for a status page. - pub async fn list_components( + /// Lists all maintenance templates for a status page. + pub async fn list_maintenance_templates( &self, page_id: uuid::Uuid, - params: ListComponentsOptionalParams, + params: ListMaintenanceTemplatesOptionalParams, ) -> Result< - crate::datadogV2::model::StatusPagesComponentArray, - datadog::Error, + crate::datadogV2::model::MaintenanceTemplateArray, + datadog::Error, > { - match self.list_components_with_http_info(page_id, params).await { + match self + .list_maintenance_templates_with_http_info(page_id, params) + .await + { Ok(response_content) => { if let Some(e) = response_content.entity { Ok(e) @@ -2680,17 +4062,17 @@ impl StatusPagesAPI { } } - /// Lists all components for a status page. - pub async fn list_components_with_http_info( + /// Lists all maintenance templates for a status page. + pub async fn list_maintenance_templates_with_http_info( &self, page_id: uuid::Uuid, - params: ListComponentsOptionalParams, + params: ListMaintenanceTemplatesOptionalParams, ) -> Result< - datadog::ResponseContent, - datadog::Error, + datadog::ResponseContent, + datadog::Error, > { let local_configuration = &self.config; - let operation_id = "v2.list_components"; + let operation_id = "v2.list_maintenance_templates"; // unbox and build optional parameters let include = params.include; @@ -2698,7 +4080,7 @@ impl StatusPagesAPI { let local_client = &self.client; let local_uri_str = format!( - "{}/api/v2/statuspages/{page_id}/components", + "{}/api/v2/statuspages/{page_id}/maintenance_templates", local_configuration.get_operation_host(operation_id), page_id = datadog::urlencode(page_id.to_string()) ); @@ -2752,7 +4134,7 @@ impl StatusPagesAPI { log::debug!("response content: {}", local_content); if !local_status.is_client_error() && !local_status.is_server_error() { - match serde_json::from_str::( + match serde_json::from_str::( &local_content, ) { Ok(e) => { @@ -2765,7 +4147,7 @@ impl StatusPagesAPI { Err(e) => return Err(datadog::Error::Serde(e)), }; } else { - let local_entity: Option = + let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = datadog::ResponseContent { status: local_status, @@ -2776,13 +4158,13 @@ impl StatusPagesAPI { } } - /// Lists all degradations for the organization. Optionally filter by status and page. - pub async fn list_degradations( + /// Lists all maintenances for the organization. Optionally filter by status and page. + pub async fn list_maintenances( &self, - params: ListDegradationsOptionalParams, - ) -> Result> + params: ListMaintenancesOptionalParams, + ) -> Result> { - match self.list_degradations_with_http_info(params).await { + match self.list_maintenances_with_http_info(params).await { Ok(response_content) => { if let Some(e) = response_content.entity { Ok(e) @@ -2796,16 +4178,16 @@ impl StatusPagesAPI { } } - /// Lists all degradations for the organization. Optionally filter by status and page. - pub async fn list_degradations_with_http_info( + /// Lists all maintenances for the organization. Optionally filter by status and page. + pub async fn list_maintenances_with_http_info( &self, - params: ListDegradationsOptionalParams, + params: ListMaintenancesOptionalParams, ) -> Result< - datadog::ResponseContent, - datadog::Error, + datadog::ResponseContent, + datadog::Error, > { let local_configuration = &self.config; - let operation_id = "v2.list_degradations"; + let operation_id = "v2.list_maintenances"; // unbox and build optional parameters let filter_page_id = params.filter_page_id; @@ -2818,7 +4200,7 @@ impl StatusPagesAPI { let local_client = &self.client; let local_uri_str = format!( - "{}/api/v2/statuspages/degradations", + "{}/api/v2/statuspages/maintenances", local_configuration.get_operation_host(operation_id) ); let mut local_req_builder = @@ -2891,7 +4273,7 @@ impl StatusPagesAPI { log::debug!("response content: {}", local_content); if !local_status.is_client_error() && !local_status.is_server_error() { - match serde_json::from_str::(&local_content) + match serde_json::from_str::(&local_content) { Ok(e) => { return Ok(datadog::ResponseContent { @@ -2903,7 +4285,7 @@ impl StatusPagesAPI { Err(e) => return Err(datadog::Error::Serde(e)), }; } else { - let local_entity: Option = + let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = datadog::ResponseContent { status: local_status, @@ -2914,13 +4296,13 @@ impl StatusPagesAPI { } } - /// Lists all maintenances for the organization. Optionally filter by status and page. - pub async fn list_maintenances( + /// Lists all status pages for the organization. + pub async fn list_status_pages( &self, - params: ListMaintenancesOptionalParams, - ) -> Result> + params: ListStatusPagesOptionalParams, + ) -> Result> { - match self.list_maintenances_with_http_info(params).await { + match self.list_status_pages_with_http_info(params).await { Ok(response_content) => { if let Some(e) = response_content.entity { Ok(e) @@ -2934,38 +4316,32 @@ impl StatusPagesAPI { } } - /// Lists all maintenances for the organization. Optionally filter by status and page. - pub async fn list_maintenances_with_http_info( + /// Lists all status pages for the organization. + pub async fn list_status_pages_with_http_info( &self, - params: ListMaintenancesOptionalParams, + params: ListStatusPagesOptionalParams, ) -> Result< - datadog::ResponseContent, - datadog::Error, + datadog::ResponseContent, + datadog::Error, > { let local_configuration = &self.config; - let operation_id = "v2.list_maintenances"; + let operation_id = "v2.list_status_pages"; // unbox and build optional parameters - let filter_page_id = params.filter_page_id; let page_offset = params.page_offset; let page_limit = params.page_limit; + let filter_domain_prefix = params.filter_domain_prefix; let include = params.include; - let filter_status = params.filter_status; - let sort = params.sort; let local_client = &self.client; let local_uri_str = format!( - "{}/api/v2/statuspages/maintenances", + "{}/api/v2/statuspages", local_configuration.get_operation_host(operation_id) ); let mut local_req_builder = local_client.request(reqwest::Method::GET, local_uri_str.as_str()); - if let Some(ref local_query_param) = filter_page_id { - local_req_builder = - local_req_builder.query(&[("filter[page_id]", &local_query_param.to_string())]); - }; if let Some(ref local_query_param) = page_offset { local_req_builder = local_req_builder.query(&[("page[offset]", &local_query_param.to_string())]); @@ -2974,22 +4350,111 @@ impl StatusPagesAPI { local_req_builder = local_req_builder.query(&[("page[limit]", &local_query_param.to_string())]); }; + if let Some(ref local_query_param) = filter_domain_prefix { + local_req_builder = local_req_builder + .query(&[("filter[domain_prefix]", &local_query_param.to_string())]); + }; if let Some(ref local_query_param) = include { local_req_builder = local_req_builder.query(&[("include", &local_query_param.to_string())]); }; - if let Some(ref local_query_param) = filter_status { - local_req_builder = - local_req_builder.query(&[("filter[status]", &local_query_param.to_string())]); + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Accept", HeaderValue::from_static("application/json")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } }; - if let Some(ref local_query_param) = sort { - local_req_builder = - local_req_builder.query(&[("sort", &local_query_param.to_string())]); + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); }; + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + match serde_json::from_str::(&local_content) { + Ok(e) => { + return Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: Some(e), + }) + } + Err(e) => return Err(datadog::Error::Serde(e)), + }; + } else { + let local_entity: Option = + serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } + + /// Publishes a status page. For pages of type `public`, makes the status page available on the public internet and requires the `status_pages_public_page_publish` permission. For pages of type `internal`, makes the status page available under the `status-pages/$domain_prefix/view` route within the Datadog organization and requires the `status_pages_internal_page_publish` permission. The `status_pages_settings_write` permission is temporarily honored as we migrate publishing functionality from the update status page endpoint to the publish status page endpoint. + pub async fn publish_status_page( + &self, + page_id: uuid::Uuid, + ) -> Result<(), datadog::Error> { + match self.publish_status_page_with_http_info(page_id).await { + Ok(_) => Ok(()), + Err(err) => Err(err), + } + } + + /// Publishes a status page. For pages of type `public`, makes the status page available on the public internet and requires the `status_pages_public_page_publish` permission. For pages of type `internal`, makes the status page available under the `status-pages/$domain_prefix/view` route within the Datadog organization and requires the `status_pages_internal_page_publish` permission. The `status_pages_settings_write` permission is temporarily honored as we migrate publishing functionality from the update status page endpoint to the publish status page endpoint. + pub async fn publish_status_page_with_http_info( + &self, + page_id: uuid::Uuid, + ) -> Result, datadog::Error> { + let local_configuration = &self.config; + let operation_id = "v2.publish_status_page"; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/statuspages/{page_id}/publish", + local_configuration.get_operation_host(operation_id), + page_id = datadog::urlencode(page_id.to_string()) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::POST, local_uri_str.as_str()); + // build headers let mut headers = HeaderMap::new(); - headers.insert("Accept", HeaderValue::from_static("application/json")); + headers.insert("Accept", HeaderValue::from_static("*/*")); // build user agent match HeaderValue::from_str(local_configuration.user_agent.as_str()) { @@ -3029,19 +4494,13 @@ impl StatusPagesAPI { log::debug!("response content: {}", local_content); if !local_status.is_client_error() && !local_status.is_server_error() { - match serde_json::from_str::(&local_content) - { - Ok(e) => { - return Ok(datadog::ResponseContent { - status: local_status, - content: local_content, - entity: Some(e), - }) - } - Err(e) => return Err(datadog::Error::Serde(e)), - }; + Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: None, + }) } else { - let local_entity: Option = + let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = datadog::ResponseContent { status: local_status, @@ -3052,72 +4511,48 @@ impl StatusPagesAPI { } } - /// Lists all status pages for the organization. - pub async fn list_status_pages( + /// Soft-deletes a degradation update. + pub async fn soft_delete_degradation_update( &self, - params: ListStatusPagesOptionalParams, - ) -> Result> - { - match self.list_status_pages_with_http_info(params).await { - Ok(response_content) => { - if let Some(e) = response_content.entity { - Ok(e) - } else { - Err(datadog::Error::Serde(serde::de::Error::custom( - "response content was None", - ))) - } - } + degradation_id: uuid::Uuid, + page_id: uuid::Uuid, + update_id: uuid::Uuid, + ) -> Result<(), datadog::Error> { + match self + .soft_delete_degradation_update_with_http_info(degradation_id, page_id, update_id) + .await + { + Ok(_) => Ok(()), Err(err) => Err(err), } } - /// Lists all status pages for the organization. - pub async fn list_status_pages_with_http_info( + /// Soft-deletes a degradation update. + pub async fn soft_delete_degradation_update_with_http_info( &self, - params: ListStatusPagesOptionalParams, - ) -> Result< - datadog::ResponseContent, - datadog::Error, - > { + degradation_id: uuid::Uuid, + page_id: uuid::Uuid, + update_id: uuid::Uuid, + ) -> Result, datadog::Error> + { let local_configuration = &self.config; - let operation_id = "v2.list_status_pages"; - - // unbox and build optional parameters - let page_offset = params.page_offset; - let page_limit = params.page_limit; - let filter_domain_prefix = params.filter_domain_prefix; - let include = params.include; + let operation_id = "v2.soft_delete_degradation_update"; let local_client = &self.client; let local_uri_str = format!( - "{}/api/v2/statuspages", - local_configuration.get_operation_host(operation_id) + "{}/api/v2/statuspages/{page_id}/degradations/{degradation_id}/updates/{update_id}", + local_configuration.get_operation_host(operation_id), + degradation_id = datadog::urlencode(degradation_id.to_string()), + page_id = datadog::urlencode(page_id.to_string()), + update_id = datadog::urlencode(update_id.to_string()) ); let mut local_req_builder = - local_client.request(reqwest::Method::GET, local_uri_str.as_str()); - - if let Some(ref local_query_param) = page_offset { - local_req_builder = - local_req_builder.query(&[("page[offset]", &local_query_param.to_string())]); - }; - if let Some(ref local_query_param) = page_limit { - local_req_builder = - local_req_builder.query(&[("page[limit]", &local_query_param.to_string())]); - }; - if let Some(ref local_query_param) = filter_domain_prefix { - local_req_builder = local_req_builder - .query(&[("filter[domain_prefix]", &local_query_param.to_string())]); - }; - if let Some(ref local_query_param) = include { - local_req_builder = - local_req_builder.query(&[("include", &local_query_param.to_string())]); - }; + local_client.request(reqwest::Method::DELETE, local_uri_str.as_str()); // build headers let mut headers = HeaderMap::new(); - headers.insert("Accept", HeaderValue::from_static("application/json")); + headers.insert("Accept", HeaderValue::from_static("*/*")); // build user agent match HeaderValue::from_str(local_configuration.user_agent.as_str()) { @@ -3157,18 +4592,13 @@ impl StatusPagesAPI { log::debug!("response content: {}", local_content); if !local_status.is_client_error() && !local_status.is_server_error() { - match serde_json::from_str::(&local_content) { - Ok(e) => { - return Ok(datadog::ResponseContent { - status: local_status, - content: local_content, - entity: Some(e), - }) - } - Err(e) => return Err(datadog::Error::Serde(e)), - }; + Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: None, + }) } else { - let local_entity: Option = + let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = datadog::ResponseContent { status: local_status, @@ -3179,29 +4609,29 @@ impl StatusPagesAPI { } } - /// Publishes a status page. For pages of type `public`, makes the status page available on the public internet and requires the `status_pages_public_page_publish` permission. For pages of type `internal`, makes the status page available under the `status-pages/$domain_prefix/view` route within the Datadog organization and requires the `status_pages_internal_page_publish` permission. The `status_pages_settings_write` permission is temporarily honored as we migrate publishing functionality from the update status page endpoint to the publish status page endpoint. - pub async fn publish_status_page( + /// Unpublishes a status page. For pages of type `public`, removes the status page from the public internet and requires the `status_pages_public_page_publish` permission. For pages of type `internal`, removes the `status-pages/$domain_prefix/view` route from the Datadog organization and requires the `status_pages_internal_page_publish` permission. The `status_pages_settings_write` permission is temporarily honored as we migrate unpublishing functionality from the update status page endpoint to the unpublish status page endpoint. + pub async fn unpublish_status_page( &self, page_id: uuid::Uuid, - ) -> Result<(), datadog::Error> { - match self.publish_status_page_with_http_info(page_id).await { + ) -> Result<(), datadog::Error> { + match self.unpublish_status_page_with_http_info(page_id).await { Ok(_) => Ok(()), Err(err) => Err(err), } } - /// Publishes a status page. For pages of type `public`, makes the status page available on the public internet and requires the `status_pages_public_page_publish` permission. For pages of type `internal`, makes the status page available under the `status-pages/$domain_prefix/view` route within the Datadog organization and requires the `status_pages_internal_page_publish` permission. The `status_pages_settings_write` permission is temporarily honored as we migrate publishing functionality from the update status page endpoint to the publish status page endpoint. - pub async fn publish_status_page_with_http_info( + /// Unpublishes a status page. For pages of type `public`, removes the status page from the public internet and requires the `status_pages_public_page_publish` permission. For pages of type `internal`, removes the `status-pages/$domain_prefix/view` route from the Datadog organization and requires the `status_pages_internal_page_publish` permission. The `status_pages_settings_write` permission is temporarily honored as we migrate unpublishing functionality from the update status page endpoint to the unpublish status page endpoint. + pub async fn unpublish_status_page_with_http_info( &self, page_id: uuid::Uuid, - ) -> Result, datadog::Error> { + ) -> Result, datadog::Error> { let local_configuration = &self.config; - let operation_id = "v2.publish_status_page"; + let operation_id = "v2.unpublish_status_page"; let local_client = &self.client; let local_uri_str = format!( - "{}/api/v2/statuspages/{page_id}/publish", + "{}/api/v2/statuspages/{page_id}/unpublish", local_configuration.get_operation_host(operation_id), page_id = datadog::urlencode(page_id.to_string()) ); @@ -3256,7 +4686,7 @@ impl StatusPagesAPI { entity: None, }) } else { - let local_entity: Option = + let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = datadog::ResponseContent { status: local_status, @@ -3267,48 +4697,69 @@ impl StatusPagesAPI { } } - /// Soft-deletes a degradation update. - pub async fn soft_delete_degradation_update( + /// Updates an existing component's attributes. + pub async fn update_component( &self, - degradation_id: uuid::Uuid, page_id: uuid::Uuid, - update_id: uuid::Uuid, - ) -> Result<(), datadog::Error> { + component_id: uuid::Uuid, + body: crate::datadogV2::model::PatchComponentRequest, + params: UpdateComponentOptionalParams, + ) -> Result> + { match self - .soft_delete_degradation_update_with_http_info(degradation_id, page_id, update_id) + .update_component_with_http_info(page_id, component_id, body, params) .await { - Ok(_) => Ok(()), + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(datadog::Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } - /// Soft-deletes a degradation update. - pub async fn soft_delete_degradation_update_with_http_info( + /// Updates an existing component's attributes. + pub async fn update_component_with_http_info( &self, - degradation_id: uuid::Uuid, page_id: uuid::Uuid, - update_id: uuid::Uuid, - ) -> Result, datadog::Error> - { + component_id: uuid::Uuid, + body: crate::datadogV2::model::PatchComponentRequest, + params: UpdateComponentOptionalParams, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { let local_configuration = &self.config; - let operation_id = "v2.soft_delete_degradation_update"; + let operation_id = "v2.update_component"; + + // unbox and build optional parameters + let include = params.include; let local_client = &self.client; let local_uri_str = format!( - "{}/api/v2/statuspages/{page_id}/degradations/{degradation_id}/updates/{update_id}", + "{}/api/v2/statuspages/{page_id}/components/{component_id}", local_configuration.get_operation_host(operation_id), - degradation_id = datadog::urlencode(degradation_id.to_string()), page_id = datadog::urlencode(page_id.to_string()), - update_id = datadog::urlencode(update_id.to_string()) + component_id = datadog::urlencode(component_id.to_string()) ); let mut local_req_builder = - local_client.request(reqwest::Method::DELETE, local_uri_str.as_str()); + local_client.request(reqwest::Method::PATCH, local_uri_str.as_str()); + + if let Some(ref local_query_param) = include { + local_req_builder = + local_req_builder.query(&[("include", &local_query_param.to_string())]); + }; // build headers let mut headers = HeaderMap::new(); - headers.insert("Accept", HeaderValue::from_static("*/*")); + headers.insert("Content-Type", HeaderValue::from_static("application/json")); + headers.insert("Accept", HeaderValue::from_static("application/json")); // build user agent match HeaderValue::from_str(local_configuration.user_agent.as_str()) { @@ -3320,23 +4771,69 @@ impl StatusPagesAPI { HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), ) } - }; - - // build auth - if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { - headers.insert( - "DD-API-KEY", - HeaderValue::from_str(local_key.key.as_str()) - .expect("failed to parse DD-API-KEY header"), - ); - }; - if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { - headers.insert( - "DD-APPLICATION-KEY", - HeaderValue::from_str(local_key.key.as_str()) - .expect("failed to parse DD-APPLICATION-KEY header"), - ); - }; + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + // build body parameters + let output = Vec::new(); + let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter); + if body.serialize(&mut ser).is_ok() { + if let Some(content_encoding) = headers.get("Content-Encoding") { + match content_encoding.to_str().unwrap_or_default() { + "gzip" => { + let mut enc = GzEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + "deflate" => { + let mut enc = ZlibEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + #[cfg(feature = "zstd")] + "zstd1" => { + let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap(); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + _ => { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + } else { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } local_req_builder = local_req_builder.headers(headers); let local_req = local_req_builder.build()?; @@ -3348,13 +4845,20 @@ impl StatusPagesAPI { log::debug!("response content: {}", local_content); if !local_status.is_client_error() && !local_status.is_server_error() { - Ok(datadog::ResponseContent { - status: local_status, - content: local_content, - entity: None, - }) + match serde_json::from_str::( + &local_content, + ) { + Ok(e) => { + return Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: Some(e), + }) + } + Err(e) => return Err(datadog::Error::Serde(e)), + }; } else { - let local_entity: Option = + let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = datadog::ResponseContent { status: local_status, @@ -3365,38 +4869,73 @@ impl StatusPagesAPI { } } - /// Unpublishes a status page. For pages of type `public`, removes the status page from the public internet and requires the `status_pages_public_page_publish` permission. For pages of type `internal`, removes the `status-pages/$domain_prefix/view` route from the Datadog organization and requires the `status_pages_internal_page_publish` permission. The `status_pages_settings_write` permission is temporarily honored as we migrate unpublishing functionality from the update status page endpoint to the unpublish status page endpoint. - pub async fn unpublish_status_page( + /// Updates an existing degradation's attributes. + pub async fn update_degradation( &self, page_id: uuid::Uuid, - ) -> Result<(), datadog::Error> { - match self.unpublish_status_page_with_http_info(page_id).await { - Ok(_) => Ok(()), + degradation_id: uuid::Uuid, + body: crate::datadogV2::model::PatchDegradationRequest, + params: UpdateDegradationOptionalParams, + ) -> Result> { + match self + .update_degradation_with_http_info(page_id, degradation_id, body, params) + .await + { + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(datadog::Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } Err(err) => Err(err), } } - /// Unpublishes a status page. For pages of type `public`, removes the status page from the public internet and requires the `status_pages_public_page_publish` permission. For pages of type `internal`, removes the `status-pages/$domain_prefix/view` route from the Datadog organization and requires the `status_pages_internal_page_publish` permission. The `status_pages_settings_write` permission is temporarily honored as we migrate unpublishing functionality from the update status page endpoint to the unpublish status page endpoint. - pub async fn unpublish_status_page_with_http_info( + /// Updates an existing degradation's attributes. + pub async fn update_degradation_with_http_info( &self, page_id: uuid::Uuid, - ) -> Result, datadog::Error> { + degradation_id: uuid::Uuid, + body: crate::datadogV2::model::PatchDegradationRequest, + params: UpdateDegradationOptionalParams, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { let local_configuration = &self.config; - let operation_id = "v2.unpublish_status_page"; + let operation_id = "v2.update_degradation"; + + // unbox and build optional parameters + let notify_subscribers = params.notify_subscribers; + let include = params.include; let local_client = &self.client; let local_uri_str = format!( - "{}/api/v2/statuspages/{page_id}/unpublish", + "{}/api/v2/statuspages/{page_id}/degradations/{degradation_id}", local_configuration.get_operation_host(operation_id), - page_id = datadog::urlencode(page_id.to_string()) + page_id = datadog::urlencode(page_id.to_string()), + degradation_id = datadog::urlencode(degradation_id.to_string()) ); let mut local_req_builder = - local_client.request(reqwest::Method::POST, local_uri_str.as_str()); + local_client.request(reqwest::Method::PATCH, local_uri_str.as_str()); + + if let Some(ref local_query_param) = notify_subscribers { + local_req_builder = + local_req_builder.query(&[("notify_subscribers", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = include { + local_req_builder = + local_req_builder.query(&[("include", &local_query_param.to_string())]); + }; // build headers let mut headers = HeaderMap::new(); - headers.insert("Accept", HeaderValue::from_static("*/*")); + headers.insert("Content-Type", HeaderValue::from_static("application/json")); + headers.insert("Accept", HeaderValue::from_static("application/json")); // build user agent match HeaderValue::from_str(local_configuration.user_agent.as_str()) { @@ -3426,6 +4965,52 @@ impl StatusPagesAPI { ); }; + // build body parameters + let output = Vec::new(); + let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter); + if body.serialize(&mut ser).is_ok() { + if let Some(content_encoding) = headers.get("Content-Encoding") { + match content_encoding.to_str().unwrap_or_default() { + "gzip" => { + let mut enc = GzEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + "deflate" => { + let mut enc = ZlibEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + #[cfg(feature = "zstd")] + "zstd1" => { + let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap(); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + _ => { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + } else { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + local_req_builder = local_req_builder.headers(headers); let local_req = local_req_builder.build()?; log::debug!("request content: {:?}", local_req.body()); @@ -3436,13 +5021,18 @@ impl StatusPagesAPI { log::debug!("response content: {}", local_content); if !local_status.is_client_error() && !local_status.is_server_error() { - Ok(datadog::ResponseContent { - status: local_status, - content: local_content, - entity: None, - }) + match serde_json::from_str::(&local_content) { + Ok(e) => { + return Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: Some(e), + }) + } + Err(e) => return Err(datadog::Error::Serde(e)), + }; } else { - let local_entity: Option = + let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = datadog::ResponseContent { status: local_status, @@ -3453,17 +5043,19 @@ impl StatusPagesAPI { } } - /// Updates an existing component's attributes. - pub async fn update_component( + /// Updates an existing degradation template's attributes. + pub async fn update_degradation_template( &self, + template_id: uuid::Uuid, page_id: uuid::Uuid, - component_id: uuid::Uuid, - body: crate::datadogV2::model::PatchComponentRequest, - params: UpdateComponentOptionalParams, - ) -> Result> - { + body: crate::datadogV2::model::PatchDegradationTemplateRequest, + params: UpdateDegradationTemplateOptionalParams, + ) -> Result< + crate::datadogV2::model::DegradationTemplate, + datadog::Error, + > { match self - .update_component_with_http_info(page_id, component_id, body, params) + .update_degradation_template_with_http_info(template_id, page_id, body, params) .await { Ok(response_content) => { @@ -3479,19 +5071,19 @@ impl StatusPagesAPI { } } - /// Updates an existing component's attributes. - pub async fn update_component_with_http_info( + /// Updates an existing degradation template's attributes. + pub async fn update_degradation_template_with_http_info( &self, + template_id: uuid::Uuid, page_id: uuid::Uuid, - component_id: uuid::Uuid, - body: crate::datadogV2::model::PatchComponentRequest, - params: UpdateComponentOptionalParams, + body: crate::datadogV2::model::PatchDegradationTemplateRequest, + params: UpdateDegradationTemplateOptionalParams, ) -> Result< - datadog::ResponseContent, - datadog::Error, + datadog::ResponseContent, + datadog::Error, > { let local_configuration = &self.config; - let operation_id = "v2.update_component"; + let operation_id = "v2.update_degradation_template"; // unbox and build optional parameters let include = params.include; @@ -3499,10 +5091,10 @@ impl StatusPagesAPI { let local_client = &self.client; let local_uri_str = format!( - "{}/api/v2/statuspages/{page_id}/components/{component_id}", + "{}/api/v2/statuspages/{page_id}/degradation_templates/{template_id}", local_configuration.get_operation_host(operation_id), - page_id = datadog::urlencode(page_id.to_string()), - component_id = datadog::urlencode(component_id.to_string()) + template_id = datadog::urlencode(template_id.to_string()), + page_id = datadog::urlencode(page_id.to_string()) ); let mut local_req_builder = local_client.request(reqwest::Method::PATCH, local_uri_str.as_str()); @@ -3601,7 +5193,7 @@ impl StatusPagesAPI { log::debug!("response content: {}", local_content); if !local_status.is_client_error() && !local_status.is_server_error() { - match serde_json::from_str::( + match serde_json::from_str::( &local_content, ) { Ok(e) => { @@ -3614,7 +5206,7 @@ impl StatusPagesAPI { Err(e) => return Err(datadog::Error::Serde(e)), }; } else { - let local_entity: Option = + let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = datadog::ResponseContent { status: local_status, @@ -3625,16 +5217,16 @@ impl StatusPagesAPI { } } - /// Updates an existing degradation's attributes. - pub async fn update_degradation( + /// Updates an existing maintenance's attributes. + pub async fn update_maintenance( &self, page_id: uuid::Uuid, - degradation_id: uuid::Uuid, - body: crate::datadogV2::model::PatchDegradationRequest, - params: UpdateDegradationOptionalParams, - ) -> Result> { + maintenance_id: uuid::Uuid, + body: crate::datadogV2::model::PatchMaintenanceRequest, + params: UpdateMaintenanceOptionalParams, + ) -> Result> { match self - .update_degradation_with_http_info(page_id, degradation_id, body, params) + .update_maintenance_with_http_info(page_id, maintenance_id, body, params) .await { Ok(response_content) => { @@ -3650,19 +5242,19 @@ impl StatusPagesAPI { } } - /// Updates an existing degradation's attributes. - pub async fn update_degradation_with_http_info( + /// Updates an existing maintenance's attributes. + pub async fn update_maintenance_with_http_info( &self, page_id: uuid::Uuid, - degradation_id: uuid::Uuid, - body: crate::datadogV2::model::PatchDegradationRequest, - params: UpdateDegradationOptionalParams, + maintenance_id: uuid::Uuid, + body: crate::datadogV2::model::PatchMaintenanceRequest, + params: UpdateMaintenanceOptionalParams, ) -> Result< - datadog::ResponseContent, - datadog::Error, + datadog::ResponseContent, + datadog::Error, > { let local_configuration = &self.config; - let operation_id = "v2.update_degradation"; + let operation_id = "v2.update_maintenance"; // unbox and build optional parameters let notify_subscribers = params.notify_subscribers; @@ -3671,10 +5263,10 @@ impl StatusPagesAPI { let local_client = &self.client; let local_uri_str = format!( - "{}/api/v2/statuspages/{page_id}/degradations/{degradation_id}", + "{}/api/v2/statuspages/{page_id}/maintenances/{maintenance_id}", local_configuration.get_operation_host(operation_id), page_id = datadog::urlencode(page_id.to_string()), - degradation_id = datadog::urlencode(degradation_id.to_string()) + maintenance_id = datadog::urlencode(maintenance_id.to_string()) ); let mut local_req_builder = local_client.request(reqwest::Method::PATCH, local_uri_str.as_str()); @@ -3777,7 +5369,7 @@ impl StatusPagesAPI { log::debug!("response content: {}", local_content); if !local_status.is_client_error() && !local_status.is_server_error() { - match serde_json::from_str::(&local_content) { + match serde_json::from_str::(&local_content) { Ok(e) => { return Ok(datadog::ResponseContent { status: local_status, @@ -3788,7 +5380,7 @@ impl StatusPagesAPI { Err(e) => return Err(datadog::Error::Serde(e)), }; } else { - let local_entity: Option = + let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = datadog::ResponseContent { status: local_status, @@ -3799,16 +5391,19 @@ impl StatusPagesAPI { } } - /// Updates an existing maintenance's attributes. - pub async fn update_maintenance( + /// Updates an existing maintenance template's attributes. + pub async fn update_maintenance_template( &self, page_id: uuid::Uuid, - maintenance_id: uuid::Uuid, - body: crate::datadogV2::model::PatchMaintenanceRequest, - params: UpdateMaintenanceOptionalParams, - ) -> Result> { + template_id: uuid::Uuid, + body: crate::datadogV2::model::PatchMaintenanceTemplateRequest, + params: UpdateMaintenanceTemplateOptionalParams, + ) -> Result< + crate::datadogV2::model::MaintenanceTemplate, + datadog::Error, + > { match self - .update_maintenance_with_http_info(page_id, maintenance_id, body, params) + .update_maintenance_template_with_http_info(page_id, template_id, body, params) .await { Ok(response_content) => { @@ -3824,39 +5419,34 @@ impl StatusPagesAPI { } } - /// Updates an existing maintenance's attributes. - pub async fn update_maintenance_with_http_info( + /// Updates an existing maintenance template's attributes. + pub async fn update_maintenance_template_with_http_info( &self, page_id: uuid::Uuid, - maintenance_id: uuid::Uuid, - body: crate::datadogV2::model::PatchMaintenanceRequest, - params: UpdateMaintenanceOptionalParams, + template_id: uuid::Uuid, + body: crate::datadogV2::model::PatchMaintenanceTemplateRequest, + params: UpdateMaintenanceTemplateOptionalParams, ) -> Result< - datadog::ResponseContent, - datadog::Error, + datadog::ResponseContent, + datadog::Error, > { let local_configuration = &self.config; - let operation_id = "v2.update_maintenance"; + let operation_id = "v2.update_maintenance_template"; // unbox and build optional parameters - let notify_subscribers = params.notify_subscribers; let include = params.include; let local_client = &self.client; let local_uri_str = format!( - "{}/api/v2/statuspages/{page_id}/maintenances/{maintenance_id}", + "{}/api/v2/statuspages/{page_id}/maintenance_templates/{template_id}", local_configuration.get_operation_host(operation_id), page_id = datadog::urlencode(page_id.to_string()), - maintenance_id = datadog::urlencode(maintenance_id.to_string()) + template_id = datadog::urlencode(template_id.to_string()) ); let mut local_req_builder = local_client.request(reqwest::Method::PATCH, local_uri_str.as_str()); - if let Some(ref local_query_param) = notify_subscribers { - local_req_builder = - local_req_builder.query(&[("notify_subscribers", &local_query_param.to_string())]); - }; if let Some(ref local_query_param) = include { local_req_builder = local_req_builder.query(&[("include", &local_query_param.to_string())]); @@ -3951,7 +5541,9 @@ impl StatusPagesAPI { log::debug!("response content: {}", local_content); if !local_status.is_client_error() && !local_status.is_server_error() { - match serde_json::from_str::(&local_content) { + match serde_json::from_str::( + &local_content, + ) { Ok(e) => { return Ok(datadog::ResponseContent { status: local_status, @@ -3962,7 +5554,7 @@ impl StatusPagesAPI { Err(e) => return Err(datadog::Error::Serde(e)), }; } else { - let local_entity: Option = + let local_entity: Option = serde_json::from_str(&local_content).ok(); let local_error = datadog::ResponseContent { status: local_status, diff --git a/src/datadogV2/model/mod.rs b/src/datadogV2/model/mod.rs index afd71a72d..3e1b0740c 100644 --- a/src/datadogV2/model/mod.rs +++ b/src/datadogV2/model/mod.rs @@ -12422,6 +12422,12 @@ pub mod model_degradation_data_relationships_status_page; pub use self::model_degradation_data_relationships_status_page::DegradationDataRelationshipsStatusPage; pub mod model_degradation_data_relationships_status_page_data; pub use self::model_degradation_data_relationships_status_page_data::DegradationDataRelationshipsStatusPageData; +pub mod model_degradation_data_relationships_template; +pub use self::model_degradation_data_relationships_template::DegradationDataRelationshipsTemplate; +pub mod model_degradation_data_relationships_template_data; +pub use self::model_degradation_data_relationships_template_data::DegradationDataRelationshipsTemplateData; +pub mod model_patch_degradation_template_request_data_type; +pub use self::model_patch_degradation_template_request_data_type::PatchDegradationTemplateRequestDataType; pub mod model_patch_degradation_request_data_type; pub use self::model_patch_degradation_request_data_type::PatchDegradationRequestDataType; pub mod model_status_page_as_included; @@ -12474,6 +12480,12 @@ pub mod model_maintenance_data_relationships_status_page; pub use self::model_maintenance_data_relationships_status_page::MaintenanceDataRelationshipsStatusPage; pub mod model_maintenance_data_relationships_status_page_data; pub use self::model_maintenance_data_relationships_status_page_data::MaintenanceDataRelationshipsStatusPageData; +pub mod model_maintenance_data_relationships_template; +pub use self::model_maintenance_data_relationships_template::MaintenanceDataRelationshipsTemplate; +pub mod model_maintenance_data_relationships_template_data; +pub use self::model_maintenance_data_relationships_template_data::MaintenanceDataRelationshipsTemplateData; +pub mod model_patch_maintenance_template_request_data_type; +pub use self::model_patch_maintenance_template_request_data_type::PatchMaintenanceTemplateRequestDataType; pub mod model_patch_maintenance_request_data_type; pub use self::model_patch_maintenance_request_data_type::PatchMaintenanceRequestDataType; pub mod model_patch_status_page_request; @@ -12558,6 +12570,54 @@ pub mod model_patch_component_request_data; pub use self::model_patch_component_request_data::PatchComponentRequestData; pub mod model_patch_component_request_data_attributes; pub use self::model_patch_component_request_data_attributes::PatchComponentRequestDataAttributes; +pub mod model_degradation_template_array; +pub use self::model_degradation_template_array::DegradationTemplateArray; +pub mod model_degradation_template_data; +pub use self::model_degradation_template_data::DegradationTemplateData; +pub mod model_degradation_template_data_attributes; +pub use self::model_degradation_template_data_attributes::DegradationTemplateDataAttributes; +pub mod model_degradation_template_data_attributes_components_affected_items; +pub use self::model_degradation_template_data_attributes_components_affected_items::DegradationTemplateDataAttributesComponentsAffectedItems; +pub mod model_patch_degradation_template_request_data_attributes_components_affected_items_status; +pub use self::model_patch_degradation_template_request_data_attributes_components_affected_items_status::PatchDegradationTemplateRequestDataAttributesComponentsAffectedItemsStatus; +pub mod model_degradation_template_data_attributes_updates_items; +pub use self::model_degradation_template_data_attributes_updates_items::DegradationTemplateDataAttributesUpdatesItems; +pub mod model_degradation_template_data_relationships; +pub use self::model_degradation_template_data_relationships::DegradationTemplateDataRelationships; +pub mod model_degradation_template_data_relationships_created_by_user; +pub use self::model_degradation_template_data_relationships_created_by_user::DegradationTemplateDataRelationshipsCreatedByUser; +pub mod model_degradation_template_data_relationships_created_by_user_data; +pub use self::model_degradation_template_data_relationships_created_by_user_data::DegradationTemplateDataRelationshipsCreatedByUserData; +pub mod model_degradation_template_data_relationships_last_modified_by_user; +pub use self::model_degradation_template_data_relationships_last_modified_by_user::DegradationTemplateDataRelationshipsLastModifiedByUser; +pub mod model_degradation_template_data_relationships_last_modified_by_user_data; +pub use self::model_degradation_template_data_relationships_last_modified_by_user_data::DegradationTemplateDataRelationshipsLastModifiedByUserData; +pub mod model_degradation_template_data_relationships_status_page; +pub use self::model_degradation_template_data_relationships_status_page::DegradationTemplateDataRelationshipsStatusPage; +pub mod model_degradation_template_data_relationships_status_page_data; +pub use self::model_degradation_template_data_relationships_status_page_data::DegradationTemplateDataRelationshipsStatusPageData; +pub mod model_create_degradation_template_request; +pub use self::model_create_degradation_template_request::CreateDegradationTemplateRequest; +pub mod model_create_degradation_template_request_data; +pub use self::model_create_degradation_template_request_data::CreateDegradationTemplateRequestData; +pub mod model_create_degradation_template_request_data_attributes; +pub use self::model_create_degradation_template_request_data_attributes::CreateDegradationTemplateRequestDataAttributes; +pub mod model_create_degradation_template_request_data_attributes_components_affected_items; +pub use self::model_create_degradation_template_request_data_attributes_components_affected_items::CreateDegradationTemplateRequestDataAttributesComponentsAffectedItems; +pub mod model_create_degradation_template_request_data_attributes_updates_items; +pub use self::model_create_degradation_template_request_data_attributes_updates_items::CreateDegradationTemplateRequestDataAttributesUpdatesItems; +pub mod model_degradation_template; +pub use self::model_degradation_template::DegradationTemplate; +pub mod model_patch_degradation_template_request; +pub use self::model_patch_degradation_template_request::PatchDegradationTemplateRequest; +pub mod model_patch_degradation_template_request_data; +pub use self::model_patch_degradation_template_request_data::PatchDegradationTemplateRequestData; +pub mod model_patch_degradation_template_request_data_attributes; +pub use self::model_patch_degradation_template_request_data_attributes::PatchDegradationTemplateRequestDataAttributes; +pub mod model_patch_degradation_template_request_data_attributes_components_affected_items; +pub use self::model_patch_degradation_template_request_data_attributes_components_affected_items::PatchDegradationTemplateRequestDataAttributesComponentsAffectedItems; +pub mod model_patch_degradation_template_request_data_attributes_updates_items; +pub use self::model_patch_degradation_template_request_data_attributes_updates_items::PatchDegradationTemplateRequestDataAttributesUpdatesItems; pub mod model_create_degradation_request; pub use self::model_create_degradation_request::CreateDegradationRequest; pub mod model_create_degradation_request_data; @@ -12566,6 +12626,12 @@ pub mod model_create_degradation_request_data_attributes; pub use self::model_create_degradation_request_data_attributes::CreateDegradationRequestDataAttributes; pub mod model_create_degradation_request_data_attributes_components_affected_items; pub use self::model_create_degradation_request_data_attributes_components_affected_items::CreateDegradationRequestDataAttributesComponentsAffectedItems; +pub mod model_create_degradation_request_data_relationships; +pub use self::model_create_degradation_request_data_relationships::CreateDegradationRequestDataRelationships; +pub mod model_create_degradation_request_data_relationships_template; +pub use self::model_create_degradation_request_data_relationships_template::CreateDegradationRequestDataRelationshipsTemplate; +pub mod model_create_degradation_request_data_relationships_template_data; +pub use self::model_create_degradation_request_data_relationships_template_data::CreateDegradationRequestDataRelationshipsTemplateData; pub mod model_degradation; pub use self::model_degradation::Degradation; pub mod model_create_backfilled_degradation_request; @@ -12576,6 +12642,12 @@ pub mod model_create_backfilled_degradation_request_data_attributes; pub use self::model_create_backfilled_degradation_request_data_attributes::CreateBackfilledDegradationRequestDataAttributes; pub mod model_create_backfilled_degradation_request_data_attributes_updates_items; pub use self::model_create_backfilled_degradation_request_data_attributes_updates_items::CreateBackfilledDegradationRequestDataAttributesUpdatesItems; +pub mod model_create_backfilled_degradation_request_data_relationships; +pub use self::model_create_backfilled_degradation_request_data_relationships::CreateBackfilledDegradationRequestDataRelationships; +pub mod model_create_backfilled_degradation_request_data_relationships_template; +pub use self::model_create_backfilled_degradation_request_data_relationships_template::CreateBackfilledDegradationRequestDataRelationshipsTemplate; +pub mod model_create_backfilled_degradation_request_data_relationships_template_data; +pub use self::model_create_backfilled_degradation_request_data_relationships_template_data::CreateBackfilledDegradationRequestDataRelationshipsTemplateData; pub mod model_patch_degradation_request; pub use self::model_patch_degradation_request::PatchDegradationRequest; pub mod model_patch_degradation_request_data; @@ -12586,6 +12658,12 @@ pub mod model_patch_degradation_request_data_attributes_components_affected_item pub use self::model_patch_degradation_request_data_attributes_components_affected_items::PatchDegradationRequestDataAttributesComponentsAffectedItems; pub mod model_patch_degradation_request_data_attributes_status; pub use self::model_patch_degradation_request_data_attributes_status::PatchDegradationRequestDataAttributesStatus; +pub mod model_patch_degradation_request_data_relationships; +pub use self::model_patch_degradation_request_data_relationships::PatchDegradationRequestDataRelationships; +pub mod model_patch_degradation_request_data_relationships_template; +pub use self::model_patch_degradation_request_data_relationships_template::PatchDegradationRequestDataRelationshipsTemplate; +pub mod model_patch_degradation_request_data_relationships_template_data; +pub use self::model_patch_degradation_request_data_relationships_template_data::PatchDegradationRequestDataRelationshipsTemplateData; pub mod model_patch_degradation_update_request; pub use self::model_patch_degradation_update_request::PatchDegradationUpdateRequest; pub mod model_patch_degradation_update_request_data; @@ -12620,6 +12698,40 @@ pub mod model_degradation_update_data_relationships_status_page_data; pub use self::model_degradation_update_data_relationships_status_page_data::DegradationUpdateDataRelationshipsStatusPageData; pub mod model_degradation_update_included; pub use self::model_degradation_update_included::DegradationUpdateIncluded; +pub mod model_maintenance_template_array; +pub use self::model_maintenance_template_array::MaintenanceTemplateArray; +pub mod model_maintenance_template_data; +pub use self::model_maintenance_template_data::MaintenanceTemplateData; +pub mod model_maintenance_template_data_attributes; +pub use self::model_maintenance_template_data_attributes::MaintenanceTemplateDataAttributes; +pub mod model_maintenance_template_data_relationships; +pub use self::model_maintenance_template_data_relationships::MaintenanceTemplateDataRelationships; +pub mod model_maintenance_template_data_relationships_created_by_user; +pub use self::model_maintenance_template_data_relationships_created_by_user::MaintenanceTemplateDataRelationshipsCreatedByUser; +pub mod model_maintenance_template_data_relationships_created_by_user_data; +pub use self::model_maintenance_template_data_relationships_created_by_user_data::MaintenanceTemplateDataRelationshipsCreatedByUserData; +pub mod model_maintenance_template_data_relationships_last_modified_by_user; +pub use self::model_maintenance_template_data_relationships_last_modified_by_user::MaintenanceTemplateDataRelationshipsLastModifiedByUser; +pub mod model_maintenance_template_data_relationships_last_modified_by_user_data; +pub use self::model_maintenance_template_data_relationships_last_modified_by_user_data::MaintenanceTemplateDataRelationshipsLastModifiedByUserData; +pub mod model_maintenance_template_data_relationships_status_page; +pub use self::model_maintenance_template_data_relationships_status_page::MaintenanceTemplateDataRelationshipsStatusPage; +pub mod model_maintenance_template_data_relationships_status_page_data; +pub use self::model_maintenance_template_data_relationships_status_page_data::MaintenanceTemplateDataRelationshipsStatusPageData; +pub mod model_create_maintenance_template_request; +pub use self::model_create_maintenance_template_request::CreateMaintenanceTemplateRequest; +pub mod model_create_maintenance_template_request_data; +pub use self::model_create_maintenance_template_request_data::CreateMaintenanceTemplateRequestData; +pub mod model_create_maintenance_template_request_data_attributes; +pub use self::model_create_maintenance_template_request_data_attributes::CreateMaintenanceTemplateRequestDataAttributes; +pub mod model_maintenance_template; +pub use self::model_maintenance_template::MaintenanceTemplate; +pub mod model_patch_maintenance_template_request; +pub use self::model_patch_maintenance_template_request::PatchMaintenanceTemplateRequest; +pub mod model_patch_maintenance_template_request_data; +pub use self::model_patch_maintenance_template_request_data::PatchMaintenanceTemplateRequestData; +pub mod model_patch_maintenance_template_request_data_attributes; +pub use self::model_patch_maintenance_template_request_data_attributes::PatchMaintenanceTemplateRequestDataAttributes; pub mod model_create_maintenance_request; pub use self::model_create_maintenance_request::CreateMaintenanceRequest; pub mod model_create_maintenance_request_data; @@ -12628,6 +12740,12 @@ pub mod model_create_maintenance_request_data_attributes; pub use self::model_create_maintenance_request_data_attributes::CreateMaintenanceRequestDataAttributes; pub mod model_create_maintenance_request_data_attributes_components_affected_items; pub use self::model_create_maintenance_request_data_attributes_components_affected_items::CreateMaintenanceRequestDataAttributesComponentsAffectedItems; +pub mod model_create_maintenance_request_data_relationships; +pub use self::model_create_maintenance_request_data_relationships::CreateMaintenanceRequestDataRelationships; +pub mod model_create_maintenance_request_data_relationships_template; +pub use self::model_create_maintenance_request_data_relationships_template::CreateMaintenanceRequestDataRelationshipsTemplate; +pub mod model_create_maintenance_request_data_relationships_template_data; +pub use self::model_create_maintenance_request_data_relationships_template_data::CreateMaintenanceRequestDataRelationshipsTemplateData; pub mod model_maintenance; pub use self::model_maintenance::Maintenance; pub mod model_create_backfilled_maintenance_request; @@ -12640,6 +12758,12 @@ pub mod model_create_backfilled_maintenance_request_data_attributes_updates_item pub use self::model_create_backfilled_maintenance_request_data_attributes_updates_items::CreateBackfilledMaintenanceRequestDataAttributesUpdatesItems; pub mod model_create_maintenance_request_data_attributes_updates_items_status; pub use self::model_create_maintenance_request_data_attributes_updates_items_status::CreateMaintenanceRequestDataAttributesUpdatesItemsStatus; +pub mod model_create_backfilled_maintenance_request_data_relationships; +pub use self::model_create_backfilled_maintenance_request_data_relationships::CreateBackfilledMaintenanceRequestDataRelationships; +pub mod model_create_backfilled_maintenance_request_data_relationships_template; +pub use self::model_create_backfilled_maintenance_request_data_relationships_template::CreateBackfilledMaintenanceRequestDataRelationshipsTemplate; +pub mod model_create_backfilled_maintenance_request_data_relationships_template_data; +pub use self::model_create_backfilled_maintenance_request_data_relationships_template_data::CreateBackfilledMaintenanceRequestDataRelationshipsTemplateData; pub mod model_patch_maintenance_request; pub use self::model_patch_maintenance_request::PatchMaintenanceRequest; pub mod model_patch_maintenance_request_data; @@ -12648,6 +12772,12 @@ pub mod model_patch_maintenance_request_data_attributes; pub use self::model_patch_maintenance_request_data_attributes::PatchMaintenanceRequestDataAttributes; pub mod model_patch_maintenance_request_data_attributes_components_affected_items; pub use self::model_patch_maintenance_request_data_attributes_components_affected_items::PatchMaintenanceRequestDataAttributesComponentsAffectedItems; +pub mod model_patch_maintenance_request_data_relationships; +pub use self::model_patch_maintenance_request_data_relationships::PatchMaintenanceRequestDataRelationships; +pub mod model_patch_maintenance_request_data_relationships_template; +pub use self::model_patch_maintenance_request_data_relationships_template::PatchMaintenanceRequestDataRelationshipsTemplate; +pub mod model_patch_maintenance_request_data_relationships_template_data; +pub use self::model_patch_maintenance_request_data_relationships_template_data::PatchMaintenanceRequestDataRelationshipsTemplateData; pub mod model_stegadography_get_widgets_request; pub use self::model_stegadography_get_widgets_request::StegadographyGetWidgetsRequest; pub mod model_stegadography_get_widgets_response; diff --git a/src/datadogV2/model/model_create_backfilled_degradation_request_data.rs b/src/datadogV2/model/model_create_backfilled_degradation_request_data.rs index 2a689810f..682d22aa4 100644 --- a/src/datadogV2/model/model_create_backfilled_degradation_request_data.rs +++ b/src/datadogV2/model/model_create_backfilled_degradation_request_data.rs @@ -15,6 +15,10 @@ pub struct CreateBackfilledDegradationRequestData { #[serde(rename = "attributes")] pub attributes: Option, + /// The supported relationships for creating a backfilled degradation. + #[serde(rename = "relationships")] + pub relationships: + Option, /// Degradations resource type. #[serde(rename = "type")] pub type_: crate::datadogV2::model::PatchDegradationRequestDataType, @@ -31,6 +35,7 @@ impl CreateBackfilledDegradationRequestData { ) -> CreateBackfilledDegradationRequestData { CreateBackfilledDegradationRequestData { attributes: None, + relationships: None, type_, additional_properties: std::collections::BTreeMap::new(), _unparsed: false, @@ -45,6 +50,14 @@ impl CreateBackfilledDegradationRequestData { self } + pub fn relationships( + mut self, + value: crate::datadogV2::model::CreateBackfilledDegradationRequestDataRelationships, + ) -> Self { + self.relationships = Some(value); + self + } + pub fn additional_properties( mut self, value: std::collections::BTreeMap, @@ -74,6 +87,9 @@ impl<'de> Deserialize<'de> for CreateBackfilledDegradationRequestData { let mut attributes: Option< crate::datadogV2::model::CreateBackfilledDegradationRequestDataAttributes, > = None; + let mut relationships: Option< + crate::datadogV2::model::CreateBackfilledDegradationRequestDataRelationships, + > = None; let mut type_: Option = None; let mut additional_properties: std::collections::BTreeMap< @@ -90,6 +106,13 @@ impl<'de> Deserialize<'de> for CreateBackfilledDegradationRequestData { } attributes = Some(serde_json::from_value(v).map_err(M::Error::custom)?); } + "relationships" => { + if v.is_null() { + continue; + } + relationships = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } "type" => { type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); if let Some(ref _type_) = type_ { @@ -112,6 +135,7 @@ impl<'de> Deserialize<'de> for CreateBackfilledDegradationRequestData { let content = CreateBackfilledDegradationRequestData { attributes, + relationships, type_, additional_properties, _unparsed, diff --git a/src/datadogV2/model/model_create_backfilled_degradation_request_data_relationships.rs b/src/datadogV2/model/model_create_backfilled_degradation_request_data_relationships.rs new file mode 100644 index 000000000..edb6b3387 --- /dev/null +++ b/src/datadogV2/model/model_create_backfilled_degradation_request_data_relationships.rs @@ -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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The supported relationships for creating a backfilled degradation. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct CreateBackfilledDegradationRequestDataRelationships { + /// The template used to create the backfilled degradation. + #[serde(rename = "template")] + pub template: Option< + crate::datadogV2::model::CreateBackfilledDegradationRequestDataRelationshipsTemplate, + >, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl CreateBackfilledDegradationRequestDataRelationships { + pub fn new() -> CreateBackfilledDegradationRequestDataRelationships { + CreateBackfilledDegradationRequestDataRelationships { + template: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn template( + mut self, + value: crate::datadogV2::model::CreateBackfilledDegradationRequestDataRelationshipsTemplate, + ) -> Self { + self.template = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for CreateBackfilledDegradationRequestDataRelationships { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for CreateBackfilledDegradationRequestDataRelationships { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct CreateBackfilledDegradationRequestDataRelationshipsVisitor; + impl<'a> Visitor<'a> for CreateBackfilledDegradationRequestDataRelationshipsVisitor { + type Value = CreateBackfilledDegradationRequestDataRelationships; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut template: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "template" => { + if v.is_null() { + continue; + } + template = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = CreateBackfilledDegradationRequestDataRelationships { + template, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(CreateBackfilledDegradationRequestDataRelationshipsVisitor) + } +} diff --git a/src/datadogV2/model/model_create_backfilled_degradation_request_data_relationships_template.rs b/src/datadogV2/model/model_create_backfilled_degradation_request_data_relationships_template.rs new file mode 100644 index 000000000..6f24fbc22 --- /dev/null +++ b/src/datadogV2/model/model_create_backfilled_degradation_request_data_relationships_template.rs @@ -0,0 +1,96 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The template used to create the backfilled degradation. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct CreateBackfilledDegradationRequestDataRelationshipsTemplate { + /// The data object identifying the template used to create the backfilled degradation. + #[serde(rename = "data")] + pub data: + crate::datadogV2::model::CreateBackfilledDegradationRequestDataRelationshipsTemplateData, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl CreateBackfilledDegradationRequestDataRelationshipsTemplate { + pub fn new( + data: crate::datadogV2::model::CreateBackfilledDegradationRequestDataRelationshipsTemplateData, + ) -> CreateBackfilledDegradationRequestDataRelationshipsTemplate { + CreateBackfilledDegradationRequestDataRelationshipsTemplate { + data, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for CreateBackfilledDegradationRequestDataRelationshipsTemplate { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct CreateBackfilledDegradationRequestDataRelationshipsTemplateVisitor; + impl<'a> Visitor<'a> for CreateBackfilledDegradationRequestDataRelationshipsTemplateVisitor { + type Value = CreateBackfilledDegradationRequestDataRelationshipsTemplate; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "data" => { + data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let data = data.ok_or_else(|| M::Error::missing_field("data"))?; + + let content = CreateBackfilledDegradationRequestDataRelationshipsTemplate { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer + .deserialize_any(CreateBackfilledDegradationRequestDataRelationshipsTemplateVisitor) + } +} diff --git a/src/datadogV2/model/model_create_backfilled_degradation_request_data_relationships_template_data.rs b/src/datadogV2/model/model_create_backfilled_degradation_request_data_relationships_template_data.rs new file mode 100644 index 000000000..9ad383d0c --- /dev/null +++ b/src/datadogV2/model/model_create_backfilled_degradation_request_data_relationships_template_data.rs @@ -0,0 +1,116 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The data object identifying the template used to create the backfilled degradation. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct CreateBackfilledDegradationRequestDataRelationshipsTemplateData { + /// The ID of the degradation template. + #[serde(rename = "id")] + pub id: String, + /// Degradation templates resource type. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::PatchDegradationTemplateRequestDataType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl CreateBackfilledDegradationRequestDataRelationshipsTemplateData { + pub fn new( + id: String, + type_: crate::datadogV2::model::PatchDegradationTemplateRequestDataType, + ) -> CreateBackfilledDegradationRequestDataRelationshipsTemplateData { + CreateBackfilledDegradationRequestDataRelationshipsTemplateData { + id, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for CreateBackfilledDegradationRequestDataRelationshipsTemplateData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct CreateBackfilledDegradationRequestDataRelationshipsTemplateDataVisitor; + impl<'a> Visitor<'a> for CreateBackfilledDegradationRequestDataRelationshipsTemplateDataVisitor { + type Value = CreateBackfilledDegradationRequestDataRelationshipsTemplateData; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut id: Option = None; + let mut type_: Option< + crate::datadogV2::model::PatchDegradationTemplateRequestDataType, + > = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "id" => { + id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::PatchDegradationTemplateRequestDataType::UnparsedObject(_type_) => { + _unparsed = true; + }, + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let id = id.ok_or_else(|| M::Error::missing_field("id"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = CreateBackfilledDegradationRequestDataRelationshipsTemplateData { + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer + .deserialize_any(CreateBackfilledDegradationRequestDataRelationshipsTemplateDataVisitor) + } +} diff --git a/src/datadogV2/model/model_create_backfilled_maintenance_request_data.rs b/src/datadogV2/model/model_create_backfilled_maintenance_request_data.rs index 4b2441e7f..bf29ed3dc 100644 --- a/src/datadogV2/model/model_create_backfilled_maintenance_request_data.rs +++ b/src/datadogV2/model/model_create_backfilled_maintenance_request_data.rs @@ -15,6 +15,10 @@ pub struct CreateBackfilledMaintenanceRequestData { #[serde(rename = "attributes")] pub attributes: Option, + /// The supported relationships for creating a backfilled maintenance. + #[serde(rename = "relationships")] + pub relationships: + Option, /// Maintenances resource type. #[serde(rename = "type")] pub type_: crate::datadogV2::model::PatchMaintenanceRequestDataType, @@ -31,6 +35,7 @@ impl CreateBackfilledMaintenanceRequestData { ) -> CreateBackfilledMaintenanceRequestData { CreateBackfilledMaintenanceRequestData { attributes: None, + relationships: None, type_, additional_properties: std::collections::BTreeMap::new(), _unparsed: false, @@ -45,6 +50,14 @@ impl CreateBackfilledMaintenanceRequestData { self } + pub fn relationships( + mut self, + value: crate::datadogV2::model::CreateBackfilledMaintenanceRequestDataRelationships, + ) -> Self { + self.relationships = Some(value); + self + } + pub fn additional_properties( mut self, value: std::collections::BTreeMap, @@ -74,6 +87,9 @@ impl<'de> Deserialize<'de> for CreateBackfilledMaintenanceRequestData { let mut attributes: Option< crate::datadogV2::model::CreateBackfilledMaintenanceRequestDataAttributes, > = None; + let mut relationships: Option< + crate::datadogV2::model::CreateBackfilledMaintenanceRequestDataRelationships, + > = None; let mut type_: Option = None; let mut additional_properties: std::collections::BTreeMap< @@ -90,6 +106,13 @@ impl<'de> Deserialize<'de> for CreateBackfilledMaintenanceRequestData { } attributes = Some(serde_json::from_value(v).map_err(M::Error::custom)?); } + "relationships" => { + if v.is_null() { + continue; + } + relationships = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } "type" => { type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); if let Some(ref _type_) = type_ { @@ -112,6 +135,7 @@ impl<'de> Deserialize<'de> for CreateBackfilledMaintenanceRequestData { let content = CreateBackfilledMaintenanceRequestData { attributes, + relationships, type_, additional_properties, _unparsed, diff --git a/src/datadogV2/model/model_create_backfilled_maintenance_request_data_relationships.rs b/src/datadogV2/model/model_create_backfilled_maintenance_request_data_relationships.rs new file mode 100644 index 000000000..b04ee4076 --- /dev/null +++ b/src/datadogV2/model/model_create_backfilled_maintenance_request_data_relationships.rs @@ -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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The supported relationships for creating a backfilled maintenance. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct CreateBackfilledMaintenanceRequestDataRelationships { + /// The template used to create the backfilled maintenance. + #[serde(rename = "template")] + pub template: Option< + crate::datadogV2::model::CreateBackfilledMaintenanceRequestDataRelationshipsTemplate, + >, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl CreateBackfilledMaintenanceRequestDataRelationships { + pub fn new() -> CreateBackfilledMaintenanceRequestDataRelationships { + CreateBackfilledMaintenanceRequestDataRelationships { + template: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn template( + mut self, + value: crate::datadogV2::model::CreateBackfilledMaintenanceRequestDataRelationshipsTemplate, + ) -> Self { + self.template = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for CreateBackfilledMaintenanceRequestDataRelationships { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for CreateBackfilledMaintenanceRequestDataRelationships { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct CreateBackfilledMaintenanceRequestDataRelationshipsVisitor; + impl<'a> Visitor<'a> for CreateBackfilledMaintenanceRequestDataRelationshipsVisitor { + type Value = CreateBackfilledMaintenanceRequestDataRelationships; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut template: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "template" => { + if v.is_null() { + continue; + } + template = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = CreateBackfilledMaintenanceRequestDataRelationships { + template, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(CreateBackfilledMaintenanceRequestDataRelationshipsVisitor) + } +} diff --git a/src/datadogV2/model/model_create_backfilled_maintenance_request_data_relationships_template.rs b/src/datadogV2/model/model_create_backfilled_maintenance_request_data_relationships_template.rs new file mode 100644 index 000000000..c2f7ac7cd --- /dev/null +++ b/src/datadogV2/model/model_create_backfilled_maintenance_request_data_relationships_template.rs @@ -0,0 +1,96 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The template used to create the backfilled maintenance. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct CreateBackfilledMaintenanceRequestDataRelationshipsTemplate { + /// The data object identifying the template used to create the backfilled maintenance. + #[serde(rename = "data")] + pub data: + crate::datadogV2::model::CreateBackfilledMaintenanceRequestDataRelationshipsTemplateData, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl CreateBackfilledMaintenanceRequestDataRelationshipsTemplate { + pub fn new( + data: crate::datadogV2::model::CreateBackfilledMaintenanceRequestDataRelationshipsTemplateData, + ) -> CreateBackfilledMaintenanceRequestDataRelationshipsTemplate { + CreateBackfilledMaintenanceRequestDataRelationshipsTemplate { + data, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for CreateBackfilledMaintenanceRequestDataRelationshipsTemplate { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct CreateBackfilledMaintenanceRequestDataRelationshipsTemplateVisitor; + impl<'a> Visitor<'a> for CreateBackfilledMaintenanceRequestDataRelationshipsTemplateVisitor { + type Value = CreateBackfilledMaintenanceRequestDataRelationshipsTemplate; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "data" => { + data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let data = data.ok_or_else(|| M::Error::missing_field("data"))?; + + let content = CreateBackfilledMaintenanceRequestDataRelationshipsTemplate { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer + .deserialize_any(CreateBackfilledMaintenanceRequestDataRelationshipsTemplateVisitor) + } +} diff --git a/src/datadogV2/model/model_create_backfilled_maintenance_request_data_relationships_template_data.rs b/src/datadogV2/model/model_create_backfilled_maintenance_request_data_relationships_template_data.rs new file mode 100644 index 000000000..537784e29 --- /dev/null +++ b/src/datadogV2/model/model_create_backfilled_maintenance_request_data_relationships_template_data.rs @@ -0,0 +1,116 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The data object identifying the template used to create the backfilled maintenance. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct CreateBackfilledMaintenanceRequestDataRelationshipsTemplateData { + /// The ID of the maintenance template. + #[serde(rename = "id")] + pub id: String, + /// Maintenance templates resource type. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::PatchMaintenanceTemplateRequestDataType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl CreateBackfilledMaintenanceRequestDataRelationshipsTemplateData { + pub fn new( + id: String, + type_: crate::datadogV2::model::PatchMaintenanceTemplateRequestDataType, + ) -> CreateBackfilledMaintenanceRequestDataRelationshipsTemplateData { + CreateBackfilledMaintenanceRequestDataRelationshipsTemplateData { + id, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for CreateBackfilledMaintenanceRequestDataRelationshipsTemplateData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct CreateBackfilledMaintenanceRequestDataRelationshipsTemplateDataVisitor; + impl<'a> Visitor<'a> for CreateBackfilledMaintenanceRequestDataRelationshipsTemplateDataVisitor { + type Value = CreateBackfilledMaintenanceRequestDataRelationshipsTemplateData; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut id: Option = None; + let mut type_: Option< + crate::datadogV2::model::PatchMaintenanceTemplateRequestDataType, + > = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "id" => { + id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::PatchMaintenanceTemplateRequestDataType::UnparsedObject(_type_) => { + _unparsed = true; + }, + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let id = id.ok_or_else(|| M::Error::missing_field("id"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = CreateBackfilledMaintenanceRequestDataRelationshipsTemplateData { + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer + .deserialize_any(CreateBackfilledMaintenanceRequestDataRelationshipsTemplateDataVisitor) + } +} diff --git a/src/datadogV2/model/model_create_degradation_request_data.rs b/src/datadogV2/model/model_create_degradation_request_data.rs index adfe93cb1..f00fa592e 100644 --- a/src/datadogV2/model/model_create_degradation_request_data.rs +++ b/src/datadogV2/model/model_create_degradation_request_data.rs @@ -14,6 +14,9 @@ pub struct CreateDegradationRequestData { /// The supported attributes for creating a degradation. #[serde(rename = "attributes")] pub attributes: crate::datadogV2::model::CreateDegradationRequestDataAttributes, + /// The supported relationships for creating a degradation. + #[serde(rename = "relationships")] + pub relationships: Option, /// Degradations resource type. #[serde(rename = "type")] pub type_: crate::datadogV2::model::PatchDegradationRequestDataType, @@ -31,12 +34,21 @@ impl CreateDegradationRequestData { ) -> CreateDegradationRequestData { CreateDegradationRequestData { attributes, + relationships: None, type_, additional_properties: std::collections::BTreeMap::new(), _unparsed: false, } } + pub fn relationships( + mut self, + value: crate::datadogV2::model::CreateDegradationRequestDataRelationships, + ) -> Self { + self.relationships = Some(value); + self + } + pub fn additional_properties( mut self, value: std::collections::BTreeMap, @@ -66,6 +78,9 @@ impl<'de> Deserialize<'de> for CreateDegradationRequestData { let mut attributes: Option< crate::datadogV2::model::CreateDegradationRequestDataAttributes, > = None; + let mut relationships: Option< + crate::datadogV2::model::CreateDegradationRequestDataRelationships, + > = None; let mut type_: Option = None; let mut additional_properties: std::collections::BTreeMap< @@ -79,6 +94,13 @@ impl<'de> Deserialize<'de> for CreateDegradationRequestData { "attributes" => { attributes = Some(serde_json::from_value(v).map_err(M::Error::custom)?); } + "relationships" => { + if v.is_null() { + continue; + } + relationships = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } "type" => { type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); if let Some(ref _type_) = type_ { @@ -102,6 +124,7 @@ impl<'de> Deserialize<'de> for CreateDegradationRequestData { let content = CreateDegradationRequestData { attributes, + relationships, type_, additional_properties, _unparsed, diff --git a/src/datadogV2/model/model_create_degradation_request_data_relationships.rs b/src/datadogV2/model/model_create_degradation_request_data_relationships.rs new file mode 100644 index 000000000..cc8d50721 --- /dev/null +++ b/src/datadogV2/model/model_create_degradation_request_data_relationships.rs @@ -0,0 +1,111 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The supported relationships for creating a degradation. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct CreateDegradationRequestDataRelationships { + /// The template used to create the degradation. + #[serde(rename = "template")] + pub template: + Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl CreateDegradationRequestDataRelationships { + pub fn new() -> CreateDegradationRequestDataRelationships { + CreateDegradationRequestDataRelationships { + template: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn template( + mut self, + value: crate::datadogV2::model::CreateDegradationRequestDataRelationshipsTemplate, + ) -> Self { + self.template = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for CreateDegradationRequestDataRelationships { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for CreateDegradationRequestDataRelationships { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct CreateDegradationRequestDataRelationshipsVisitor; + impl<'a> Visitor<'a> for CreateDegradationRequestDataRelationshipsVisitor { + type Value = CreateDegradationRequestDataRelationships; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut template: Option< + crate::datadogV2::model::CreateDegradationRequestDataRelationshipsTemplate, + > = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "template" => { + if v.is_null() { + continue; + } + template = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = CreateDegradationRequestDataRelationships { + template, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(CreateDegradationRequestDataRelationshipsVisitor) + } +} diff --git a/src/datadogV2/model/model_create_degradation_request_data_relationships_template.rs b/src/datadogV2/model/model_create_degradation_request_data_relationships_template.rs new file mode 100644 index 000000000..593d16faa --- /dev/null +++ b/src/datadogV2/model/model_create_degradation_request_data_relationships_template.rs @@ -0,0 +1,96 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The template used to create the degradation. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct CreateDegradationRequestDataRelationshipsTemplate { + /// The data object identifying the template used to create the degradation. + #[serde(rename = "data")] + pub data: crate::datadogV2::model::CreateDegradationRequestDataRelationshipsTemplateData, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl CreateDegradationRequestDataRelationshipsTemplate { + pub fn new( + data: crate::datadogV2::model::CreateDegradationRequestDataRelationshipsTemplateData, + ) -> CreateDegradationRequestDataRelationshipsTemplate { + CreateDegradationRequestDataRelationshipsTemplate { + data, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for CreateDegradationRequestDataRelationshipsTemplate { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct CreateDegradationRequestDataRelationshipsTemplateVisitor; + impl<'a> Visitor<'a> for CreateDegradationRequestDataRelationshipsTemplateVisitor { + type Value = CreateDegradationRequestDataRelationshipsTemplate; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data: Option< + crate::datadogV2::model::CreateDegradationRequestDataRelationshipsTemplateData, + > = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "data" => { + data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let data = data.ok_or_else(|| M::Error::missing_field("data"))?; + + let content = CreateDegradationRequestDataRelationshipsTemplate { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(CreateDegradationRequestDataRelationshipsTemplateVisitor) + } +} diff --git a/src/datadogV2/model/model_create_degradation_request_data_relationships_template_data.rs b/src/datadogV2/model/model_create_degradation_request_data_relationships_template_data.rs new file mode 100644 index 000000000..0756bf598 --- /dev/null +++ b/src/datadogV2/model/model_create_degradation_request_data_relationships_template_data.rs @@ -0,0 +1,115 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The data object identifying the template used to create the degradation. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct CreateDegradationRequestDataRelationshipsTemplateData { + /// The ID of the degradation template. + #[serde(rename = "id")] + pub id: String, + /// Degradation templates resource type. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::PatchDegradationTemplateRequestDataType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl CreateDegradationRequestDataRelationshipsTemplateData { + pub fn new( + id: String, + type_: crate::datadogV2::model::PatchDegradationTemplateRequestDataType, + ) -> CreateDegradationRequestDataRelationshipsTemplateData { + CreateDegradationRequestDataRelationshipsTemplateData { + id, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for CreateDegradationRequestDataRelationshipsTemplateData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct CreateDegradationRequestDataRelationshipsTemplateDataVisitor; + impl<'a> Visitor<'a> for CreateDegradationRequestDataRelationshipsTemplateDataVisitor { + type Value = CreateDegradationRequestDataRelationshipsTemplateData; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut id: Option = None; + let mut type_: Option< + crate::datadogV2::model::PatchDegradationTemplateRequestDataType, + > = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "id" => { + id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::PatchDegradationTemplateRequestDataType::UnparsedObject(_type_) => { + _unparsed = true; + }, + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let id = id.ok_or_else(|| M::Error::missing_field("id"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = CreateDegradationRequestDataRelationshipsTemplateData { + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(CreateDegradationRequestDataRelationshipsTemplateDataVisitor) + } +} diff --git a/src/datadogV2/model/model_create_degradation_template_request.rs b/src/datadogV2/model/model_create_degradation_template_request.rs new file mode 100644 index 000000000..80ef2800c --- /dev/null +++ b/src/datadogV2/model/model_create_degradation_template_request.rs @@ -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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Request object for creating a degradation template. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct CreateDegradationTemplateRequest { + /// The data object for creating a degradation template. + #[serde(rename = "data")] + pub data: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl CreateDegradationTemplateRequest { + pub fn new() -> CreateDegradationTemplateRequest { + CreateDegradationTemplateRequest { + data: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn data( + mut self, + value: crate::datadogV2::model::CreateDegradationTemplateRequestData, + ) -> Self { + self.data = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for CreateDegradationTemplateRequest { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for CreateDegradationTemplateRequest { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct CreateDegradationTemplateRequestVisitor; + impl<'a> Visitor<'a> for CreateDegradationTemplateRequestVisitor { + type Value = CreateDegradationTemplateRequest; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data: Option< + crate::datadogV2::model::CreateDegradationTemplateRequestData, + > = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "data" => { + if v.is_null() { + continue; + } + data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = CreateDegradationTemplateRequest { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(CreateDegradationTemplateRequestVisitor) + } +} diff --git a/src/datadogV2/model/model_create_degradation_template_request_data.rs b/src/datadogV2/model/model_create_degradation_template_request_data.rs new file mode 100644 index 000000000..cccf23d12 --- /dev/null +++ b/src/datadogV2/model/model_create_degradation_template_request_data.rs @@ -0,0 +1,126 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The data object for creating a degradation template. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct CreateDegradationTemplateRequestData { + /// The attributes for creating a degradation template. + #[serde(rename = "attributes")] + pub attributes: Option, + /// Degradation templates resource type. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::PatchDegradationTemplateRequestDataType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl CreateDegradationTemplateRequestData { + pub fn new( + type_: crate::datadogV2::model::PatchDegradationTemplateRequestDataType, + ) -> CreateDegradationTemplateRequestData { + CreateDegradationTemplateRequestData { + attributes: None, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn attributes( + mut self, + value: crate::datadogV2::model::CreateDegradationTemplateRequestDataAttributes, + ) -> Self { + self.attributes = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for CreateDegradationTemplateRequestData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct CreateDegradationTemplateRequestDataVisitor; + impl<'a> Visitor<'a> for CreateDegradationTemplateRequestDataVisitor { + type Value = CreateDegradationTemplateRequestData; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut attributes: Option< + crate::datadogV2::model::CreateDegradationTemplateRequestDataAttributes, + > = None; + let mut type_: Option< + crate::datadogV2::model::PatchDegradationTemplateRequestDataType, + > = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "attributes" => { + if v.is_null() { + continue; + } + attributes = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::PatchDegradationTemplateRequestDataType::UnparsedObject(_type_) => { + _unparsed = true; + }, + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = CreateDegradationTemplateRequestData { + attributes, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(CreateDegradationTemplateRequestDataVisitor) + } +} diff --git a/src/datadogV2/model/model_create_degradation_template_request_data_attributes.rs b/src/datadogV2/model/model_create_degradation_template_request_data_attributes.rs new file mode 100644 index 000000000..3b7135ba7 --- /dev/null +++ b/src/datadogV2/model/model_create_degradation_template_request_data_attributes.rs @@ -0,0 +1,153 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The attributes for creating a degradation template. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct CreateDegradationTemplateRequestDataAttributes { + /// The components affected by a degradation created from this template. + #[serde(rename = "components_affected")] + pub components_affected: Option>, + /// The title used for a degradation created from this template. + #[serde(rename = "degradation_title")] + pub degradation_title: Option, + /// The name of the degradation template. + #[serde(rename = "name")] + pub name: String, + /// The pre-filled updates for a degradation created from this template. + #[serde(rename = "updates")] + pub updates: Option>, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool +} + +impl CreateDegradationTemplateRequestDataAttributes { + pub fn new(name: String) -> CreateDegradationTemplateRequestDataAttributes { + CreateDegradationTemplateRequestDataAttributes { + components_affected: None, + degradation_title: None, + name, + updates: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn components_affected( + mut self, + value: Vec, + ) -> Self { + self.components_affected = Some(value); + self + } + + pub fn degradation_title(mut self, value: String) -> Self { + self.degradation_title = Some(value); + self + } + + pub fn updates( + mut self, + value: Vec< + crate::datadogV2::model::CreateDegradationTemplateRequestDataAttributesUpdatesItems, + >, + ) -> Self { + self.updates = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for CreateDegradationTemplateRequestDataAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct CreateDegradationTemplateRequestDataAttributesVisitor; + impl<'a> Visitor<'a> for CreateDegradationTemplateRequestDataAttributesVisitor { + type Value = CreateDegradationTemplateRequestDataAttributes; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut components_affected: Option> = None; + let mut degradation_title: Option = None; + let mut name: Option = None; + let mut updates: Option> = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "components_affected" => { + if v.is_null() { + continue; + } + components_affected = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "degradation_title" => { + if v.is_null() { + continue; + } + degradation_title = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "name" => { + name = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "updates" => { + if v.is_null() { + continue; + } + updates = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let name = name.ok_or_else(|| M::Error::missing_field("name"))?; + + let content = CreateDegradationTemplateRequestDataAttributes { + components_affected, + degradation_title, + name, + updates, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(CreateDegradationTemplateRequestDataAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_create_degradation_template_request_data_attributes_components_affected_items.rs b/src/datadogV2/model/model_create_degradation_template_request_data_attributes_components_affected_items.rs new file mode 100644 index 000000000..137e64643 --- /dev/null +++ b/src/datadogV2/model/model_create_degradation_template_request_data_attributes_components_affected_items.rs @@ -0,0 +1,137 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// A component affected by a degradation created from this template. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct CreateDegradationTemplateRequestDataAttributesComponentsAffectedItems { + /// The ID of the component. Must be a component of type `component`. + #[serde(rename = "id")] + pub id: String, + /// The name of the component. + #[serde(rename = "name")] + pub name: Option, + /// The status of the component. + #[serde(rename = "status")] + pub status: crate::datadogV2::model::PatchDegradationTemplateRequestDataAttributesComponentsAffectedItemsStatus, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool +} + +impl CreateDegradationTemplateRequestDataAttributesComponentsAffectedItems { + pub fn new( + id: String, + status: crate::datadogV2::model::PatchDegradationTemplateRequestDataAttributesComponentsAffectedItemsStatus, + ) -> CreateDegradationTemplateRequestDataAttributesComponentsAffectedItems { + CreateDegradationTemplateRequestDataAttributesComponentsAffectedItems { + id, + name: None, + status, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn name(mut self, value: String) -> Self { + self.name = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> + for CreateDegradationTemplateRequestDataAttributesComponentsAffectedItems +{ + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct CreateDegradationTemplateRequestDataAttributesComponentsAffectedItemsVisitor; + impl<'a> Visitor<'a> + for CreateDegradationTemplateRequestDataAttributesComponentsAffectedItemsVisitor + { + type Value = CreateDegradationTemplateRequestDataAttributesComponentsAffectedItems; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut id: Option = None; + let mut name: Option = None; + let mut status: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "id" => { + id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "name" => { + if v.is_null() { + continue; + } + name = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "status" => { + status = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _status) = status { + match _status { + crate::datadogV2::model::PatchDegradationTemplateRequestDataAttributesComponentsAffectedItemsStatus::UnparsedObject(_status) => { + _unparsed = true; + }, + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let id = id.ok_or_else(|| M::Error::missing_field("id"))?; + let status = status.ok_or_else(|| M::Error::missing_field("status"))?; + + let content = + CreateDegradationTemplateRequestDataAttributesComponentsAffectedItems { + id, + name, + status, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any( + CreateDegradationTemplateRequestDataAttributesComponentsAffectedItemsVisitor, + ) + } +} diff --git a/src/datadogV2/model/model_create_degradation_template_request_data_attributes_updates_items.rs b/src/datadogV2/model/model_create_degradation_template_request_data_attributes_updates_items.rs new file mode 100644 index 000000000..2dcddc80c --- /dev/null +++ b/src/datadogV2/model/model_create_degradation_template_request_data_attributes_updates_items.rs @@ -0,0 +1,122 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// A pre-filled update for a degradation created from this template. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct CreateDegradationTemplateRequestDataAttributesUpdatesItems { + /// The message of the update. + #[serde(rename = "message")] + pub message: Option, + /// The status of the degradation. + #[serde(rename = "status")] + pub status: crate::datadogV2::model::CreateDegradationRequestDataAttributesStatus, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl CreateDegradationTemplateRequestDataAttributesUpdatesItems { + pub fn new( + status: crate::datadogV2::model::CreateDegradationRequestDataAttributesStatus, + ) -> CreateDegradationTemplateRequestDataAttributesUpdatesItems { + CreateDegradationTemplateRequestDataAttributesUpdatesItems { + message: None, + status, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn message(mut self, value: String) -> Self { + self.message = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for CreateDegradationTemplateRequestDataAttributesUpdatesItems { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct CreateDegradationTemplateRequestDataAttributesUpdatesItemsVisitor; + impl<'a> Visitor<'a> for CreateDegradationTemplateRequestDataAttributesUpdatesItemsVisitor { + type Value = CreateDegradationTemplateRequestDataAttributesUpdatesItems; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut message: Option = None; + let mut status: Option< + crate::datadogV2::model::CreateDegradationRequestDataAttributesStatus, + > = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "message" => { + if v.is_null() { + continue; + } + message = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "status" => { + status = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _status) = status { + match _status { + crate::datadogV2::model::CreateDegradationRequestDataAttributesStatus::UnparsedObject(_status) => { + _unparsed = true; + }, + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let status = status.ok_or_else(|| M::Error::missing_field("status"))?; + + let content = CreateDegradationTemplateRequestDataAttributesUpdatesItems { + message, + status, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer + .deserialize_any(CreateDegradationTemplateRequestDataAttributesUpdatesItemsVisitor) + } +} diff --git a/src/datadogV2/model/model_create_maintenance_request_data.rs b/src/datadogV2/model/model_create_maintenance_request_data.rs index 94497b799..66ee6012d 100644 --- a/src/datadogV2/model/model_create_maintenance_request_data.rs +++ b/src/datadogV2/model/model_create_maintenance_request_data.rs @@ -14,6 +14,9 @@ pub struct CreateMaintenanceRequestData { /// The supported attributes for creating a maintenance. #[serde(rename = "attributes")] pub attributes: crate::datadogV2::model::CreateMaintenanceRequestDataAttributes, + /// The supported relationships for creating a maintenance. + #[serde(rename = "relationships")] + pub relationships: Option, /// Maintenances resource type. #[serde(rename = "type")] pub type_: crate::datadogV2::model::PatchMaintenanceRequestDataType, @@ -31,12 +34,21 @@ impl CreateMaintenanceRequestData { ) -> CreateMaintenanceRequestData { CreateMaintenanceRequestData { attributes, + relationships: None, type_, additional_properties: std::collections::BTreeMap::new(), _unparsed: false, } } + pub fn relationships( + mut self, + value: crate::datadogV2::model::CreateMaintenanceRequestDataRelationships, + ) -> Self { + self.relationships = Some(value); + self + } + pub fn additional_properties( mut self, value: std::collections::BTreeMap, @@ -66,6 +78,9 @@ impl<'de> Deserialize<'de> for CreateMaintenanceRequestData { let mut attributes: Option< crate::datadogV2::model::CreateMaintenanceRequestDataAttributes, > = None; + let mut relationships: Option< + crate::datadogV2::model::CreateMaintenanceRequestDataRelationships, + > = None; let mut type_: Option = None; let mut additional_properties: std::collections::BTreeMap< @@ -79,6 +94,13 @@ impl<'de> Deserialize<'de> for CreateMaintenanceRequestData { "attributes" => { attributes = Some(serde_json::from_value(v).map_err(M::Error::custom)?); } + "relationships" => { + if v.is_null() { + continue; + } + relationships = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } "type" => { type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); if let Some(ref _type_) = type_ { @@ -102,6 +124,7 @@ impl<'de> Deserialize<'de> for CreateMaintenanceRequestData { let content = CreateMaintenanceRequestData { attributes, + relationships, type_, additional_properties, _unparsed, diff --git a/src/datadogV2/model/model_create_maintenance_request_data_relationships.rs b/src/datadogV2/model/model_create_maintenance_request_data_relationships.rs new file mode 100644 index 000000000..aa6d41552 --- /dev/null +++ b/src/datadogV2/model/model_create_maintenance_request_data_relationships.rs @@ -0,0 +1,111 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The supported relationships for creating a maintenance. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct CreateMaintenanceRequestDataRelationships { + /// The template used to create the maintenance. + #[serde(rename = "template")] + pub template: + Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl CreateMaintenanceRequestDataRelationships { + pub fn new() -> CreateMaintenanceRequestDataRelationships { + CreateMaintenanceRequestDataRelationships { + template: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn template( + mut self, + value: crate::datadogV2::model::CreateMaintenanceRequestDataRelationshipsTemplate, + ) -> Self { + self.template = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for CreateMaintenanceRequestDataRelationships { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for CreateMaintenanceRequestDataRelationships { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct CreateMaintenanceRequestDataRelationshipsVisitor; + impl<'a> Visitor<'a> for CreateMaintenanceRequestDataRelationshipsVisitor { + type Value = CreateMaintenanceRequestDataRelationships; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut template: Option< + crate::datadogV2::model::CreateMaintenanceRequestDataRelationshipsTemplate, + > = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "template" => { + if v.is_null() { + continue; + } + template = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = CreateMaintenanceRequestDataRelationships { + template, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(CreateMaintenanceRequestDataRelationshipsVisitor) + } +} diff --git a/src/datadogV2/model/model_create_maintenance_request_data_relationships_template.rs b/src/datadogV2/model/model_create_maintenance_request_data_relationships_template.rs new file mode 100644 index 000000000..5afb8494b --- /dev/null +++ b/src/datadogV2/model/model_create_maintenance_request_data_relationships_template.rs @@ -0,0 +1,96 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The template used to create the maintenance. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct CreateMaintenanceRequestDataRelationshipsTemplate { + /// The data object identifying the template used to create the maintenance. + #[serde(rename = "data")] + pub data: crate::datadogV2::model::CreateMaintenanceRequestDataRelationshipsTemplateData, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl CreateMaintenanceRequestDataRelationshipsTemplate { + pub fn new( + data: crate::datadogV2::model::CreateMaintenanceRequestDataRelationshipsTemplateData, + ) -> CreateMaintenanceRequestDataRelationshipsTemplate { + CreateMaintenanceRequestDataRelationshipsTemplate { + data, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for CreateMaintenanceRequestDataRelationshipsTemplate { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct CreateMaintenanceRequestDataRelationshipsTemplateVisitor; + impl<'a> Visitor<'a> for CreateMaintenanceRequestDataRelationshipsTemplateVisitor { + type Value = CreateMaintenanceRequestDataRelationshipsTemplate; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data: Option< + crate::datadogV2::model::CreateMaintenanceRequestDataRelationshipsTemplateData, + > = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "data" => { + data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let data = data.ok_or_else(|| M::Error::missing_field("data"))?; + + let content = CreateMaintenanceRequestDataRelationshipsTemplate { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(CreateMaintenanceRequestDataRelationshipsTemplateVisitor) + } +} diff --git a/src/datadogV2/model/model_create_maintenance_request_data_relationships_template_data.rs b/src/datadogV2/model/model_create_maintenance_request_data_relationships_template_data.rs new file mode 100644 index 000000000..0d50ab400 --- /dev/null +++ b/src/datadogV2/model/model_create_maintenance_request_data_relationships_template_data.rs @@ -0,0 +1,115 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The data object identifying the template used to create the maintenance. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct CreateMaintenanceRequestDataRelationshipsTemplateData { + /// The ID of the maintenance template. + #[serde(rename = "id")] + pub id: String, + /// Maintenance templates resource type. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::PatchMaintenanceTemplateRequestDataType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl CreateMaintenanceRequestDataRelationshipsTemplateData { + pub fn new( + id: String, + type_: crate::datadogV2::model::PatchMaintenanceTemplateRequestDataType, + ) -> CreateMaintenanceRequestDataRelationshipsTemplateData { + CreateMaintenanceRequestDataRelationshipsTemplateData { + id, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for CreateMaintenanceRequestDataRelationshipsTemplateData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct CreateMaintenanceRequestDataRelationshipsTemplateDataVisitor; + impl<'a> Visitor<'a> for CreateMaintenanceRequestDataRelationshipsTemplateDataVisitor { + type Value = CreateMaintenanceRequestDataRelationshipsTemplateData; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut id: Option = None; + let mut type_: Option< + crate::datadogV2::model::PatchMaintenanceTemplateRequestDataType, + > = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "id" => { + id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::PatchMaintenanceTemplateRequestDataType::UnparsedObject(_type_) => { + _unparsed = true; + }, + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let id = id.ok_or_else(|| M::Error::missing_field("id"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = CreateMaintenanceRequestDataRelationshipsTemplateData { + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(CreateMaintenanceRequestDataRelationshipsTemplateDataVisitor) + } +} diff --git a/src/datadogV2/model/model_create_maintenance_template_request.rs b/src/datadogV2/model/model_create_maintenance_template_request.rs new file mode 100644 index 000000000..260e74c3e --- /dev/null +++ b/src/datadogV2/model/model_create_maintenance_template_request.rs @@ -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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Request object for creating a maintenance template. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct CreateMaintenanceTemplateRequest { + /// The data object for creating a maintenance template. + #[serde(rename = "data")] + pub data: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl CreateMaintenanceTemplateRequest { + pub fn new() -> CreateMaintenanceTemplateRequest { + CreateMaintenanceTemplateRequest { + data: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn data( + mut self, + value: crate::datadogV2::model::CreateMaintenanceTemplateRequestData, + ) -> Self { + self.data = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for CreateMaintenanceTemplateRequest { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for CreateMaintenanceTemplateRequest { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct CreateMaintenanceTemplateRequestVisitor; + impl<'a> Visitor<'a> for CreateMaintenanceTemplateRequestVisitor { + type Value = CreateMaintenanceTemplateRequest; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data: Option< + crate::datadogV2::model::CreateMaintenanceTemplateRequestData, + > = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "data" => { + if v.is_null() { + continue; + } + data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = CreateMaintenanceTemplateRequest { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(CreateMaintenanceTemplateRequestVisitor) + } +} diff --git a/src/datadogV2/model/model_create_maintenance_template_request_data.rs b/src/datadogV2/model/model_create_maintenance_template_request_data.rs new file mode 100644 index 000000000..6fce14b8a --- /dev/null +++ b/src/datadogV2/model/model_create_maintenance_template_request_data.rs @@ -0,0 +1,126 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The data object for creating a maintenance template. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct CreateMaintenanceTemplateRequestData { + /// The attributes for creating a maintenance template. + #[serde(rename = "attributes")] + pub attributes: Option, + /// Maintenance templates resource type. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::PatchMaintenanceTemplateRequestDataType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl CreateMaintenanceTemplateRequestData { + pub fn new( + type_: crate::datadogV2::model::PatchMaintenanceTemplateRequestDataType, + ) -> CreateMaintenanceTemplateRequestData { + CreateMaintenanceTemplateRequestData { + attributes: None, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn attributes( + mut self, + value: crate::datadogV2::model::CreateMaintenanceTemplateRequestDataAttributes, + ) -> Self { + self.attributes = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for CreateMaintenanceTemplateRequestData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct CreateMaintenanceTemplateRequestDataVisitor; + impl<'a> Visitor<'a> for CreateMaintenanceTemplateRequestDataVisitor { + type Value = CreateMaintenanceTemplateRequestData; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut attributes: Option< + crate::datadogV2::model::CreateMaintenanceTemplateRequestDataAttributes, + > = None; + let mut type_: Option< + crate::datadogV2::model::PatchMaintenanceTemplateRequestDataType, + > = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "attributes" => { + if v.is_null() { + continue; + } + attributes = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::PatchMaintenanceTemplateRequestDataType::UnparsedObject(_type_) => { + _unparsed = true; + }, + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = CreateMaintenanceTemplateRequestData { + attributes, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(CreateMaintenanceTemplateRequestDataVisitor) + } +} diff --git a/src/datadogV2/model/model_create_maintenance_template_request_data_attributes.rs b/src/datadogV2/model/model_create_maintenance_template_request_data_attributes.rs new file mode 100644 index 000000000..80046831b --- /dev/null +++ b/src/datadogV2/model/model_create_maintenance_template_request_data_attributes.rs @@ -0,0 +1,182 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The attributes for creating a maintenance template. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct CreateMaintenanceTemplateRequestDataAttributes { + /// The description shown when a maintenance created from this template is completed. + #[serde(rename = "completed_description")] + pub completed_description: Option, + /// The IDs of the components affected by a maintenance created from this template. + #[serde(rename = "component_ids")] + pub component_ids: Option>, + /// The description shown while a maintenance created from this template is in progress. + #[serde(rename = "in_progress_description")] + pub in_progress_description: Option, + /// The title used for a maintenance created from this template. + #[serde(rename = "maintenance_title")] + pub maintenance_title: Option, + /// The name of the maintenance template. + #[serde(rename = "name")] + pub name: String, + /// The description shown when a maintenance created from this template is scheduled. + #[serde(rename = "scheduled_description")] + pub scheduled_description: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl CreateMaintenanceTemplateRequestDataAttributes { + pub fn new(name: String) -> CreateMaintenanceTemplateRequestDataAttributes { + CreateMaintenanceTemplateRequestDataAttributes { + completed_description: None, + component_ids: None, + in_progress_description: None, + maintenance_title: None, + name, + scheduled_description: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn completed_description(mut self, value: String) -> Self { + self.completed_description = Some(value); + self + } + + pub fn component_ids(mut self, value: Vec) -> Self { + self.component_ids = Some(value); + self + } + + pub fn in_progress_description(mut self, value: String) -> Self { + self.in_progress_description = Some(value); + self + } + + pub fn maintenance_title(mut self, value: String) -> Self { + self.maintenance_title = Some(value); + self + } + + pub fn scheduled_description(mut self, value: String) -> Self { + self.scheduled_description = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for CreateMaintenanceTemplateRequestDataAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct CreateMaintenanceTemplateRequestDataAttributesVisitor; + impl<'a> Visitor<'a> for CreateMaintenanceTemplateRequestDataAttributesVisitor { + type Value = CreateMaintenanceTemplateRequestDataAttributes; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut completed_description: Option = None; + let mut component_ids: Option> = None; + let mut in_progress_description: Option = None; + let mut maintenance_title: Option = None; + let mut name: Option = None; + let mut scheduled_description: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "completed_description" => { + if v.is_null() { + continue; + } + completed_description = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "component_ids" => { + if v.is_null() { + continue; + } + component_ids = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "in_progress_description" => { + if v.is_null() { + continue; + } + in_progress_description = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "maintenance_title" => { + if v.is_null() { + continue; + } + maintenance_title = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "name" => { + name = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "scheduled_description" => { + if v.is_null() { + continue; + } + scheduled_description = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let name = name.ok_or_else(|| M::Error::missing_field("name"))?; + + let content = CreateMaintenanceTemplateRequestDataAttributes { + completed_description, + component_ids, + in_progress_description, + maintenance_title, + name, + scheduled_description, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(CreateMaintenanceTemplateRequestDataAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_degradation_data_relationships.rs b/src/datadogV2/model/model_degradation_data_relationships.rs index 18602b14e..bbd2d080f 100644 --- a/src/datadogV2/model/model_degradation_data_relationships.rs +++ b/src/datadogV2/model/model_degradation_data_relationships.rs @@ -21,6 +21,9 @@ pub struct DegradationDataRelationships { /// The status page the degradation belongs to. #[serde(rename = "status_page")] pub status_page: Option, + /// The template the degradation was created from. + #[serde(rename = "template")] + pub template: Option, #[serde(flatten)] pub additional_properties: std::collections::BTreeMap, #[serde(skip)] @@ -34,6 +37,7 @@ impl DegradationDataRelationships { created_by_user: None, last_modified_by_user: None, status_page: None, + template: None, additional_properties: std::collections::BTreeMap::new(), _unparsed: false, } @@ -63,6 +67,14 @@ impl DegradationDataRelationships { self } + pub fn template( + mut self, + value: crate::datadogV2::model::DegradationDataRelationshipsTemplate, + ) -> Self { + self.template = Some(value); + self + } + pub fn additional_properties( mut self, value: std::collections::BTreeMap, @@ -104,6 +116,9 @@ impl<'de> Deserialize<'de> for DegradationDataRelationships { let mut status_page: Option< crate::datadogV2::model::DegradationDataRelationshipsStatusPage, > = None; + let mut template: Option< + crate::datadogV2::model::DegradationDataRelationshipsTemplate, + > = None; let mut additional_properties: std::collections::BTreeMap< String, serde_json::Value, @@ -133,6 +148,12 @@ impl<'de> Deserialize<'de> for DegradationDataRelationships { status_page = Some(serde_json::from_value(v).map_err(M::Error::custom)?); } + "template" => { + if v.is_null() { + continue; + } + template = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } &_ => { if let Ok(value) = serde_json::from_value(v.clone()) { additional_properties.insert(k, value); @@ -145,6 +166,7 @@ impl<'de> Deserialize<'de> for DegradationDataRelationships { created_by_user, last_modified_by_user, status_page, + template, additional_properties, _unparsed, }; diff --git a/src/datadogV2/model/model_degradation_data_relationships_template.rs b/src/datadogV2/model/model_degradation_data_relationships_template.rs new file mode 100644 index 000000000..4241469e4 --- /dev/null +++ b/src/datadogV2/model/model_degradation_data_relationships_template.rs @@ -0,0 +1,96 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The template the degradation was created from. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct DegradationDataRelationshipsTemplate { + /// The data object identifying the template the degradation was created from. + #[serde(rename = "data")] + pub data: crate::datadogV2::model::DegradationDataRelationshipsTemplateData, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl DegradationDataRelationshipsTemplate { + pub fn new( + data: crate::datadogV2::model::DegradationDataRelationshipsTemplateData, + ) -> DegradationDataRelationshipsTemplate { + DegradationDataRelationshipsTemplate { + data, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for DegradationDataRelationshipsTemplate { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct DegradationDataRelationshipsTemplateVisitor; + impl<'a> Visitor<'a> for DegradationDataRelationshipsTemplateVisitor { + type Value = DegradationDataRelationshipsTemplate; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data: Option< + crate::datadogV2::model::DegradationDataRelationshipsTemplateData, + > = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "data" => { + data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let data = data.ok_or_else(|| M::Error::missing_field("data"))?; + + let content = DegradationDataRelationshipsTemplate { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(DegradationDataRelationshipsTemplateVisitor) + } +} diff --git a/src/datadogV2/model/model_degradation_data_relationships_template_data.rs b/src/datadogV2/model/model_degradation_data_relationships_template_data.rs new file mode 100644 index 000000000..2cf989a52 --- /dev/null +++ b/src/datadogV2/model/model_degradation_data_relationships_template_data.rs @@ -0,0 +1,115 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The data object identifying the template the degradation was created from. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct DegradationDataRelationshipsTemplateData { + /// The ID of the degradation template. + #[serde(rename = "id")] + pub id: String, + /// Degradation templates resource type. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::PatchDegradationTemplateRequestDataType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl DegradationDataRelationshipsTemplateData { + pub fn new( + id: String, + type_: crate::datadogV2::model::PatchDegradationTemplateRequestDataType, + ) -> DegradationDataRelationshipsTemplateData { + DegradationDataRelationshipsTemplateData { + id, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for DegradationDataRelationshipsTemplateData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct DegradationDataRelationshipsTemplateDataVisitor; + impl<'a> Visitor<'a> for DegradationDataRelationshipsTemplateDataVisitor { + type Value = DegradationDataRelationshipsTemplateData; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut id: Option = None; + let mut type_: Option< + crate::datadogV2::model::PatchDegradationTemplateRequestDataType, + > = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "id" => { + id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::PatchDegradationTemplateRequestDataType::UnparsedObject(_type_) => { + _unparsed = true; + }, + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let id = id.ok_or_else(|| M::Error::missing_field("id"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = DegradationDataRelationshipsTemplateData { + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(DegradationDataRelationshipsTemplateDataVisitor) + } +} diff --git a/src/datadogV2/model/model_degradation_template.rs b/src/datadogV2/model/model_degradation_template.rs new file mode 100644 index 000000000..f27f9c365 --- /dev/null +++ b/src/datadogV2/model/model_degradation_template.rs @@ -0,0 +1,122 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Response object for a single degradation template. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct DegradationTemplate { + /// The data object for a degradation template. + #[serde(rename = "data")] + pub data: Option, + /// The included related resources of a degradation template. Client must explicitly request these resources by name in the `include` query parameter. + #[serde(rename = "included")] + pub included: Option>, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl DegradationTemplate { + pub fn new() -> DegradationTemplate { + DegradationTemplate { + data: None, + included: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn data(mut self, value: crate::datadogV2::model::DegradationTemplateData) -> Self { + self.data = Some(value); + self + } + + pub fn included(mut self, value: Vec) -> Self { + self.included = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for DegradationTemplate { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for DegradationTemplate { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct DegradationTemplateVisitor; + impl<'a> Visitor<'a> for DegradationTemplateVisitor { + type Value = DegradationTemplate; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data: Option = None; + let mut included: Option> = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "data" => { + if v.is_null() { + continue; + } + data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "included" => { + if v.is_null() { + continue; + } + included = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = DegradationTemplate { + data, + included, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(DegradationTemplateVisitor) + } +} diff --git a/src/datadogV2/model/model_degradation_template_array.rs b/src/datadogV2/model/model_degradation_template_array.rs new file mode 100644 index 000000000..1e23faa03 --- /dev/null +++ b/src/datadogV2/model/model_degradation_template_array.rs @@ -0,0 +1,111 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Response object for a list of degradation templates. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct DegradationTemplateArray { + /// A list of degradation template data objects. + #[serde(rename = "data")] + pub data: Vec, + /// The included related resources of a degradation template. Client must explicitly request these resources by name in the `include` query parameter. + #[serde(rename = "included")] + pub included: Option>, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl DegradationTemplateArray { + pub fn new( + data: Vec, + ) -> DegradationTemplateArray { + DegradationTemplateArray { + data, + included: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn included(mut self, value: Vec) -> Self { + self.included = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for DegradationTemplateArray { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct DegradationTemplateArrayVisitor; + impl<'a> Visitor<'a> for DegradationTemplateArrayVisitor { + type Value = DegradationTemplateArray; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data: Option> = None; + let mut included: Option> = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "data" => { + data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "included" => { + if v.is_null() { + continue; + } + included = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let data = data.ok_or_else(|| M::Error::missing_field("data"))?; + + let content = DegradationTemplateArray { + data, + included, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(DegradationTemplateArrayVisitor) + } +} diff --git a/src/datadogV2/model/model_degradation_template_data.rs b/src/datadogV2/model/model_degradation_template_data.rs new file mode 100644 index 000000000..5f3a3ad52 --- /dev/null +++ b/src/datadogV2/model/model_degradation_template_data.rs @@ -0,0 +1,166 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The data object for a degradation template. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct DegradationTemplateData { + /// The attributes of a degradation template. + #[serde(rename = "attributes")] + pub attributes: Option, + /// The ID of the degradation template. + #[serde(rename = "id")] + pub id: Option, + /// The relationships of a degradation template. + #[serde(rename = "relationships")] + pub relationships: Option, + /// Degradation templates resource type. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::PatchDegradationTemplateRequestDataType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl DegradationTemplateData { + pub fn new( + type_: crate::datadogV2::model::PatchDegradationTemplateRequestDataType, + ) -> DegradationTemplateData { + DegradationTemplateData { + attributes: None, + id: None, + relationships: None, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn attributes( + mut self, + value: crate::datadogV2::model::DegradationTemplateDataAttributes, + ) -> Self { + self.attributes = Some(value); + self + } + + pub fn id(mut self, value: String) -> Self { + self.id = Some(value); + self + } + + pub fn relationships( + mut self, + value: crate::datadogV2::model::DegradationTemplateDataRelationships, + ) -> Self { + self.relationships = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for DegradationTemplateData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct DegradationTemplateDataVisitor; + impl<'a> Visitor<'a> for DegradationTemplateDataVisitor { + type Value = DegradationTemplateData; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut attributes: Option< + crate::datadogV2::model::DegradationTemplateDataAttributes, + > = None; + let mut id: Option = None; + let mut relationships: Option< + crate::datadogV2::model::DegradationTemplateDataRelationships, + > = None; + let mut type_: Option< + crate::datadogV2::model::PatchDegradationTemplateRequestDataType, + > = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "attributes" => { + if v.is_null() { + continue; + } + attributes = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "id" => { + if v.is_null() { + continue; + } + id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "relationships" => { + if v.is_null() { + continue; + } + relationships = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::PatchDegradationTemplateRequestDataType::UnparsedObject(_type_) => { + _unparsed = true; + }, + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = DegradationTemplateData { + attributes, + id, + relationships, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(DegradationTemplateDataVisitor) + } +} diff --git a/src/datadogV2/model/model_degradation_template_data_attributes.rs b/src/datadogV2/model/model_degradation_template_data_attributes.rs new file mode 100644 index 000000000..2dccc18df --- /dev/null +++ b/src/datadogV2/model/model_degradation_template_data_attributes.rs @@ -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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The attributes of a degradation template. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct DegradationTemplateDataAttributes { + /// The components affected by a degradation created from this template. + #[serde(rename = "components_affected")] + pub components_affected: Option< + Vec, + >, + /// Timestamp of when the degradation template was created. + #[serde(rename = "created_at")] + pub created_at: Option>, + /// The title used for a degradation created from this template. + #[serde(rename = "degradation_title")] + pub degradation_title: Option, + /// Timestamp of when the degradation template was last modified. + #[serde(rename = "modified_at")] + pub modified_at: Option>, + /// The name of the degradation template. + #[serde(rename = "name")] + pub name: Option, + /// The pre-filled updates for a degradation created from this template. + #[serde(rename = "updates")] + pub updates: + Option>, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl DegradationTemplateDataAttributes { + pub fn new() -> DegradationTemplateDataAttributes { + DegradationTemplateDataAttributes { + components_affected: None, + created_at: None, + degradation_title: None, + modified_at: None, + name: None, + updates: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn components_affected( + mut self, + value: Vec< + crate::datadogV2::model::DegradationTemplateDataAttributesComponentsAffectedItems, + >, + ) -> Self { + self.components_affected = Some(value); + self + } + + pub fn created_at(mut self, value: chrono::DateTime) -> Self { + self.created_at = Some(value); + self + } + + pub fn degradation_title(mut self, value: String) -> Self { + self.degradation_title = Some(value); + self + } + + pub fn modified_at(mut self, value: chrono::DateTime) -> Self { + self.modified_at = Some(value); + self + } + + pub fn name(mut self, value: String) -> Self { + self.name = Some(value); + self + } + + pub fn updates( + mut self, + value: Vec, + ) -> Self { + self.updates = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for DegradationTemplateDataAttributes { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for DegradationTemplateDataAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct DegradationTemplateDataAttributesVisitor; + impl<'a> Visitor<'a> for DegradationTemplateDataAttributesVisitor { + type Value = DegradationTemplateDataAttributes; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut components_affected: Option> = None; + let mut created_at: Option> = None; + let mut degradation_title: Option = None; + let mut modified_at: Option> = None; + let mut name: Option = None; + let mut updates: Option< + Vec, + > = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "components_affected" => { + if v.is_null() { + continue; + } + components_affected = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "created_at" => { + if v.is_null() { + continue; + } + created_at = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "degradation_title" => { + if v.is_null() { + continue; + } + degradation_title = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "modified_at" => { + if v.is_null() { + continue; + } + modified_at = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "name" => { + if v.is_null() { + continue; + } + name = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "updates" => { + if v.is_null() { + continue; + } + updates = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = DegradationTemplateDataAttributes { + components_affected, + created_at, + degradation_title, + modified_at, + name, + updates, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(DegradationTemplateDataAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_degradation_template_data_attributes_components_affected_items.rs b/src/datadogV2/model/model_degradation_template_data_attributes_components_affected_items.rs new file mode 100644 index 000000000..50c298552 --- /dev/null +++ b/src/datadogV2/model/model_degradation_template_data_attributes_components_affected_items.rs @@ -0,0 +1,131 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// A component affected by a degradation created from this template. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct DegradationTemplateDataAttributesComponentsAffectedItems { + /// The ID of the component. + #[serde(rename = "id")] + pub id: String, + /// The name of the component. + #[serde(rename = "name")] + pub name: Option, + /// The status of the component. + #[serde(rename = "status")] + pub status: crate::datadogV2::model::PatchDegradationTemplateRequestDataAttributesComponentsAffectedItemsStatus, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool +} + +impl DegradationTemplateDataAttributesComponentsAffectedItems { + pub fn new( + id: String, + status: crate::datadogV2::model::PatchDegradationTemplateRequestDataAttributesComponentsAffectedItemsStatus, + ) -> DegradationTemplateDataAttributesComponentsAffectedItems { + DegradationTemplateDataAttributesComponentsAffectedItems { + id, + name: None, + status, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn name(mut self, value: String) -> Self { + self.name = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for DegradationTemplateDataAttributesComponentsAffectedItems { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct DegradationTemplateDataAttributesComponentsAffectedItemsVisitor; + impl<'a> Visitor<'a> for DegradationTemplateDataAttributesComponentsAffectedItemsVisitor { + type Value = DegradationTemplateDataAttributesComponentsAffectedItems; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut id: Option = None; + let mut name: Option = None; + let mut status: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "id" => { + id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "name" => { + if v.is_null() { + continue; + } + name = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "status" => { + status = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _status) = status { + match _status { + crate::datadogV2::model::PatchDegradationTemplateRequestDataAttributesComponentsAffectedItemsStatus::UnparsedObject(_status) => { + _unparsed = true; + }, + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let id = id.ok_or_else(|| M::Error::missing_field("id"))?; + let status = status.ok_or_else(|| M::Error::missing_field("status"))?; + + let content = DegradationTemplateDataAttributesComponentsAffectedItems { + id, + name, + status, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer + .deserialize_any(DegradationTemplateDataAttributesComponentsAffectedItemsVisitor) + } +} diff --git a/src/datadogV2/model/model_degradation_template_data_attributes_updates_items.rs b/src/datadogV2/model/model_degradation_template_data_attributes_updates_items.rs new file mode 100644 index 000000000..bf2a64b88 --- /dev/null +++ b/src/datadogV2/model/model_degradation_template_data_attributes_updates_items.rs @@ -0,0 +1,121 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// A pre-filled update for a degradation created from this template. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct DegradationTemplateDataAttributesUpdatesItems { + /// The message of the update. + #[serde(rename = "message")] + pub message: Option, + /// The status of the degradation. + #[serde(rename = "status")] + pub status: crate::datadogV2::model::CreateDegradationRequestDataAttributesStatus, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl DegradationTemplateDataAttributesUpdatesItems { + pub fn new( + status: crate::datadogV2::model::CreateDegradationRequestDataAttributesStatus, + ) -> DegradationTemplateDataAttributesUpdatesItems { + DegradationTemplateDataAttributesUpdatesItems { + message: None, + status, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn message(mut self, value: String) -> Self { + self.message = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for DegradationTemplateDataAttributesUpdatesItems { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct DegradationTemplateDataAttributesUpdatesItemsVisitor; + impl<'a> Visitor<'a> for DegradationTemplateDataAttributesUpdatesItemsVisitor { + type Value = DegradationTemplateDataAttributesUpdatesItems; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut message: Option = None; + let mut status: Option< + crate::datadogV2::model::CreateDegradationRequestDataAttributesStatus, + > = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "message" => { + if v.is_null() { + continue; + } + message = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "status" => { + status = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _status) = status { + match _status { + crate::datadogV2::model::CreateDegradationRequestDataAttributesStatus::UnparsedObject(_status) => { + _unparsed = true; + }, + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let status = status.ok_or_else(|| M::Error::missing_field("status"))?; + + let content = DegradationTemplateDataAttributesUpdatesItems { + message, + status, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(DegradationTemplateDataAttributesUpdatesItemsVisitor) + } +} diff --git a/src/datadogV2/model/model_degradation_template_data_relationships.rs b/src/datadogV2/model/model_degradation_template_data_relationships.rs new file mode 100644 index 000000000..e73bd8bd6 --- /dev/null +++ b/src/datadogV2/model/model_degradation_template_data_relationships.rs @@ -0,0 +1,160 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The relationships of a degradation template. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct DegradationTemplateDataRelationships { + /// The Datadog user who created the degradation template. + #[serde(rename = "created_by_user")] + pub created_by_user: + Option, + /// The Datadog user who last modified the degradation template. + #[serde(rename = "last_modified_by_user")] + pub last_modified_by_user: + Option, + /// The status page the degradation template belongs to. + #[serde(rename = "status_page")] + pub status_page: + Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl DegradationTemplateDataRelationships { + pub fn new() -> DegradationTemplateDataRelationships { + DegradationTemplateDataRelationships { + created_by_user: None, + last_modified_by_user: None, + status_page: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn created_by_user( + mut self, + value: crate::datadogV2::model::DegradationTemplateDataRelationshipsCreatedByUser, + ) -> Self { + self.created_by_user = Some(value); + self + } + + pub fn last_modified_by_user( + mut self, + value: crate::datadogV2::model::DegradationTemplateDataRelationshipsLastModifiedByUser, + ) -> Self { + self.last_modified_by_user = Some(value); + self + } + + pub fn status_page( + mut self, + value: crate::datadogV2::model::DegradationTemplateDataRelationshipsStatusPage, + ) -> Self { + self.status_page = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for DegradationTemplateDataRelationships { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for DegradationTemplateDataRelationships { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct DegradationTemplateDataRelationshipsVisitor; + impl<'a> Visitor<'a> for DegradationTemplateDataRelationshipsVisitor { + type Value = DegradationTemplateDataRelationships; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut created_by_user: Option< + crate::datadogV2::model::DegradationTemplateDataRelationshipsCreatedByUser, + > = None; + let mut last_modified_by_user: Option< + crate::datadogV2::model::DegradationTemplateDataRelationshipsLastModifiedByUser, + > = None; + let mut status_page: Option< + crate::datadogV2::model::DegradationTemplateDataRelationshipsStatusPage, + > = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "created_by_user" => { + if v.is_null() { + continue; + } + created_by_user = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "last_modified_by_user" => { + if v.is_null() { + continue; + } + last_modified_by_user = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "status_page" => { + if v.is_null() { + continue; + } + status_page = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = DegradationTemplateDataRelationships { + created_by_user, + last_modified_by_user, + status_page, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(DegradationTemplateDataRelationshipsVisitor) + } +} diff --git a/src/datadogV2/model/model_degradation_template_data_relationships_created_by_user.rs b/src/datadogV2/model/model_degradation_template_data_relationships_created_by_user.rs new file mode 100644 index 000000000..ed0752a3c --- /dev/null +++ b/src/datadogV2/model/model_degradation_template_data_relationships_created_by_user.rs @@ -0,0 +1,96 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The Datadog user who created the degradation template. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct DegradationTemplateDataRelationshipsCreatedByUser { + /// The data object identifying the Datadog user who created the degradation template. + #[serde(rename = "data")] + pub data: crate::datadogV2::model::DegradationTemplateDataRelationshipsCreatedByUserData, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl DegradationTemplateDataRelationshipsCreatedByUser { + pub fn new( + data: crate::datadogV2::model::DegradationTemplateDataRelationshipsCreatedByUserData, + ) -> DegradationTemplateDataRelationshipsCreatedByUser { + DegradationTemplateDataRelationshipsCreatedByUser { + data, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for DegradationTemplateDataRelationshipsCreatedByUser { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct DegradationTemplateDataRelationshipsCreatedByUserVisitor; + impl<'a> Visitor<'a> for DegradationTemplateDataRelationshipsCreatedByUserVisitor { + type Value = DegradationTemplateDataRelationshipsCreatedByUser; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data: Option< + crate::datadogV2::model::DegradationTemplateDataRelationshipsCreatedByUserData, + > = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "data" => { + data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let data = data.ok_or_else(|| M::Error::missing_field("data"))?; + + let content = DegradationTemplateDataRelationshipsCreatedByUser { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(DegradationTemplateDataRelationshipsCreatedByUserVisitor) + } +} diff --git a/src/datadogV2/model/model_degradation_template_data_relationships_created_by_user_data.rs b/src/datadogV2/model/model_degradation_template_data_relationships_created_by_user_data.rs new file mode 100644 index 000000000..bbbeb9921 --- /dev/null +++ b/src/datadogV2/model/model_degradation_template_data_relationships_created_by_user_data.rs @@ -0,0 +1,113 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The data object identifying the Datadog user who created the degradation template. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct DegradationTemplateDataRelationshipsCreatedByUserData { + /// The ID of the Datadog user who created the degradation template. + #[serde(rename = "id")] + pub id: String, + /// Users resource type. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::StatusPagesUserType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl DegradationTemplateDataRelationshipsCreatedByUserData { + pub fn new( + id: String, + type_: crate::datadogV2::model::StatusPagesUserType, + ) -> DegradationTemplateDataRelationshipsCreatedByUserData { + DegradationTemplateDataRelationshipsCreatedByUserData { + id, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for DegradationTemplateDataRelationshipsCreatedByUserData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct DegradationTemplateDataRelationshipsCreatedByUserDataVisitor; + impl<'a> Visitor<'a> for DegradationTemplateDataRelationshipsCreatedByUserDataVisitor { + type Value = DegradationTemplateDataRelationshipsCreatedByUserData; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut id: Option = None; + let mut type_: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "id" => { + id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::StatusPagesUserType::UnparsedObject(_type_) => { + _unparsed = true; + }, + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let id = id.ok_or_else(|| M::Error::missing_field("id"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = DegradationTemplateDataRelationshipsCreatedByUserData { + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(DegradationTemplateDataRelationshipsCreatedByUserDataVisitor) + } +} diff --git a/src/datadogV2/model/model_degradation_template_data_relationships_last_modified_by_user.rs b/src/datadogV2/model/model_degradation_template_data_relationships_last_modified_by_user.rs new file mode 100644 index 000000000..bec4b9b40 --- /dev/null +++ b/src/datadogV2/model/model_degradation_template_data_relationships_last_modified_by_user.rs @@ -0,0 +1,94 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The Datadog user who last modified the degradation template. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct DegradationTemplateDataRelationshipsLastModifiedByUser { + /// The data object identifying the Datadog user who last modified the degradation template. + #[serde(rename = "data")] + pub data: crate::datadogV2::model::DegradationTemplateDataRelationshipsLastModifiedByUserData, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl DegradationTemplateDataRelationshipsLastModifiedByUser { + pub fn new( + data: crate::datadogV2::model::DegradationTemplateDataRelationshipsLastModifiedByUserData, + ) -> DegradationTemplateDataRelationshipsLastModifiedByUser { + DegradationTemplateDataRelationshipsLastModifiedByUser { + data, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for DegradationTemplateDataRelationshipsLastModifiedByUser { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct DegradationTemplateDataRelationshipsLastModifiedByUserVisitor; + impl<'a> Visitor<'a> for DegradationTemplateDataRelationshipsLastModifiedByUserVisitor { + type Value = DegradationTemplateDataRelationshipsLastModifiedByUser; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "data" => { + data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let data = data.ok_or_else(|| M::Error::missing_field("data"))?; + + let content = DegradationTemplateDataRelationshipsLastModifiedByUser { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(DegradationTemplateDataRelationshipsLastModifiedByUserVisitor) + } +} diff --git a/src/datadogV2/model/model_degradation_template_data_relationships_last_modified_by_user_data.rs b/src/datadogV2/model/model_degradation_template_data_relationships_last_modified_by_user_data.rs new file mode 100644 index 000000000..aff21cfed --- /dev/null +++ b/src/datadogV2/model/model_degradation_template_data_relationships_last_modified_by_user_data.rs @@ -0,0 +1,114 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The data object identifying the Datadog user who last modified the degradation template. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct DegradationTemplateDataRelationshipsLastModifiedByUserData { + /// The ID of the Datadog user who last modified the degradation template. + #[serde(rename = "id")] + pub id: String, + /// Users resource type. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::StatusPagesUserType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl DegradationTemplateDataRelationshipsLastModifiedByUserData { + pub fn new( + id: String, + type_: crate::datadogV2::model::StatusPagesUserType, + ) -> DegradationTemplateDataRelationshipsLastModifiedByUserData { + DegradationTemplateDataRelationshipsLastModifiedByUserData { + id, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for DegradationTemplateDataRelationshipsLastModifiedByUserData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct DegradationTemplateDataRelationshipsLastModifiedByUserDataVisitor; + impl<'a> Visitor<'a> for DegradationTemplateDataRelationshipsLastModifiedByUserDataVisitor { + type Value = DegradationTemplateDataRelationshipsLastModifiedByUserData; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut id: Option = None; + let mut type_: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "id" => { + id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::StatusPagesUserType::UnparsedObject(_type_) => { + _unparsed = true; + }, + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let id = id.ok_or_else(|| M::Error::missing_field("id"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = DegradationTemplateDataRelationshipsLastModifiedByUserData { + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer + .deserialize_any(DegradationTemplateDataRelationshipsLastModifiedByUserDataVisitor) + } +} diff --git a/src/datadogV2/model/model_degradation_template_data_relationships_status_page.rs b/src/datadogV2/model/model_degradation_template_data_relationships_status_page.rs new file mode 100644 index 000000000..eadf12577 --- /dev/null +++ b/src/datadogV2/model/model_degradation_template_data_relationships_status_page.rs @@ -0,0 +1,96 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The status page the degradation template belongs to. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct DegradationTemplateDataRelationshipsStatusPage { + /// The data object identifying the status page associated with a degradation template. + #[serde(rename = "data")] + pub data: crate::datadogV2::model::DegradationTemplateDataRelationshipsStatusPageData, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl DegradationTemplateDataRelationshipsStatusPage { + pub fn new( + data: crate::datadogV2::model::DegradationTemplateDataRelationshipsStatusPageData, + ) -> DegradationTemplateDataRelationshipsStatusPage { + DegradationTemplateDataRelationshipsStatusPage { + data, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for DegradationTemplateDataRelationshipsStatusPage { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct DegradationTemplateDataRelationshipsStatusPageVisitor; + impl<'a> Visitor<'a> for DegradationTemplateDataRelationshipsStatusPageVisitor { + type Value = DegradationTemplateDataRelationshipsStatusPage; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data: Option< + crate::datadogV2::model::DegradationTemplateDataRelationshipsStatusPageData, + > = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "data" => { + data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let data = data.ok_or_else(|| M::Error::missing_field("data"))?; + + let content = DegradationTemplateDataRelationshipsStatusPage { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(DegradationTemplateDataRelationshipsStatusPageVisitor) + } +} diff --git a/src/datadogV2/model/model_degradation_template_data_relationships_status_page_data.rs b/src/datadogV2/model/model_degradation_template_data_relationships_status_page_data.rs new file mode 100644 index 000000000..3058fe92f --- /dev/null +++ b/src/datadogV2/model/model_degradation_template_data_relationships_status_page_data.rs @@ -0,0 +1,115 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The data object identifying the status page associated with a degradation template. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct DegradationTemplateDataRelationshipsStatusPageData { + /// The ID of the status page. + #[serde(rename = "id")] + pub id: String, + /// Status pages resource type. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::StatusPageDataType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl DegradationTemplateDataRelationshipsStatusPageData { + pub fn new( + id: String, + type_: crate::datadogV2::model::StatusPageDataType, + ) -> DegradationTemplateDataRelationshipsStatusPageData { + DegradationTemplateDataRelationshipsStatusPageData { + id, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for DegradationTemplateDataRelationshipsStatusPageData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct DegradationTemplateDataRelationshipsStatusPageDataVisitor; + impl<'a> Visitor<'a> for DegradationTemplateDataRelationshipsStatusPageDataVisitor { + type Value = DegradationTemplateDataRelationshipsStatusPageData; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut id: Option = None; + let mut type_: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "id" => { + id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::StatusPageDataType::UnparsedObject( + _type_, + ) => { + _unparsed = true; + } + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let id = id.ok_or_else(|| M::Error::missing_field("id"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = DegradationTemplateDataRelationshipsStatusPageData { + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(DegradationTemplateDataRelationshipsStatusPageDataVisitor) + } +} diff --git a/src/datadogV2/model/model_maintenance_data_relationships.rs b/src/datadogV2/model/model_maintenance_data_relationships.rs index 1b4657c7b..e5493af8c 100644 --- a/src/datadogV2/model/model_maintenance_data_relationships.rs +++ b/src/datadogV2/model/model_maintenance_data_relationships.rs @@ -21,6 +21,9 @@ pub struct MaintenanceDataRelationships { /// The status page the maintenance belongs to. #[serde(rename = "status_page")] pub status_page: Option, + /// The template the maintenance was created from. + #[serde(rename = "template")] + pub template: Option, #[serde(flatten)] pub additional_properties: std::collections::BTreeMap, #[serde(skip)] @@ -34,6 +37,7 @@ impl MaintenanceDataRelationships { created_by_user: None, last_modified_by_user: None, status_page: None, + template: None, additional_properties: std::collections::BTreeMap::new(), _unparsed: false, } @@ -63,6 +67,14 @@ impl MaintenanceDataRelationships { self } + pub fn template( + mut self, + value: crate::datadogV2::model::MaintenanceDataRelationshipsTemplate, + ) -> Self { + self.template = Some(value); + self + } + pub fn additional_properties( mut self, value: std::collections::BTreeMap, @@ -104,6 +116,9 @@ impl<'de> Deserialize<'de> for MaintenanceDataRelationships { let mut status_page: Option< crate::datadogV2::model::MaintenanceDataRelationshipsStatusPage, > = None; + let mut template: Option< + crate::datadogV2::model::MaintenanceDataRelationshipsTemplate, + > = None; let mut additional_properties: std::collections::BTreeMap< String, serde_json::Value, @@ -133,6 +148,12 @@ impl<'de> Deserialize<'de> for MaintenanceDataRelationships { status_page = Some(serde_json::from_value(v).map_err(M::Error::custom)?); } + "template" => { + if v.is_null() { + continue; + } + template = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } &_ => { if let Ok(value) = serde_json::from_value(v.clone()) { additional_properties.insert(k, value); @@ -145,6 +166,7 @@ impl<'de> Deserialize<'de> for MaintenanceDataRelationships { created_by_user, last_modified_by_user, status_page, + template, additional_properties, _unparsed, }; diff --git a/src/datadogV2/model/model_maintenance_data_relationships_template.rs b/src/datadogV2/model/model_maintenance_data_relationships_template.rs new file mode 100644 index 000000000..70f8c2f23 --- /dev/null +++ b/src/datadogV2/model/model_maintenance_data_relationships_template.rs @@ -0,0 +1,96 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The template the maintenance was created from. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct MaintenanceDataRelationshipsTemplate { + /// The data object identifying the template the maintenance was created from. + #[serde(rename = "data")] + pub data: crate::datadogV2::model::MaintenanceDataRelationshipsTemplateData, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl MaintenanceDataRelationshipsTemplate { + pub fn new( + data: crate::datadogV2::model::MaintenanceDataRelationshipsTemplateData, + ) -> MaintenanceDataRelationshipsTemplate { + MaintenanceDataRelationshipsTemplate { + data, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for MaintenanceDataRelationshipsTemplate { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct MaintenanceDataRelationshipsTemplateVisitor; + impl<'a> Visitor<'a> for MaintenanceDataRelationshipsTemplateVisitor { + type Value = MaintenanceDataRelationshipsTemplate; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data: Option< + crate::datadogV2::model::MaintenanceDataRelationshipsTemplateData, + > = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "data" => { + data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let data = data.ok_or_else(|| M::Error::missing_field("data"))?; + + let content = MaintenanceDataRelationshipsTemplate { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(MaintenanceDataRelationshipsTemplateVisitor) + } +} diff --git a/src/datadogV2/model/model_maintenance_data_relationships_template_data.rs b/src/datadogV2/model/model_maintenance_data_relationships_template_data.rs new file mode 100644 index 000000000..fbe1ae7a9 --- /dev/null +++ b/src/datadogV2/model/model_maintenance_data_relationships_template_data.rs @@ -0,0 +1,115 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The data object identifying the template the maintenance was created from. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct MaintenanceDataRelationshipsTemplateData { + /// The ID of the maintenance template. + #[serde(rename = "id")] + pub id: String, + /// Maintenance templates resource type. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::PatchMaintenanceTemplateRequestDataType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl MaintenanceDataRelationshipsTemplateData { + pub fn new( + id: String, + type_: crate::datadogV2::model::PatchMaintenanceTemplateRequestDataType, + ) -> MaintenanceDataRelationshipsTemplateData { + MaintenanceDataRelationshipsTemplateData { + id, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for MaintenanceDataRelationshipsTemplateData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct MaintenanceDataRelationshipsTemplateDataVisitor; + impl<'a> Visitor<'a> for MaintenanceDataRelationshipsTemplateDataVisitor { + type Value = MaintenanceDataRelationshipsTemplateData; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut id: Option = None; + let mut type_: Option< + crate::datadogV2::model::PatchMaintenanceTemplateRequestDataType, + > = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "id" => { + id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::PatchMaintenanceTemplateRequestDataType::UnparsedObject(_type_) => { + _unparsed = true; + }, + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let id = id.ok_or_else(|| M::Error::missing_field("id"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = MaintenanceDataRelationshipsTemplateData { + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(MaintenanceDataRelationshipsTemplateDataVisitor) + } +} diff --git a/src/datadogV2/model/model_maintenance_template.rs b/src/datadogV2/model/model_maintenance_template.rs new file mode 100644 index 000000000..09813f42e --- /dev/null +++ b/src/datadogV2/model/model_maintenance_template.rs @@ -0,0 +1,122 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Response object for a single maintenance template. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct MaintenanceTemplate { + /// The data object for a maintenance template. + #[serde(rename = "data")] + pub data: Option, + /// The included related resources of a maintenance template. Client must explicitly request these resources by name in the `include` query parameter. + #[serde(rename = "included")] + pub included: Option>, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl MaintenanceTemplate { + pub fn new() -> MaintenanceTemplate { + MaintenanceTemplate { + data: None, + included: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn data(mut self, value: crate::datadogV2::model::MaintenanceTemplateData) -> Self { + self.data = Some(value); + self + } + + pub fn included(mut self, value: Vec) -> Self { + self.included = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for MaintenanceTemplate { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for MaintenanceTemplate { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct MaintenanceTemplateVisitor; + impl<'a> Visitor<'a> for MaintenanceTemplateVisitor { + type Value = MaintenanceTemplate; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data: Option = None; + let mut included: Option> = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "data" => { + if v.is_null() { + continue; + } + data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "included" => { + if v.is_null() { + continue; + } + included = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = MaintenanceTemplate { + data, + included, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(MaintenanceTemplateVisitor) + } +} diff --git a/src/datadogV2/model/model_maintenance_template_array.rs b/src/datadogV2/model/model_maintenance_template_array.rs new file mode 100644 index 000000000..8484a6f8f --- /dev/null +++ b/src/datadogV2/model/model_maintenance_template_array.rs @@ -0,0 +1,111 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Response object for a list of maintenance templates. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct MaintenanceTemplateArray { + /// A list of maintenance template data objects. + #[serde(rename = "data")] + pub data: Vec, + /// The included related resources of a maintenance template. Client must explicitly request these resources by name in the `include` query parameter. + #[serde(rename = "included")] + pub included: Option>, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl MaintenanceTemplateArray { + pub fn new( + data: Vec, + ) -> MaintenanceTemplateArray { + MaintenanceTemplateArray { + data, + included: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn included(mut self, value: Vec) -> Self { + self.included = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for MaintenanceTemplateArray { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct MaintenanceTemplateArrayVisitor; + impl<'a> Visitor<'a> for MaintenanceTemplateArrayVisitor { + type Value = MaintenanceTemplateArray; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data: Option> = None; + let mut included: Option> = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "data" => { + data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "included" => { + if v.is_null() { + continue; + } + included = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let data = data.ok_or_else(|| M::Error::missing_field("data"))?; + + let content = MaintenanceTemplateArray { + data, + included, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(MaintenanceTemplateArrayVisitor) + } +} diff --git a/src/datadogV2/model/model_maintenance_template_data.rs b/src/datadogV2/model/model_maintenance_template_data.rs new file mode 100644 index 000000000..94403e03e --- /dev/null +++ b/src/datadogV2/model/model_maintenance_template_data.rs @@ -0,0 +1,166 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The data object for a maintenance template. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct MaintenanceTemplateData { + /// The attributes of a maintenance template. + #[serde(rename = "attributes")] + pub attributes: Option, + /// The ID of the maintenance template. + #[serde(rename = "id")] + pub id: Option, + /// The relationships of a maintenance template. + #[serde(rename = "relationships")] + pub relationships: Option, + /// Maintenance templates resource type. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::PatchMaintenanceTemplateRequestDataType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl MaintenanceTemplateData { + pub fn new( + type_: crate::datadogV2::model::PatchMaintenanceTemplateRequestDataType, + ) -> MaintenanceTemplateData { + MaintenanceTemplateData { + attributes: None, + id: None, + relationships: None, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn attributes( + mut self, + value: crate::datadogV2::model::MaintenanceTemplateDataAttributes, + ) -> Self { + self.attributes = Some(value); + self + } + + pub fn id(mut self, value: String) -> Self { + self.id = Some(value); + self + } + + pub fn relationships( + mut self, + value: crate::datadogV2::model::MaintenanceTemplateDataRelationships, + ) -> Self { + self.relationships = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for MaintenanceTemplateData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct MaintenanceTemplateDataVisitor; + impl<'a> Visitor<'a> for MaintenanceTemplateDataVisitor { + type Value = MaintenanceTemplateData; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut attributes: Option< + crate::datadogV2::model::MaintenanceTemplateDataAttributes, + > = None; + let mut id: Option = None; + let mut relationships: Option< + crate::datadogV2::model::MaintenanceTemplateDataRelationships, + > = None; + let mut type_: Option< + crate::datadogV2::model::PatchMaintenanceTemplateRequestDataType, + > = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "attributes" => { + if v.is_null() { + continue; + } + attributes = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "id" => { + if v.is_null() { + continue; + } + id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "relationships" => { + if v.is_null() { + continue; + } + relationships = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::PatchMaintenanceTemplateRequestDataType::UnparsedObject(_type_) => { + _unparsed = true; + }, + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = MaintenanceTemplateData { + attributes, + id, + relationships, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(MaintenanceTemplateDataVisitor) + } +} diff --git a/src/datadogV2/model/model_maintenance_template_data_attributes.rs b/src/datadogV2/model/model_maintenance_template_data_attributes.rs new file mode 100644 index 000000000..614156041 --- /dev/null +++ b/src/datadogV2/model/model_maintenance_template_data_attributes.rs @@ -0,0 +1,230 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The attributes of a maintenance template. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct MaintenanceTemplateDataAttributes { + /// The description shown when a maintenance created from this template is completed. + #[serde(rename = "completed_description")] + pub completed_description: Option, + /// The IDs of the components affected by a maintenance created from this template. + #[serde(rename = "component_ids")] + pub component_ids: Option>, + /// Timestamp of when the maintenance template was created. + #[serde(rename = "created_at")] + pub created_at: Option>, + /// The description shown while a maintenance created from this template is in progress. + #[serde(rename = "in_progress_description")] + pub in_progress_description: Option, + /// The title used for a maintenance created from this template. + #[serde(rename = "maintenance_title")] + pub maintenance_title: Option, + /// Timestamp of when the maintenance template was last modified. + #[serde(rename = "modified_at")] + pub modified_at: Option>, + /// The name of the maintenance template. + #[serde(rename = "name")] + pub name: Option, + /// The description shown when a maintenance created from this template is scheduled. + #[serde(rename = "scheduled_description")] + pub scheduled_description: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl MaintenanceTemplateDataAttributes { + pub fn new() -> MaintenanceTemplateDataAttributes { + MaintenanceTemplateDataAttributes { + completed_description: None, + component_ids: None, + created_at: None, + in_progress_description: None, + maintenance_title: None, + modified_at: None, + name: None, + scheduled_description: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn completed_description(mut self, value: String) -> Self { + self.completed_description = Some(value); + self + } + + pub fn component_ids(mut self, value: Vec) -> Self { + self.component_ids = Some(value); + self + } + + pub fn created_at(mut self, value: chrono::DateTime) -> Self { + self.created_at = Some(value); + self + } + + pub fn in_progress_description(mut self, value: String) -> Self { + self.in_progress_description = Some(value); + self + } + + pub fn maintenance_title(mut self, value: String) -> Self { + self.maintenance_title = Some(value); + self + } + + pub fn modified_at(mut self, value: chrono::DateTime) -> Self { + self.modified_at = Some(value); + self + } + + pub fn name(mut self, value: String) -> Self { + self.name = Some(value); + self + } + + pub fn scheduled_description(mut self, value: String) -> Self { + self.scheduled_description = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for MaintenanceTemplateDataAttributes { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for MaintenanceTemplateDataAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct MaintenanceTemplateDataAttributesVisitor; + impl<'a> Visitor<'a> for MaintenanceTemplateDataAttributesVisitor { + type Value = MaintenanceTemplateDataAttributes; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut completed_description: Option = None; + let mut component_ids: Option> = None; + let mut created_at: Option> = None; + let mut in_progress_description: Option = None; + let mut maintenance_title: Option = None; + let mut modified_at: Option> = None; + let mut name: Option = None; + let mut scheduled_description: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "completed_description" => { + if v.is_null() { + continue; + } + completed_description = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "component_ids" => { + if v.is_null() { + continue; + } + component_ids = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "created_at" => { + if v.is_null() { + continue; + } + created_at = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "in_progress_description" => { + if v.is_null() { + continue; + } + in_progress_description = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "maintenance_title" => { + if v.is_null() { + continue; + } + maintenance_title = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "modified_at" => { + if v.is_null() { + continue; + } + modified_at = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "name" => { + if v.is_null() { + continue; + } + name = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "scheduled_description" => { + if v.is_null() { + continue; + } + scheduled_description = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = MaintenanceTemplateDataAttributes { + completed_description, + component_ids, + created_at, + in_progress_description, + maintenance_title, + modified_at, + name, + scheduled_description, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(MaintenanceTemplateDataAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_maintenance_template_data_relationships.rs b/src/datadogV2/model/model_maintenance_template_data_relationships.rs new file mode 100644 index 000000000..ba15dca10 --- /dev/null +++ b/src/datadogV2/model/model_maintenance_template_data_relationships.rs @@ -0,0 +1,160 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The relationships of a maintenance template. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct MaintenanceTemplateDataRelationships { + /// The Datadog user who created the maintenance template. + #[serde(rename = "created_by_user")] + pub created_by_user: + Option, + /// The Datadog user who last modified the maintenance template. + #[serde(rename = "last_modified_by_user")] + pub last_modified_by_user: + Option, + /// The status page the maintenance template belongs to. + #[serde(rename = "status_page")] + pub status_page: + Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl MaintenanceTemplateDataRelationships { + pub fn new() -> MaintenanceTemplateDataRelationships { + MaintenanceTemplateDataRelationships { + created_by_user: None, + last_modified_by_user: None, + status_page: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn created_by_user( + mut self, + value: crate::datadogV2::model::MaintenanceTemplateDataRelationshipsCreatedByUser, + ) -> Self { + self.created_by_user = Some(value); + self + } + + pub fn last_modified_by_user( + mut self, + value: crate::datadogV2::model::MaintenanceTemplateDataRelationshipsLastModifiedByUser, + ) -> Self { + self.last_modified_by_user = Some(value); + self + } + + pub fn status_page( + mut self, + value: crate::datadogV2::model::MaintenanceTemplateDataRelationshipsStatusPage, + ) -> Self { + self.status_page = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for MaintenanceTemplateDataRelationships { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for MaintenanceTemplateDataRelationships { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct MaintenanceTemplateDataRelationshipsVisitor; + impl<'a> Visitor<'a> for MaintenanceTemplateDataRelationshipsVisitor { + type Value = MaintenanceTemplateDataRelationships; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut created_by_user: Option< + crate::datadogV2::model::MaintenanceTemplateDataRelationshipsCreatedByUser, + > = None; + let mut last_modified_by_user: Option< + crate::datadogV2::model::MaintenanceTemplateDataRelationshipsLastModifiedByUser, + > = None; + let mut status_page: Option< + crate::datadogV2::model::MaintenanceTemplateDataRelationshipsStatusPage, + > = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "created_by_user" => { + if v.is_null() { + continue; + } + created_by_user = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "last_modified_by_user" => { + if v.is_null() { + continue; + } + last_modified_by_user = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "status_page" => { + if v.is_null() { + continue; + } + status_page = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = MaintenanceTemplateDataRelationships { + created_by_user, + last_modified_by_user, + status_page, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(MaintenanceTemplateDataRelationshipsVisitor) + } +} diff --git a/src/datadogV2/model/model_maintenance_template_data_relationships_created_by_user.rs b/src/datadogV2/model/model_maintenance_template_data_relationships_created_by_user.rs new file mode 100644 index 000000000..7c5dccf44 --- /dev/null +++ b/src/datadogV2/model/model_maintenance_template_data_relationships_created_by_user.rs @@ -0,0 +1,96 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The Datadog user who created the maintenance template. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct MaintenanceTemplateDataRelationshipsCreatedByUser { + /// The data object identifying the Datadog user who created the maintenance template. + #[serde(rename = "data")] + pub data: crate::datadogV2::model::MaintenanceTemplateDataRelationshipsCreatedByUserData, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl MaintenanceTemplateDataRelationshipsCreatedByUser { + pub fn new( + data: crate::datadogV2::model::MaintenanceTemplateDataRelationshipsCreatedByUserData, + ) -> MaintenanceTemplateDataRelationshipsCreatedByUser { + MaintenanceTemplateDataRelationshipsCreatedByUser { + data, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for MaintenanceTemplateDataRelationshipsCreatedByUser { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct MaintenanceTemplateDataRelationshipsCreatedByUserVisitor; + impl<'a> Visitor<'a> for MaintenanceTemplateDataRelationshipsCreatedByUserVisitor { + type Value = MaintenanceTemplateDataRelationshipsCreatedByUser; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data: Option< + crate::datadogV2::model::MaintenanceTemplateDataRelationshipsCreatedByUserData, + > = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "data" => { + data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let data = data.ok_or_else(|| M::Error::missing_field("data"))?; + + let content = MaintenanceTemplateDataRelationshipsCreatedByUser { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(MaintenanceTemplateDataRelationshipsCreatedByUserVisitor) + } +} diff --git a/src/datadogV2/model/model_maintenance_template_data_relationships_created_by_user_data.rs b/src/datadogV2/model/model_maintenance_template_data_relationships_created_by_user_data.rs new file mode 100644 index 000000000..e0e54a412 --- /dev/null +++ b/src/datadogV2/model/model_maintenance_template_data_relationships_created_by_user_data.rs @@ -0,0 +1,113 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The data object identifying the Datadog user who created the maintenance template. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct MaintenanceTemplateDataRelationshipsCreatedByUserData { + /// The ID of the Datadog user who created the maintenance template. + #[serde(rename = "id")] + pub id: String, + /// Users resource type. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::StatusPagesUserType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl MaintenanceTemplateDataRelationshipsCreatedByUserData { + pub fn new( + id: String, + type_: crate::datadogV2::model::StatusPagesUserType, + ) -> MaintenanceTemplateDataRelationshipsCreatedByUserData { + MaintenanceTemplateDataRelationshipsCreatedByUserData { + id, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for MaintenanceTemplateDataRelationshipsCreatedByUserData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct MaintenanceTemplateDataRelationshipsCreatedByUserDataVisitor; + impl<'a> Visitor<'a> for MaintenanceTemplateDataRelationshipsCreatedByUserDataVisitor { + type Value = MaintenanceTemplateDataRelationshipsCreatedByUserData; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut id: Option = None; + let mut type_: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "id" => { + id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::StatusPagesUserType::UnparsedObject(_type_) => { + _unparsed = true; + }, + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let id = id.ok_or_else(|| M::Error::missing_field("id"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = MaintenanceTemplateDataRelationshipsCreatedByUserData { + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(MaintenanceTemplateDataRelationshipsCreatedByUserDataVisitor) + } +} diff --git a/src/datadogV2/model/model_maintenance_template_data_relationships_last_modified_by_user.rs b/src/datadogV2/model/model_maintenance_template_data_relationships_last_modified_by_user.rs new file mode 100644 index 000000000..eb480ff4a --- /dev/null +++ b/src/datadogV2/model/model_maintenance_template_data_relationships_last_modified_by_user.rs @@ -0,0 +1,94 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The Datadog user who last modified the maintenance template. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct MaintenanceTemplateDataRelationshipsLastModifiedByUser { + /// The data object identifying the Datadog user who last modified the maintenance template. + #[serde(rename = "data")] + pub data: crate::datadogV2::model::MaintenanceTemplateDataRelationshipsLastModifiedByUserData, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl MaintenanceTemplateDataRelationshipsLastModifiedByUser { + pub fn new( + data: crate::datadogV2::model::MaintenanceTemplateDataRelationshipsLastModifiedByUserData, + ) -> MaintenanceTemplateDataRelationshipsLastModifiedByUser { + MaintenanceTemplateDataRelationshipsLastModifiedByUser { + data, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for MaintenanceTemplateDataRelationshipsLastModifiedByUser { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct MaintenanceTemplateDataRelationshipsLastModifiedByUserVisitor; + impl<'a> Visitor<'a> for MaintenanceTemplateDataRelationshipsLastModifiedByUserVisitor { + type Value = MaintenanceTemplateDataRelationshipsLastModifiedByUser; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "data" => { + data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let data = data.ok_or_else(|| M::Error::missing_field("data"))?; + + let content = MaintenanceTemplateDataRelationshipsLastModifiedByUser { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(MaintenanceTemplateDataRelationshipsLastModifiedByUserVisitor) + } +} diff --git a/src/datadogV2/model/model_maintenance_template_data_relationships_last_modified_by_user_data.rs b/src/datadogV2/model/model_maintenance_template_data_relationships_last_modified_by_user_data.rs new file mode 100644 index 000000000..e27fedcfc --- /dev/null +++ b/src/datadogV2/model/model_maintenance_template_data_relationships_last_modified_by_user_data.rs @@ -0,0 +1,114 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The data object identifying the Datadog user who last modified the maintenance template. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct MaintenanceTemplateDataRelationshipsLastModifiedByUserData { + /// The ID of the Datadog user who last modified the maintenance template. + #[serde(rename = "id")] + pub id: String, + /// Users resource type. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::StatusPagesUserType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl MaintenanceTemplateDataRelationshipsLastModifiedByUserData { + pub fn new( + id: String, + type_: crate::datadogV2::model::StatusPagesUserType, + ) -> MaintenanceTemplateDataRelationshipsLastModifiedByUserData { + MaintenanceTemplateDataRelationshipsLastModifiedByUserData { + id, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for MaintenanceTemplateDataRelationshipsLastModifiedByUserData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct MaintenanceTemplateDataRelationshipsLastModifiedByUserDataVisitor; + impl<'a> Visitor<'a> for MaintenanceTemplateDataRelationshipsLastModifiedByUserDataVisitor { + type Value = MaintenanceTemplateDataRelationshipsLastModifiedByUserData; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut id: Option = None; + let mut type_: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "id" => { + id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::StatusPagesUserType::UnparsedObject(_type_) => { + _unparsed = true; + }, + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let id = id.ok_or_else(|| M::Error::missing_field("id"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = MaintenanceTemplateDataRelationshipsLastModifiedByUserData { + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer + .deserialize_any(MaintenanceTemplateDataRelationshipsLastModifiedByUserDataVisitor) + } +} diff --git a/src/datadogV2/model/model_maintenance_template_data_relationships_status_page.rs b/src/datadogV2/model/model_maintenance_template_data_relationships_status_page.rs new file mode 100644 index 000000000..b01dd3df7 --- /dev/null +++ b/src/datadogV2/model/model_maintenance_template_data_relationships_status_page.rs @@ -0,0 +1,96 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The status page the maintenance template belongs to. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct MaintenanceTemplateDataRelationshipsStatusPage { + /// The data object identifying the status page associated with a maintenance template. + #[serde(rename = "data")] + pub data: crate::datadogV2::model::MaintenanceTemplateDataRelationshipsStatusPageData, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl MaintenanceTemplateDataRelationshipsStatusPage { + pub fn new( + data: crate::datadogV2::model::MaintenanceTemplateDataRelationshipsStatusPageData, + ) -> MaintenanceTemplateDataRelationshipsStatusPage { + MaintenanceTemplateDataRelationshipsStatusPage { + data, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for MaintenanceTemplateDataRelationshipsStatusPage { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct MaintenanceTemplateDataRelationshipsStatusPageVisitor; + impl<'a> Visitor<'a> for MaintenanceTemplateDataRelationshipsStatusPageVisitor { + type Value = MaintenanceTemplateDataRelationshipsStatusPage; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data: Option< + crate::datadogV2::model::MaintenanceTemplateDataRelationshipsStatusPageData, + > = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "data" => { + data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let data = data.ok_or_else(|| M::Error::missing_field("data"))?; + + let content = MaintenanceTemplateDataRelationshipsStatusPage { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(MaintenanceTemplateDataRelationshipsStatusPageVisitor) + } +} diff --git a/src/datadogV2/model/model_maintenance_template_data_relationships_status_page_data.rs b/src/datadogV2/model/model_maintenance_template_data_relationships_status_page_data.rs new file mode 100644 index 000000000..d1c79bddd --- /dev/null +++ b/src/datadogV2/model/model_maintenance_template_data_relationships_status_page_data.rs @@ -0,0 +1,115 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The data object identifying the status page associated with a maintenance template. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct MaintenanceTemplateDataRelationshipsStatusPageData { + /// The ID of the status page. + #[serde(rename = "id")] + pub id: String, + /// Status pages resource type. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::StatusPageDataType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl MaintenanceTemplateDataRelationshipsStatusPageData { + pub fn new( + id: String, + type_: crate::datadogV2::model::StatusPageDataType, + ) -> MaintenanceTemplateDataRelationshipsStatusPageData { + MaintenanceTemplateDataRelationshipsStatusPageData { + id, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for MaintenanceTemplateDataRelationshipsStatusPageData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct MaintenanceTemplateDataRelationshipsStatusPageDataVisitor; + impl<'a> Visitor<'a> for MaintenanceTemplateDataRelationshipsStatusPageDataVisitor { + type Value = MaintenanceTemplateDataRelationshipsStatusPageData; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut id: Option = None; + let mut type_: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "id" => { + id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::StatusPageDataType::UnparsedObject( + _type_, + ) => { + _unparsed = true; + } + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let id = id.ok_or_else(|| M::Error::missing_field("id"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = MaintenanceTemplateDataRelationshipsStatusPageData { + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(MaintenanceTemplateDataRelationshipsStatusPageDataVisitor) + } +} diff --git a/src/datadogV2/model/model_patch_degradation_request_data.rs b/src/datadogV2/model/model_patch_degradation_request_data.rs index 1d8b3e8d2..9d23f11e4 100644 --- a/src/datadogV2/model/model_patch_degradation_request_data.rs +++ b/src/datadogV2/model/model_patch_degradation_request_data.rs @@ -17,6 +17,9 @@ pub struct PatchDegradationRequestData { /// The ID of the degradation. #[serde(rename = "id")] pub id: uuid::Uuid, + /// The supported relationships for updating a degradation. + #[serde(rename = "relationships")] + pub relationships: Option, /// Degradations resource type. #[serde(rename = "type")] pub type_: crate::datadogV2::model::PatchDegradationRequestDataType, @@ -36,12 +39,21 @@ impl PatchDegradationRequestData { PatchDegradationRequestData { attributes, id, + relationships: None, type_, additional_properties: std::collections::BTreeMap::new(), _unparsed: false, } } + pub fn relationships( + mut self, + value: crate::datadogV2::model::PatchDegradationRequestDataRelationships, + ) -> Self { + self.relationships = Some(value); + self + } + pub fn additional_properties( mut self, value: std::collections::BTreeMap, @@ -72,6 +84,9 @@ impl<'de> Deserialize<'de> for PatchDegradationRequestData { crate::datadogV2::model::PatchDegradationRequestDataAttributes, > = None; let mut id: Option = None; + let mut relationships: Option< + crate::datadogV2::model::PatchDegradationRequestDataRelationships, + > = None; let mut type_: Option = None; let mut additional_properties: std::collections::BTreeMap< @@ -88,6 +103,13 @@ impl<'de> Deserialize<'de> for PatchDegradationRequestData { "id" => { id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); } + "relationships" => { + if v.is_null() { + continue; + } + relationships = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } "type" => { type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); if let Some(ref _type_) = type_ { @@ -113,6 +135,7 @@ impl<'de> Deserialize<'de> for PatchDegradationRequestData { let content = PatchDegradationRequestData { attributes, id, + relationships, type_, additional_properties, _unparsed, diff --git a/src/datadogV2/model/model_patch_degradation_request_data_relationships.rs b/src/datadogV2/model/model_patch_degradation_request_data_relationships.rs new file mode 100644 index 000000000..2773f8a83 --- /dev/null +++ b/src/datadogV2/model/model_patch_degradation_request_data_relationships.rs @@ -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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The supported relationships for updating a degradation. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct PatchDegradationRequestDataRelationships { + /// The template used to create the degradation. + #[serde(rename = "template")] + pub template: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl PatchDegradationRequestDataRelationships { + pub fn new() -> PatchDegradationRequestDataRelationships { + PatchDegradationRequestDataRelationships { + template: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn template( + mut self, + value: crate::datadogV2::model::PatchDegradationRequestDataRelationshipsTemplate, + ) -> Self { + self.template = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for PatchDegradationRequestDataRelationships { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for PatchDegradationRequestDataRelationships { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct PatchDegradationRequestDataRelationshipsVisitor; + impl<'a> Visitor<'a> for PatchDegradationRequestDataRelationshipsVisitor { + type Value = PatchDegradationRequestDataRelationships; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut template: Option< + crate::datadogV2::model::PatchDegradationRequestDataRelationshipsTemplate, + > = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "template" => { + if v.is_null() { + continue; + } + template = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = PatchDegradationRequestDataRelationships { + template, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(PatchDegradationRequestDataRelationshipsVisitor) + } +} diff --git a/src/datadogV2/model/model_patch_degradation_request_data_relationships_template.rs b/src/datadogV2/model/model_patch_degradation_request_data_relationships_template.rs new file mode 100644 index 000000000..8388c04b4 --- /dev/null +++ b/src/datadogV2/model/model_patch_degradation_request_data_relationships_template.rs @@ -0,0 +1,96 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The template used to create the degradation. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct PatchDegradationRequestDataRelationshipsTemplate { + /// The data object identifying the template used to create the degradation. + #[serde(rename = "data")] + pub data: crate::datadogV2::model::PatchDegradationRequestDataRelationshipsTemplateData, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl PatchDegradationRequestDataRelationshipsTemplate { + pub fn new( + data: crate::datadogV2::model::PatchDegradationRequestDataRelationshipsTemplateData, + ) -> PatchDegradationRequestDataRelationshipsTemplate { + PatchDegradationRequestDataRelationshipsTemplate { + data, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for PatchDegradationRequestDataRelationshipsTemplate { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct PatchDegradationRequestDataRelationshipsTemplateVisitor; + impl<'a> Visitor<'a> for PatchDegradationRequestDataRelationshipsTemplateVisitor { + type Value = PatchDegradationRequestDataRelationshipsTemplate; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data: Option< + crate::datadogV2::model::PatchDegradationRequestDataRelationshipsTemplateData, + > = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "data" => { + data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let data = data.ok_or_else(|| M::Error::missing_field("data"))?; + + let content = PatchDegradationRequestDataRelationshipsTemplate { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(PatchDegradationRequestDataRelationshipsTemplateVisitor) + } +} diff --git a/src/datadogV2/model/model_patch_degradation_request_data_relationships_template_data.rs b/src/datadogV2/model/model_patch_degradation_request_data_relationships_template_data.rs new file mode 100644 index 000000000..7e3c72d41 --- /dev/null +++ b/src/datadogV2/model/model_patch_degradation_request_data_relationships_template_data.rs @@ -0,0 +1,115 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The data object identifying the template used to create the degradation. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct PatchDegradationRequestDataRelationshipsTemplateData { + /// The ID of the degradation template. + #[serde(rename = "id")] + pub id: String, + /// Degradation templates resource type. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::PatchDegradationTemplateRequestDataType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl PatchDegradationRequestDataRelationshipsTemplateData { + pub fn new( + id: String, + type_: crate::datadogV2::model::PatchDegradationTemplateRequestDataType, + ) -> PatchDegradationRequestDataRelationshipsTemplateData { + PatchDegradationRequestDataRelationshipsTemplateData { + id, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for PatchDegradationRequestDataRelationshipsTemplateData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct PatchDegradationRequestDataRelationshipsTemplateDataVisitor; + impl<'a> Visitor<'a> for PatchDegradationRequestDataRelationshipsTemplateDataVisitor { + type Value = PatchDegradationRequestDataRelationshipsTemplateData; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut id: Option = None; + let mut type_: Option< + crate::datadogV2::model::PatchDegradationTemplateRequestDataType, + > = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "id" => { + id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::PatchDegradationTemplateRequestDataType::UnparsedObject(_type_) => { + _unparsed = true; + }, + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let id = id.ok_or_else(|| M::Error::missing_field("id"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = PatchDegradationRequestDataRelationshipsTemplateData { + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(PatchDegradationRequestDataRelationshipsTemplateDataVisitor) + } +} diff --git a/src/datadogV2/model/model_patch_degradation_template_request.rs b/src/datadogV2/model/model_patch_degradation_template_request.rs new file mode 100644 index 000000000..96e7587ab --- /dev/null +++ b/src/datadogV2/model/model_patch_degradation_template_request.rs @@ -0,0 +1,109 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Request object for updating a degradation template. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct PatchDegradationTemplateRequest { + /// The data object for updating a degradation template. + #[serde(rename = "data")] + pub data: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl PatchDegradationTemplateRequest { + pub fn new() -> PatchDegradationTemplateRequest { + PatchDegradationTemplateRequest { + data: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn data( + mut self, + value: crate::datadogV2::model::PatchDegradationTemplateRequestData, + ) -> Self { + self.data = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for PatchDegradationTemplateRequest { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for PatchDegradationTemplateRequest { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct PatchDegradationTemplateRequestVisitor; + impl<'a> Visitor<'a> for PatchDegradationTemplateRequestVisitor { + type Value = PatchDegradationTemplateRequest; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data: Option = + None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "data" => { + if v.is_null() { + continue; + } + data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = PatchDegradationTemplateRequest { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(PatchDegradationTemplateRequestVisitor) + } +} diff --git a/src/datadogV2/model/model_patch_degradation_template_request_data.rs b/src/datadogV2/model/model_patch_degradation_template_request_data.rs new file mode 100644 index 000000000..37568f4ba --- /dev/null +++ b/src/datadogV2/model/model_patch_degradation_template_request_data.rs @@ -0,0 +1,137 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The data object for updating a degradation template. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct PatchDegradationTemplateRequestData { + /// The supported attributes for updating a degradation template. + #[serde(rename = "attributes")] + pub attributes: Option, + /// The ID of the degradation template. + #[serde(rename = "id")] + pub id: String, + /// Degradation templates resource type. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::PatchDegradationTemplateRequestDataType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl PatchDegradationTemplateRequestData { + pub fn new( + id: String, + type_: crate::datadogV2::model::PatchDegradationTemplateRequestDataType, + ) -> PatchDegradationTemplateRequestData { + PatchDegradationTemplateRequestData { + attributes: None, + id, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn attributes( + mut self, + value: crate::datadogV2::model::PatchDegradationTemplateRequestDataAttributes, + ) -> Self { + self.attributes = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for PatchDegradationTemplateRequestData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct PatchDegradationTemplateRequestDataVisitor; + impl<'a> Visitor<'a> for PatchDegradationTemplateRequestDataVisitor { + type Value = PatchDegradationTemplateRequestData; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut attributes: Option< + crate::datadogV2::model::PatchDegradationTemplateRequestDataAttributes, + > = None; + let mut id: Option = None; + let mut type_: Option< + crate::datadogV2::model::PatchDegradationTemplateRequestDataType, + > = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "attributes" => { + if v.is_null() { + continue; + } + attributes = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "id" => { + id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::PatchDegradationTemplateRequestDataType::UnparsedObject(_type_) => { + _unparsed = true; + }, + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let id = id.ok_or_else(|| M::Error::missing_field("id"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = PatchDegradationTemplateRequestData { + attributes, + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(PatchDegradationTemplateRequestDataVisitor) + } +} diff --git a/src/datadogV2/model/model_patch_degradation_template_request_data_attributes.rs b/src/datadogV2/model/model_patch_degradation_template_request_data_attributes.rs new file mode 100644 index 000000000..f6ea7dec3 --- /dev/null +++ b/src/datadogV2/model/model_patch_degradation_template_request_data_attributes.rs @@ -0,0 +1,166 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The supported attributes for updating a degradation template. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct PatchDegradationTemplateRequestDataAttributes { + /// The components affected by a degradation created from this template. + #[serde(rename = "components_affected")] + pub components_affected: Option>, + /// The title used for a degradation created from this template. + #[serde(rename = "degradation_title")] + pub degradation_title: Option, + /// The name of the degradation template. + #[serde(rename = "name")] + pub name: Option, + /// The pre-filled updates for a degradation created from this template. + #[serde(rename = "updates")] + pub updates: Option>, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool +} + +impl PatchDegradationTemplateRequestDataAttributes { + pub fn new() -> PatchDegradationTemplateRequestDataAttributes { + PatchDegradationTemplateRequestDataAttributes { + components_affected: None, + degradation_title: None, + name: None, + updates: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn components_affected( + mut self, + value: Vec, + ) -> Self { + self.components_affected = Some(value); + self + } + + pub fn degradation_title(mut self, value: String) -> Self { + self.degradation_title = Some(value); + self + } + + pub fn name(mut self, value: String) -> Self { + self.name = Some(value); + self + } + + pub fn updates( + mut self, + value: Vec< + crate::datadogV2::model::PatchDegradationTemplateRequestDataAttributesUpdatesItems, + >, + ) -> Self { + self.updates = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for PatchDegradationTemplateRequestDataAttributes { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for PatchDegradationTemplateRequestDataAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct PatchDegradationTemplateRequestDataAttributesVisitor; + impl<'a> Visitor<'a> for PatchDegradationTemplateRequestDataAttributesVisitor { + type Value = PatchDegradationTemplateRequestDataAttributes; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut components_affected: Option> = None; + let mut degradation_title: Option = None; + let mut name: Option = None; + let mut updates: Option> = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "components_affected" => { + if v.is_null() { + continue; + } + components_affected = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "degradation_title" => { + if v.is_null() { + continue; + } + degradation_title = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "name" => { + if v.is_null() { + continue; + } + name = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "updates" => { + if v.is_null() { + continue; + } + updates = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = PatchDegradationTemplateRequestDataAttributes { + components_affected, + degradation_title, + name, + updates, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(PatchDegradationTemplateRequestDataAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_patch_degradation_template_request_data_attributes_components_affected_items.rs b/src/datadogV2/model/model_patch_degradation_template_request_data_attributes_components_affected_items.rs new file mode 100644 index 000000000..3d580bf29 --- /dev/null +++ b/src/datadogV2/model/model_patch_degradation_template_request_data_attributes_components_affected_items.rs @@ -0,0 +1,137 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// A component affected by a degradation created from this template. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct PatchDegradationTemplateRequestDataAttributesComponentsAffectedItems { + /// The ID of the component. Must be a component of type `component`. + #[serde(rename = "id")] + pub id: String, + /// The name of the component. + #[serde(rename = "name")] + pub name: Option, + /// The status of the component. + #[serde(rename = "status")] + pub status: crate::datadogV2::model::PatchDegradationTemplateRequestDataAttributesComponentsAffectedItemsStatus, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool +} + +impl PatchDegradationTemplateRequestDataAttributesComponentsAffectedItems { + pub fn new( + id: String, + status: crate::datadogV2::model::PatchDegradationTemplateRequestDataAttributesComponentsAffectedItemsStatus, + ) -> PatchDegradationTemplateRequestDataAttributesComponentsAffectedItems { + PatchDegradationTemplateRequestDataAttributesComponentsAffectedItems { + id, + name: None, + status, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn name(mut self, value: String) -> Self { + self.name = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> + for PatchDegradationTemplateRequestDataAttributesComponentsAffectedItems +{ + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct PatchDegradationTemplateRequestDataAttributesComponentsAffectedItemsVisitor; + impl<'a> Visitor<'a> + for PatchDegradationTemplateRequestDataAttributesComponentsAffectedItemsVisitor + { + type Value = PatchDegradationTemplateRequestDataAttributesComponentsAffectedItems; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut id: Option = None; + let mut name: Option = None; + let mut status: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "id" => { + id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "name" => { + if v.is_null() { + continue; + } + name = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "status" => { + status = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _status) = status { + match _status { + crate::datadogV2::model::PatchDegradationTemplateRequestDataAttributesComponentsAffectedItemsStatus::UnparsedObject(_status) => { + _unparsed = true; + }, + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let id = id.ok_or_else(|| M::Error::missing_field("id"))?; + let status = status.ok_or_else(|| M::Error::missing_field("status"))?; + + let content = + PatchDegradationTemplateRequestDataAttributesComponentsAffectedItems { + id, + name, + status, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any( + PatchDegradationTemplateRequestDataAttributesComponentsAffectedItemsVisitor, + ) + } +} diff --git a/src/datadogV2/model/model_patch_degradation_template_request_data_attributes_components_affected_items_status.rs b/src/datadogV2/model/model_patch_degradation_template_request_data_attributes_components_affected_items_status.rs new file mode 100644 index 000000000..861a57551 --- /dev/null +++ b/src/datadogV2/model/model_patch_degradation_template_request_data_attributes_components_affected_items_status.rs @@ -0,0 +1,59 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +use serde::{Deserialize, Deserializer, Serialize, Serializer}; + +#[non_exhaustive] +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum PatchDegradationTemplateRequestDataAttributesComponentsAffectedItemsStatus { + OPERATIONAL, + DEGRADED, + PARTIAL_OUTAGE, + MAJOR_OUTAGE, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for PatchDegradationTemplateRequestDataAttributesComponentsAffectedItemsStatus { + fn to_string(&self) -> String { + match self { + Self::OPERATIONAL => String::from("operational"), + Self::DEGRADED => String::from("degraded"), + Self::PARTIAL_OUTAGE => String::from("partial_outage"), + Self::MAJOR_OUTAGE => String::from("major_outage"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for PatchDegradationTemplateRequestDataAttributesComponentsAffectedItemsStatus { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match self { + Self::UnparsedObject(v) => v.serialize(serializer), + _ => serializer.serialize_str(self.to_string().as_str()), + } + } +} + +impl<'de> Deserialize<'de> + for PatchDegradationTemplateRequestDataAttributesComponentsAffectedItemsStatus +{ + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "operational" => Self::OPERATIONAL, + "degraded" => Self::DEGRADED, + "partial_outage" => Self::PARTIAL_OUTAGE, + "major_outage" => Self::MAJOR_OUTAGE, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_patch_degradation_template_request_data_attributes_updates_items.rs b/src/datadogV2/model/model_patch_degradation_template_request_data_attributes_updates_items.rs new file mode 100644 index 000000000..d9e40ae57 --- /dev/null +++ b/src/datadogV2/model/model_patch_degradation_template_request_data_attributes_updates_items.rs @@ -0,0 +1,122 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// A pre-filled update for a degradation created from this template. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct PatchDegradationTemplateRequestDataAttributesUpdatesItems { + /// The message of the update. + #[serde(rename = "message")] + pub message: Option, + /// The status of the degradation. + #[serde(rename = "status")] + pub status: crate::datadogV2::model::CreateDegradationRequestDataAttributesStatus, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl PatchDegradationTemplateRequestDataAttributesUpdatesItems { + pub fn new( + status: crate::datadogV2::model::CreateDegradationRequestDataAttributesStatus, + ) -> PatchDegradationTemplateRequestDataAttributesUpdatesItems { + PatchDegradationTemplateRequestDataAttributesUpdatesItems { + message: None, + status, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn message(mut self, value: String) -> Self { + self.message = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for PatchDegradationTemplateRequestDataAttributesUpdatesItems { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct PatchDegradationTemplateRequestDataAttributesUpdatesItemsVisitor; + impl<'a> Visitor<'a> for PatchDegradationTemplateRequestDataAttributesUpdatesItemsVisitor { + type Value = PatchDegradationTemplateRequestDataAttributesUpdatesItems; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut message: Option = None; + let mut status: Option< + crate::datadogV2::model::CreateDegradationRequestDataAttributesStatus, + > = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "message" => { + if v.is_null() { + continue; + } + message = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "status" => { + status = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _status) = status { + match _status { + crate::datadogV2::model::CreateDegradationRequestDataAttributesStatus::UnparsedObject(_status) => { + _unparsed = true; + }, + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let status = status.ok_or_else(|| M::Error::missing_field("status"))?; + + let content = PatchDegradationTemplateRequestDataAttributesUpdatesItems { + message, + status, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer + .deserialize_any(PatchDegradationTemplateRequestDataAttributesUpdatesItemsVisitor) + } +} diff --git a/src/datadogV2/model/model_patch_degradation_template_request_data_type.rs b/src/datadogV2/model/model_patch_degradation_template_request_data_type.rs new file mode 100644 index 000000000..31a090eb0 --- /dev/null +++ b/src/datadogV2/model/model_patch_degradation_template_request_data_type.rs @@ -0,0 +1,48 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +use serde::{Deserialize, Deserializer, Serialize, Serializer}; + +#[non_exhaustive] +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum PatchDegradationTemplateRequestDataType { + DEGRADATION_TEMPLATES, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for PatchDegradationTemplateRequestDataType { + fn to_string(&self) -> String { + match self { + Self::DEGRADATION_TEMPLATES => String::from("degradation_templates"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for PatchDegradationTemplateRequestDataType { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match self { + Self::UnparsedObject(v) => v.serialize(serializer), + _ => serializer.serialize_str(self.to_string().as_str()), + } + } +} + +impl<'de> Deserialize<'de> for PatchDegradationTemplateRequestDataType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "degradation_templates" => Self::DEGRADATION_TEMPLATES, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_patch_maintenance_request_data.rs b/src/datadogV2/model/model_patch_maintenance_request_data.rs index 77491f499..64e927d4a 100644 --- a/src/datadogV2/model/model_patch_maintenance_request_data.rs +++ b/src/datadogV2/model/model_patch_maintenance_request_data.rs @@ -17,6 +17,9 @@ pub struct PatchMaintenanceRequestData { /// The ID of the maintenance. #[serde(rename = "id")] pub id: uuid::Uuid, + /// The supported relationships for updating a maintenance. + #[serde(rename = "relationships")] + pub relationships: Option, /// Maintenances resource type. #[serde(rename = "type")] pub type_: crate::datadogV2::model::PatchMaintenanceRequestDataType, @@ -36,12 +39,21 @@ impl PatchMaintenanceRequestData { PatchMaintenanceRequestData { attributes, id, + relationships: None, type_, additional_properties: std::collections::BTreeMap::new(), _unparsed: false, } } + pub fn relationships( + mut self, + value: crate::datadogV2::model::PatchMaintenanceRequestDataRelationships, + ) -> Self { + self.relationships = Some(value); + self + } + pub fn additional_properties( mut self, value: std::collections::BTreeMap, @@ -72,6 +84,9 @@ impl<'de> Deserialize<'de> for PatchMaintenanceRequestData { crate::datadogV2::model::PatchMaintenanceRequestDataAttributes, > = None; let mut id: Option = None; + let mut relationships: Option< + crate::datadogV2::model::PatchMaintenanceRequestDataRelationships, + > = None; let mut type_: Option = None; let mut additional_properties: std::collections::BTreeMap< @@ -88,6 +103,13 @@ impl<'de> Deserialize<'de> for PatchMaintenanceRequestData { "id" => { id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); } + "relationships" => { + if v.is_null() { + continue; + } + relationships = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } "type" => { type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); if let Some(ref _type_) = type_ { @@ -113,6 +135,7 @@ impl<'de> Deserialize<'de> for PatchMaintenanceRequestData { let content = PatchMaintenanceRequestData { attributes, id, + relationships, type_, additional_properties, _unparsed, diff --git a/src/datadogV2/model/model_patch_maintenance_request_data_relationships.rs b/src/datadogV2/model/model_patch_maintenance_request_data_relationships.rs new file mode 100644 index 000000000..df3dca1f1 --- /dev/null +++ b/src/datadogV2/model/model_patch_maintenance_request_data_relationships.rs @@ -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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The supported relationships for updating a maintenance. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct PatchMaintenanceRequestDataRelationships { + /// The template used to create the maintenance. + #[serde(rename = "template")] + pub template: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl PatchMaintenanceRequestDataRelationships { + pub fn new() -> PatchMaintenanceRequestDataRelationships { + PatchMaintenanceRequestDataRelationships { + template: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn template( + mut self, + value: crate::datadogV2::model::PatchMaintenanceRequestDataRelationshipsTemplate, + ) -> Self { + self.template = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for PatchMaintenanceRequestDataRelationships { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for PatchMaintenanceRequestDataRelationships { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct PatchMaintenanceRequestDataRelationshipsVisitor; + impl<'a> Visitor<'a> for PatchMaintenanceRequestDataRelationshipsVisitor { + type Value = PatchMaintenanceRequestDataRelationships; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut template: Option< + crate::datadogV2::model::PatchMaintenanceRequestDataRelationshipsTemplate, + > = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "template" => { + if v.is_null() { + continue; + } + template = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = PatchMaintenanceRequestDataRelationships { + template, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(PatchMaintenanceRequestDataRelationshipsVisitor) + } +} diff --git a/src/datadogV2/model/model_patch_maintenance_request_data_relationships_template.rs b/src/datadogV2/model/model_patch_maintenance_request_data_relationships_template.rs new file mode 100644 index 000000000..55b62d28f --- /dev/null +++ b/src/datadogV2/model/model_patch_maintenance_request_data_relationships_template.rs @@ -0,0 +1,96 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The template used to create the maintenance. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct PatchMaintenanceRequestDataRelationshipsTemplate { + /// The data object identifying the template used to create the maintenance. + #[serde(rename = "data")] + pub data: crate::datadogV2::model::PatchMaintenanceRequestDataRelationshipsTemplateData, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl PatchMaintenanceRequestDataRelationshipsTemplate { + pub fn new( + data: crate::datadogV2::model::PatchMaintenanceRequestDataRelationshipsTemplateData, + ) -> PatchMaintenanceRequestDataRelationshipsTemplate { + PatchMaintenanceRequestDataRelationshipsTemplate { + data, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for PatchMaintenanceRequestDataRelationshipsTemplate { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct PatchMaintenanceRequestDataRelationshipsTemplateVisitor; + impl<'a> Visitor<'a> for PatchMaintenanceRequestDataRelationshipsTemplateVisitor { + type Value = PatchMaintenanceRequestDataRelationshipsTemplate; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data: Option< + crate::datadogV2::model::PatchMaintenanceRequestDataRelationshipsTemplateData, + > = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "data" => { + data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let data = data.ok_or_else(|| M::Error::missing_field("data"))?; + + let content = PatchMaintenanceRequestDataRelationshipsTemplate { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(PatchMaintenanceRequestDataRelationshipsTemplateVisitor) + } +} diff --git a/src/datadogV2/model/model_patch_maintenance_request_data_relationships_template_data.rs b/src/datadogV2/model/model_patch_maintenance_request_data_relationships_template_data.rs new file mode 100644 index 000000000..322751a69 --- /dev/null +++ b/src/datadogV2/model/model_patch_maintenance_request_data_relationships_template_data.rs @@ -0,0 +1,115 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The data object identifying the template used to create the maintenance. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct PatchMaintenanceRequestDataRelationshipsTemplateData { + /// The ID of the maintenance template. + #[serde(rename = "id")] + pub id: String, + /// Maintenance templates resource type. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::PatchMaintenanceTemplateRequestDataType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl PatchMaintenanceRequestDataRelationshipsTemplateData { + pub fn new( + id: String, + type_: crate::datadogV2::model::PatchMaintenanceTemplateRequestDataType, + ) -> PatchMaintenanceRequestDataRelationshipsTemplateData { + PatchMaintenanceRequestDataRelationshipsTemplateData { + id, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for PatchMaintenanceRequestDataRelationshipsTemplateData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct PatchMaintenanceRequestDataRelationshipsTemplateDataVisitor; + impl<'a> Visitor<'a> for PatchMaintenanceRequestDataRelationshipsTemplateDataVisitor { + type Value = PatchMaintenanceRequestDataRelationshipsTemplateData; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut id: Option = None; + let mut type_: Option< + crate::datadogV2::model::PatchMaintenanceTemplateRequestDataType, + > = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "id" => { + id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::PatchMaintenanceTemplateRequestDataType::UnparsedObject(_type_) => { + _unparsed = true; + }, + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let id = id.ok_or_else(|| M::Error::missing_field("id"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = PatchMaintenanceRequestDataRelationshipsTemplateData { + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(PatchMaintenanceRequestDataRelationshipsTemplateDataVisitor) + } +} diff --git a/src/datadogV2/model/model_patch_maintenance_template_request.rs b/src/datadogV2/model/model_patch_maintenance_template_request.rs new file mode 100644 index 000000000..f0fe51fdc --- /dev/null +++ b/src/datadogV2/model/model_patch_maintenance_template_request.rs @@ -0,0 +1,109 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Request object for updating a maintenance template. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct PatchMaintenanceTemplateRequest { + /// The data object for updating a maintenance template. + #[serde(rename = "data")] + pub data: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl PatchMaintenanceTemplateRequest { + pub fn new() -> PatchMaintenanceTemplateRequest { + PatchMaintenanceTemplateRequest { + data: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn data( + mut self, + value: crate::datadogV2::model::PatchMaintenanceTemplateRequestData, + ) -> Self { + self.data = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for PatchMaintenanceTemplateRequest { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for PatchMaintenanceTemplateRequest { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct PatchMaintenanceTemplateRequestVisitor; + impl<'a> Visitor<'a> for PatchMaintenanceTemplateRequestVisitor { + type Value = PatchMaintenanceTemplateRequest; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data: Option = + None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "data" => { + if v.is_null() { + continue; + } + data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = PatchMaintenanceTemplateRequest { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(PatchMaintenanceTemplateRequestVisitor) + } +} diff --git a/src/datadogV2/model/model_patch_maintenance_template_request_data.rs b/src/datadogV2/model/model_patch_maintenance_template_request_data.rs new file mode 100644 index 000000000..355053506 --- /dev/null +++ b/src/datadogV2/model/model_patch_maintenance_template_request_data.rs @@ -0,0 +1,137 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The data object for updating a maintenance template. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct PatchMaintenanceTemplateRequestData { + /// The supported attributes for updating a maintenance template. + #[serde(rename = "attributes")] + pub attributes: Option, + /// The ID of the maintenance template. + #[serde(rename = "id")] + pub id: String, + /// Maintenance templates resource type. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::PatchMaintenanceTemplateRequestDataType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl PatchMaintenanceTemplateRequestData { + pub fn new( + id: String, + type_: crate::datadogV2::model::PatchMaintenanceTemplateRequestDataType, + ) -> PatchMaintenanceTemplateRequestData { + PatchMaintenanceTemplateRequestData { + attributes: None, + id, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn attributes( + mut self, + value: crate::datadogV2::model::PatchMaintenanceTemplateRequestDataAttributes, + ) -> Self { + self.attributes = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for PatchMaintenanceTemplateRequestData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct PatchMaintenanceTemplateRequestDataVisitor; + impl<'a> Visitor<'a> for PatchMaintenanceTemplateRequestDataVisitor { + type Value = PatchMaintenanceTemplateRequestData; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut attributes: Option< + crate::datadogV2::model::PatchMaintenanceTemplateRequestDataAttributes, + > = None; + let mut id: Option = None; + let mut type_: Option< + crate::datadogV2::model::PatchMaintenanceTemplateRequestDataType, + > = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "attributes" => { + if v.is_null() { + continue; + } + attributes = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "id" => { + id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::PatchMaintenanceTemplateRequestDataType::UnparsedObject(_type_) => { + _unparsed = true; + }, + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let id = id.ok_or_else(|| M::Error::missing_field("id"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = PatchMaintenanceTemplateRequestData { + attributes, + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(PatchMaintenanceTemplateRequestDataVisitor) + } +} diff --git a/src/datadogV2/model/model_patch_maintenance_template_request_data_attributes.rs b/src/datadogV2/model/model_patch_maintenance_template_request_data_attributes.rs new file mode 100644 index 000000000..83c48d694 --- /dev/null +++ b/src/datadogV2/model/model_patch_maintenance_template_request_data_attributes.rs @@ -0,0 +1,195 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The supported attributes for updating a maintenance template. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct PatchMaintenanceTemplateRequestDataAttributes { + /// The description shown when a maintenance created from this template is completed. + #[serde(rename = "completed_description")] + pub completed_description: Option, + /// The IDs of the components affected by a maintenance created from this template. + #[serde(rename = "component_ids")] + pub component_ids: Option>, + /// The description shown while a maintenance created from this template is in progress. + #[serde(rename = "in_progress_description")] + pub in_progress_description: Option, + /// The title used for a maintenance created from this template. + #[serde(rename = "maintenance_title")] + pub maintenance_title: Option, + /// The name of the maintenance template. + #[serde(rename = "name")] + pub name: Option, + /// The description shown when a maintenance created from this template is scheduled. + #[serde(rename = "scheduled_description")] + pub scheduled_description: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl PatchMaintenanceTemplateRequestDataAttributes { + pub fn new() -> PatchMaintenanceTemplateRequestDataAttributes { + PatchMaintenanceTemplateRequestDataAttributes { + completed_description: None, + component_ids: None, + in_progress_description: None, + maintenance_title: None, + name: None, + scheduled_description: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn completed_description(mut self, value: String) -> Self { + self.completed_description = Some(value); + self + } + + pub fn component_ids(mut self, value: Vec) -> Self { + self.component_ids = Some(value); + self + } + + pub fn in_progress_description(mut self, value: String) -> Self { + self.in_progress_description = Some(value); + self + } + + pub fn maintenance_title(mut self, value: String) -> Self { + self.maintenance_title = Some(value); + self + } + + pub fn name(mut self, value: String) -> Self { + self.name = Some(value); + self + } + + pub fn scheduled_description(mut self, value: String) -> Self { + self.scheduled_description = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for PatchMaintenanceTemplateRequestDataAttributes { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for PatchMaintenanceTemplateRequestDataAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct PatchMaintenanceTemplateRequestDataAttributesVisitor; + impl<'a> Visitor<'a> for PatchMaintenanceTemplateRequestDataAttributesVisitor { + type Value = PatchMaintenanceTemplateRequestDataAttributes; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut completed_description: Option = None; + let mut component_ids: Option> = None; + let mut in_progress_description: Option = None; + let mut maintenance_title: Option = None; + let mut name: Option = None; + let mut scheduled_description: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "completed_description" => { + if v.is_null() { + continue; + } + completed_description = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "component_ids" => { + if v.is_null() { + continue; + } + component_ids = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "in_progress_description" => { + if v.is_null() { + continue; + } + in_progress_description = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "maintenance_title" => { + if v.is_null() { + continue; + } + maintenance_title = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "name" => { + if v.is_null() { + continue; + } + name = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "scheduled_description" => { + if v.is_null() { + continue; + } + scheduled_description = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = PatchMaintenanceTemplateRequestDataAttributes { + completed_description, + component_ids, + in_progress_description, + maintenance_title, + name, + scheduled_description, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(PatchMaintenanceTemplateRequestDataAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_patch_maintenance_template_request_data_type.rs b/src/datadogV2/model/model_patch_maintenance_template_request_data_type.rs new file mode 100644 index 000000000..0c335ce2b --- /dev/null +++ b/src/datadogV2/model/model_patch_maintenance_template_request_data_type.rs @@ -0,0 +1,48 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +use serde::{Deserialize, Deserializer, Serialize, Serializer}; + +#[non_exhaustive] +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum PatchMaintenanceTemplateRequestDataType { + MAINTENANCE_TEMPLATES, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for PatchMaintenanceTemplateRequestDataType { + fn to_string(&self) -> String { + match self { + Self::MAINTENANCE_TEMPLATES => String::from("maintenance_templates"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for PatchMaintenanceTemplateRequestDataType { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match self { + Self::UnparsedObject(v) => v.serialize(serializer), + _ => serializer.serialize_str(self.to_string().as_str()), + } + } +} + +impl<'de> Deserialize<'de> for PatchMaintenanceTemplateRequestDataType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "maintenance_templates" => Self::MAINTENANCE_TEMPLATES, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/tests/scenarios/features/v2/status_pages.feature b/tests/scenarios/features/v2/status_pages.feature index 99cb8e3ed..c7f922bf6 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 e72767d8e..b0a500071 100644 --- a/tests/scenarios/features/v2/undo.json +++ b/tests/scenarios/features/v2/undo.json @@ -8828,6 +8828,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": { @@ -8892,6 +8933,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": { diff --git a/tests/scenarios/function_mappings.rs b/tests/scenarios/function_mappings.rs index 3f5c3795a..012a48875 100644 --- a/tests/scenarios/function_mappings.rs +++ b/tests/scenarios/function_mappings.rs @@ -7370,6 +7370,26 @@ pub fn collect_function_calls(world: &mut DatadogWorld) { world .function_mappings .insert("v2.UpdateComponent".into(), test_v2_update_component); + world.function_mappings.insert( + "v2.ListDegradationTemplates".into(), + test_v2_list_degradation_templates, + ); + world.function_mappings.insert( + "v2.CreateDegradationTemplate".into(), + test_v2_create_degradation_template, + ); + world.function_mappings.insert( + "v2.DeleteDegradationTemplate".into(), + test_v2_delete_degradation_template, + ); + world.function_mappings.insert( + "v2.GetDegradationTemplate".into(), + test_v2_get_degradation_template, + ); + world.function_mappings.insert( + "v2.UpdateDegradationTemplate".into(), + test_v2_update_degradation_template, + ); world .function_mappings .insert("v2.CreateDegradation".into(), test_v2_create_degradation); @@ -7394,6 +7414,26 @@ pub fn collect_function_calls(world: &mut DatadogWorld) { "v2.EditDegradationUpdate".into(), test_v2_edit_degradation_update, ); + world.function_mappings.insert( + "v2.ListMaintenanceTemplates".into(), + test_v2_list_maintenance_templates, + ); + world.function_mappings.insert( + "v2.CreateMaintenanceTemplate".into(), + test_v2_create_maintenance_template, + ); + world.function_mappings.insert( + "v2.DeleteMaintenanceTemplate".into(), + test_v2_delete_maintenance_template, + ); + world.function_mappings.insert( + "v2.GetMaintenanceTemplate".into(), + test_v2_get_maintenance_template, + ); + world.function_mappings.insert( + "v2.UpdateMaintenanceTemplate".into(), + test_v2_update_maintenance_template, + ); world .function_mappings .insert("v2.CreateMaintenance".into(), test_v2_create_maintenance); @@ -58186,6 +58226,9 @@ fn test_v2_list_degradations(world: &mut DatadogWorld, _parameters: &HashMap response, Err(error) => { @@ -58504,6 +58548,184 @@ fn test_v2_update_component(world: &mut DatadogWorld, _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_status_pages + .as_ref() + .expect("api instance not found"); + let page_id = serde_json::from_value(_parameters.get("page_id").unwrap().clone()).unwrap(); + let include = _parameters + .get("include") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let mut params = datadogV2::api_status_pages::ListDegradationTemplatesOptionalParams::default(); + params.include = include; + let response = match block_on(api.list_degradation_templates_with_http_info(page_id, params)) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + +fn test_v2_create_degradation_template( + world: &mut DatadogWorld, + _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_status_pages + .as_ref() + .expect("api instance not found"); + let page_id = serde_json::from_value(_parameters.get("page_id").unwrap().clone()).unwrap(); + let body = serde_json::from_value(_parameters.get("body").unwrap().clone()).unwrap(); + let include = _parameters + .get("include") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let mut params = + datadogV2::api_status_pages::CreateDegradationTemplateOptionalParams::default(); + params.include = include; + let response = + match block_on(api.create_degradation_template_with_http_info(page_id, body, params)) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + +fn test_v2_delete_degradation_template( + world: &mut DatadogWorld, + _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_status_pages + .as_ref() + .expect("api instance not found"); + let page_id = serde_json::from_value(_parameters.get("page_id").unwrap().clone()).unwrap(); + let template_id = + serde_json::from_value(_parameters.get("template_id").unwrap().clone()).unwrap(); + let response = + match block_on(api.delete_degradation_template_with_http_info(page_id, template_id)) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + +fn test_v2_get_degradation_template( + world: &mut DatadogWorld, + _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_status_pages + .as_ref() + .expect("api instance not found"); + let page_id = serde_json::from_value(_parameters.get("page_id").unwrap().clone()).unwrap(); + let template_id = + serde_json::from_value(_parameters.get("template_id").unwrap().clone()).unwrap(); + let include = _parameters + .get("include") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let mut params = datadogV2::api_status_pages::GetDegradationTemplateOptionalParams::default(); + params.include = include; + let response = + match block_on(api.get_degradation_template_with_http_info(page_id, template_id, params)) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + +fn test_v2_update_degradation_template( + world: &mut DatadogWorld, + _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_status_pages + .as_ref() + .expect("api instance not found"); + let template_id = + serde_json::from_value(_parameters.get("template_id").unwrap().clone()).unwrap(); + let page_id = serde_json::from_value(_parameters.get("page_id").unwrap().clone()).unwrap(); + let body = serde_json::from_value(_parameters.get("body").unwrap().clone()).unwrap(); + let include = _parameters + .get("include") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let mut params = + datadogV2::api_status_pages::UpdateDegradationTemplateOptionalParams::default(); + params.include = include; + let response = match block_on(api.update_degradation_template_with_http_info( + template_id, + page_id, + body, + params, + )) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + fn test_v2_create_degradation(world: &mut DatadogWorld, _parameters: &HashMap) { let api = world .api_instances @@ -58752,6 +58974,184 @@ fn test_v2_edit_degradation_update(world: &mut DatadogWorld, _parameters: &HashM world.response.code = response.status.as_u16(); } +fn test_v2_list_maintenance_templates( + world: &mut DatadogWorld, + _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_status_pages + .as_ref() + .expect("api instance not found"); + let page_id = serde_json::from_value(_parameters.get("page_id").unwrap().clone()).unwrap(); + let include = _parameters + .get("include") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let mut params = datadogV2::api_status_pages::ListMaintenanceTemplatesOptionalParams::default(); + params.include = include; + let response = match block_on(api.list_maintenance_templates_with_http_info(page_id, params)) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + +fn test_v2_create_maintenance_template( + world: &mut DatadogWorld, + _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_status_pages + .as_ref() + .expect("api instance not found"); + let page_id = serde_json::from_value(_parameters.get("page_id").unwrap().clone()).unwrap(); + let body = serde_json::from_value(_parameters.get("body").unwrap().clone()).unwrap(); + let include = _parameters + .get("include") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let mut params = + datadogV2::api_status_pages::CreateMaintenanceTemplateOptionalParams::default(); + params.include = include; + let response = + match block_on(api.create_maintenance_template_with_http_info(page_id, body, params)) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + +fn test_v2_delete_maintenance_template( + world: &mut DatadogWorld, + _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_status_pages + .as_ref() + .expect("api instance not found"); + let page_id = serde_json::from_value(_parameters.get("page_id").unwrap().clone()).unwrap(); + let template_id = + serde_json::from_value(_parameters.get("template_id").unwrap().clone()).unwrap(); + let response = + match block_on(api.delete_maintenance_template_with_http_info(page_id, template_id)) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + +fn test_v2_get_maintenance_template( + world: &mut DatadogWorld, + _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_status_pages + .as_ref() + .expect("api instance not found"); + let page_id = serde_json::from_value(_parameters.get("page_id").unwrap().clone()).unwrap(); + let template_id = + serde_json::from_value(_parameters.get("template_id").unwrap().clone()).unwrap(); + let include = _parameters + .get("include") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let mut params = datadogV2::api_status_pages::GetMaintenanceTemplateOptionalParams::default(); + params.include = include; + let response = + match block_on(api.get_maintenance_template_with_http_info(page_id, template_id, params)) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + +fn test_v2_update_maintenance_template( + world: &mut DatadogWorld, + _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_status_pages + .as_ref() + .expect("api instance not found"); + let page_id = serde_json::from_value(_parameters.get("page_id").unwrap().clone()).unwrap(); + let template_id = + serde_json::from_value(_parameters.get("template_id").unwrap().clone()).unwrap(); + let body = serde_json::from_value(_parameters.get("body").unwrap().clone()).unwrap(); + let include = _parameters + .get("include") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let mut params = + datadogV2::api_status_pages::UpdateMaintenanceTemplateOptionalParams::default(); + params.include = include; + let response = match block_on(api.update_maintenance_template_with_http_info( + page_id, + template_id, + body, + params, + )) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + fn test_v2_create_maintenance(world: &mut DatadogWorld, _parameters: &HashMap) { let api = world .api_instances