diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 07a00c9a7f3..5b0100ae0ea 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -16059,6 +16059,161 @@ components: example: Postmortem-IR-123 type: string type: object + CreateBackfilledDegradationRequest: + description: Request object for creating a backfilled degradation. + example: + data: + attributes: + title: Past API Outage + updates: + - components_affected: + - id: 1234abcd-12ab-34cd-56ef-123456abcdef + status: degraded + description: We detected elevated error rates in the API. + started_at: "2026-04-27T13:37:31.038001628Z" + status: investigating + - components_affected: + - id: 1234abcd-12ab-34cd-56ef-123456abcdef + status: degraded + description: Root cause identified as a misconfigured deployment. + started_at: "2026-04-27T14:07:31.038001628Z" + status: identified + - components_affected: + - id: 1234abcd-12ab-34cd-56ef-123456abcdef + status: operational + description: The issue has been resolved and API is operating normally. + started_at: "2026-04-27T14:37:31.038001628Z" + status: resolved + type: degradations + properties: + data: + $ref: "#/components/schemas/CreateBackfilledDegradationRequestData" + type: object + CreateBackfilledDegradationRequestData: + description: The data object for creating a backfilled degradation. + properties: + attributes: + $ref: "#/components/schemas/CreateBackfilledDegradationRequestDataAttributes" + type: + $ref: "#/components/schemas/PatchDegradationRequestDataType" + required: + - type + type: object + CreateBackfilledDegradationRequestDataAttributes: + description: The supported attributes for creating a backfilled degradation. + properties: + title: + description: The title of the backfilled degradation. + example: "" + type: string + updates: + description: The list of status updates describing the timeline of the degradation. + items: + $ref: "#/components/schemas/CreateBackfilledDegradationRequestDataAttributesUpdatesItems" + type: array + required: + - title + - updates + type: object + CreateBackfilledDegradationRequestDataAttributesUpdatesItems: + description: A backfilled degradation update entry. + properties: + components_affected: + description: The components affected. + items: + $ref: "#/components/schemas/CreateDegradationRequestDataAttributesComponentsAffectedItems" + type: array + description: + description: A description of the update. + type: string + started_at: + description: Timestamp of when the update occurred. + example: "" + format: date-time + type: string + status: + $ref: "#/components/schemas/CreateDegradationRequestDataAttributesStatus" + required: + - started_at + - status + type: object + CreateBackfilledMaintenanceRequest: + description: Request object for creating a backfilled maintenance. + example: + data: + attributes: + title: Past Database Maintenance + updates: + - components_affected: + - id: 1234abcd-12ab-34cd-56ef-123456abcdef + status: maintenance + description: Database maintenance is in progress. + started_at: "2026-04-27T13:37:31.038003786Z" + status: in_progress + - components_affected: + - id: 1234abcd-12ab-34cd-56ef-123456abcdef + status: operational + description: Database maintenance has been completed successfully. + started_at: "2026-04-27T14:37:31.038003786Z" + status: completed + type: maintenances + properties: + data: + $ref: "#/components/schemas/CreateBackfilledMaintenanceRequestData" + type: object + CreateBackfilledMaintenanceRequestData: + description: The data object for creating a backfilled maintenance. + properties: + attributes: + $ref: "#/components/schemas/CreateBackfilledMaintenanceRequestDataAttributes" + type: + $ref: "#/components/schemas/PatchMaintenanceRequestDataType" + required: + - type + type: object + CreateBackfilledMaintenanceRequestDataAttributes: + description: The supported attributes for creating a backfilled maintenance. + properties: + title: + description: The title of the backfilled maintenance. + example: "" + type: string + updates: + description: "The list of updates. Exactly two updates are required: the start (`in_progress`) and the end (`completed`)." + items: + $ref: "#/components/schemas/CreateBackfilledMaintenanceRequestDataAttributesUpdatesItems" + maxItems: 2 + minItems: 2 + type: array + required: + - title + - updates + type: object + CreateBackfilledMaintenanceRequestDataAttributesUpdatesItems: + description: A backfilled maintenance update entry. + properties: + components_affected: + description: The components affected. + items: + $ref: "#/components/schemas/CreateMaintenanceRequestDataAttributesComponentsAffectedItems" + type: array + description: + description: A description of the update. + example: "" + type: string + started_at: + description: Timestamp of when the update occurred. + example: "" + format: date-time + type: string + status: + $ref: "#/components/schemas/CreateMaintenanceRequestDataAttributesUpdatesItemsStatus" + required: + - components_affected + - description + - started_at + - status + type: object CreateCampaignRequest: description: Request to create a new campaign. properties: @@ -16540,6 +16695,10 @@ components: description: The title of the degradation. example: Elevated API Latency type: string + updates: + items: + $ref: "#/components/schemas/CreateDegradationRequestDataAttributesUpdatesItems" + type: array required: - components_affected - status @@ -16577,6 +16736,48 @@ components: - IDENTIFIED - MONITORING - RESOLVED + CreateDegradationRequestDataAttributesUpdatesItems: + description: A degradation update entry. + properties: + components_affected: + description: The components affected. + items: + $ref: "#/components/schemas/CreateDegradationRequestDataAttributesUpdatesItemsComponentsAffectedItems" + type: array + description: + description: A description of the update. + example: "" + type: string + started_at: + description: Timestamp of when the update occurred. + example: "" + format: date-time + type: string + status: + $ref: "#/components/schemas/CreateDegradationRequestDataAttributesStatus" + required: + - components_affected + - description + - started_at + - status + type: object + CreateDegradationRequestDataAttributesUpdatesItemsComponentsAffectedItems: + description: A component affected by a degradation update. + 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/StatusPagesComponentDataAttributesStatus" + required: + - id + - status + type: object CreateDeploymentGateParams: description: Parameters for creating a deployment gate. properties: @@ -16945,6 +17146,10 @@ components: description: The title of the maintenance. example: "API Maintenance" type: string + updates: + items: + $ref: "#/components/schemas/CreateMaintenanceRequestDataAttributesUpdatesItems" + type: array required: - components_affected - title @@ -16972,6 +17177,58 @@ components: - id - status type: object + CreateMaintenanceRequestDataAttributesUpdatesItems: + description: A maintenance update entry. + properties: + components_affected: + description: The components affected. + items: + $ref: "#/components/schemas/CreateMaintenanceRequestDataAttributesUpdatesItemsComponentsAffectedItems" + type: array + description: + description: A description of the update. + example: "" + type: string + started_at: + description: Timestamp of when the update occurred. + example: "" + format: date-time + type: string + status: + $ref: "#/components/schemas/CreateMaintenanceRequestDataAttributesUpdatesItemsStatus" + required: + - components_affected + - description + - started_at + - status + type: object + CreateMaintenanceRequestDataAttributesUpdatesItemsComponentsAffectedItems: + description: A component affected by a maintenance update. + 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/PatchMaintenanceRequestDataAttributesComponentsAffectedItemsStatus" + required: + - id + - status + type: object + CreateMaintenanceRequestDataAttributesUpdatesItemsStatus: + description: The status of a maintenance update. + enum: + - in_progress + - completed + example: in_progress + type: string + x-enum-varnames: + - IN_PROGRESS + - COMPLETED CreateNotificationChannelAttributes: description: Attributes for creating an on-call notification channel. properties: @@ -138395,6 +138652,85 @@ paths: operator: AND permissions: - status_pages_incident_write + /api/v2/statuspages/{page_id}/degradations/backfill: + post: + description: Creates a backfilled degradation with predefined updates. + operationId: CreateBackfilledDegradation + 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 + requestBody: + content: + application/json: + examples: + default: + value: + data: + attributes: + title: Past API Outage + updates: + - components_affected: + - id: 1234abcd-12ab-34cd-56ef-123456abcdef + status: degraded + description: We detected elevated error rates in the API. + started_at: "2026-04-27T13:37:31Z" + status: investigating + - components_affected: + - id: 1234abcd-12ab-34cd-56ef-123456abcdef + status: operational + description: The issue has been resolved. + started_at: "2026-04-27T14:37:31Z" + status: resolved + type: degradations + schema: + $ref: "#/components/schemas/CreateBackfilledDegradationRequest" + required: true + responses: + "201": + content: + application/json: + examples: + default: + value: + data: + attributes: + components_affected: + - id: 1234abcd-12ab-34cd-56ef-123456abcdef + status: operational + created_at: "2026-04-27T13:37:31+00:00" + description: The issue has been resolved. + modified_at: "2026-04-27T14:37:31+00:00" + status: resolved + title: Past API Outage + updates: [] + id: 00000000-0000-0000-0000-000000000010 + type: degradations + schema: + $ref: "#/components/schemas/Degradation" + description: Created + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: [] + summary: Create backfilled degradation + tags: + - Status Pages + x-permission: + operator: AND + permissions: + - status_pages_incident_write /api/v2/statuspages/{page_id}/degradations/{degradation_id}: delete: description: Deletes a degradation by its ID. @@ -138658,6 +138994,84 @@ paths: operator: AND permissions: - status_pages_incident_write + /api/v2/statuspages/{page_id}/maintenances/backfill: + post: + description: Creates a backfilled maintenance with predefined updates. + operationId: CreateBackfilledMaintenance + 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 + requestBody: + content: + application/json: + examples: + default: + value: + data: + attributes: + title: Past Database Maintenance + updates: + - components_affected: + - id: 1234abcd-12ab-34cd-56ef-123456abcdef + status: maintenance + description: Database maintenance is in progress. + started_at: "2026-04-27T13:37:31Z" + status: in_progress + - components_affected: + - id: 1234abcd-12ab-34cd-56ef-123456abcdef + status: operational + description: Database maintenance has been completed. + started_at: "2026-04-27T14:37:31Z" + status: completed + type: maintenances + schema: + $ref: "#/components/schemas/CreateBackfilledMaintenanceRequest" + required: true + responses: + "201": + content: + application/json: + examples: + default: + value: + data: + attributes: + completed_date: "2026-04-27T14:37:31+00:00" + completed_description: "" + components_affected: [] + in_progress_description: "" + scheduled_description: "" + start_date: "2026-04-27T13:37:31+00:00" + status: completed + title: Past Database Maintenance + id: 00000000-0000-0000-0000-000000000015 + type: maintenances + schema: + $ref: "#/components/schemas/Maintenance" + description: Created + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: [] + summary: Create backfilled maintenance + tags: + - Status Pages + x-permission: + operator: AND + permissions: + - status_pages_incident_write /api/v2/statuspages/{page_id}/maintenances/{maintenance_id}: get: description: Retrieves a specific maintenance by its ID. diff --git a/api/datadogV2/api_status_pages.go b/api/datadogV2/api_status_pages.go index b329000dcb2..d5b7383e90e 100644 --- a/api/datadogV2/api_status_pages.go +++ b/api/datadogV2/api_status_pages.go @@ -16,6 +16,224 @@ import ( // StatusPagesApi service type type StatusPagesApi datadog.Service +// CreateBackfilledDegradationOptionalParameters holds optional parameters for CreateBackfilledDegradation. +type CreateBackfilledDegradationOptionalParameters struct { + Include *string +} + +// NewCreateBackfilledDegradationOptionalParameters creates an empty struct for parameters. +func NewCreateBackfilledDegradationOptionalParameters() *CreateBackfilledDegradationOptionalParameters { + this := CreateBackfilledDegradationOptionalParameters{} + return &this +} + +// WithInclude sets the corresponding parameter name and returns the struct. +func (r *CreateBackfilledDegradationOptionalParameters) WithInclude(include string) *CreateBackfilledDegradationOptionalParameters { + r.Include = &include + return r +} + +// CreateBackfilledDegradation Create backfilled degradation. +// Creates a backfilled degradation with predefined updates. +func (a *StatusPagesApi) CreateBackfilledDegradation(ctx _context.Context, pageId uuid.UUID, body CreateBackfilledDegradationRequest, o ...CreateBackfilledDegradationOptionalParameters) (Degradation, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPost + localVarPostBody interface{} + localVarReturnValue Degradation + optionalParams CreateBackfilledDegradationOptionalParameters + ) + + if len(o) > 1 { + return localVarReturnValue, nil, datadog.ReportError("only one argument of type CreateBackfilledDegradationOptionalParameters is allowed") + } + if len(o) == 1 { + optionalParams = o[0] + } + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.StatusPagesApi.CreateBackfilledDegradation") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/statuspages/{page_id}/degradations/backfill" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{page_id}", _neturl.PathEscape(datadog.ParameterToString(pageId, ""))) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + if optionalParams.Include != nil { + localVarQueryParams.Add("include", datadog.ParameterToString(*optionalParams.Include, "")) + } + localVarHeaderParams["Content-Type"] = "application/json" + localVarHeaderParams["Accept"] = "application/json" + + // body params + localVarPostBody = &body + if a.Client.Cfg.DelegatedTokenConfig != nil { + err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig) + if err != nil { + return localVarReturnValue, nil, err + } + } else { + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + } + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +// CreateBackfilledMaintenanceOptionalParameters holds optional parameters for CreateBackfilledMaintenance. +type CreateBackfilledMaintenanceOptionalParameters struct { + Include *string +} + +// NewCreateBackfilledMaintenanceOptionalParameters creates an empty struct for parameters. +func NewCreateBackfilledMaintenanceOptionalParameters() *CreateBackfilledMaintenanceOptionalParameters { + this := CreateBackfilledMaintenanceOptionalParameters{} + return &this +} + +// WithInclude sets the corresponding parameter name and returns the struct. +func (r *CreateBackfilledMaintenanceOptionalParameters) WithInclude(include string) *CreateBackfilledMaintenanceOptionalParameters { + r.Include = &include + return r +} + +// CreateBackfilledMaintenance Create backfilled maintenance. +// Creates a backfilled maintenance with predefined updates. +func (a *StatusPagesApi) CreateBackfilledMaintenance(ctx _context.Context, pageId uuid.UUID, body CreateBackfilledMaintenanceRequest, o ...CreateBackfilledMaintenanceOptionalParameters) (Maintenance, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPost + localVarPostBody interface{} + localVarReturnValue Maintenance + optionalParams CreateBackfilledMaintenanceOptionalParameters + ) + + if len(o) > 1 { + return localVarReturnValue, nil, datadog.ReportError("only one argument of type CreateBackfilledMaintenanceOptionalParameters is allowed") + } + if len(o) == 1 { + optionalParams = o[0] + } + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.StatusPagesApi.CreateBackfilledMaintenance") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/statuspages/{page_id}/maintenances/backfill" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{page_id}", _neturl.PathEscape(datadog.ParameterToString(pageId, ""))) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + if optionalParams.Include != nil { + localVarQueryParams.Add("include", datadog.ParameterToString(*optionalParams.Include, "")) + } + localVarHeaderParams["Content-Type"] = "application/json" + localVarHeaderParams["Accept"] = "application/json" + + // body params + localVarPostBody = &body + if a.Client.Cfg.DelegatedTokenConfig != nil { + err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig) + if err != nil { + return localVarReturnValue, nil, err + } + } else { + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + } + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + // CreateComponentOptionalParameters holds optional parameters for CreateComponent. type CreateComponentOptionalParameters struct { Include *string diff --git a/api/datadogV2/doc.go b/api/datadogV2/doc.go index fde870b88e9..f26917ef020 100644 --- a/api/datadogV2/doc.go +++ b/api/datadogV2/doc.go @@ -900,6 +900,8 @@ // - [StaticAnalysisApi.ListCustomRuleRevisions] // - [StaticAnalysisApi.RevertCustomRuleRevision] // - [StaticAnalysisApi.UpdateCustomRuleset] +// - [StatusPagesApi.CreateBackfilledDegradation] +// - [StatusPagesApi.CreateBackfilledMaintenance] // - [StatusPagesApi.CreateComponent] // - [StatusPagesApi.CreateDegradation] // - [StatusPagesApi.CreateMaintenance] diff --git a/api/datadogV2/model_create_backfilled_degradation_request.go b/api/datadogV2/model_create_backfilled_degradation_request.go new file mode 100644 index 00000000000..f7942d03194 --- /dev/null +++ b/api/datadogV2/model_create_backfilled_degradation_request.go @@ -0,0 +1,111 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// CreateBackfilledDegradationRequest Request object for creating a backfilled degradation. +type CreateBackfilledDegradationRequest struct { + // The data object for creating a backfilled degradation. + Data *CreateBackfilledDegradationRequestData `json:"data,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewCreateBackfilledDegradationRequest instantiates a new CreateBackfilledDegradationRequest object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewCreateBackfilledDegradationRequest() *CreateBackfilledDegradationRequest { + this := CreateBackfilledDegradationRequest{} + return &this +} + +// NewCreateBackfilledDegradationRequestWithDefaults instantiates a new CreateBackfilledDegradationRequest object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewCreateBackfilledDegradationRequestWithDefaults() *CreateBackfilledDegradationRequest { + this := CreateBackfilledDegradationRequest{} + return &this +} + +// GetData returns the Data field value if set, zero value otherwise. +func (o *CreateBackfilledDegradationRequest) GetData() CreateBackfilledDegradationRequestData { + if o == nil || o.Data == nil { + var ret CreateBackfilledDegradationRequestData + return ret + } + return *o.Data +} + +// GetDataOk returns a tuple with the Data field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CreateBackfilledDegradationRequest) GetDataOk() (*CreateBackfilledDegradationRequestData, bool) { + if o == nil || o.Data == nil { + return nil, false + } + return o.Data, true +} + +// HasData returns a boolean if a field has been set. +func (o *CreateBackfilledDegradationRequest) HasData() bool { + return o != nil && o.Data != nil +} + +// SetData gets a reference to the given CreateBackfilledDegradationRequestData and assigns it to the Data field. +func (o *CreateBackfilledDegradationRequest) SetData(v CreateBackfilledDegradationRequestData) { + o.Data = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o CreateBackfilledDegradationRequest) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Data != nil { + toSerialize["data"] = o.Data + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *CreateBackfilledDegradationRequest) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *CreateBackfilledDegradationRequestData `json:"data,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + + hasInvalidField := false + if all.Data != nil && all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Data = all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_create_backfilled_degradation_request_data.go b/api/datadogV2/model_create_backfilled_degradation_request_data.go new file mode 100644 index 00000000000..f02da7d6b85 --- /dev/null +++ b/api/datadogV2/model_create_backfilled_degradation_request_data.go @@ -0,0 +1,151 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// CreateBackfilledDegradationRequestData The data object for creating a backfilled degradation. +type CreateBackfilledDegradationRequestData struct { + // The supported attributes for creating a backfilled degradation. + Attributes *CreateBackfilledDegradationRequestDataAttributes `json:"attributes,omitempty"` + // Degradations resource type. + Type PatchDegradationRequestDataType `json:"type"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewCreateBackfilledDegradationRequestData instantiates a new CreateBackfilledDegradationRequestData object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewCreateBackfilledDegradationRequestData(typeVar PatchDegradationRequestDataType) *CreateBackfilledDegradationRequestData { + this := CreateBackfilledDegradationRequestData{} + this.Type = typeVar + return &this +} + +// NewCreateBackfilledDegradationRequestDataWithDefaults instantiates a new CreateBackfilledDegradationRequestData object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewCreateBackfilledDegradationRequestDataWithDefaults() *CreateBackfilledDegradationRequestData { + this := CreateBackfilledDegradationRequestData{} + var typeVar PatchDegradationRequestDataType = PATCHDEGRADATIONREQUESTDATATYPE_DEGRADATIONS + this.Type = typeVar + return &this +} + +// GetAttributes returns the Attributes field value if set, zero value otherwise. +func (o *CreateBackfilledDegradationRequestData) GetAttributes() CreateBackfilledDegradationRequestDataAttributes { + if o == nil || o.Attributes == nil { + var ret CreateBackfilledDegradationRequestDataAttributes + return ret + } + return *o.Attributes +} + +// GetAttributesOk returns a tuple with the Attributes field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CreateBackfilledDegradationRequestData) GetAttributesOk() (*CreateBackfilledDegradationRequestDataAttributes, bool) { + if o == nil || o.Attributes == nil { + return nil, false + } + return o.Attributes, true +} + +// HasAttributes returns a boolean if a field has been set. +func (o *CreateBackfilledDegradationRequestData) HasAttributes() bool { + return o != nil && o.Attributes != nil +} + +// SetAttributes gets a reference to the given CreateBackfilledDegradationRequestDataAttributes and assigns it to the Attributes field. +func (o *CreateBackfilledDegradationRequestData) SetAttributes(v CreateBackfilledDegradationRequestDataAttributes) { + o.Attributes = &v +} + +// GetType returns the Type field value. +func (o *CreateBackfilledDegradationRequestData) GetType() PatchDegradationRequestDataType { + if o == nil { + var ret PatchDegradationRequestDataType + return ret + } + return o.Type +} + +// GetTypeOk returns a tuple with the Type field value +// and a boolean to check if the value has been set. +func (o *CreateBackfilledDegradationRequestData) GetTypeOk() (*PatchDegradationRequestDataType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *CreateBackfilledDegradationRequestData) SetType(v PatchDegradationRequestDataType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o CreateBackfilledDegradationRequestData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Attributes != nil { + toSerialize["attributes"] = o.Attributes + } + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *CreateBackfilledDegradationRequestData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *CreateBackfilledDegradationRequestDataAttributes `json:"attributes,omitempty"` + Type *PatchDegradationRequestDataType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "type"}) + } else { + return err + } + + hasInvalidField := false + if all.Attributes != nil && all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Attributes = all.Attributes + if !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = *all.Type + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_create_backfilled_degradation_request_data_attributes.go b/api/datadogV2/model_create_backfilled_degradation_request_data_attributes.go new file mode 100644 index 00000000000..114bdf14f9f --- /dev/null +++ b/api/datadogV2/model_create_backfilled_degradation_request_data_attributes.go @@ -0,0 +1,133 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// CreateBackfilledDegradationRequestDataAttributes The supported attributes for creating a backfilled degradation. +type CreateBackfilledDegradationRequestDataAttributes struct { + // The title of the backfilled degradation. + Title string `json:"title"` + // The list of status updates describing the timeline of the degradation. + Updates []CreateBackfilledDegradationRequestDataAttributesUpdatesItems `json:"updates"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewCreateBackfilledDegradationRequestDataAttributes instantiates a new CreateBackfilledDegradationRequestDataAttributes object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewCreateBackfilledDegradationRequestDataAttributes(title string, updates []CreateBackfilledDegradationRequestDataAttributesUpdatesItems) *CreateBackfilledDegradationRequestDataAttributes { + this := CreateBackfilledDegradationRequestDataAttributes{} + this.Title = title + this.Updates = updates + return &this +} + +// NewCreateBackfilledDegradationRequestDataAttributesWithDefaults instantiates a new CreateBackfilledDegradationRequestDataAttributes object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewCreateBackfilledDegradationRequestDataAttributesWithDefaults() *CreateBackfilledDegradationRequestDataAttributes { + this := CreateBackfilledDegradationRequestDataAttributes{} + return &this +} + +// GetTitle returns the Title field value. +func (o *CreateBackfilledDegradationRequestDataAttributes) GetTitle() string { + if o == nil { + var ret string + return ret + } + return o.Title +} + +// GetTitleOk returns a tuple with the Title field value +// and a boolean to check if the value has been set. +func (o *CreateBackfilledDegradationRequestDataAttributes) GetTitleOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Title, true +} + +// SetTitle sets field value. +func (o *CreateBackfilledDegradationRequestDataAttributes) SetTitle(v string) { + o.Title = v +} + +// GetUpdates returns the Updates field value. +func (o *CreateBackfilledDegradationRequestDataAttributes) GetUpdates() []CreateBackfilledDegradationRequestDataAttributesUpdatesItems { + if o == nil { + var ret []CreateBackfilledDegradationRequestDataAttributesUpdatesItems + return ret + } + return o.Updates +} + +// GetUpdatesOk returns a tuple with the Updates field value +// and a boolean to check if the value has been set. +func (o *CreateBackfilledDegradationRequestDataAttributes) GetUpdatesOk() (*[]CreateBackfilledDegradationRequestDataAttributesUpdatesItems, bool) { + if o == nil { + return nil, false + } + return &o.Updates, true +} + +// SetUpdates sets field value. +func (o *CreateBackfilledDegradationRequestDataAttributes) SetUpdates(v []CreateBackfilledDegradationRequestDataAttributesUpdatesItems) { + o.Updates = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o CreateBackfilledDegradationRequestDataAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["title"] = o.Title + toSerialize["updates"] = o.Updates + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *CreateBackfilledDegradationRequestDataAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Title *string `json:"title"` + Updates *[]CreateBackfilledDegradationRequestDataAttributesUpdatesItems `json:"updates"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Title == nil { + return fmt.Errorf("required field title missing") + } + if all.Updates == nil { + return fmt.Errorf("required field updates missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"title", "updates"}) + } else { + return err + } + o.Title = *all.Title + o.Updates = *all.Updates + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_create_backfilled_degradation_request_data_attributes_updates_items.go b/api/datadogV2/model_create_backfilled_degradation_request_data_attributes_updates_items.go new file mode 100644 index 00000000000..c876b2abbc3 --- /dev/null +++ b/api/datadogV2/model_create_backfilled_degradation_request_data_attributes_updates_items.go @@ -0,0 +1,218 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + "time" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// CreateBackfilledDegradationRequestDataAttributesUpdatesItems A backfilled degradation update entry. +type CreateBackfilledDegradationRequestDataAttributesUpdatesItems struct { + // The components affected. + ComponentsAffected []CreateDegradationRequestDataAttributesComponentsAffectedItems `json:"components_affected,omitempty"` + // A description of the update. + Description *string `json:"description,omitempty"` + // Timestamp of when the update occurred. + StartedAt time.Time `json:"started_at"` + // The status of the degradation. + Status CreateDegradationRequestDataAttributesStatus `json:"status"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewCreateBackfilledDegradationRequestDataAttributesUpdatesItems instantiates a new CreateBackfilledDegradationRequestDataAttributesUpdatesItems object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewCreateBackfilledDegradationRequestDataAttributesUpdatesItems(startedAt time.Time, status CreateDegradationRequestDataAttributesStatus) *CreateBackfilledDegradationRequestDataAttributesUpdatesItems { + this := CreateBackfilledDegradationRequestDataAttributesUpdatesItems{} + this.StartedAt = startedAt + this.Status = status + return &this +} + +// NewCreateBackfilledDegradationRequestDataAttributesUpdatesItemsWithDefaults instantiates a new CreateBackfilledDegradationRequestDataAttributesUpdatesItems object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewCreateBackfilledDegradationRequestDataAttributesUpdatesItemsWithDefaults() *CreateBackfilledDegradationRequestDataAttributesUpdatesItems { + this := CreateBackfilledDegradationRequestDataAttributesUpdatesItems{} + return &this +} + +// GetComponentsAffected returns the ComponentsAffected field value if set, zero value otherwise. +func (o *CreateBackfilledDegradationRequestDataAttributesUpdatesItems) GetComponentsAffected() []CreateDegradationRequestDataAttributesComponentsAffectedItems { + if o == nil || o.ComponentsAffected == nil { + var ret []CreateDegradationRequestDataAttributesComponentsAffectedItems + return ret + } + return o.ComponentsAffected +} + +// GetComponentsAffectedOk returns a tuple with the ComponentsAffected field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CreateBackfilledDegradationRequestDataAttributesUpdatesItems) GetComponentsAffectedOk() (*[]CreateDegradationRequestDataAttributesComponentsAffectedItems, bool) { + if o == nil || o.ComponentsAffected == nil { + return nil, false + } + return &o.ComponentsAffected, true +} + +// HasComponentsAffected returns a boolean if a field has been set. +func (o *CreateBackfilledDegradationRequestDataAttributesUpdatesItems) HasComponentsAffected() bool { + return o != nil && o.ComponentsAffected != nil +} + +// SetComponentsAffected gets a reference to the given []CreateDegradationRequestDataAttributesComponentsAffectedItems and assigns it to the ComponentsAffected field. +func (o *CreateBackfilledDegradationRequestDataAttributesUpdatesItems) SetComponentsAffected(v []CreateDegradationRequestDataAttributesComponentsAffectedItems) { + o.ComponentsAffected = v +} + +// GetDescription returns the Description field value if set, zero value otherwise. +func (o *CreateBackfilledDegradationRequestDataAttributesUpdatesItems) GetDescription() string { + if o == nil || o.Description == nil { + var ret string + return ret + } + return *o.Description +} + +// GetDescriptionOk returns a tuple with the Description field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CreateBackfilledDegradationRequestDataAttributesUpdatesItems) GetDescriptionOk() (*string, bool) { + if o == nil || o.Description == nil { + return nil, false + } + return o.Description, true +} + +// HasDescription returns a boolean if a field has been set. +func (o *CreateBackfilledDegradationRequestDataAttributesUpdatesItems) HasDescription() bool { + return o != nil && o.Description != nil +} + +// SetDescription gets a reference to the given string and assigns it to the Description field. +func (o *CreateBackfilledDegradationRequestDataAttributesUpdatesItems) SetDescription(v string) { + o.Description = &v +} + +// GetStartedAt returns the StartedAt field value. +func (o *CreateBackfilledDegradationRequestDataAttributesUpdatesItems) GetStartedAt() time.Time { + if o == nil { + var ret time.Time + return ret + } + return o.StartedAt +} + +// GetStartedAtOk returns a tuple with the StartedAt field value +// and a boolean to check if the value has been set. +func (o *CreateBackfilledDegradationRequestDataAttributesUpdatesItems) GetStartedAtOk() (*time.Time, bool) { + if o == nil { + return nil, false + } + return &o.StartedAt, true +} + +// SetStartedAt sets field value. +func (o *CreateBackfilledDegradationRequestDataAttributesUpdatesItems) SetStartedAt(v time.Time) { + o.StartedAt = v +} + +// GetStatus returns the Status field value. +func (o *CreateBackfilledDegradationRequestDataAttributesUpdatesItems) GetStatus() CreateDegradationRequestDataAttributesStatus { + if o == nil { + var ret CreateDegradationRequestDataAttributesStatus + return ret + } + return o.Status +} + +// GetStatusOk returns a tuple with the Status field value +// and a boolean to check if the value has been set. +func (o *CreateBackfilledDegradationRequestDataAttributesUpdatesItems) GetStatusOk() (*CreateDegradationRequestDataAttributesStatus, bool) { + if o == nil { + return nil, false + } + return &o.Status, true +} + +// SetStatus sets field value. +func (o *CreateBackfilledDegradationRequestDataAttributesUpdatesItems) SetStatus(v CreateDegradationRequestDataAttributesStatus) { + o.Status = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o CreateBackfilledDegradationRequestDataAttributesUpdatesItems) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.ComponentsAffected != nil { + toSerialize["components_affected"] = o.ComponentsAffected + } + if o.Description != nil { + toSerialize["description"] = o.Description + } + if o.StartedAt.Nanosecond() == 0 { + toSerialize["started_at"] = o.StartedAt.Format("2006-01-02T15:04:05Z07:00") + } else { + toSerialize["started_at"] = o.StartedAt.Format("2006-01-02T15:04:05.000Z07:00") + } + toSerialize["status"] = o.Status + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *CreateBackfilledDegradationRequestDataAttributesUpdatesItems) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + ComponentsAffected []CreateDegradationRequestDataAttributesComponentsAffectedItems `json:"components_affected,omitempty"` + Description *string `json:"description,omitempty"` + StartedAt *time.Time `json:"started_at"` + Status *CreateDegradationRequestDataAttributesStatus `json:"status"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.StartedAt == nil { + return fmt.Errorf("required field started_at missing") + } + if all.Status == nil { + return fmt.Errorf("required field status missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"components_affected", "description", "started_at", "status"}) + } else { + return err + } + + hasInvalidField := false + o.ComponentsAffected = all.ComponentsAffected + o.Description = all.Description + o.StartedAt = *all.StartedAt + if !all.Status.IsValid() { + hasInvalidField = true + } else { + o.Status = *all.Status + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_create_backfilled_maintenance_request.go b/api/datadogV2/model_create_backfilled_maintenance_request.go new file mode 100644 index 00000000000..be295e5f536 --- /dev/null +++ b/api/datadogV2/model_create_backfilled_maintenance_request.go @@ -0,0 +1,111 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// CreateBackfilledMaintenanceRequest Request object for creating a backfilled maintenance. +type CreateBackfilledMaintenanceRequest struct { + // The data object for creating a backfilled maintenance. + Data *CreateBackfilledMaintenanceRequestData `json:"data,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewCreateBackfilledMaintenanceRequest instantiates a new CreateBackfilledMaintenanceRequest object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewCreateBackfilledMaintenanceRequest() *CreateBackfilledMaintenanceRequest { + this := CreateBackfilledMaintenanceRequest{} + return &this +} + +// NewCreateBackfilledMaintenanceRequestWithDefaults instantiates a new CreateBackfilledMaintenanceRequest object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewCreateBackfilledMaintenanceRequestWithDefaults() *CreateBackfilledMaintenanceRequest { + this := CreateBackfilledMaintenanceRequest{} + return &this +} + +// GetData returns the Data field value if set, zero value otherwise. +func (o *CreateBackfilledMaintenanceRequest) GetData() CreateBackfilledMaintenanceRequestData { + if o == nil || o.Data == nil { + var ret CreateBackfilledMaintenanceRequestData + return ret + } + return *o.Data +} + +// GetDataOk returns a tuple with the Data field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CreateBackfilledMaintenanceRequest) GetDataOk() (*CreateBackfilledMaintenanceRequestData, bool) { + if o == nil || o.Data == nil { + return nil, false + } + return o.Data, true +} + +// HasData returns a boolean if a field has been set. +func (o *CreateBackfilledMaintenanceRequest) HasData() bool { + return o != nil && o.Data != nil +} + +// SetData gets a reference to the given CreateBackfilledMaintenanceRequestData and assigns it to the Data field. +func (o *CreateBackfilledMaintenanceRequest) SetData(v CreateBackfilledMaintenanceRequestData) { + o.Data = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o CreateBackfilledMaintenanceRequest) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Data != nil { + toSerialize["data"] = o.Data + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *CreateBackfilledMaintenanceRequest) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *CreateBackfilledMaintenanceRequestData `json:"data,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + + hasInvalidField := false + if all.Data != nil && all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Data = all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_create_backfilled_maintenance_request_data.go b/api/datadogV2/model_create_backfilled_maintenance_request_data.go new file mode 100644 index 00000000000..89dcd6ffb80 --- /dev/null +++ b/api/datadogV2/model_create_backfilled_maintenance_request_data.go @@ -0,0 +1,151 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// CreateBackfilledMaintenanceRequestData The data object for creating a backfilled maintenance. +type CreateBackfilledMaintenanceRequestData struct { + // The supported attributes for creating a backfilled maintenance. + Attributes *CreateBackfilledMaintenanceRequestDataAttributes `json:"attributes,omitempty"` + // Maintenances resource type. + Type PatchMaintenanceRequestDataType `json:"type"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewCreateBackfilledMaintenanceRequestData instantiates a new CreateBackfilledMaintenanceRequestData object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewCreateBackfilledMaintenanceRequestData(typeVar PatchMaintenanceRequestDataType) *CreateBackfilledMaintenanceRequestData { + this := CreateBackfilledMaintenanceRequestData{} + this.Type = typeVar + return &this +} + +// NewCreateBackfilledMaintenanceRequestDataWithDefaults instantiates a new CreateBackfilledMaintenanceRequestData object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewCreateBackfilledMaintenanceRequestDataWithDefaults() *CreateBackfilledMaintenanceRequestData { + this := CreateBackfilledMaintenanceRequestData{} + var typeVar PatchMaintenanceRequestDataType = PATCHMAINTENANCEREQUESTDATATYPE_MAINTENANCES + this.Type = typeVar + return &this +} + +// GetAttributes returns the Attributes field value if set, zero value otherwise. +func (o *CreateBackfilledMaintenanceRequestData) GetAttributes() CreateBackfilledMaintenanceRequestDataAttributes { + if o == nil || o.Attributes == nil { + var ret CreateBackfilledMaintenanceRequestDataAttributes + return ret + } + return *o.Attributes +} + +// GetAttributesOk returns a tuple with the Attributes field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CreateBackfilledMaintenanceRequestData) GetAttributesOk() (*CreateBackfilledMaintenanceRequestDataAttributes, bool) { + if o == nil || o.Attributes == nil { + return nil, false + } + return o.Attributes, true +} + +// HasAttributes returns a boolean if a field has been set. +func (o *CreateBackfilledMaintenanceRequestData) HasAttributes() bool { + return o != nil && o.Attributes != nil +} + +// SetAttributes gets a reference to the given CreateBackfilledMaintenanceRequestDataAttributes and assigns it to the Attributes field. +func (o *CreateBackfilledMaintenanceRequestData) SetAttributes(v CreateBackfilledMaintenanceRequestDataAttributes) { + o.Attributes = &v +} + +// GetType returns the Type field value. +func (o *CreateBackfilledMaintenanceRequestData) GetType() PatchMaintenanceRequestDataType { + if o == nil { + var ret PatchMaintenanceRequestDataType + return ret + } + return o.Type +} + +// GetTypeOk returns a tuple with the Type field value +// and a boolean to check if the value has been set. +func (o *CreateBackfilledMaintenanceRequestData) GetTypeOk() (*PatchMaintenanceRequestDataType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *CreateBackfilledMaintenanceRequestData) SetType(v PatchMaintenanceRequestDataType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o CreateBackfilledMaintenanceRequestData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Attributes != nil { + toSerialize["attributes"] = o.Attributes + } + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *CreateBackfilledMaintenanceRequestData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *CreateBackfilledMaintenanceRequestDataAttributes `json:"attributes,omitempty"` + Type *PatchMaintenanceRequestDataType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "type"}) + } else { + return err + } + + hasInvalidField := false + if all.Attributes != nil && all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Attributes = all.Attributes + if !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = *all.Type + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_create_backfilled_maintenance_request_data_attributes.go b/api/datadogV2/model_create_backfilled_maintenance_request_data_attributes.go new file mode 100644 index 00000000000..2c8d2d82047 --- /dev/null +++ b/api/datadogV2/model_create_backfilled_maintenance_request_data_attributes.go @@ -0,0 +1,133 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// CreateBackfilledMaintenanceRequestDataAttributes The supported attributes for creating a backfilled maintenance. +type CreateBackfilledMaintenanceRequestDataAttributes struct { + // The title of the backfilled maintenance. + Title string `json:"title"` + // The list of updates. Exactly two updates are required: the start (`in_progress`) and the end (`completed`). + Updates []CreateBackfilledMaintenanceRequestDataAttributesUpdatesItems `json:"updates"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewCreateBackfilledMaintenanceRequestDataAttributes instantiates a new CreateBackfilledMaintenanceRequestDataAttributes object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewCreateBackfilledMaintenanceRequestDataAttributes(title string, updates []CreateBackfilledMaintenanceRequestDataAttributesUpdatesItems) *CreateBackfilledMaintenanceRequestDataAttributes { + this := CreateBackfilledMaintenanceRequestDataAttributes{} + this.Title = title + this.Updates = updates + return &this +} + +// NewCreateBackfilledMaintenanceRequestDataAttributesWithDefaults instantiates a new CreateBackfilledMaintenanceRequestDataAttributes object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewCreateBackfilledMaintenanceRequestDataAttributesWithDefaults() *CreateBackfilledMaintenanceRequestDataAttributes { + this := CreateBackfilledMaintenanceRequestDataAttributes{} + return &this +} + +// GetTitle returns the Title field value. +func (o *CreateBackfilledMaintenanceRequestDataAttributes) GetTitle() string { + if o == nil { + var ret string + return ret + } + return o.Title +} + +// GetTitleOk returns a tuple with the Title field value +// and a boolean to check if the value has been set. +func (o *CreateBackfilledMaintenanceRequestDataAttributes) GetTitleOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Title, true +} + +// SetTitle sets field value. +func (o *CreateBackfilledMaintenanceRequestDataAttributes) SetTitle(v string) { + o.Title = v +} + +// GetUpdates returns the Updates field value. +func (o *CreateBackfilledMaintenanceRequestDataAttributes) GetUpdates() []CreateBackfilledMaintenanceRequestDataAttributesUpdatesItems { + if o == nil { + var ret []CreateBackfilledMaintenanceRequestDataAttributesUpdatesItems + return ret + } + return o.Updates +} + +// GetUpdatesOk returns a tuple with the Updates field value +// and a boolean to check if the value has been set. +func (o *CreateBackfilledMaintenanceRequestDataAttributes) GetUpdatesOk() (*[]CreateBackfilledMaintenanceRequestDataAttributesUpdatesItems, bool) { + if o == nil { + return nil, false + } + return &o.Updates, true +} + +// SetUpdates sets field value. +func (o *CreateBackfilledMaintenanceRequestDataAttributes) SetUpdates(v []CreateBackfilledMaintenanceRequestDataAttributesUpdatesItems) { + o.Updates = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o CreateBackfilledMaintenanceRequestDataAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["title"] = o.Title + toSerialize["updates"] = o.Updates + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *CreateBackfilledMaintenanceRequestDataAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Title *string `json:"title"` + Updates *[]CreateBackfilledMaintenanceRequestDataAttributesUpdatesItems `json:"updates"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Title == nil { + return fmt.Errorf("required field title missing") + } + if all.Updates == nil { + return fmt.Errorf("required field updates missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"title", "updates"}) + } else { + return err + } + o.Title = *all.Title + o.Updates = *all.Updates + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_create_backfilled_maintenance_request_data_attributes_updates_items.go b/api/datadogV2/model_create_backfilled_maintenance_request_data_attributes_updates_items.go new file mode 100644 index 00000000000..83b14c4d3c9 --- /dev/null +++ b/api/datadogV2/model_create_backfilled_maintenance_request_data_attributes_updates_items.go @@ -0,0 +1,212 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + "time" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// CreateBackfilledMaintenanceRequestDataAttributesUpdatesItems A backfilled maintenance update entry. +type CreateBackfilledMaintenanceRequestDataAttributesUpdatesItems struct { + // The components affected. + ComponentsAffected []CreateMaintenanceRequestDataAttributesComponentsAffectedItems `json:"components_affected"` + // A description of the update. + Description string `json:"description"` + // Timestamp of when the update occurred. + StartedAt time.Time `json:"started_at"` + // The status of a maintenance update. + Status CreateMaintenanceRequestDataAttributesUpdatesItemsStatus `json:"status"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewCreateBackfilledMaintenanceRequestDataAttributesUpdatesItems instantiates a new CreateBackfilledMaintenanceRequestDataAttributesUpdatesItems object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewCreateBackfilledMaintenanceRequestDataAttributesUpdatesItems(componentsAffected []CreateMaintenanceRequestDataAttributesComponentsAffectedItems, description string, startedAt time.Time, status CreateMaintenanceRequestDataAttributesUpdatesItemsStatus) *CreateBackfilledMaintenanceRequestDataAttributesUpdatesItems { + this := CreateBackfilledMaintenanceRequestDataAttributesUpdatesItems{} + this.ComponentsAffected = componentsAffected + this.Description = description + this.StartedAt = startedAt + this.Status = status + return &this +} + +// NewCreateBackfilledMaintenanceRequestDataAttributesUpdatesItemsWithDefaults instantiates a new CreateBackfilledMaintenanceRequestDataAttributesUpdatesItems object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewCreateBackfilledMaintenanceRequestDataAttributesUpdatesItemsWithDefaults() *CreateBackfilledMaintenanceRequestDataAttributesUpdatesItems { + this := CreateBackfilledMaintenanceRequestDataAttributesUpdatesItems{} + return &this +} + +// GetComponentsAffected returns the ComponentsAffected field value. +func (o *CreateBackfilledMaintenanceRequestDataAttributesUpdatesItems) GetComponentsAffected() []CreateMaintenanceRequestDataAttributesComponentsAffectedItems { + if o == nil { + var ret []CreateMaintenanceRequestDataAttributesComponentsAffectedItems + return ret + } + return o.ComponentsAffected +} + +// GetComponentsAffectedOk returns a tuple with the ComponentsAffected field value +// and a boolean to check if the value has been set. +func (o *CreateBackfilledMaintenanceRequestDataAttributesUpdatesItems) GetComponentsAffectedOk() (*[]CreateMaintenanceRequestDataAttributesComponentsAffectedItems, bool) { + if o == nil { + return nil, false + } + return &o.ComponentsAffected, true +} + +// SetComponentsAffected sets field value. +func (o *CreateBackfilledMaintenanceRequestDataAttributesUpdatesItems) SetComponentsAffected(v []CreateMaintenanceRequestDataAttributesComponentsAffectedItems) { + o.ComponentsAffected = v +} + +// GetDescription returns the Description field value. +func (o *CreateBackfilledMaintenanceRequestDataAttributesUpdatesItems) GetDescription() string { + if o == nil { + var ret string + return ret + } + return o.Description +} + +// GetDescriptionOk returns a tuple with the Description field value +// and a boolean to check if the value has been set. +func (o *CreateBackfilledMaintenanceRequestDataAttributesUpdatesItems) GetDescriptionOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Description, true +} + +// SetDescription sets field value. +func (o *CreateBackfilledMaintenanceRequestDataAttributesUpdatesItems) SetDescription(v string) { + o.Description = v +} + +// GetStartedAt returns the StartedAt field value. +func (o *CreateBackfilledMaintenanceRequestDataAttributesUpdatesItems) GetStartedAt() time.Time { + if o == nil { + var ret time.Time + return ret + } + return o.StartedAt +} + +// GetStartedAtOk returns a tuple with the StartedAt field value +// and a boolean to check if the value has been set. +func (o *CreateBackfilledMaintenanceRequestDataAttributesUpdatesItems) GetStartedAtOk() (*time.Time, bool) { + if o == nil { + return nil, false + } + return &o.StartedAt, true +} + +// SetStartedAt sets field value. +func (o *CreateBackfilledMaintenanceRequestDataAttributesUpdatesItems) SetStartedAt(v time.Time) { + o.StartedAt = v +} + +// GetStatus returns the Status field value. +func (o *CreateBackfilledMaintenanceRequestDataAttributesUpdatesItems) GetStatus() CreateMaintenanceRequestDataAttributesUpdatesItemsStatus { + if o == nil { + var ret CreateMaintenanceRequestDataAttributesUpdatesItemsStatus + return ret + } + return o.Status +} + +// GetStatusOk returns a tuple with the Status field value +// and a boolean to check if the value has been set. +func (o *CreateBackfilledMaintenanceRequestDataAttributesUpdatesItems) GetStatusOk() (*CreateMaintenanceRequestDataAttributesUpdatesItemsStatus, bool) { + if o == nil { + return nil, false + } + return &o.Status, true +} + +// SetStatus sets field value. +func (o *CreateBackfilledMaintenanceRequestDataAttributesUpdatesItems) SetStatus(v CreateMaintenanceRequestDataAttributesUpdatesItemsStatus) { + o.Status = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o CreateBackfilledMaintenanceRequestDataAttributesUpdatesItems) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["components_affected"] = o.ComponentsAffected + toSerialize["description"] = o.Description + if o.StartedAt.Nanosecond() == 0 { + toSerialize["started_at"] = o.StartedAt.Format("2006-01-02T15:04:05Z07:00") + } else { + toSerialize["started_at"] = o.StartedAt.Format("2006-01-02T15:04:05.000Z07:00") + } + toSerialize["status"] = o.Status + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *CreateBackfilledMaintenanceRequestDataAttributesUpdatesItems) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + ComponentsAffected *[]CreateMaintenanceRequestDataAttributesComponentsAffectedItems `json:"components_affected"` + Description *string `json:"description"` + StartedAt *time.Time `json:"started_at"` + Status *CreateMaintenanceRequestDataAttributesUpdatesItemsStatus `json:"status"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.ComponentsAffected == nil { + return fmt.Errorf("required field components_affected missing") + } + if all.Description == nil { + return fmt.Errorf("required field description missing") + } + if all.StartedAt == nil { + return fmt.Errorf("required field started_at missing") + } + if all.Status == nil { + return fmt.Errorf("required field status missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"components_affected", "description", "started_at", "status"}) + } else { + return err + } + + hasInvalidField := false + o.ComponentsAffected = *all.ComponentsAffected + o.Description = *all.Description + o.StartedAt = *all.StartedAt + if !all.Status.IsValid() { + hasInvalidField = true + } else { + o.Status = *all.Status + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_create_degradation_request_data_attributes.go b/api/datadogV2/model_create_degradation_request_data_attributes.go index 86c9430c531..f1aaa9c412d 100644 --- a/api/datadogV2/model_create_degradation_request_data_attributes.go +++ b/api/datadogV2/model_create_degradation_request_data_attributes.go @@ -20,6 +20,8 @@ type CreateDegradationRequestDataAttributes struct { Status CreateDegradationRequestDataAttributesStatus `json:"status"` // The title of the degradation. Title string `json:"title"` + // + Updates []CreateDegradationRequestDataAttributesUpdatesItems `json:"updates,omitempty"` // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct UnparsedObject map[string]interface{} `json:"-"` AdditionalProperties map[string]interface{} `json:"-"` @@ -142,6 +144,34 @@ func (o *CreateDegradationRequestDataAttributes) SetTitle(v string) { o.Title = v } +// GetUpdates returns the Updates field value if set, zero value otherwise. +func (o *CreateDegradationRequestDataAttributes) GetUpdates() []CreateDegradationRequestDataAttributesUpdatesItems { + if o == nil || o.Updates == nil { + var ret []CreateDegradationRequestDataAttributesUpdatesItems + return ret + } + return o.Updates +} + +// GetUpdatesOk returns a tuple with the Updates field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CreateDegradationRequestDataAttributes) GetUpdatesOk() (*[]CreateDegradationRequestDataAttributesUpdatesItems, bool) { + if o == nil || o.Updates == nil { + return nil, false + } + return &o.Updates, true +} + +// HasUpdates returns a boolean if a field has been set. +func (o *CreateDegradationRequestDataAttributes) HasUpdates() bool { + return o != nil && o.Updates != nil +} + +// SetUpdates gets a reference to the given []CreateDegradationRequestDataAttributesUpdatesItems and assigns it to the Updates field. +func (o *CreateDegradationRequestDataAttributes) SetUpdates(v []CreateDegradationRequestDataAttributesUpdatesItems) { + o.Updates = v +} + // MarshalJSON serializes the struct using spec logic. func (o CreateDegradationRequestDataAttributes) MarshalJSON() ([]byte, error) { toSerialize := map[string]interface{}{} @@ -154,6 +184,9 @@ func (o CreateDegradationRequestDataAttributes) MarshalJSON() ([]byte, error) { } toSerialize["status"] = o.Status toSerialize["title"] = o.Title + if o.Updates != nil { + toSerialize["updates"] = o.Updates + } for key, value := range o.AdditionalProperties { toSerialize[key] = value @@ -168,6 +201,7 @@ func (o *CreateDegradationRequestDataAttributes) UnmarshalJSON(bytes []byte) (er Description *string `json:"description,omitempty"` Status *CreateDegradationRequestDataAttributesStatus `json:"status"` Title *string `json:"title"` + Updates []CreateDegradationRequestDataAttributesUpdatesItems `json:"updates,omitempty"` }{} if err = datadog.Unmarshal(bytes, &all); err != nil { return datadog.Unmarshal(bytes, &o.UnparsedObject) @@ -183,7 +217,7 @@ func (o *CreateDegradationRequestDataAttributes) UnmarshalJSON(bytes []byte) (er } additionalProperties := make(map[string]interface{}) if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { - datadog.DeleteKeys(additionalProperties, &[]string{"components_affected", "description", "status", "title"}) + datadog.DeleteKeys(additionalProperties, &[]string{"components_affected", "description", "status", "title", "updates"}) } else { return err } @@ -197,6 +231,7 @@ func (o *CreateDegradationRequestDataAttributes) UnmarshalJSON(bytes []byte) (er o.Status = *all.Status } o.Title = *all.Title + o.Updates = all.Updates if len(additionalProperties) > 0 { o.AdditionalProperties = additionalProperties diff --git a/api/datadogV2/model_create_degradation_request_data_attributes_updates_items.go b/api/datadogV2/model_create_degradation_request_data_attributes_updates_items.go new file mode 100644 index 00000000000..8b4fe54a982 --- /dev/null +++ b/api/datadogV2/model_create_degradation_request_data_attributes_updates_items.go @@ -0,0 +1,212 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + "time" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// CreateDegradationRequestDataAttributesUpdatesItems A degradation update entry. +type CreateDegradationRequestDataAttributesUpdatesItems struct { + // The components affected. + ComponentsAffected []CreateDegradationRequestDataAttributesUpdatesItemsComponentsAffectedItems `json:"components_affected"` + // A description of the update. + Description string `json:"description"` + // Timestamp of when the update occurred. + StartedAt time.Time `json:"started_at"` + // The status of the degradation. + Status CreateDegradationRequestDataAttributesStatus `json:"status"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewCreateDegradationRequestDataAttributesUpdatesItems instantiates a new CreateDegradationRequestDataAttributesUpdatesItems object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewCreateDegradationRequestDataAttributesUpdatesItems(componentsAffected []CreateDegradationRequestDataAttributesUpdatesItemsComponentsAffectedItems, description string, startedAt time.Time, status CreateDegradationRequestDataAttributesStatus) *CreateDegradationRequestDataAttributesUpdatesItems { + this := CreateDegradationRequestDataAttributesUpdatesItems{} + this.ComponentsAffected = componentsAffected + this.Description = description + this.StartedAt = startedAt + this.Status = status + return &this +} + +// NewCreateDegradationRequestDataAttributesUpdatesItemsWithDefaults instantiates a new CreateDegradationRequestDataAttributesUpdatesItems object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewCreateDegradationRequestDataAttributesUpdatesItemsWithDefaults() *CreateDegradationRequestDataAttributesUpdatesItems { + this := CreateDegradationRequestDataAttributesUpdatesItems{} + return &this +} + +// GetComponentsAffected returns the ComponentsAffected field value. +func (o *CreateDegradationRequestDataAttributesUpdatesItems) GetComponentsAffected() []CreateDegradationRequestDataAttributesUpdatesItemsComponentsAffectedItems { + if o == nil { + var ret []CreateDegradationRequestDataAttributesUpdatesItemsComponentsAffectedItems + return ret + } + return o.ComponentsAffected +} + +// GetComponentsAffectedOk returns a tuple with the ComponentsAffected field value +// and a boolean to check if the value has been set. +func (o *CreateDegradationRequestDataAttributesUpdatesItems) GetComponentsAffectedOk() (*[]CreateDegradationRequestDataAttributesUpdatesItemsComponentsAffectedItems, bool) { + if o == nil { + return nil, false + } + return &o.ComponentsAffected, true +} + +// SetComponentsAffected sets field value. +func (o *CreateDegradationRequestDataAttributesUpdatesItems) SetComponentsAffected(v []CreateDegradationRequestDataAttributesUpdatesItemsComponentsAffectedItems) { + o.ComponentsAffected = v +} + +// GetDescription returns the Description field value. +func (o *CreateDegradationRequestDataAttributesUpdatesItems) GetDescription() string { + if o == nil { + var ret string + return ret + } + return o.Description +} + +// GetDescriptionOk returns a tuple with the Description field value +// and a boolean to check if the value has been set. +func (o *CreateDegradationRequestDataAttributesUpdatesItems) GetDescriptionOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Description, true +} + +// SetDescription sets field value. +func (o *CreateDegradationRequestDataAttributesUpdatesItems) SetDescription(v string) { + o.Description = v +} + +// GetStartedAt returns the StartedAt field value. +func (o *CreateDegradationRequestDataAttributesUpdatesItems) GetStartedAt() time.Time { + if o == nil { + var ret time.Time + return ret + } + return o.StartedAt +} + +// GetStartedAtOk returns a tuple with the StartedAt field value +// and a boolean to check if the value has been set. +func (o *CreateDegradationRequestDataAttributesUpdatesItems) GetStartedAtOk() (*time.Time, bool) { + if o == nil { + return nil, false + } + return &o.StartedAt, true +} + +// SetStartedAt sets field value. +func (o *CreateDegradationRequestDataAttributesUpdatesItems) SetStartedAt(v time.Time) { + o.StartedAt = v +} + +// GetStatus returns the Status field value. +func (o *CreateDegradationRequestDataAttributesUpdatesItems) GetStatus() CreateDegradationRequestDataAttributesStatus { + if o == nil { + var ret CreateDegradationRequestDataAttributesStatus + return ret + } + return o.Status +} + +// GetStatusOk returns a tuple with the Status field value +// and a boolean to check if the value has been set. +func (o *CreateDegradationRequestDataAttributesUpdatesItems) GetStatusOk() (*CreateDegradationRequestDataAttributesStatus, bool) { + if o == nil { + return nil, false + } + return &o.Status, true +} + +// SetStatus sets field value. +func (o *CreateDegradationRequestDataAttributesUpdatesItems) SetStatus(v CreateDegradationRequestDataAttributesStatus) { + o.Status = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o CreateDegradationRequestDataAttributesUpdatesItems) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["components_affected"] = o.ComponentsAffected + toSerialize["description"] = o.Description + if o.StartedAt.Nanosecond() == 0 { + toSerialize["started_at"] = o.StartedAt.Format("2006-01-02T15:04:05Z07:00") + } else { + toSerialize["started_at"] = o.StartedAt.Format("2006-01-02T15:04:05.000Z07:00") + } + toSerialize["status"] = o.Status + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *CreateDegradationRequestDataAttributesUpdatesItems) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + ComponentsAffected *[]CreateDegradationRequestDataAttributesUpdatesItemsComponentsAffectedItems `json:"components_affected"` + Description *string `json:"description"` + StartedAt *time.Time `json:"started_at"` + Status *CreateDegradationRequestDataAttributesStatus `json:"status"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.ComponentsAffected == nil { + return fmt.Errorf("required field components_affected missing") + } + if all.Description == nil { + return fmt.Errorf("required field description missing") + } + if all.StartedAt == nil { + return fmt.Errorf("required field started_at missing") + } + if all.Status == nil { + return fmt.Errorf("required field status missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"components_affected", "description", "started_at", "status"}) + } else { + return err + } + + hasInvalidField := false + o.ComponentsAffected = *all.ComponentsAffected + o.Description = *all.Description + o.StartedAt = *all.StartedAt + if !all.Status.IsValid() { + hasInvalidField = true + } else { + o.Status = *all.Status + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_create_degradation_request_data_attributes_updates_items_components_affected_items.go b/api/datadogV2/model_create_degradation_request_data_attributes_updates_items_components_affected_items.go new file mode 100644 index 00000000000..c6a505458ac --- /dev/null +++ b/api/datadogV2/model_create_degradation_request_data_attributes_updates_items_components_affected_items.go @@ -0,0 +1,178 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// CreateDegradationRequestDataAttributesUpdatesItemsComponentsAffectedItems A component affected by a degradation update. +type CreateDegradationRequestDataAttributesUpdatesItemsComponentsAffectedItems struct { + // The ID of the component. Must be a component of type `component`. + Id string `json:"id"` + // The name of the component. + Name *string `json:"name,omitempty"` + // The status of the component. + Status StatusPagesComponentDataAttributesStatus `json:"status"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewCreateDegradationRequestDataAttributesUpdatesItemsComponentsAffectedItems instantiates a new CreateDegradationRequestDataAttributesUpdatesItemsComponentsAffectedItems object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewCreateDegradationRequestDataAttributesUpdatesItemsComponentsAffectedItems(id string, status StatusPagesComponentDataAttributesStatus) *CreateDegradationRequestDataAttributesUpdatesItemsComponentsAffectedItems { + this := CreateDegradationRequestDataAttributesUpdatesItemsComponentsAffectedItems{} + this.Id = id + this.Status = status + return &this +} + +// NewCreateDegradationRequestDataAttributesUpdatesItemsComponentsAffectedItemsWithDefaults instantiates a new CreateDegradationRequestDataAttributesUpdatesItemsComponentsAffectedItems object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewCreateDegradationRequestDataAttributesUpdatesItemsComponentsAffectedItemsWithDefaults() *CreateDegradationRequestDataAttributesUpdatesItemsComponentsAffectedItems { + this := CreateDegradationRequestDataAttributesUpdatesItemsComponentsAffectedItems{} + return &this +} + +// GetId returns the Id field value. +func (o *CreateDegradationRequestDataAttributesUpdatesItemsComponentsAffectedItems) GetId() string { + if o == nil { + var ret string + return ret + } + return o.Id +} + +// GetIdOk returns a tuple with the Id field value +// and a boolean to check if the value has been set. +func (o *CreateDegradationRequestDataAttributesUpdatesItemsComponentsAffectedItems) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Id, true +} + +// SetId sets field value. +func (o *CreateDegradationRequestDataAttributesUpdatesItemsComponentsAffectedItems) SetId(v string) { + o.Id = v +} + +// GetName returns the Name field value if set, zero value otherwise. +func (o *CreateDegradationRequestDataAttributesUpdatesItemsComponentsAffectedItems) GetName() string { + if o == nil || o.Name == nil { + var ret string + return ret + } + return *o.Name +} + +// GetNameOk returns a tuple with the Name field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CreateDegradationRequestDataAttributesUpdatesItemsComponentsAffectedItems) GetNameOk() (*string, bool) { + if o == nil || o.Name == nil { + return nil, false + } + return o.Name, true +} + +// HasName returns a boolean if a field has been set. +func (o *CreateDegradationRequestDataAttributesUpdatesItemsComponentsAffectedItems) HasName() bool { + return o != nil && o.Name != nil +} + +// SetName gets a reference to the given string and assigns it to the Name field. +func (o *CreateDegradationRequestDataAttributesUpdatesItemsComponentsAffectedItems) SetName(v string) { + o.Name = &v +} + +// GetStatus returns the Status field value. +func (o *CreateDegradationRequestDataAttributesUpdatesItemsComponentsAffectedItems) GetStatus() StatusPagesComponentDataAttributesStatus { + if o == nil { + var ret StatusPagesComponentDataAttributesStatus + return ret + } + return o.Status +} + +// GetStatusOk returns a tuple with the Status field value +// and a boolean to check if the value has been set. +func (o *CreateDegradationRequestDataAttributesUpdatesItemsComponentsAffectedItems) GetStatusOk() (*StatusPagesComponentDataAttributesStatus, bool) { + if o == nil { + return nil, false + } + return &o.Status, true +} + +// SetStatus sets field value. +func (o *CreateDegradationRequestDataAttributesUpdatesItemsComponentsAffectedItems) SetStatus(v StatusPagesComponentDataAttributesStatus) { + o.Status = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o CreateDegradationRequestDataAttributesUpdatesItemsComponentsAffectedItems) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["id"] = o.Id + if o.Name != nil { + toSerialize["name"] = o.Name + } + toSerialize["status"] = o.Status + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *CreateDegradationRequestDataAttributesUpdatesItemsComponentsAffectedItems) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Id *string `json:"id"` + Name *string `json:"name,omitempty"` + Status *StatusPagesComponentDataAttributesStatus `json:"status"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Id == nil { + return fmt.Errorf("required field id missing") + } + if all.Status == nil { + return fmt.Errorf("required field status missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"id", "name", "status"}) + } else { + return err + } + + hasInvalidField := false + o.Id = *all.Id + o.Name = all.Name + if !all.Status.IsValid() { + hasInvalidField = true + } else { + o.Status = *all.Status + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_create_maintenance_request_data_attributes.go b/api/datadogV2/model_create_maintenance_request_data_attributes.go index 0b8080da994..b93385fbfec 100644 --- a/api/datadogV2/model_create_maintenance_request_data_attributes.go +++ b/api/datadogV2/model_create_maintenance_request_data_attributes.go @@ -27,6 +27,8 @@ type CreateMaintenanceRequestDataAttributes struct { StartDate time.Time `json:"start_date"` // The title of the maintenance. Title string `json:"title"` + // + Updates []CreateMaintenanceRequestDataAttributesUpdatesItems `json:"updates,omitempty"` // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct UnparsedObject map[string]interface{} `json:"-"` AdditionalProperties map[string]interface{} `json:"-"` @@ -217,6 +219,34 @@ func (o *CreateMaintenanceRequestDataAttributes) SetTitle(v string) { o.Title = v } +// GetUpdates returns the Updates field value if set, zero value otherwise. +func (o *CreateMaintenanceRequestDataAttributes) GetUpdates() []CreateMaintenanceRequestDataAttributesUpdatesItems { + if o == nil || o.Updates == nil { + var ret []CreateMaintenanceRequestDataAttributesUpdatesItems + return ret + } + return o.Updates +} + +// GetUpdatesOk returns a tuple with the Updates field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CreateMaintenanceRequestDataAttributes) GetUpdatesOk() (*[]CreateMaintenanceRequestDataAttributesUpdatesItems, bool) { + if o == nil || o.Updates == nil { + return nil, false + } + return &o.Updates, true +} + +// HasUpdates returns a boolean if a field has been set. +func (o *CreateMaintenanceRequestDataAttributes) HasUpdates() bool { + return o != nil && o.Updates != nil +} + +// SetUpdates gets a reference to the given []CreateMaintenanceRequestDataAttributesUpdatesItems and assigns it to the Updates field. +func (o *CreateMaintenanceRequestDataAttributes) SetUpdates(v []CreateMaintenanceRequestDataAttributesUpdatesItems) { + o.Updates = v +} + // MarshalJSON serializes the struct using spec logic. func (o CreateMaintenanceRequestDataAttributes) MarshalJSON() ([]byte, error) { toSerialize := map[string]interface{}{} @@ -238,6 +268,9 @@ func (o CreateMaintenanceRequestDataAttributes) MarshalJSON() ([]byte, error) { toSerialize["start_date"] = o.StartDate.Format("2006-01-02T15:04:05.000Z07:00") } toSerialize["title"] = o.Title + if o.Updates != nil { + toSerialize["updates"] = o.Updates + } for key, value := range o.AdditionalProperties { toSerialize[key] = value @@ -255,6 +288,7 @@ func (o *CreateMaintenanceRequestDataAttributes) UnmarshalJSON(bytes []byte) (er ScheduledDescription *string `json:"scheduled_description"` StartDate *time.Time `json:"start_date"` Title *string `json:"title"` + Updates []CreateMaintenanceRequestDataAttributesUpdatesItems `json:"updates,omitempty"` }{} if err = datadog.Unmarshal(bytes, &all); err != nil { return datadog.Unmarshal(bytes, &o.UnparsedObject) @@ -282,7 +316,7 @@ func (o *CreateMaintenanceRequestDataAttributes) UnmarshalJSON(bytes []byte) (er } additionalProperties := make(map[string]interface{}) if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { - datadog.DeleteKeys(additionalProperties, &[]string{"completed_date", "completed_description", "components_affected", "in_progress_description", "scheduled_description", "start_date", "title"}) + datadog.DeleteKeys(additionalProperties, &[]string{"completed_date", "completed_description", "components_affected", "in_progress_description", "scheduled_description", "start_date", "title", "updates"}) } else { return err } @@ -293,6 +327,7 @@ func (o *CreateMaintenanceRequestDataAttributes) UnmarshalJSON(bytes []byte) (er o.ScheduledDescription = *all.ScheduledDescription o.StartDate = *all.StartDate o.Title = *all.Title + o.Updates = all.Updates if len(additionalProperties) > 0 { o.AdditionalProperties = additionalProperties diff --git a/api/datadogV2/model_create_maintenance_request_data_attributes_updates_items.go b/api/datadogV2/model_create_maintenance_request_data_attributes_updates_items.go new file mode 100644 index 00000000000..3bac7c8b151 --- /dev/null +++ b/api/datadogV2/model_create_maintenance_request_data_attributes_updates_items.go @@ -0,0 +1,212 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + "time" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// CreateMaintenanceRequestDataAttributesUpdatesItems A maintenance update entry. +type CreateMaintenanceRequestDataAttributesUpdatesItems struct { + // The components affected. + ComponentsAffected []CreateMaintenanceRequestDataAttributesUpdatesItemsComponentsAffectedItems `json:"components_affected"` + // A description of the update. + Description string `json:"description"` + // Timestamp of when the update occurred. + StartedAt time.Time `json:"started_at"` + // The status of a maintenance update. + Status CreateMaintenanceRequestDataAttributesUpdatesItemsStatus `json:"status"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewCreateMaintenanceRequestDataAttributesUpdatesItems instantiates a new CreateMaintenanceRequestDataAttributesUpdatesItems object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewCreateMaintenanceRequestDataAttributesUpdatesItems(componentsAffected []CreateMaintenanceRequestDataAttributesUpdatesItemsComponentsAffectedItems, description string, startedAt time.Time, status CreateMaintenanceRequestDataAttributesUpdatesItemsStatus) *CreateMaintenanceRequestDataAttributesUpdatesItems { + this := CreateMaintenanceRequestDataAttributesUpdatesItems{} + this.ComponentsAffected = componentsAffected + this.Description = description + this.StartedAt = startedAt + this.Status = status + return &this +} + +// NewCreateMaintenanceRequestDataAttributesUpdatesItemsWithDefaults instantiates a new CreateMaintenanceRequestDataAttributesUpdatesItems object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewCreateMaintenanceRequestDataAttributesUpdatesItemsWithDefaults() *CreateMaintenanceRequestDataAttributesUpdatesItems { + this := CreateMaintenanceRequestDataAttributesUpdatesItems{} + return &this +} + +// GetComponentsAffected returns the ComponentsAffected field value. +func (o *CreateMaintenanceRequestDataAttributesUpdatesItems) GetComponentsAffected() []CreateMaintenanceRequestDataAttributesUpdatesItemsComponentsAffectedItems { + if o == nil { + var ret []CreateMaintenanceRequestDataAttributesUpdatesItemsComponentsAffectedItems + return ret + } + return o.ComponentsAffected +} + +// GetComponentsAffectedOk returns a tuple with the ComponentsAffected field value +// and a boolean to check if the value has been set. +func (o *CreateMaintenanceRequestDataAttributesUpdatesItems) GetComponentsAffectedOk() (*[]CreateMaintenanceRequestDataAttributesUpdatesItemsComponentsAffectedItems, bool) { + if o == nil { + return nil, false + } + return &o.ComponentsAffected, true +} + +// SetComponentsAffected sets field value. +func (o *CreateMaintenanceRequestDataAttributesUpdatesItems) SetComponentsAffected(v []CreateMaintenanceRequestDataAttributesUpdatesItemsComponentsAffectedItems) { + o.ComponentsAffected = v +} + +// GetDescription returns the Description field value. +func (o *CreateMaintenanceRequestDataAttributesUpdatesItems) GetDescription() string { + if o == nil { + var ret string + return ret + } + return o.Description +} + +// GetDescriptionOk returns a tuple with the Description field value +// and a boolean to check if the value has been set. +func (o *CreateMaintenanceRequestDataAttributesUpdatesItems) GetDescriptionOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Description, true +} + +// SetDescription sets field value. +func (o *CreateMaintenanceRequestDataAttributesUpdatesItems) SetDescription(v string) { + o.Description = v +} + +// GetStartedAt returns the StartedAt field value. +func (o *CreateMaintenanceRequestDataAttributesUpdatesItems) GetStartedAt() time.Time { + if o == nil { + var ret time.Time + return ret + } + return o.StartedAt +} + +// GetStartedAtOk returns a tuple with the StartedAt field value +// and a boolean to check if the value has been set. +func (o *CreateMaintenanceRequestDataAttributesUpdatesItems) GetStartedAtOk() (*time.Time, bool) { + if o == nil { + return nil, false + } + return &o.StartedAt, true +} + +// SetStartedAt sets field value. +func (o *CreateMaintenanceRequestDataAttributesUpdatesItems) SetStartedAt(v time.Time) { + o.StartedAt = v +} + +// GetStatus returns the Status field value. +func (o *CreateMaintenanceRequestDataAttributesUpdatesItems) GetStatus() CreateMaintenanceRequestDataAttributesUpdatesItemsStatus { + if o == nil { + var ret CreateMaintenanceRequestDataAttributesUpdatesItemsStatus + return ret + } + return o.Status +} + +// GetStatusOk returns a tuple with the Status field value +// and a boolean to check if the value has been set. +func (o *CreateMaintenanceRequestDataAttributesUpdatesItems) GetStatusOk() (*CreateMaintenanceRequestDataAttributesUpdatesItemsStatus, bool) { + if o == nil { + return nil, false + } + return &o.Status, true +} + +// SetStatus sets field value. +func (o *CreateMaintenanceRequestDataAttributesUpdatesItems) SetStatus(v CreateMaintenanceRequestDataAttributesUpdatesItemsStatus) { + o.Status = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o CreateMaintenanceRequestDataAttributesUpdatesItems) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["components_affected"] = o.ComponentsAffected + toSerialize["description"] = o.Description + if o.StartedAt.Nanosecond() == 0 { + toSerialize["started_at"] = o.StartedAt.Format("2006-01-02T15:04:05Z07:00") + } else { + toSerialize["started_at"] = o.StartedAt.Format("2006-01-02T15:04:05.000Z07:00") + } + toSerialize["status"] = o.Status + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *CreateMaintenanceRequestDataAttributesUpdatesItems) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + ComponentsAffected *[]CreateMaintenanceRequestDataAttributesUpdatesItemsComponentsAffectedItems `json:"components_affected"` + Description *string `json:"description"` + StartedAt *time.Time `json:"started_at"` + Status *CreateMaintenanceRequestDataAttributesUpdatesItemsStatus `json:"status"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.ComponentsAffected == nil { + return fmt.Errorf("required field components_affected missing") + } + if all.Description == nil { + return fmt.Errorf("required field description missing") + } + if all.StartedAt == nil { + return fmt.Errorf("required field started_at missing") + } + if all.Status == nil { + return fmt.Errorf("required field status missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"components_affected", "description", "started_at", "status"}) + } else { + return err + } + + hasInvalidField := false + o.ComponentsAffected = *all.ComponentsAffected + o.Description = *all.Description + o.StartedAt = *all.StartedAt + if !all.Status.IsValid() { + hasInvalidField = true + } else { + o.Status = *all.Status + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_create_maintenance_request_data_attributes_updates_items_components_affected_items.go b/api/datadogV2/model_create_maintenance_request_data_attributes_updates_items_components_affected_items.go new file mode 100644 index 00000000000..b4cabd1a5ae --- /dev/null +++ b/api/datadogV2/model_create_maintenance_request_data_attributes_updates_items_components_affected_items.go @@ -0,0 +1,178 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// CreateMaintenanceRequestDataAttributesUpdatesItemsComponentsAffectedItems A component affected by a maintenance update. +type CreateMaintenanceRequestDataAttributesUpdatesItemsComponentsAffectedItems struct { + // The ID of the component. Must be a component of type `component`. + Id string `json:"id"` + // The name of the component. + Name *string `json:"name,omitempty"` + // The status of the component. + Status PatchMaintenanceRequestDataAttributesComponentsAffectedItemsStatus `json:"status"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewCreateMaintenanceRequestDataAttributesUpdatesItemsComponentsAffectedItems instantiates a new CreateMaintenanceRequestDataAttributesUpdatesItemsComponentsAffectedItems object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewCreateMaintenanceRequestDataAttributesUpdatesItemsComponentsAffectedItems(id string, status PatchMaintenanceRequestDataAttributesComponentsAffectedItemsStatus) *CreateMaintenanceRequestDataAttributesUpdatesItemsComponentsAffectedItems { + this := CreateMaintenanceRequestDataAttributesUpdatesItemsComponentsAffectedItems{} + this.Id = id + this.Status = status + return &this +} + +// NewCreateMaintenanceRequestDataAttributesUpdatesItemsComponentsAffectedItemsWithDefaults instantiates a new CreateMaintenanceRequestDataAttributesUpdatesItemsComponentsAffectedItems object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewCreateMaintenanceRequestDataAttributesUpdatesItemsComponentsAffectedItemsWithDefaults() *CreateMaintenanceRequestDataAttributesUpdatesItemsComponentsAffectedItems { + this := CreateMaintenanceRequestDataAttributesUpdatesItemsComponentsAffectedItems{} + return &this +} + +// GetId returns the Id field value. +func (o *CreateMaintenanceRequestDataAttributesUpdatesItemsComponentsAffectedItems) GetId() string { + if o == nil { + var ret string + return ret + } + return o.Id +} + +// GetIdOk returns a tuple with the Id field value +// and a boolean to check if the value has been set. +func (o *CreateMaintenanceRequestDataAttributesUpdatesItemsComponentsAffectedItems) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Id, true +} + +// SetId sets field value. +func (o *CreateMaintenanceRequestDataAttributesUpdatesItemsComponentsAffectedItems) SetId(v string) { + o.Id = v +} + +// GetName returns the Name field value if set, zero value otherwise. +func (o *CreateMaintenanceRequestDataAttributesUpdatesItemsComponentsAffectedItems) GetName() string { + if o == nil || o.Name == nil { + var ret string + return ret + } + return *o.Name +} + +// GetNameOk returns a tuple with the Name field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *CreateMaintenanceRequestDataAttributesUpdatesItemsComponentsAffectedItems) GetNameOk() (*string, bool) { + if o == nil || o.Name == nil { + return nil, false + } + return o.Name, true +} + +// HasName returns a boolean if a field has been set. +func (o *CreateMaintenanceRequestDataAttributesUpdatesItemsComponentsAffectedItems) HasName() bool { + return o != nil && o.Name != nil +} + +// SetName gets a reference to the given string and assigns it to the Name field. +func (o *CreateMaintenanceRequestDataAttributesUpdatesItemsComponentsAffectedItems) SetName(v string) { + o.Name = &v +} + +// GetStatus returns the Status field value. +func (o *CreateMaintenanceRequestDataAttributesUpdatesItemsComponentsAffectedItems) GetStatus() PatchMaintenanceRequestDataAttributesComponentsAffectedItemsStatus { + if o == nil { + var ret PatchMaintenanceRequestDataAttributesComponentsAffectedItemsStatus + return ret + } + return o.Status +} + +// GetStatusOk returns a tuple with the Status field value +// and a boolean to check if the value has been set. +func (o *CreateMaintenanceRequestDataAttributesUpdatesItemsComponentsAffectedItems) GetStatusOk() (*PatchMaintenanceRequestDataAttributesComponentsAffectedItemsStatus, bool) { + if o == nil { + return nil, false + } + return &o.Status, true +} + +// SetStatus sets field value. +func (o *CreateMaintenanceRequestDataAttributesUpdatesItemsComponentsAffectedItems) SetStatus(v PatchMaintenanceRequestDataAttributesComponentsAffectedItemsStatus) { + o.Status = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o CreateMaintenanceRequestDataAttributesUpdatesItemsComponentsAffectedItems) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["id"] = o.Id + if o.Name != nil { + toSerialize["name"] = o.Name + } + toSerialize["status"] = o.Status + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *CreateMaintenanceRequestDataAttributesUpdatesItemsComponentsAffectedItems) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Id *string `json:"id"` + Name *string `json:"name,omitempty"` + Status *PatchMaintenanceRequestDataAttributesComponentsAffectedItemsStatus `json:"status"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Id == nil { + return fmt.Errorf("required field id missing") + } + if all.Status == nil { + return fmt.Errorf("required field status missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"id", "name", "status"}) + } else { + return err + } + + hasInvalidField := false + o.Id = *all.Id + o.Name = all.Name + if !all.Status.IsValid() { + hasInvalidField = true + } else { + o.Status = *all.Status + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_create_maintenance_request_data_attributes_updates_items_status.go b/api/datadogV2/model_create_maintenance_request_data_attributes_updates_items_status.go new file mode 100644 index 00000000000..249675eddc3 --- /dev/null +++ b/api/datadogV2/model_create_maintenance_request_data_attributes_updates_items_status.go @@ -0,0 +1,66 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// CreateMaintenanceRequestDataAttributesUpdatesItemsStatus The status of a maintenance update. +type CreateMaintenanceRequestDataAttributesUpdatesItemsStatus string + +// List of CreateMaintenanceRequestDataAttributesUpdatesItemsStatus. +const ( + CREATEMAINTENANCEREQUESTDATAATTRIBUTESUPDATESITEMSSTATUS_IN_PROGRESS CreateMaintenanceRequestDataAttributesUpdatesItemsStatus = "in_progress" + CREATEMAINTENANCEREQUESTDATAATTRIBUTESUPDATESITEMSSTATUS_COMPLETED CreateMaintenanceRequestDataAttributesUpdatesItemsStatus = "completed" +) + +var allowedCreateMaintenanceRequestDataAttributesUpdatesItemsStatusEnumValues = []CreateMaintenanceRequestDataAttributesUpdatesItemsStatus{ + CREATEMAINTENANCEREQUESTDATAATTRIBUTESUPDATESITEMSSTATUS_IN_PROGRESS, + CREATEMAINTENANCEREQUESTDATAATTRIBUTESUPDATESITEMSSTATUS_COMPLETED, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *CreateMaintenanceRequestDataAttributesUpdatesItemsStatus) GetAllowedValues() []CreateMaintenanceRequestDataAttributesUpdatesItemsStatus { + return allowedCreateMaintenanceRequestDataAttributesUpdatesItemsStatusEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *CreateMaintenanceRequestDataAttributesUpdatesItemsStatus) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = CreateMaintenanceRequestDataAttributesUpdatesItemsStatus(value) + return nil +} + +// NewCreateMaintenanceRequestDataAttributesUpdatesItemsStatusFromValue returns a pointer to a valid CreateMaintenanceRequestDataAttributesUpdatesItemsStatus +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewCreateMaintenanceRequestDataAttributesUpdatesItemsStatusFromValue(v string) (*CreateMaintenanceRequestDataAttributesUpdatesItemsStatus, error) { + ev := CreateMaintenanceRequestDataAttributesUpdatesItemsStatus(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for CreateMaintenanceRequestDataAttributesUpdatesItemsStatus: valid values are %v", v, allowedCreateMaintenanceRequestDataAttributesUpdatesItemsStatusEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v CreateMaintenanceRequestDataAttributesUpdatesItemsStatus) IsValid() bool { + for _, existing := range allowedCreateMaintenanceRequestDataAttributesUpdatesItemsStatusEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to CreateMaintenanceRequestDataAttributesUpdatesItemsStatus value. +func (v CreateMaintenanceRequestDataAttributesUpdatesItemsStatus) Ptr() *CreateMaintenanceRequestDataAttributesUpdatesItemsStatus { + return &v +} diff --git a/examples/v2/status-pages/CreateBackfilledDegradation.go b/examples/v2/status-pages/CreateBackfilledDegradation.go new file mode 100644 index 00000000000..8d41d791a3e --- /dev/null +++ b/examples/v2/status-pages/CreateBackfilledDegradation.go @@ -0,0 +1,78 @@ +// Create backfilled degradation returns "Created" response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + "time" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" + "github.com/google/uuid" +) + +func main() { + // there is a valid "status_page" in the system + StatusPageDataAttributesComponents0Components0ID := uuid.MustParse(os.Getenv("STATUS_PAGE_DATA_ATTRIBUTES_COMPONENTS_0_COMPONENTS_0_ID")) + StatusPageDataID := uuid.MustParse(os.Getenv("STATUS_PAGE_DATA_ID")) + + body := datadogV2.CreateBackfilledDegradationRequest{ + Data: &datadogV2.CreateBackfilledDegradationRequestData{ + Attributes: &datadogV2.CreateBackfilledDegradationRequestDataAttributes{ + Title: "Past API Outage", + Updates: []datadogV2.CreateBackfilledDegradationRequestDataAttributesUpdatesItems{ + { + ComponentsAffected: []datadogV2.CreateDegradationRequestDataAttributesComponentsAffectedItems{ + { + Id: StatusPageDataAttributesComponents0Components0ID, + Status: datadogV2.STATUSPAGESCOMPONENTDATAATTRIBUTESSTATUS_DEGRADED, + }, + }, + Description: datadog.PtrString("We detected elevated error rates in the API."), + StartedAt: time.Now().Add(time.Hour * -1), + Status: datadogV2.CREATEDEGRADATIONREQUESTDATAATTRIBUTESSTATUS_INVESTIGATING, + }, + { + ComponentsAffected: []datadogV2.CreateDegradationRequestDataAttributesComponentsAffectedItems{ + { + Id: StatusPageDataAttributesComponents0Components0ID, + Status: datadogV2.STATUSPAGESCOMPONENTDATAATTRIBUTESSTATUS_DEGRADED, + }, + }, + Description: datadog.PtrString("Root cause identified as a misconfigured deployment."), + StartedAt: time.Now().Add(time.Minute * -30), + Status: datadogV2.CREATEDEGRADATIONREQUESTDATAATTRIBUTESSTATUS_IDENTIFIED, + }, + { + ComponentsAffected: []datadogV2.CreateDegradationRequestDataAttributesComponentsAffectedItems{ + { + Id: StatusPageDataAttributesComponents0Components0ID, + Status: datadogV2.STATUSPAGESCOMPONENTDATAATTRIBUTESSTATUS_OPERATIONAL, + }, + }, + Description: datadog.PtrString("The issue has been resolved and API is operating normally."), + StartedAt: time.Now(), + Status: datadogV2.CREATEDEGRADATIONREQUESTDATAATTRIBUTESSTATUS_RESOLVED, + }, + }, + }, + Type: datadogV2.PATCHDEGRADATIONREQUESTDATATYPE_DEGRADATIONS, + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewStatusPagesApi(apiClient) + resp, r, err := api.CreateBackfilledDegradation(ctx, StatusPageDataID, body, *datadogV2.NewCreateBackfilledDegradationOptionalParameters()) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `StatusPagesApi.CreateBackfilledDegradation`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `StatusPagesApi.CreateBackfilledDegradation`:\n%s\n", responseContent) +} diff --git a/examples/v2/status-pages/CreateBackfilledMaintenance.go b/examples/v2/status-pages/CreateBackfilledMaintenance.go new file mode 100644 index 00000000000..d49c0567114 --- /dev/null +++ b/examples/v2/status-pages/CreateBackfilledMaintenance.go @@ -0,0 +1,67 @@ +// Create backfilled maintenance returns "Created" response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + "time" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" + "github.com/google/uuid" +) + +func main() { + // there is a valid "status_page" in the system + StatusPageDataAttributesComponents0Components0ID := uuid.MustParse(os.Getenv("STATUS_PAGE_DATA_ATTRIBUTES_COMPONENTS_0_COMPONENTS_0_ID")) + StatusPageDataID := uuid.MustParse(os.Getenv("STATUS_PAGE_DATA_ID")) + + body := datadogV2.CreateBackfilledMaintenanceRequest{ + Data: &datadogV2.CreateBackfilledMaintenanceRequestData{ + Attributes: &datadogV2.CreateBackfilledMaintenanceRequestDataAttributes{ + Title: "Past Database Maintenance", + Updates: []datadogV2.CreateBackfilledMaintenanceRequestDataAttributesUpdatesItems{ + { + ComponentsAffected: []datadogV2.CreateMaintenanceRequestDataAttributesComponentsAffectedItems{ + { + Id: StatusPageDataAttributesComponents0Components0ID, + Status: datadogV2.PATCHMAINTENANCEREQUESTDATAATTRIBUTESCOMPONENTSAFFECTEDITEMSSTATUS_MAINTENANCE, + }, + }, + Description: "Database maintenance is in progress.", + StartedAt: time.Now().Add(time.Hour * -1), + Status: datadogV2.CREATEMAINTENANCEREQUESTDATAATTRIBUTESUPDATESITEMSSTATUS_IN_PROGRESS, + }, + { + ComponentsAffected: []datadogV2.CreateMaintenanceRequestDataAttributesComponentsAffectedItems{ + { + Id: StatusPageDataAttributesComponents0Components0ID, + Status: datadogV2.PATCHMAINTENANCEREQUESTDATAATTRIBUTESCOMPONENTSAFFECTEDITEMSSTATUS_OPERATIONAL, + }, + }, + Description: "Database maintenance has been completed successfully.", + StartedAt: time.Now(), + Status: datadogV2.CREATEMAINTENANCEREQUESTDATAATTRIBUTESUPDATESITEMSSTATUS_COMPLETED, + }, + }, + }, + Type: datadogV2.PATCHMAINTENANCEREQUESTDATATYPE_MAINTENANCES, + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewStatusPagesApi(apiClient) + resp, r, err := api.CreateBackfilledMaintenance(ctx, StatusPageDataID, body, *datadogV2.NewCreateBackfilledMaintenanceOptionalParameters()) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `StatusPagesApi.CreateBackfilledMaintenance`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `StatusPagesApi.CreateBackfilledMaintenance`:\n%s\n", responseContent) +} diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Status_Pages/Scenario_Create_backfilled_degradation_returns_Created_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Status_Pages/Scenario_Create_backfilled_degradation_returns_Created_response.freeze new file mode 100644 index 00000000000..29a31337fe4 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Status_Pages/Scenario_Create_backfilled_degradation_returns_Created_response.freeze @@ -0,0 +1 @@ +2026-05-04T14:30:13.862Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Status_Pages/Scenario_Create_backfilled_degradation_returns_Created_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Status_Pages/Scenario_Create_backfilled_degradation_returns_Created_response.yaml new file mode 100644 index 00000000000..3b7ee44a85a --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Status_Pages/Scenario_Create_backfilled_degradation_returns_Created_response.yaml @@ -0,0 +1,78 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"components":[{"components":[{"name":"Login","position":0,"type":"component"},{"name":"Settings","position":1,"type":"component"}],"name":"Application","type":"group"}],"domain_prefix":"2aea4cad6466d9b2","name":"A Status Page","type":"internal","visualization_type":"bars_and_uptime_percentage"},"type":"status_pages"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v2/statuspages + response: + body: '{"data":{"id":"a8c9f5bc-864f-4984-8420-736468d76baf","type":"status_pages","attributes":{"company_logo":null,"components":[{"id":"5f67ec78-bc7f-4930-91ae-b29b64e4440e","name":"Application","type":"group","position":0,"components":[{"id":"b2e9cb5e-57d3-4c32-9ed2-f2883441ca75","name":"Login","type":"component","status":"operational","position":0},{"id":"6eba0779-8989-43e2-994d-56d244a4ffac","name":"Settings","type":"component","status":"operational","position":1}]}],"created_at":"2026-05-04T14:30:15.791383Z","custom_domain":null,"custom_domain_enabled":false,"domain_prefix":"2aea4cad6466d9b2","email_header_image":null,"enabled":true,"favicon":null,"modified_at":"2026-05-04T14:30:15.791383Z","name":"A + Status Page","page_url":"https://frog.datadoghq.com/status-pages/a8c9f5bc-864f-4984-8420-736468d76baf/view","subscriptions_enabled":false,"type":"internal","visualization_type":"bars_and_uptime_percentage"},"relationships":{"created_by_user":{"data":{"id":"9919ec9b-ebc7-49ee-8dc8-03626e717cca","type":"users"}},"last_modified_by_user":{"data":{"id":"9919ec9b-ebc7-49ee-8dc8-03626e717cca","type":"users"}}}}}' + code: 201 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 201 Created +- request: + body: | + {"data":{"attributes":{"title":"Past API Outage","updates":[{"components_affected":[{"id":"b2e9cb5e-57d3-4c32-9ed2-f2883441ca75","status":"degraded"}],"description":"We detected elevated error rates in the API.","started_at":"2026-05-04T13:30:13.862Z","status":"investigating"},{"components_affected":[{"id":"b2e9cb5e-57d3-4c32-9ed2-f2883441ca75","status":"degraded"}],"description":"Root cause identified as a misconfigured deployment.","started_at":"2026-05-04T14:00:13.862Z","status":"identified"},{"components_affected":[{"id":"b2e9cb5e-57d3-4c32-9ed2-f2883441ca75","status":"operational"}],"description":"The issue has been resolved and API is operating normally.","started_at":"2026-05-04T14:30:13.862Z","status":"resolved"}]},"type":"degradations"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 1 + method: POST + url: https://api.datadoghq.com/api/v2/statuspages/a8c9f5bc-864f-4984-8420-736468d76baf/degradations/backfill + response: + body: '{"data":{"id":"6d4e1a6f-df56-4178-88c3-f950b9da3f95","type":"degradations","attributes":{"components_affected":[{"id":"b2e9cb5e-57d3-4c32-9ed2-f2883441ca75","name":"Login","status":"operational"}],"created_at":"2026-05-04T13:30:13.862Z","description":"The + issue has been resolved and API is operating normally.","modified_at":"2026-05-04T14:30:16.509023Z","status":"resolved","title":"Past + API Outage","updates":[{"id":"7acc1fa8-556f-4fa8-978a-58f5c19bcc6d","created_at":"2026-05-04T14:30:16.509023Z","modified_at":"2026-05-04T14:30:16.509023Z","started_at":"2026-05-04T13:30:13.862Z","status":"investigating","description":"We + detected elevated error rates in the API.","components_affected":[{"id":"b2e9cb5e-57d3-4c32-9ed2-f2883441ca75","name":"Login","status":"degraded"}]},{"id":"e927896e-cd9e-4c1a-bf41-427ce44e8372","created_at":"2026-05-04T14:30:16.509023Z","modified_at":"2026-05-04T14:30:16.509023Z","started_at":"2026-05-04T14:00:13.862Z","status":"identified","description":"Root + cause identified as a misconfigured deployment.","components_affected":[{"id":"b2e9cb5e-57d3-4c32-9ed2-f2883441ca75","name":"Login","status":"degraded"}]},{"id":"82326cfc-b8f7-4276-bde4-d023d5958541","created_at":"2026-05-04T14:30:16.509023Z","modified_at":"2026-05-04T14:30:16.509023Z","started_at":"2026-05-04T14:30:13.862Z","status":"resolved","description":"The + issue has been resolved and API is operating normally.","components_affected":[{"id":"b2e9cb5e-57d3-4c32-9ed2-f2883441ca75","name":"Login","status":"operational"}]}]},"relationships":{"created_by_user":{"data":{"id":"9919ec9b-ebc7-49ee-8dc8-03626e717cca","type":"users"}},"last_modified_by_user":{"data":{"id":"9919ec9b-ebc7-49ee-8dc8-03626e717cca","type":"users"}},"status_page":{"data":{"id":"a8c9f5bc-864f-4984-8420-736468d76baf","type":"status_pages"}}}}}' + code: 201 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 201 Created +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 2 + method: DELETE + url: https://api.datadoghq.com/api/v2/statuspages/a8c9f5bc-864f-4984-8420-736468d76baf/degradations/6d4e1a6f-df56-4178-88c3-f950b9da3f95 + response: + body: '' + code: 204 + duration: 0ms + headers: {} + status: 204 No Content +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 3 + method: DELETE + url: https://api.datadoghq.com/api/v2/statuspages/a8c9f5bc-864f-4984-8420-736468d76baf + response: + body: '' + code: 204 + duration: 0ms + headers: {} + status: 204 No Content +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Status_Pages/Scenario_Create_backfilled_maintenance_returns_Created_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Status_Pages/Scenario_Create_backfilled_maintenance_returns_Created_response.freeze new file mode 100644 index 00000000000..ddbc04f32e4 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Status_Pages/Scenario_Create_backfilled_maintenance_returns_Created_response.freeze @@ -0,0 +1 @@ +2026-05-04T14:30:17.282Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Status_Pages/Scenario_Create_backfilled_maintenance_returns_Created_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Status_Pages/Scenario_Create_backfilled_maintenance_returns_Created_response.yaml new file mode 100644 index 00000000000..1f59254c245 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Status_Pages/Scenario_Create_backfilled_maintenance_returns_Created_response.yaml @@ -0,0 +1,63 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"components":[{"components":[{"name":"Login","position":0,"type":"component"},{"name":"Settings","position":1,"type":"component"}],"name":"Application","type":"group"}],"domain_prefix":"29b08dd63fb635d7","name":"A Status Page","type":"internal","visualization_type":"bars_and_uptime_percentage"},"type":"status_pages"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v2/statuspages + response: + body: '{"data":{"id":"bbf96c2c-48cf-4951-96d2-f5b503c93c49","type":"status_pages","attributes":{"company_logo":null,"components":[{"id":"b7d32c93-3ab3-4d77-af3b-541a45eb3553","name":"Application","type":"group","position":0,"components":[{"id":"02c0c5d4-6735-45c8-a184-4a6d5b746793","name":"Login","type":"component","status":"operational","position":0},{"id":"b99b72d3-4df4-4242-82d9-ebb96c301c8d","name":"Settings","type":"component","status":"operational","position":1}]}],"created_at":"2026-05-04T14:30:17.408759Z","custom_domain":null,"custom_domain_enabled":false,"domain_prefix":"29b08dd63fb635d7","email_header_image":null,"enabled":true,"favicon":null,"modified_at":"2026-05-04T14:30:17.408759Z","name":"A + Status Page","page_url":"https://frog.datadoghq.com/status-pages/bbf96c2c-48cf-4951-96d2-f5b503c93c49/view","subscriptions_enabled":false,"type":"internal","visualization_type":"bars_and_uptime_percentage"},"relationships":{"created_by_user":{"data":{"id":"9919ec9b-ebc7-49ee-8dc8-03626e717cca","type":"users"}},"last_modified_by_user":{"data":{"id":"9919ec9b-ebc7-49ee-8dc8-03626e717cca","type":"users"}}}}}' + code: 201 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 201 Created +- request: + body: | + {"data":{"attributes":{"title":"Past Database Maintenance","updates":[{"components_affected":[{"id":"02c0c5d4-6735-45c8-a184-4a6d5b746793","status":"maintenance"}],"description":"Database maintenance is in progress.","started_at":"2026-05-04T13:30:17.282Z","status":"in_progress"},{"components_affected":[{"id":"02c0c5d4-6735-45c8-a184-4a6d5b746793","status":"operational"}],"description":"Database maintenance has been completed successfully.","started_at":"2026-05-04T14:30:17.282Z","status":"completed"}]},"type":"maintenances"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 1 + method: POST + url: https://api.datadoghq.com/api/v2/statuspages/bbf96c2c-48cf-4951-96d2-f5b503c93c49/maintenances/backfill + response: + body: '{"data":{"id":"1f1ccbc5-14dd-45e2-9e81-b767b4d342f0","type":"maintenances","attributes":{"completed_date":"2026-05-04T14:30:17.282Z","completed_description":"Database + maintenance has been completed successfully.","components_affected":[{"id":"02c0c5d4-6735-45c8-a184-4a6d5b746793","name":"Login","status":"operational"}],"in_progress_description":"Database + maintenance is in progress.","modified_at":"2026-05-04T14:30:17.979727Z","published_date":"2026-05-04T13:30:17.282Z","scheduled_description":"","start_date":"2026-05-04T13:30:17.282Z","status":"completed","title":"Past + Database Maintenance","updates":[{"id":"56f63654-5c40-4eed-8af0-dd53a7bb251c","created_at":"2026-05-04T14:30:17.979727Z","modified_at":"2026-05-04T14:30:17.979727Z","started_at":"2026-05-04T13:30:17.282Z","manual_transition":false,"status":"in_progress","description":"Database + maintenance is in progress.","components_affected":[{"id":"02c0c5d4-6735-45c8-a184-4a6d5b746793","name":"Login","status":"maintenance"}]},{"id":"7e2dd268-c76e-4186-9a2c-b7ca7039485b","created_at":"2026-05-04T14:30:17.979727Z","modified_at":"2026-05-04T14:30:17.979727Z","started_at":"2026-05-04T14:30:17.282Z","manual_transition":false,"status":"completed","description":"Database + maintenance has been completed successfully.","components_affected":[{"id":"02c0c5d4-6735-45c8-a184-4a6d5b746793","name":"Login","status":"operational"}]}]},"relationships":{"created_by_user":{"data":{"id":"9919ec9b-ebc7-49ee-8dc8-03626e717cca","type":"users"}},"last_modified_by_user":{"data":{"id":"9919ec9b-ebc7-49ee-8dc8-03626e717cca","type":"users"}},"status_page":{"data":{"id":"bbf96c2c-48cf-4951-96d2-f5b503c93c49","type":"status_pages"}}}}}' + code: 201 + duration: 0ms + headers: + Content-Type: + - application/vnd.api+json + status: 201 Created +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 2 + method: DELETE + url: https://api.datadoghq.com/api/v2/statuspages/bbf96c2c-48cf-4951-96d2-f5b503c93c49 + response: + body: '' + code: 204 + duration: 0ms + headers: {} + status: 204 No Content +version: 2 diff --git a/tests/scenarios/features/v2/status_pages.feature b/tests/scenarios/features/v2/status_pages.feature index 2a4cb273a61..4e671f186de 100644 --- a/tests/scenarios/features/v2/status_pages.feature +++ b/tests/scenarios/features/v2/status_pages.feature @@ -10,6 +10,26 @@ Feature: Status Pages And a valid "appKeyAuth" key in the system And an instance of "StatusPages" API + @team:DataDog/incident-app + Scenario: Create backfilled degradation returns "Created" response + Given there is a valid "status_page" in the system + And new "CreateBackfilledDegradation" request + And request contains "page_id" parameter from "status_page.data.id" + And body with value {"data": {"attributes": {"title": "Past API Outage", "updates": [{"components_affected": [{"id": "{{ status_page.data.attributes.components[0].components[0].id }}", "status": "degraded"}], "description": "We detected elevated error rates in the API.", "started_at": "{{ timeISO('now - 1h') }}", "status": "investigating"}, {"components_affected": [{"id": "{{ status_page.data.attributes.components[0].components[0].id }}", "status": "degraded"}], "description": "Root cause identified as a misconfigured deployment.", "started_at": "{{ timeISO('now - 30m') }}", "status": "identified"}, {"components_affected": [{"id": "{{ status_page.data.attributes.components[0].components[0].id }}", "status": "operational"}], "description": "The issue has been resolved and API is operating normally.", "started_at": "{{ timeISO('now') }}", "status": "resolved"}]}, "type": "degradations"}} + When the request is sent + Then the response status is 201 Created + And the response "data.attributes.title" is equal to "Past API Outage" + + @team:DataDog/incident-app + Scenario: Create backfilled maintenance returns "Created" response + Given there is a valid "status_page" in the system + And new "CreateBackfilledMaintenance" request + And request contains "page_id" parameter from "status_page.data.id" + And body with value {"data": {"attributes": {"title": "Past Database Maintenance", "updates": [{"components_affected": [{"id": "{{ status_page.data.attributes.components[0].components[0].id }}", "status": "maintenance"}], "description": "Database maintenance is in progress.", "started_at": "{{ timeISO('now - 1h') }}", "status": "in_progress"}, {"components_affected": [{"id": "{{ status_page.data.attributes.components[0].components[0].id }}", "status": "operational"}], "description": "Database maintenance has been completed successfully.", "started_at": "{{ timeISO('now') }}", "status": "completed"}]}, "type": "maintenances"}} + When the request is sent + Then the response status is 201 Created + And the response "data.attributes.title" is equal to "Past Database Maintenance" + @team:DataDog/incident-app Scenario: Create component returns "Created" response Given there is a valid "status_page" in the system diff --git a/tests/scenarios/features/v2/undo.json b/tests/scenarios/features/v2/undo.json index 049acf0531b..3d8451720f7 100644 --- a/tests/scenarios/features/v2/undo.json +++ b/tests/scenarios/features/v2/undo.json @@ -6417,6 +6417,23 @@ "type": "unsafe" } }, + "CreateBackfilledDegradation": { + "tag": "Status Pages", + "undo": { + "operationId": "DeleteDegradation", + "parameters": [ + { + "name": "page_id", + "source": "data.relationships.status_page.data.id" + }, + { + "name": "degradation_id", + "source": "data.id" + } + ], + "type": "unsafe" + } + }, "DeleteDegradation": { "tag": "Status Pages", "undo": { @@ -6441,6 +6458,12 @@ "type": "safe" } }, + "CreateBackfilledMaintenance": { + "tag": "Status Pages", + "undo": { + "type": "safe" + } + }, "GetMaintenance": { "tag": "Status Pages", "undo": {