diff --git a/.generator/schemas/v1/openapi.yaml b/.generator/schemas/v1/openapi.yaml index 992ffcf045e..bb7b61547e7 100644 --- a/.generator/schemas/v1/openapi.yaml +++ b/.generator/schemas/v1/openapi.yaml @@ -25956,6 +25956,8 @@ components: $ref: '#/components/schemas/WidgetLineType' line_width: $ref: '#/components/schemas/WidgetLineWidth' + order_by: + $ref: '#/components/schemas/WidgetStyleOrderBy' palette: description: Color palette to apply to the widget. type: string @@ -26018,6 +26020,19 @@ components: description: Color palette to apply to the widget. type: string type: object + WidgetStyleOrderBy: + description: 'How to order series in timeseries visualizations. + + - `tags`: Order series alphabetically by tag name (default behavior) + + - `values`: Order series by their current metric values (typically descending)' + enum: + - tags + - values + type: string + x-enum-varnames: + - TAGS + - VALUES WidgetSummaryType: description: Which summary type should be used. enum: diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index de9b3ca4f4d..5190081e023 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -26666,6 +26666,82 @@ components: required: - type type: object + GlobalIncidentSettingsAttributesRequest: + description: Global incident settings attributes + properties: + analytics_dashboard_id: + description: The analytics dashboard ID + example: abc-123-def + type: string + type: object + GlobalIncidentSettingsAttributesResponse: + description: Global incident settings attributes + properties: + analytics_dashboard_id: + description: The analytics dashboard ID + example: abc-123-def + type: string + created: + description: Timestamp when the settings were created + example: '2026-01-13T17:15:56.557278191Z' + format: date-time + type: string + modified: + description: Timestamp when the settings were last modified + example: '2026-01-13T17:15:56.557278191Z' + format: date-time + type: string + required: + - created + - modified + - analytics_dashboard_id + type: object + GlobalIncidentSettingsDataRequest: + properties: + attributes: + $ref: '#/components/schemas/GlobalIncidentSettingsAttributesRequest' + type: + $ref: '#/components/schemas/GlobalIncidentSettingsType' + required: + - type + type: object + GlobalIncidentSettingsDataResponse: + properties: + attributes: + $ref: '#/components/schemas/GlobalIncidentSettingsAttributesResponse' + id: + description: The unique identifier for the global incident settings + example: f8b9a915-ed85-48b4-9071-ceba567a3db5 + type: string + type: + $ref: '#/components/schemas/GlobalIncidentSettingsType' + required: + - id + - type + - attributes + type: object + GlobalIncidentSettingsRequest: + properties: + data: + $ref: '#/components/schemas/GlobalIncidentSettingsDataRequest' + required: + - data + type: object + GlobalIncidentSettingsResponse: + properties: + data: + $ref: '#/components/schemas/GlobalIncidentSettingsDataResponse' + required: + - data + type: object + GlobalIncidentSettingsType: + description: Global incident settings resource type + enum: + - incidents_global_settings + example: incidents_global_settings + type: string + x-enum-varnames: + - INCIDENTS_GLOBAL_SETTINGS GlobalVariableData: description: Synthetics global variable data. Wrapper around the global variable object. @@ -27694,6 +27770,184 @@ components: - TEXTARRAY - METRICTAG - AUTOCOMPLETE + IncidentHandleAttributesFields: + description: Dynamic fields associated with the handle + example: + severity: + - SEV-1 + properties: + severity: + description: Severity levels associated with the handle + items: + $ref: '#/components/schemas/IncidentHandleAttributesFieldsSeverity' + type: array + type: object + IncidentHandleAttributesFieldsSeverity: + example: SEV-1 + type: string + IncidentHandleAttributesRequest: + description: Incident handle attributes for requests + properties: + fields: + $ref: '#/components/schemas/IncidentHandleAttributesFields' + name: + description: The handle name + example: '@incident-sev-1' + type: string + required: + - name + type: object + IncidentHandleAttributesResponse: + description: Incident handle attributes for responses + properties: + created_at: + description: Timestamp when the handle was created + example: '2026-01-13T17:15:52.726905Z' + format: date-time + type: string + fields: + $ref: '#/components/schemas/IncidentHandleAttributesFields' + modified_at: + description: Timestamp when the handle was last modified + example: '2026-01-13T17:15:52.726905Z' + format: date-time + type: string + name: + description: The handle name + example: '@incident-sev-1' + type: string + required: + - name + - fields + - created_at + - modified_at + type: object + IncidentHandleDataRequest: + properties: + attributes: + $ref: '#/components/schemas/IncidentHandleAttributesRequest' + id: + description: The ID of the incident handle (required for PUT requests) + example: b2494081-cdf0-4205-b366-4e1dd4fdf0bf + type: string + relationships: + $ref: '#/components/schemas/IncidentHandleRelationshipsRequest' + type: + $ref: '#/components/schemas/IncidentHandleType' + required: + - type + - attributes + type: object + IncidentHandleDataResponse: + properties: + attributes: + $ref: '#/components/schemas/IncidentHandleAttributesResponse' + id: + description: The ID of the incident handle + example: 12ceee6d-a7c0-4407-bc54-30e54140d7f0 + type: string + relationships: + $ref: '#/components/schemas/IncidentHandleRelationships' + type: + $ref: '#/components/schemas/IncidentHandleType' + required: + - id + - type + - attributes + type: object + IncidentHandleIncludedItemResponse: + oneOf: + - $ref: '#/components/schemas/IncidentUserData' + - $ref: '#/components/schemas/IncidentTypeObject' + IncidentHandleIncludedResponse: + description: Included related resources + items: + $ref: '#/components/schemas/IncidentHandleIncludedItemResponse' + type: array + IncidentHandleRelationship: + properties: + data: + $ref: '#/components/schemas/IncidentHandleRelationshipData' + required: + - data + type: object + IncidentHandleRelationshipData: + properties: + id: + description: The ID of the related resource + example: f7b538b1-ed7c-4e84-82de-fdf84a539d40 + type: string + type: + description: The type of the related resource + example: incident_types + type: string + required: + - id + - type + type: object + IncidentHandleRelationships: + nullable: true + properties: + commander_user: + $ref: '#/components/schemas/IncidentHandleRelationship' + created_by_user: + $ref: '#/components/schemas/IncidentHandleRelationship' + incident_type: + $ref: '#/components/schemas/IncidentHandleRelationship' + last_modified_by_user: + $ref: '#/components/schemas/IncidentHandleRelationship' + required: + - incident_type + - created_by_user + - last_modified_by_user + type: object + IncidentHandleRelationshipsRequest: + nullable: true + properties: + commander_user: + $ref: '#/components/schemas/IncidentHandleRelationship' + incident_type: + $ref: '#/components/schemas/IncidentHandleRelationship' + required: + - incident_type + type: object + IncidentHandleRequest: + properties: + data: + $ref: '#/components/schemas/IncidentHandleDataRequest' + required: + - data + type: object + IncidentHandleResponse: + properties: + data: + $ref: '#/components/schemas/IncidentHandleDataResponse' + included: + $ref: '#/components/schemas/IncidentHandleIncludedResponse' + required: + - data + type: object + IncidentHandleType: + description: Incident handle resource type + enum: + - incidents_handles + example: incidents_handles + type: string + x-enum-varnames: + - INCIDENTS_HANDLES + IncidentHandlesResponse: + properties: + data: + $ref: '#/components/schemas/IncidentHandlesResponseData' + included: + $ref: '#/components/schemas/IncidentHandleIncludedResponse' + required: + - data + type: object + IncidentHandlesResponseData: + items: + $ref: '#/components/schemas/IncidentHandleDataResponse' + type: array IncidentImpactAttributes: description: The incident impact's attributes. properties: @@ -67463,7 +67717,6 @@ paths: operator: OR permissions: - apm_retention_filter_read - - apm_pipelines_read post: description: 'Create a retention filter to index spans in your organization. @@ -67503,7 +67756,6 @@ paths: operator: OR permissions: - apm_retention_filter_write - - apm_pipelines_write /api/v2/apm/config/retention-filters-execution-order: put: description: Re-order the execution order of retention filters. @@ -67532,7 +67784,6 @@ paths: operator: OR permissions: - apm_retention_filter_write - - apm_pipelines_write /api/v2/apm/config/retention-filters/{filter_id}: delete: description: 'Delete a specific retention filter from your organization. @@ -67559,7 +67810,6 @@ paths: operator: OR permissions: - apm_retention_filter_write - - apm_pipelines_write get: description: Get an APM retention filter. operationId: GetApmRetentionFilter @@ -67585,7 +67835,6 @@ paths: operator: OR permissions: - apm_retention_filter_read - - apm_pipelines_read put: description: 'Update a retention filter from your organization. @@ -67625,7 +67874,6 @@ paths: operator: OR permissions: - apm_retention_filter_write - - apm_pipelines_write /api/v2/apm/services: get: operationId: GetServiceList @@ -71267,7 +71515,7 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/BudgetValidationRequest' + $ref: '#/components/schemas/BudgetWithEntries' description: OK '429': $ref: '#/components/responses/TooManyRequestsResponse' @@ -74583,6 +74831,190 @@ paths: - incident_write x-unstable: '**Note**: This endpoint is in public beta. + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + /api/v2/incidents/config/global/incident-handles: + delete: + description: Delete a global incident handle. + operationId: DeleteGlobalIncidentHandle + responses: + '204': + description: No Content + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Bad Request + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: Delete global incident handle + tags: + - Incidents + x-unstable: '**Note**: This endpoint is in public beta and is subject to change. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + get: + description: Retrieve a list of global incident handles. + operationId: ListGlobalIncidentHandles + parameters: + - description: Comma-separated list of related resources to include in the response + in: query + name: include + required: false + schema: + example: created_by_user,last_modified_by_user,commander_user,incident_type + type: string + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/IncidentHandlesResponse' + description: OK + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Bad Request + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: List global incident handles + tags: + - Incidents + x-unstable: '**Note**: This endpoint is in public beta and is subject to change. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + post: + description: Create a new global incident handle. + operationId: CreateGlobalIncidentHandle + parameters: + - description: Comma-separated list of related resources to include in the response + in: query + name: include + required: false + schema: + example: created_by_user,last_modified_by_user,commander_user,incident_type + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/IncidentHandleRequest' + required: true + responses: + '201': + content: + application/json: + schema: + $ref: '#/components/schemas/IncidentHandleResponse' + description: Created + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Bad Request + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: Create global incident handle + tags: + - Incidents + x-unstable: '**Note**: This endpoint is in public beta and is subject to change. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + put: + description: Update an existing global incident handle. + operationId: UpdateGlobalIncidentHandle + parameters: + - description: Comma-separated list of related resources to include in the response + in: query + name: include + required: false + schema: + example: created_by_user,last_modified_by_user,commander_user,incident_type + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/IncidentHandleRequest' + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/IncidentHandleResponse' + description: OK + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Bad Request + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: Update global incident handle + tags: + - Incidents + x-unstable: '**Note**: This endpoint is in public beta and is subject to change. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + /api/v2/incidents/config/global/settings: + get: + description: Retrieve global incident settings for the organization. + operationId: GetGlobalIncidentSettings + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/GlobalIncidentSettingsResponse' + description: OK + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Bad Request + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: Get global incident settings + tags: + - Incidents + x-unstable: '**Note**: This endpoint is in public beta and is subject to change. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + patch: + description: Update global incident settings for the organization. + operationId: UpdateGlobalIncidentSettings + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/GlobalIncidentSettingsRequest' + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/GlobalIncidentSettingsResponse' + description: OK + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Bad Request + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: Update global incident settings + tags: + - Incidents + x-unstable: '**Note**: This endpoint is in public beta and is subject to change. + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' /api/v2/incidents/config/notification-rules: get: diff --git a/api/datadog/configuration.go b/api/datadog/configuration.go index eedca5cf537..ac6f5f63cce 100644 --- a/api/datadog/configuration.go +++ b/api/datadog/configuration.go @@ -710,6 +710,7 @@ func NewConfiguration() *Configuration { "v2.UpdateDeploymentRule": false, "v2.CreateHamrOrgConnection": false, "v2.GetHamrOrgConnection": false, + "v2.CreateGlobalIncidentHandle": false, "v2.CreateIncident": false, "v2.CreateIncidentAttachment": false, "v2.CreateIncidentIntegration": false, @@ -718,6 +719,7 @@ func NewConfiguration() *Configuration { "v2.CreateIncidentPostmortemAttachment": false, "v2.CreateIncidentTodo": false, "v2.CreateIncidentType": false, + "v2.DeleteGlobalIncidentHandle": false, "v2.DeleteIncident": false, "v2.DeleteIncidentAttachment": false, "v2.DeleteIncidentIntegration": false, @@ -725,12 +727,14 @@ func NewConfiguration() *Configuration { "v2.DeleteIncidentNotificationTemplate": false, "v2.DeleteIncidentTodo": false, "v2.DeleteIncidentType": false, + "v2.GetGlobalIncidentSettings": false, "v2.GetIncident": false, "v2.GetIncidentIntegration": false, "v2.GetIncidentNotificationRule": false, "v2.GetIncidentNotificationTemplate": false, "v2.GetIncidentTodo": false, "v2.GetIncidentType": false, + "v2.ListGlobalIncidentHandles": false, "v2.ListIncidentAttachments": false, "v2.ListIncidentIntegrations": false, "v2.ListIncidentNotificationRules": false, @@ -739,6 +743,8 @@ func NewConfiguration() *Configuration { "v2.ListIncidentTodos": false, "v2.ListIncidentTypes": false, "v2.SearchIncidents": false, + "v2.UpdateGlobalIncidentHandle": false, + "v2.UpdateGlobalIncidentSettings": false, "v2.UpdateIncident": false, "v2.UpdateIncidentAttachment": false, "v2.UpdateIncidentIntegration": false, diff --git a/api/datadogV1/model_widget_request_style.go b/api/datadogV1/model_widget_request_style.go index dbfd616a26b..ac412c447c6 100644 --- a/api/datadogV1/model_widget_request_style.go +++ b/api/datadogV1/model_widget_request_style.go @@ -14,6 +14,10 @@ type WidgetRequestStyle struct { LineType *WidgetLineType `json:"line_type,omitempty"` // Width of line displayed. LineWidth *WidgetLineWidth `json:"line_width,omitempty"` + // How to order series in timeseries visualizations. + // - `tags`: Order series alphabetically by tag name (default behavior) + // - `values`: Order series by their current metric values (typically descending) + OrderBy *WidgetStyleOrderBy `json:"order_by,omitempty"` // Color palette to apply to the widget. Palette *string `json:"palette,omitempty"` // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct @@ -94,6 +98,34 @@ func (o *WidgetRequestStyle) SetLineWidth(v WidgetLineWidth) { o.LineWidth = &v } +// GetOrderBy returns the OrderBy field value if set, zero value otherwise. +func (o *WidgetRequestStyle) GetOrderBy() WidgetStyleOrderBy { + if o == nil || o.OrderBy == nil { + var ret WidgetStyleOrderBy + return ret + } + return *o.OrderBy +} + +// GetOrderByOk returns a tuple with the OrderBy field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *WidgetRequestStyle) GetOrderByOk() (*WidgetStyleOrderBy, bool) { + if o == nil || o.OrderBy == nil { + return nil, false + } + return o.OrderBy, true +} + +// HasOrderBy returns a boolean if a field has been set. +func (o *WidgetRequestStyle) HasOrderBy() bool { + return o != nil && o.OrderBy != nil +} + +// SetOrderBy gets a reference to the given WidgetStyleOrderBy and assigns it to the OrderBy field. +func (o *WidgetRequestStyle) SetOrderBy(v WidgetStyleOrderBy) { + o.OrderBy = &v +} + // GetPalette returns the Palette field value if set, zero value otherwise. func (o *WidgetRequestStyle) GetPalette() string { if o == nil || o.Palette == nil { @@ -134,6 +166,9 @@ func (o WidgetRequestStyle) MarshalJSON() ([]byte, error) { if o.LineWidth != nil { toSerialize["line_width"] = o.LineWidth } + if o.OrderBy != nil { + toSerialize["order_by"] = o.OrderBy + } if o.Palette != nil { toSerialize["palette"] = o.Palette } @@ -147,16 +182,17 @@ func (o WidgetRequestStyle) MarshalJSON() ([]byte, error) { // UnmarshalJSON deserializes the given payload. func (o *WidgetRequestStyle) UnmarshalJSON(bytes []byte) (err error) { all := struct { - LineType *WidgetLineType `json:"line_type,omitempty"` - LineWidth *WidgetLineWidth `json:"line_width,omitempty"` - Palette *string `json:"palette,omitempty"` + LineType *WidgetLineType `json:"line_type,omitempty"` + LineWidth *WidgetLineWidth `json:"line_width,omitempty"` + OrderBy *WidgetStyleOrderBy `json:"order_by,omitempty"` + Palette *string `json:"palette,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{"line_type", "line_width", "palette"}) + datadog.DeleteKeys(additionalProperties, &[]string{"line_type", "line_width", "order_by", "palette"}) } else { return err } @@ -172,6 +208,11 @@ func (o *WidgetRequestStyle) UnmarshalJSON(bytes []byte) (err error) { } else { o.LineWidth = all.LineWidth } + if all.OrderBy != nil && !all.OrderBy.IsValid() { + hasInvalidField = true + } else { + o.OrderBy = all.OrderBy + } o.Palette = all.Palette if len(additionalProperties) > 0 { diff --git a/api/datadogV1/model_widget_style_order_by.go b/api/datadogV1/model_widget_style_order_by.go new file mode 100644 index 00000000000..c44540e766f --- /dev/null +++ b/api/datadogV1/model_widget_style_order_by.go @@ -0,0 +1,68 @@ +// 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 datadogV1 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// WidgetStyleOrderBy How to order series in timeseries visualizations. +// - `tags`: Order series alphabetically by tag name (default behavior) +// - `values`: Order series by their current metric values (typically descending) +type WidgetStyleOrderBy string + +// List of WidgetStyleOrderBy. +const ( + WIDGETSTYLEORDERBY_TAGS WidgetStyleOrderBy = "tags" + WIDGETSTYLEORDERBY_VALUES WidgetStyleOrderBy = "values" +) + +var allowedWidgetStyleOrderByEnumValues = []WidgetStyleOrderBy{ + WIDGETSTYLEORDERBY_TAGS, + WIDGETSTYLEORDERBY_VALUES, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *WidgetStyleOrderBy) GetAllowedValues() []WidgetStyleOrderBy { + return allowedWidgetStyleOrderByEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *WidgetStyleOrderBy) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = WidgetStyleOrderBy(value) + return nil +} + +// NewWidgetStyleOrderByFromValue returns a pointer to a valid WidgetStyleOrderBy +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewWidgetStyleOrderByFromValue(v string) (*WidgetStyleOrderBy, error) { + ev := WidgetStyleOrderBy(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for WidgetStyleOrderBy: valid values are %v", v, allowedWidgetStyleOrderByEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v WidgetStyleOrderBy) IsValid() bool { + for _, existing := range allowedWidgetStyleOrderByEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to WidgetStyleOrderBy value. +func (v WidgetStyleOrderBy) Ptr() *WidgetStyleOrderBy { + return &v +} diff --git a/api/datadogV2/api_cloud_cost_management.go b/api/datadogV2/api_cloud_cost_management.go index 624910dc3fd..d1717b7f7de 100644 --- a/api/datadogV2/api_cloud_cost_management.go +++ b/api/datadogV2/api_cloud_cost_management.go @@ -905,11 +905,11 @@ func (a *CloudCostManagementApi) DeleteTagPipelinesRuleset(ctx _context.Context, // GetBudget Get budget. // Get a budget -func (a *CloudCostManagementApi) GetBudget(ctx _context.Context, budgetId string) (BudgetValidationRequest, *_nethttp.Response, error) { +func (a *CloudCostManagementApi) GetBudget(ctx _context.Context, budgetId string) (BudgetWithEntries, *_nethttp.Response, error) { var ( localVarHTTPMethod = _nethttp.MethodGet localVarPostBody interface{} - localVarReturnValue BudgetValidationRequest + localVarReturnValue BudgetWithEntries ) localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.CloudCostManagementApi.GetBudget") diff --git a/api/datadogV2/api_incidents.go b/api/datadogV2/api_incidents.go index 82d29b19de2..91ed6c20dfb 100644 --- a/api/datadogV2/api_incidents.go +++ b/api/datadogV2/api_incidents.go @@ -18,6 +18,132 @@ import ( // IncidentsApi service type type IncidentsApi datadog.Service +// CreateGlobalIncidentHandleOptionalParameters holds optional parameters for CreateGlobalIncidentHandle. +type CreateGlobalIncidentHandleOptionalParameters struct { + Include *string +} + +// NewCreateGlobalIncidentHandleOptionalParameters creates an empty struct for parameters. +func NewCreateGlobalIncidentHandleOptionalParameters() *CreateGlobalIncidentHandleOptionalParameters { + this := CreateGlobalIncidentHandleOptionalParameters{} + return &this +} + +// WithInclude sets the corresponding parameter name and returns the struct. +func (r *CreateGlobalIncidentHandleOptionalParameters) WithInclude(include string) *CreateGlobalIncidentHandleOptionalParameters { + r.Include = &include + return r +} + +// CreateGlobalIncidentHandle Create global incident handle. +// Create a new global incident handle. +func (a *IncidentsApi) CreateGlobalIncidentHandle(ctx _context.Context, body IncidentHandleRequest, o ...CreateGlobalIncidentHandleOptionalParameters) (IncidentHandleResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPost + localVarPostBody interface{} + localVarReturnValue IncidentHandleResponse + optionalParams CreateGlobalIncidentHandleOptionalParameters + ) + + if len(o) > 1 { + return localVarReturnValue, nil, datadog.ReportError("only one argument of type CreateGlobalIncidentHandleOptionalParameters is allowed") + } + if len(o) == 1 { + optionalParams = o[0] + } + + operationId := "v2.CreateGlobalIncidentHandle" + isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId) + if !isOperationEnabled { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)} + } + if isOperationEnabled && a.Client.Cfg.Debug { + _log.Printf("WARNING: Using unstable operation '%s'", operationId) + } + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.IncidentsApi.CreateGlobalIncidentHandle") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/incidents/config/global/incident-handles" + + 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 == 400 { + var v JSONAPIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + // CreateIncident Create an incident. // Create an incident. func (a *IncidentsApi) CreateIncident(ctx _context.Context, body IncidentCreateRequest) (IncidentResponse, *_nethttp.Response, error) { @@ -880,6 +1006,91 @@ func (a *IncidentsApi) CreateIncidentType(ctx _context.Context, body IncidentTyp return localVarReturnValue, localVarHTTPResponse, nil } +// DeleteGlobalIncidentHandle Delete global incident handle. +// Delete a global incident handle. +func (a *IncidentsApi) DeleteGlobalIncidentHandle(ctx _context.Context) (*_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodDelete + localVarPostBody interface{} + ) + + operationId := "v2.DeleteGlobalIncidentHandle" + isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId) + if !isOperationEnabled { + return nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)} + } + if isOperationEnabled && a.Client.Cfg.Debug { + _log.Printf("WARNING: Using unstable operation '%s'", operationId) + } + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.IncidentsApi.DeleteGlobalIncidentHandle") + if err != nil { + return nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/incidents/config/global/incident-handles" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Accept"] = "*/*" + + if a.Client.Cfg.DelegatedTokenConfig != nil { + err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig) + if err != nil { + return nil, err + } + } else { + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + } + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 { + var v JSONAPIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + return localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarHTTPResponse, newErr + } + + return localVarHTTPResponse, nil +} + // DeleteIncident Delete an existing incident. // Deletes an existing incident from the users organization. func (a *IncidentsApi) DeleteIncident(ctx _context.Context, incidentId string) (*_nethttp.Response, error) { @@ -1547,41 +1758,16 @@ func (a *IncidentsApi) DeleteIncidentType(ctx _context.Context, incidentTypeId s return localVarHTTPResponse, nil } -// GetIncidentOptionalParameters holds optional parameters for GetIncident. -type GetIncidentOptionalParameters struct { - Include *[]IncidentRelatedObject -} - -// NewGetIncidentOptionalParameters creates an empty struct for parameters. -func NewGetIncidentOptionalParameters() *GetIncidentOptionalParameters { - this := GetIncidentOptionalParameters{} - return &this -} - -// WithInclude sets the corresponding parameter name and returns the struct. -func (r *GetIncidentOptionalParameters) WithInclude(include []IncidentRelatedObject) *GetIncidentOptionalParameters { - r.Include = &include - return r -} - -// GetIncident Get the details of an incident. -// Get the details of an incident by `incident_id`. -func (a *IncidentsApi) GetIncident(ctx _context.Context, incidentId string, o ...GetIncidentOptionalParameters) (IncidentResponse, *_nethttp.Response, error) { +// GetGlobalIncidentSettings Get global incident settings. +// Retrieve global incident settings for the organization. +func (a *IncidentsApi) GetGlobalIncidentSettings(ctx _context.Context) (GlobalIncidentSettingsResponse, *_nethttp.Response, error) { var ( localVarHTTPMethod = _nethttp.MethodGet localVarPostBody interface{} - localVarReturnValue IncidentResponse - optionalParams GetIncidentOptionalParameters + localVarReturnValue GlobalIncidentSettingsResponse ) - if len(o) > 1 { - return localVarReturnValue, nil, datadog.ReportError("only one argument of type GetIncidentOptionalParameters is allowed") - } - if len(o) == 1 { - optionalParams = o[0] - } - - operationId := "v2.GetIncident" + operationId := "v2.GetGlobalIncidentSettings" isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId) if !isOperationEnabled { return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)} @@ -1590,20 +1776,16 @@ func (a *IncidentsApi) GetIncident(ctx _context.Context, incidentId string, o .. _log.Printf("WARNING: Using unstable operation '%s'", operationId) } - localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.IncidentsApi.GetIncident") + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.IncidentsApi.GetGlobalIncidentSettings") if err != nil { return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} } - localVarPath := localBasePath + "/api/v2/incidents/{incident_id}" - localVarPath = datadog.ReplacePathParameter(localVarPath, "{incident_id}", _neturl.PathEscape(datadog.ParameterToString(incidentId, ""))) + localVarPath := localBasePath + "/api/v2/incidents/config/global/settings" localVarHeaderParams := make(map[string]string) localVarQueryParams := _neturl.Values{} localVarFormParams := _neturl.Values{} - if optionalParams.Include != nil { - localVarQueryParams.Add("include", datadog.ParameterToString(*optionalParams.Include, "csv")) - } localVarHeaderParams["Accept"] = "application/json" if a.Client.Cfg.DelegatedTokenConfig != nil { @@ -1639,7 +1821,16 @@ func (a *IncidentsApi) GetIncident(ctx _context.Context, incidentId string, o .. ErrorBody: localVarBody, ErrorMessage: localVarHTTPResponse.Status, } - if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 401 || localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 404 || localVarHTTPResponse.StatusCode == 429 { + if localVarHTTPResponse.StatusCode == 400 { + var v JSONAPIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 429 { var v APIErrorResponse err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) if err != nil { @@ -1662,23 +1853,138 @@ func (a *IncidentsApi) GetIncident(ctx _context.Context, incidentId string, o .. return localVarReturnValue, localVarHTTPResponse, nil } -// GetIncidentIntegration Get incident integration metadata details. -// Get incident integration metadata details. -func (a *IncidentsApi) GetIncidentIntegration(ctx _context.Context, incidentId string, integrationMetadataId string) (IncidentIntegrationMetadataResponse, *_nethttp.Response, error) { - var ( - localVarHTTPMethod = _nethttp.MethodGet - localVarPostBody interface{} - localVarReturnValue IncidentIntegrationMetadataResponse - ) +// GetIncidentOptionalParameters holds optional parameters for GetIncident. +type GetIncidentOptionalParameters struct { + Include *[]IncidentRelatedObject +} - operationId := "v2.GetIncidentIntegration" - isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId) - if !isOperationEnabled { - return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)} - } - if isOperationEnabled && a.Client.Cfg.Debug { - _log.Printf("WARNING: Using unstable operation '%s'", operationId) - } +// NewGetIncidentOptionalParameters creates an empty struct for parameters. +func NewGetIncidentOptionalParameters() *GetIncidentOptionalParameters { + this := GetIncidentOptionalParameters{} + return &this +} + +// WithInclude sets the corresponding parameter name and returns the struct. +func (r *GetIncidentOptionalParameters) WithInclude(include []IncidentRelatedObject) *GetIncidentOptionalParameters { + r.Include = &include + return r +} + +// GetIncident Get the details of an incident. +// Get the details of an incident by `incident_id`. +func (a *IncidentsApi) GetIncident(ctx _context.Context, incidentId string, o ...GetIncidentOptionalParameters) (IncidentResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarReturnValue IncidentResponse + optionalParams GetIncidentOptionalParameters + ) + + if len(o) > 1 { + return localVarReturnValue, nil, datadog.ReportError("only one argument of type GetIncidentOptionalParameters is allowed") + } + if len(o) == 1 { + optionalParams = o[0] + } + + operationId := "v2.GetIncident" + isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId) + if !isOperationEnabled { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)} + } + if isOperationEnabled && a.Client.Cfg.Debug { + _log.Printf("WARNING: Using unstable operation '%s'", operationId) + } + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.IncidentsApi.GetIncident") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/incidents/{incident_id}" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{incident_id}", _neturl.PathEscape(datadog.ParameterToString(incidentId, ""))) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + if optionalParams.Include != nil { + localVarQueryParams.Add("include", datadog.ParameterToString(*optionalParams.Include, "csv")) + } + localVarHeaderParams["Accept"] = "application/json" + + if a.Client.Cfg.DelegatedTokenConfig != nil { + err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig) + if err != nil { + return localVarReturnValue, nil, err + } + } else { + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + } + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 401 || localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 404 || 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 +} + +// GetIncidentIntegration Get incident integration metadata details. +// Get incident integration metadata details. +func (a *IncidentsApi) GetIncidentIntegration(ctx _context.Context, incidentId string, integrationMetadataId string) (IncidentIntegrationMetadataResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarReturnValue IncidentIntegrationMetadataResponse + ) + + operationId := "v2.GetIncidentIntegration" + isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId) + if !isOperationEnabled { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)} + } + if isOperationEnabled && a.Client.Cfg.Debug { + _log.Printf("WARNING: Using unstable operation '%s'", operationId) + } localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.IncidentsApi.GetIncidentIntegration") if err != nil { @@ -2155,6 +2461,129 @@ func (a *IncidentsApi) GetIncidentType(ctx _context.Context, incidentTypeId stri return localVarReturnValue, localVarHTTPResponse, nil } +// ListGlobalIncidentHandlesOptionalParameters holds optional parameters for ListGlobalIncidentHandles. +type ListGlobalIncidentHandlesOptionalParameters struct { + Include *string +} + +// NewListGlobalIncidentHandlesOptionalParameters creates an empty struct for parameters. +func NewListGlobalIncidentHandlesOptionalParameters() *ListGlobalIncidentHandlesOptionalParameters { + this := ListGlobalIncidentHandlesOptionalParameters{} + return &this +} + +// WithInclude sets the corresponding parameter name and returns the struct. +func (r *ListGlobalIncidentHandlesOptionalParameters) WithInclude(include string) *ListGlobalIncidentHandlesOptionalParameters { + r.Include = &include + return r +} + +// ListGlobalIncidentHandles List global incident handles. +// Retrieve a list of global incident handles. +func (a *IncidentsApi) ListGlobalIncidentHandles(ctx _context.Context, o ...ListGlobalIncidentHandlesOptionalParameters) (IncidentHandlesResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarReturnValue IncidentHandlesResponse + optionalParams ListGlobalIncidentHandlesOptionalParameters + ) + + if len(o) > 1 { + return localVarReturnValue, nil, datadog.ReportError("only one argument of type ListGlobalIncidentHandlesOptionalParameters is allowed") + } + if len(o) == 1 { + optionalParams = o[0] + } + + operationId := "v2.ListGlobalIncidentHandles" + isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId) + if !isOperationEnabled { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)} + } + if isOperationEnabled && a.Client.Cfg.Debug { + _log.Printf("WARNING: Using unstable operation '%s'", operationId) + } + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.IncidentsApi.ListGlobalIncidentHandles") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/incidents/config/global/incident-handles" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + if optionalParams.Include != nil { + localVarQueryParams.Add("include", datadog.ParameterToString(*optionalParams.Include, "")) + } + localVarHeaderParams["Accept"] = "application/json" + + if a.Client.Cfg.DelegatedTokenConfig != nil { + err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig) + if err != nil { + return localVarReturnValue, nil, err + } + } else { + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + } + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 { + var v JSONAPIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + // ListIncidentAttachmentsOptionalParameters holds optional parameters for ListIncidentAttachments. type ListIncidentAttachmentsOptionalParameters struct { FilterAttachmentType *string @@ -3299,6 +3728,230 @@ func (a *IncidentsApi) SearchIncidentsWithPagination(ctx _context.Context, query return items, cancel } +// UpdateGlobalIncidentHandleOptionalParameters holds optional parameters for UpdateGlobalIncidentHandle. +type UpdateGlobalIncidentHandleOptionalParameters struct { + Include *string +} + +// NewUpdateGlobalIncidentHandleOptionalParameters creates an empty struct for parameters. +func NewUpdateGlobalIncidentHandleOptionalParameters() *UpdateGlobalIncidentHandleOptionalParameters { + this := UpdateGlobalIncidentHandleOptionalParameters{} + return &this +} + +// WithInclude sets the corresponding parameter name and returns the struct. +func (r *UpdateGlobalIncidentHandleOptionalParameters) WithInclude(include string) *UpdateGlobalIncidentHandleOptionalParameters { + r.Include = &include + return r +} + +// UpdateGlobalIncidentHandle Update global incident handle. +// Update an existing global incident handle. +func (a *IncidentsApi) UpdateGlobalIncidentHandle(ctx _context.Context, body IncidentHandleRequest, o ...UpdateGlobalIncidentHandleOptionalParameters) (IncidentHandleResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPut + localVarPostBody interface{} + localVarReturnValue IncidentHandleResponse + optionalParams UpdateGlobalIncidentHandleOptionalParameters + ) + + if len(o) > 1 { + return localVarReturnValue, nil, datadog.ReportError("only one argument of type UpdateGlobalIncidentHandleOptionalParameters is allowed") + } + if len(o) == 1 { + optionalParams = o[0] + } + + operationId := "v2.UpdateGlobalIncidentHandle" + isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId) + if !isOperationEnabled { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)} + } + if isOperationEnabled && a.Client.Cfg.Debug { + _log.Printf("WARNING: Using unstable operation '%s'", operationId) + } + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.IncidentsApi.UpdateGlobalIncidentHandle") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/incidents/config/global/incident-handles" + + 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 == 400 { + var v JSONAPIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +// UpdateGlobalIncidentSettings Update global incident settings. +// Update global incident settings for the organization. +func (a *IncidentsApi) UpdateGlobalIncidentSettings(ctx _context.Context, body GlobalIncidentSettingsRequest) (GlobalIncidentSettingsResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPatch + localVarPostBody interface{} + localVarReturnValue GlobalIncidentSettingsResponse + ) + + operationId := "v2.UpdateGlobalIncidentSettings" + isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId) + if !isOperationEnabled { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)} + } + if isOperationEnabled && a.Client.Cfg.Debug { + _log.Printf("WARNING: Using unstable operation '%s'", operationId) + } + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.IncidentsApi.UpdateGlobalIncidentSettings") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/incidents/config/global/settings" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Content-Type"] = "application/json" + localVarHeaderParams["Accept"] = "application/json" + + // body params + localVarPostBody = &body + if a.Client.Cfg.DelegatedTokenConfig != nil { + err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig) + if err != nil { + return localVarReturnValue, nil, err + } + } else { + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + } + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 { + var v JSONAPIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + // UpdateIncidentOptionalParameters holds optional parameters for UpdateIncident. type UpdateIncidentOptionalParameters struct { Include *[]IncidentRelatedObject diff --git a/api/datadogV2/doc.go b/api/datadogV2/doc.go index c95c81a211e..e5e67a6b323 100644 --- a/api/datadogV2/doc.go +++ b/api/datadogV2/doc.go @@ -295,6 +295,7 @@ // - [IncidentTeamsApi.GetIncidentTeam] // - [IncidentTeamsApi.ListIncidentTeams] // - [IncidentTeamsApi.UpdateIncidentTeam] +// - [IncidentsApi.CreateGlobalIncidentHandle] // - [IncidentsApi.CreateIncident] // - [IncidentsApi.CreateIncidentAttachment] // - [IncidentsApi.CreateIncidentImpact] @@ -304,6 +305,7 @@ // - [IncidentsApi.CreateIncidentPostmortemAttachment] // - [IncidentsApi.CreateIncidentTodo] // - [IncidentsApi.CreateIncidentType] +// - [IncidentsApi.DeleteGlobalIncidentHandle] // - [IncidentsApi.DeleteIncident] // - [IncidentsApi.DeleteIncidentAttachment] // - [IncidentsApi.DeleteIncidentImpact] @@ -312,12 +314,14 @@ // - [IncidentsApi.DeleteIncidentNotificationTemplate] // - [IncidentsApi.DeleteIncidentTodo] // - [IncidentsApi.DeleteIncidentType] +// - [IncidentsApi.GetGlobalIncidentSettings] // - [IncidentsApi.GetIncident] // - [IncidentsApi.GetIncidentIntegration] // - [IncidentsApi.GetIncidentNotificationRule] // - [IncidentsApi.GetIncidentNotificationTemplate] // - [IncidentsApi.GetIncidentTodo] // - [IncidentsApi.GetIncidentType] +// - [IncidentsApi.ListGlobalIncidentHandles] // - [IncidentsApi.ListIncidentAttachments] // - [IncidentsApi.ListIncidentImpacts] // - [IncidentsApi.ListIncidentIntegrations] @@ -327,6 +331,8 @@ // - [IncidentsApi.ListIncidentTypes] // - [IncidentsApi.ListIncidents] // - [IncidentsApi.SearchIncidents] +// - [IncidentsApi.UpdateGlobalIncidentHandle] +// - [IncidentsApi.UpdateGlobalIncidentSettings] // - [IncidentsApi.UpdateIncident] // - [IncidentsApi.UpdateIncidentAttachment] // - [IncidentsApi.UpdateIncidentIntegration] diff --git a/api/datadogV2/model_global_incident_settings_attributes_request.go b/api/datadogV2/model_global_incident_settings_attributes_request.go new file mode 100644 index 00000000000..d90cbc2c5ea --- /dev/null +++ b/api/datadogV2/model_global_incident_settings_attributes_request.go @@ -0,0 +1,102 @@ +// 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" +) + +// GlobalIncidentSettingsAttributesRequest Global incident settings attributes +type GlobalIncidentSettingsAttributesRequest struct { + // The analytics dashboard ID + AnalyticsDashboardId *string `json:"analytics_dashboard_id,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewGlobalIncidentSettingsAttributesRequest instantiates a new GlobalIncidentSettingsAttributesRequest 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 NewGlobalIncidentSettingsAttributesRequest() *GlobalIncidentSettingsAttributesRequest { + this := GlobalIncidentSettingsAttributesRequest{} + return &this +} + +// NewGlobalIncidentSettingsAttributesRequestWithDefaults instantiates a new GlobalIncidentSettingsAttributesRequest 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 NewGlobalIncidentSettingsAttributesRequestWithDefaults() *GlobalIncidentSettingsAttributesRequest { + this := GlobalIncidentSettingsAttributesRequest{} + return &this +} + +// GetAnalyticsDashboardId returns the AnalyticsDashboardId field value if set, zero value otherwise. +func (o *GlobalIncidentSettingsAttributesRequest) GetAnalyticsDashboardId() string { + if o == nil || o.AnalyticsDashboardId == nil { + var ret string + return ret + } + return *o.AnalyticsDashboardId +} + +// GetAnalyticsDashboardIdOk returns a tuple with the AnalyticsDashboardId field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *GlobalIncidentSettingsAttributesRequest) GetAnalyticsDashboardIdOk() (*string, bool) { + if o == nil || o.AnalyticsDashboardId == nil { + return nil, false + } + return o.AnalyticsDashboardId, true +} + +// HasAnalyticsDashboardId returns a boolean if a field has been set. +func (o *GlobalIncidentSettingsAttributesRequest) HasAnalyticsDashboardId() bool { + return o != nil && o.AnalyticsDashboardId != nil +} + +// SetAnalyticsDashboardId gets a reference to the given string and assigns it to the AnalyticsDashboardId field. +func (o *GlobalIncidentSettingsAttributesRequest) SetAnalyticsDashboardId(v string) { + o.AnalyticsDashboardId = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o GlobalIncidentSettingsAttributesRequest) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.AnalyticsDashboardId != nil { + toSerialize["analytics_dashboard_id"] = o.AnalyticsDashboardId + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *GlobalIncidentSettingsAttributesRequest) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + AnalyticsDashboardId *string `json:"analytics_dashboard_id,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{"analytics_dashboard_id"}) + } else { + return err + } + o.AnalyticsDashboardId = all.AnalyticsDashboardId + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_global_incident_settings_attributes_response.go b/api/datadogV2/model_global_incident_settings_attributes_response.go new file mode 100644 index 00000000000..b52c01ce466 --- /dev/null +++ b/api/datadogV2/model_global_incident_settings_attributes_response.go @@ -0,0 +1,174 @@ +// 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" +) + +// GlobalIncidentSettingsAttributesResponse Global incident settings attributes +type GlobalIncidentSettingsAttributesResponse struct { + // The analytics dashboard ID + AnalyticsDashboardId string `json:"analytics_dashboard_id"` + // Timestamp when the settings were created + Created time.Time `json:"created"` + // Timestamp when the settings were last modified + Modified time.Time `json:"modified"` + // 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:"-"` +} + +// NewGlobalIncidentSettingsAttributesResponse instantiates a new GlobalIncidentSettingsAttributesResponse 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 NewGlobalIncidentSettingsAttributesResponse(analyticsDashboardId string, created time.Time, modified time.Time) *GlobalIncidentSettingsAttributesResponse { + this := GlobalIncidentSettingsAttributesResponse{} + this.AnalyticsDashboardId = analyticsDashboardId + this.Created = created + this.Modified = modified + return &this +} + +// NewGlobalIncidentSettingsAttributesResponseWithDefaults instantiates a new GlobalIncidentSettingsAttributesResponse 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 NewGlobalIncidentSettingsAttributesResponseWithDefaults() *GlobalIncidentSettingsAttributesResponse { + this := GlobalIncidentSettingsAttributesResponse{} + return &this +} + +// GetAnalyticsDashboardId returns the AnalyticsDashboardId field value. +func (o *GlobalIncidentSettingsAttributesResponse) GetAnalyticsDashboardId() string { + if o == nil { + var ret string + return ret + } + return o.AnalyticsDashboardId +} + +// GetAnalyticsDashboardIdOk returns a tuple with the AnalyticsDashboardId field value +// and a boolean to check if the value has been set. +func (o *GlobalIncidentSettingsAttributesResponse) GetAnalyticsDashboardIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.AnalyticsDashboardId, true +} + +// SetAnalyticsDashboardId sets field value. +func (o *GlobalIncidentSettingsAttributesResponse) SetAnalyticsDashboardId(v string) { + o.AnalyticsDashboardId = v +} + +// GetCreated returns the Created field value. +func (o *GlobalIncidentSettingsAttributesResponse) GetCreated() time.Time { + if o == nil { + var ret time.Time + return ret + } + return o.Created +} + +// GetCreatedOk returns a tuple with the Created field value +// and a boolean to check if the value has been set. +func (o *GlobalIncidentSettingsAttributesResponse) GetCreatedOk() (*time.Time, bool) { + if o == nil { + return nil, false + } + return &o.Created, true +} + +// SetCreated sets field value. +func (o *GlobalIncidentSettingsAttributesResponse) SetCreated(v time.Time) { + o.Created = v +} + +// GetModified returns the Modified field value. +func (o *GlobalIncidentSettingsAttributesResponse) GetModified() time.Time { + if o == nil { + var ret time.Time + return ret + } + return o.Modified +} + +// GetModifiedOk returns a tuple with the Modified field value +// and a boolean to check if the value has been set. +func (o *GlobalIncidentSettingsAttributesResponse) GetModifiedOk() (*time.Time, bool) { + if o == nil { + return nil, false + } + return &o.Modified, true +} + +// SetModified sets field value. +func (o *GlobalIncidentSettingsAttributesResponse) SetModified(v time.Time) { + o.Modified = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o GlobalIncidentSettingsAttributesResponse) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["analytics_dashboard_id"] = o.AnalyticsDashboardId + if o.Created.Nanosecond() == 0 { + toSerialize["created"] = o.Created.Format("2006-01-02T15:04:05Z07:00") + } else { + toSerialize["created"] = o.Created.Format("2006-01-02T15:04:05.000Z07:00") + } + if o.Modified.Nanosecond() == 0 { + toSerialize["modified"] = o.Modified.Format("2006-01-02T15:04:05Z07:00") + } else { + toSerialize["modified"] = o.Modified.Format("2006-01-02T15:04:05.000Z07:00") + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *GlobalIncidentSettingsAttributesResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + AnalyticsDashboardId *string `json:"analytics_dashboard_id"` + Created *time.Time `json:"created"` + Modified *time.Time `json:"modified"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.AnalyticsDashboardId == nil { + return fmt.Errorf("required field analytics_dashboard_id missing") + } + if all.Created == nil { + return fmt.Errorf("required field created missing") + } + if all.Modified == nil { + return fmt.Errorf("required field modified missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"analytics_dashboard_id", "created", "modified"}) + } else { + return err + } + o.AnalyticsDashboardId = *all.AnalyticsDashboardId + o.Created = *all.Created + o.Modified = *all.Modified + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_global_incident_settings_data_request.go b/api/datadogV2/model_global_incident_settings_data_request.go new file mode 100644 index 00000000000..d1631cd162e --- /dev/null +++ b/api/datadogV2/model_global_incident_settings_data_request.go @@ -0,0 +1,149 @@ +// 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" +) + +// GlobalIncidentSettingsDataRequest +type GlobalIncidentSettingsDataRequest struct { + // Global incident settings attributes + Attributes *GlobalIncidentSettingsAttributesRequest `json:"attributes,omitempty"` + // Global incident settings resource type + Type GlobalIncidentSettingsType `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:"-"` +} + +// NewGlobalIncidentSettingsDataRequest instantiates a new GlobalIncidentSettingsDataRequest 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 NewGlobalIncidentSettingsDataRequest(typeVar GlobalIncidentSettingsType) *GlobalIncidentSettingsDataRequest { + this := GlobalIncidentSettingsDataRequest{} + this.Type = typeVar + return &this +} + +// NewGlobalIncidentSettingsDataRequestWithDefaults instantiates a new GlobalIncidentSettingsDataRequest 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 NewGlobalIncidentSettingsDataRequestWithDefaults() *GlobalIncidentSettingsDataRequest { + this := GlobalIncidentSettingsDataRequest{} + return &this +} + +// GetAttributes returns the Attributes field value if set, zero value otherwise. +func (o *GlobalIncidentSettingsDataRequest) GetAttributes() GlobalIncidentSettingsAttributesRequest { + if o == nil || o.Attributes == nil { + var ret GlobalIncidentSettingsAttributesRequest + 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 *GlobalIncidentSettingsDataRequest) GetAttributesOk() (*GlobalIncidentSettingsAttributesRequest, 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 *GlobalIncidentSettingsDataRequest) HasAttributes() bool { + return o != nil && o.Attributes != nil +} + +// SetAttributes gets a reference to the given GlobalIncidentSettingsAttributesRequest and assigns it to the Attributes field. +func (o *GlobalIncidentSettingsDataRequest) SetAttributes(v GlobalIncidentSettingsAttributesRequest) { + o.Attributes = &v +} + +// GetType returns the Type field value. +func (o *GlobalIncidentSettingsDataRequest) GetType() GlobalIncidentSettingsType { + if o == nil { + var ret GlobalIncidentSettingsType + 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 *GlobalIncidentSettingsDataRequest) GetTypeOk() (*GlobalIncidentSettingsType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *GlobalIncidentSettingsDataRequest) SetType(v GlobalIncidentSettingsType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o GlobalIncidentSettingsDataRequest) 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 *GlobalIncidentSettingsDataRequest) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *GlobalIncidentSettingsAttributesRequest `json:"attributes,omitempty"` + Type *GlobalIncidentSettingsType `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_global_incident_settings_data_response.go b/api/datadogV2/model_global_incident_settings_data_response.go new file mode 100644 index 00000000000..437bf9eb9a9 --- /dev/null +++ b/api/datadogV2/model_global_incident_settings_data_response.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" +) + +// GlobalIncidentSettingsDataResponse +type GlobalIncidentSettingsDataResponse struct { + // Global incident settings attributes + Attributes GlobalIncidentSettingsAttributesResponse `json:"attributes"` + // The unique identifier for the global incident settings + Id string `json:"id"` + // Global incident settings resource type + Type GlobalIncidentSettingsType `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:"-"` +} + +// NewGlobalIncidentSettingsDataResponse instantiates a new GlobalIncidentSettingsDataResponse 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 NewGlobalIncidentSettingsDataResponse(attributes GlobalIncidentSettingsAttributesResponse, id string, typeVar GlobalIncidentSettingsType) *GlobalIncidentSettingsDataResponse { + this := GlobalIncidentSettingsDataResponse{} + this.Attributes = attributes + this.Id = id + this.Type = typeVar + return &this +} + +// NewGlobalIncidentSettingsDataResponseWithDefaults instantiates a new GlobalIncidentSettingsDataResponse 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 NewGlobalIncidentSettingsDataResponseWithDefaults() *GlobalIncidentSettingsDataResponse { + this := GlobalIncidentSettingsDataResponse{} + return &this +} + +// GetAttributes returns the Attributes field value. +func (o *GlobalIncidentSettingsDataResponse) GetAttributes() GlobalIncidentSettingsAttributesResponse { + if o == nil { + var ret GlobalIncidentSettingsAttributesResponse + return ret + } + return o.Attributes +} + +// GetAttributesOk returns a tuple with the Attributes field value +// and a boolean to check if the value has been set. +func (o *GlobalIncidentSettingsDataResponse) GetAttributesOk() (*GlobalIncidentSettingsAttributesResponse, bool) { + if o == nil { + return nil, false + } + return &o.Attributes, true +} + +// SetAttributes sets field value. +func (o *GlobalIncidentSettingsDataResponse) SetAttributes(v GlobalIncidentSettingsAttributesResponse) { + o.Attributes = v +} + +// GetId returns the Id field value. +func (o *GlobalIncidentSettingsDataResponse) 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 *GlobalIncidentSettingsDataResponse) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Id, true +} + +// SetId sets field value. +func (o *GlobalIncidentSettingsDataResponse) SetId(v string) { + o.Id = v +} + +// GetType returns the Type field value. +func (o *GlobalIncidentSettingsDataResponse) GetType() GlobalIncidentSettingsType { + if o == nil { + var ret GlobalIncidentSettingsType + 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 *GlobalIncidentSettingsDataResponse) GetTypeOk() (*GlobalIncidentSettingsType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *GlobalIncidentSettingsDataResponse) SetType(v GlobalIncidentSettingsType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o GlobalIncidentSettingsDataResponse) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["attributes"] = o.Attributes + toSerialize["id"] = o.Id + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *GlobalIncidentSettingsDataResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *GlobalIncidentSettingsAttributesResponse `json:"attributes"` + Id *string `json:"id"` + Type *GlobalIncidentSettingsType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Attributes == nil { + return fmt.Errorf("required field attributes missing") + } + if all.Id == nil { + return fmt.Errorf("required field id missing") + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "id", "type"}) + } else { + return err + } + + hasInvalidField := false + if all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Attributes = *all.Attributes + o.Id = *all.Id + if !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = *all.Type + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_global_incident_settings_request.go b/api/datadogV2/model_global_incident_settings_request.go new file mode 100644 index 00000000000..90cda053e8d --- /dev/null +++ b/api/datadogV2/model_global_incident_settings_request.go @@ -0,0 +1,110 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// GlobalIncidentSettingsRequest +type GlobalIncidentSettingsRequest struct { + // + Data GlobalIncidentSettingsDataRequest `json:"data"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewGlobalIncidentSettingsRequest instantiates a new GlobalIncidentSettingsRequest 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 NewGlobalIncidentSettingsRequest(data GlobalIncidentSettingsDataRequest) *GlobalIncidentSettingsRequest { + this := GlobalIncidentSettingsRequest{} + this.Data = data + return &this +} + +// NewGlobalIncidentSettingsRequestWithDefaults instantiates a new GlobalIncidentSettingsRequest 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 NewGlobalIncidentSettingsRequestWithDefaults() *GlobalIncidentSettingsRequest { + this := GlobalIncidentSettingsRequest{} + return &this +} + +// GetData returns the Data field value. +func (o *GlobalIncidentSettingsRequest) GetData() GlobalIncidentSettingsDataRequest { + if o == nil { + var ret GlobalIncidentSettingsDataRequest + return ret + } + return o.Data +} + +// GetDataOk returns a tuple with the Data field value +// and a boolean to check if the value has been set. +func (o *GlobalIncidentSettingsRequest) GetDataOk() (*GlobalIncidentSettingsDataRequest, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *GlobalIncidentSettingsRequest) SetData(v GlobalIncidentSettingsDataRequest) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o GlobalIncidentSettingsRequest) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["data"] = o.Data + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *GlobalIncidentSettingsRequest) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *GlobalIncidentSettingsDataRequest `json:"data"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Data == nil { + return fmt.Errorf("required field data missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + + hasInvalidField := false + if all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Data = *all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_global_incident_settings_response.go b/api/datadogV2/model_global_incident_settings_response.go new file mode 100644 index 00000000000..3a45e7564e9 --- /dev/null +++ b/api/datadogV2/model_global_incident_settings_response.go @@ -0,0 +1,110 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// GlobalIncidentSettingsResponse +type GlobalIncidentSettingsResponse struct { + // + Data GlobalIncidentSettingsDataResponse `json:"data"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewGlobalIncidentSettingsResponse instantiates a new GlobalIncidentSettingsResponse 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 NewGlobalIncidentSettingsResponse(data GlobalIncidentSettingsDataResponse) *GlobalIncidentSettingsResponse { + this := GlobalIncidentSettingsResponse{} + this.Data = data + return &this +} + +// NewGlobalIncidentSettingsResponseWithDefaults instantiates a new GlobalIncidentSettingsResponse 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 NewGlobalIncidentSettingsResponseWithDefaults() *GlobalIncidentSettingsResponse { + this := GlobalIncidentSettingsResponse{} + return &this +} + +// GetData returns the Data field value. +func (o *GlobalIncidentSettingsResponse) GetData() GlobalIncidentSettingsDataResponse { + if o == nil { + var ret GlobalIncidentSettingsDataResponse + return ret + } + return o.Data +} + +// GetDataOk returns a tuple with the Data field value +// and a boolean to check if the value has been set. +func (o *GlobalIncidentSettingsResponse) GetDataOk() (*GlobalIncidentSettingsDataResponse, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *GlobalIncidentSettingsResponse) SetData(v GlobalIncidentSettingsDataResponse) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o GlobalIncidentSettingsResponse) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["data"] = o.Data + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *GlobalIncidentSettingsResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *GlobalIncidentSettingsDataResponse `json:"data"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Data == nil { + return fmt.Errorf("required field data missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + + hasInvalidField := false + if all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Data = *all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_global_incident_settings_type.go b/api/datadogV2/model_global_incident_settings_type.go new file mode 100644 index 00000000000..d8500bf57fa --- /dev/null +++ b/api/datadogV2/model_global_incident_settings_type.go @@ -0,0 +1,64 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// GlobalIncidentSettingsType Global incident settings resource type +type GlobalIncidentSettingsType string + +// List of GlobalIncidentSettingsType. +const ( + GLOBALINCIDENTSETTINGSTYPE_INCIDENTS_GLOBAL_SETTINGS GlobalIncidentSettingsType = "incidents_global_settings" +) + +var allowedGlobalIncidentSettingsTypeEnumValues = []GlobalIncidentSettingsType{ + GLOBALINCIDENTSETTINGSTYPE_INCIDENTS_GLOBAL_SETTINGS, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *GlobalIncidentSettingsType) GetAllowedValues() []GlobalIncidentSettingsType { + return allowedGlobalIncidentSettingsTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *GlobalIncidentSettingsType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = GlobalIncidentSettingsType(value) + return nil +} + +// NewGlobalIncidentSettingsTypeFromValue returns a pointer to a valid GlobalIncidentSettingsType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewGlobalIncidentSettingsTypeFromValue(v string) (*GlobalIncidentSettingsType, error) { + ev := GlobalIncidentSettingsType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for GlobalIncidentSettingsType: valid values are %v", v, allowedGlobalIncidentSettingsTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v GlobalIncidentSettingsType) IsValid() bool { + for _, existing := range allowedGlobalIncidentSettingsTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to GlobalIncidentSettingsType value. +func (v GlobalIncidentSettingsType) Ptr() *GlobalIncidentSettingsType { + return &v +} diff --git a/api/datadogV2/model_incident_handle_attributes_fields.go b/api/datadogV2/model_incident_handle_attributes_fields.go new file mode 100644 index 00000000000..52399961648 --- /dev/null +++ b/api/datadogV2/model_incident_handle_attributes_fields.go @@ -0,0 +1,102 @@ +// 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" +) + +// IncidentHandleAttributesFields Dynamic fields associated with the handle +type IncidentHandleAttributesFields struct { + // Severity levels associated with the handle + Severity []string `json:"severity,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:"-"` +} + +// NewIncidentHandleAttributesFields instantiates a new IncidentHandleAttributesFields 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 NewIncidentHandleAttributesFields() *IncidentHandleAttributesFields { + this := IncidentHandleAttributesFields{} + return &this +} + +// NewIncidentHandleAttributesFieldsWithDefaults instantiates a new IncidentHandleAttributesFields 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 NewIncidentHandleAttributesFieldsWithDefaults() *IncidentHandleAttributesFields { + this := IncidentHandleAttributesFields{} + return &this +} + +// GetSeverity returns the Severity field value if set, zero value otherwise. +func (o *IncidentHandleAttributesFields) GetSeverity() []string { + if o == nil || o.Severity == nil { + var ret []string + return ret + } + return o.Severity +} + +// GetSeverityOk returns a tuple with the Severity field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *IncidentHandleAttributesFields) GetSeverityOk() (*[]string, bool) { + if o == nil || o.Severity == nil { + return nil, false + } + return &o.Severity, true +} + +// HasSeverity returns a boolean if a field has been set. +func (o *IncidentHandleAttributesFields) HasSeverity() bool { + return o != nil && o.Severity != nil +} + +// SetSeverity gets a reference to the given []string and assigns it to the Severity field. +func (o *IncidentHandleAttributesFields) SetSeverity(v []string) { + o.Severity = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o IncidentHandleAttributesFields) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Severity != nil { + toSerialize["severity"] = o.Severity + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *IncidentHandleAttributesFields) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Severity []string `json:"severity,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{"severity"}) + } else { + return err + } + o.Severity = all.Severity + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_incident_handle_attributes_request.go b/api/datadogV2/model_incident_handle_attributes_request.go new file mode 100644 index 00000000000..b4c94cf495d --- /dev/null +++ b/api/datadogV2/model_incident_handle_attributes_request.go @@ -0,0 +1,145 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// IncidentHandleAttributesRequest Incident handle attributes for requests +type IncidentHandleAttributesRequest struct { + // Dynamic fields associated with the handle + Fields *IncidentHandleAttributesFields `json:"fields,omitempty"` + // The handle name + Name string `json:"name"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewIncidentHandleAttributesRequest instantiates a new IncidentHandleAttributesRequest 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 NewIncidentHandleAttributesRequest(name string) *IncidentHandleAttributesRequest { + this := IncidentHandleAttributesRequest{} + this.Name = name + return &this +} + +// NewIncidentHandleAttributesRequestWithDefaults instantiates a new IncidentHandleAttributesRequest 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 NewIncidentHandleAttributesRequestWithDefaults() *IncidentHandleAttributesRequest { + this := IncidentHandleAttributesRequest{} + return &this +} + +// GetFields returns the Fields field value if set, zero value otherwise. +func (o *IncidentHandleAttributesRequest) GetFields() IncidentHandleAttributesFields { + if o == nil || o.Fields == nil { + var ret IncidentHandleAttributesFields + return ret + } + return *o.Fields +} + +// GetFieldsOk returns a tuple with the Fields field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *IncidentHandleAttributesRequest) GetFieldsOk() (*IncidentHandleAttributesFields, bool) { + if o == nil || o.Fields == nil { + return nil, false + } + return o.Fields, true +} + +// HasFields returns a boolean if a field has been set. +func (o *IncidentHandleAttributesRequest) HasFields() bool { + return o != nil && o.Fields != nil +} + +// SetFields gets a reference to the given IncidentHandleAttributesFields and assigns it to the Fields field. +func (o *IncidentHandleAttributesRequest) SetFields(v IncidentHandleAttributesFields) { + o.Fields = &v +} + +// GetName returns the Name field value. +func (o *IncidentHandleAttributesRequest) GetName() string { + if o == nil { + var ret string + return ret + } + return o.Name +} + +// GetNameOk returns a tuple with the Name field value +// and a boolean to check if the value has been set. +func (o *IncidentHandleAttributesRequest) GetNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Name, true +} + +// SetName sets field value. +func (o *IncidentHandleAttributesRequest) SetName(v string) { + o.Name = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o IncidentHandleAttributesRequest) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Fields != nil { + toSerialize["fields"] = o.Fields + } + toSerialize["name"] = o.Name + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *IncidentHandleAttributesRequest) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Fields *IncidentHandleAttributesFields `json:"fields,omitempty"` + Name *string `json:"name"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Name == nil { + return fmt.Errorf("required field name missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"fields", "name"}) + } else { + return err + } + + hasInvalidField := false + if all.Fields != nil && all.Fields.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Fields = all.Fields + o.Name = *all.Name + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_incident_handle_attributes_response.go b/api/datadogV2/model_incident_handle_attributes_response.go new file mode 100644 index 00000000000..b338c5e85da --- /dev/null +++ b/api/datadogV2/model_incident_handle_attributes_response.go @@ -0,0 +1,215 @@ +// 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" +) + +// IncidentHandleAttributesResponse Incident handle attributes for responses +type IncidentHandleAttributesResponse struct { + // Timestamp when the handle was created + CreatedAt time.Time `json:"created_at"` + // Dynamic fields associated with the handle + Fields IncidentHandleAttributesFields `json:"fields"` + // Timestamp when the handle was last modified + ModifiedAt time.Time `json:"modified_at"` + // The handle name + Name string `json:"name"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewIncidentHandleAttributesResponse instantiates a new IncidentHandleAttributesResponse 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 NewIncidentHandleAttributesResponse(createdAt time.Time, fields IncidentHandleAttributesFields, modifiedAt time.Time, name string) *IncidentHandleAttributesResponse { + this := IncidentHandleAttributesResponse{} + this.CreatedAt = createdAt + this.Fields = fields + this.ModifiedAt = modifiedAt + this.Name = name + return &this +} + +// NewIncidentHandleAttributesResponseWithDefaults instantiates a new IncidentHandleAttributesResponse 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 NewIncidentHandleAttributesResponseWithDefaults() *IncidentHandleAttributesResponse { + this := IncidentHandleAttributesResponse{} + return &this +} + +// GetCreatedAt returns the CreatedAt field value. +func (o *IncidentHandleAttributesResponse) GetCreatedAt() time.Time { + if o == nil { + var ret time.Time + return ret + } + return o.CreatedAt +} + +// GetCreatedAtOk returns a tuple with the CreatedAt field value +// and a boolean to check if the value has been set. +func (o *IncidentHandleAttributesResponse) GetCreatedAtOk() (*time.Time, bool) { + if o == nil { + return nil, false + } + return &o.CreatedAt, true +} + +// SetCreatedAt sets field value. +func (o *IncidentHandleAttributesResponse) SetCreatedAt(v time.Time) { + o.CreatedAt = v +} + +// GetFields returns the Fields field value. +func (o *IncidentHandleAttributesResponse) GetFields() IncidentHandleAttributesFields { + if o == nil { + var ret IncidentHandleAttributesFields + return ret + } + return o.Fields +} + +// GetFieldsOk returns a tuple with the Fields field value +// and a boolean to check if the value has been set. +func (o *IncidentHandleAttributesResponse) GetFieldsOk() (*IncidentHandleAttributesFields, bool) { + if o == nil { + return nil, false + } + return &o.Fields, true +} + +// SetFields sets field value. +func (o *IncidentHandleAttributesResponse) SetFields(v IncidentHandleAttributesFields) { + o.Fields = v +} + +// GetModifiedAt returns the ModifiedAt field value. +func (o *IncidentHandleAttributesResponse) GetModifiedAt() time.Time { + if o == nil { + var ret time.Time + return ret + } + return o.ModifiedAt +} + +// GetModifiedAtOk returns a tuple with the ModifiedAt field value +// and a boolean to check if the value has been set. +func (o *IncidentHandleAttributesResponse) GetModifiedAtOk() (*time.Time, bool) { + if o == nil { + return nil, false + } + return &o.ModifiedAt, true +} + +// SetModifiedAt sets field value. +func (o *IncidentHandleAttributesResponse) SetModifiedAt(v time.Time) { + o.ModifiedAt = v +} + +// GetName returns the Name field value. +func (o *IncidentHandleAttributesResponse) GetName() string { + if o == nil { + var ret string + return ret + } + return o.Name +} + +// GetNameOk returns a tuple with the Name field value +// and a boolean to check if the value has been set. +func (o *IncidentHandleAttributesResponse) GetNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Name, true +} + +// SetName sets field value. +func (o *IncidentHandleAttributesResponse) SetName(v string) { + o.Name = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o IncidentHandleAttributesResponse) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.CreatedAt.Nanosecond() == 0 { + toSerialize["created_at"] = o.CreatedAt.Format("2006-01-02T15:04:05Z07:00") + } else { + toSerialize["created_at"] = o.CreatedAt.Format("2006-01-02T15:04:05.000Z07:00") + } + toSerialize["fields"] = o.Fields + if o.ModifiedAt.Nanosecond() == 0 { + toSerialize["modified_at"] = o.ModifiedAt.Format("2006-01-02T15:04:05Z07:00") + } else { + toSerialize["modified_at"] = o.ModifiedAt.Format("2006-01-02T15:04:05.000Z07:00") + } + toSerialize["name"] = o.Name + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *IncidentHandleAttributesResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + CreatedAt *time.Time `json:"created_at"` + Fields *IncidentHandleAttributesFields `json:"fields"` + ModifiedAt *time.Time `json:"modified_at"` + Name *string `json:"name"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.CreatedAt == nil { + return fmt.Errorf("required field created_at missing") + } + if all.Fields == nil { + return fmt.Errorf("required field fields missing") + } + if all.ModifiedAt == nil { + return fmt.Errorf("required field modified_at missing") + } + if all.Name == nil { + return fmt.Errorf("required field name missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"created_at", "fields", "modified_at", "name"}) + } else { + return err + } + + hasInvalidField := false + o.CreatedAt = *all.CreatedAt + if all.Fields.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Fields = *all.Fields + o.ModifiedAt = *all.ModifiedAt + o.Name = *all.Name + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_incident_handle_data_request.go b/api/datadogV2/model_incident_handle_data_request.go new file mode 100644 index 00000000000..80b43731edf --- /dev/null +++ b/api/datadogV2/model_incident_handle_data_request.go @@ -0,0 +1,227 @@ +// 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" +) + +// IncidentHandleDataRequest +type IncidentHandleDataRequest struct { + // Incident handle attributes for requests + Attributes IncidentHandleAttributesRequest `json:"attributes"` + // The ID of the incident handle (required for PUT requests) + Id *string `json:"id,omitempty"` + // + Relationships NullableIncidentHandleRelationshipsRequest `json:"relationships,omitempty"` + // Incident handle resource type + Type IncidentHandleType `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:"-"` +} + +// NewIncidentHandleDataRequest instantiates a new IncidentHandleDataRequest 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 NewIncidentHandleDataRequest(attributes IncidentHandleAttributesRequest, typeVar IncidentHandleType) *IncidentHandleDataRequest { + this := IncidentHandleDataRequest{} + this.Attributes = attributes + this.Type = typeVar + return &this +} + +// NewIncidentHandleDataRequestWithDefaults instantiates a new IncidentHandleDataRequest 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 NewIncidentHandleDataRequestWithDefaults() *IncidentHandleDataRequest { + this := IncidentHandleDataRequest{} + return &this +} + +// GetAttributes returns the Attributes field value. +func (o *IncidentHandleDataRequest) GetAttributes() IncidentHandleAttributesRequest { + if o == nil { + var ret IncidentHandleAttributesRequest + return ret + } + return o.Attributes +} + +// GetAttributesOk returns a tuple with the Attributes field value +// and a boolean to check if the value has been set. +func (o *IncidentHandleDataRequest) GetAttributesOk() (*IncidentHandleAttributesRequest, bool) { + if o == nil { + return nil, false + } + return &o.Attributes, true +} + +// SetAttributes sets field value. +func (o *IncidentHandleDataRequest) SetAttributes(v IncidentHandleAttributesRequest) { + o.Attributes = v +} + +// GetId returns the Id field value if set, zero value otherwise. +func (o *IncidentHandleDataRequest) GetId() string { + if o == nil || o.Id == nil { + var ret string + return ret + } + return *o.Id +} + +// GetIdOk returns a tuple with the Id field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *IncidentHandleDataRequest) GetIdOk() (*string, bool) { + if o == nil || o.Id == nil { + return nil, false + } + return o.Id, true +} + +// HasId returns a boolean if a field has been set. +func (o *IncidentHandleDataRequest) HasId() bool { + return o != nil && o.Id != nil +} + +// SetId gets a reference to the given string and assigns it to the Id field. +func (o *IncidentHandleDataRequest) SetId(v string) { + o.Id = &v +} + +// GetRelationships returns the Relationships field value if set, zero value otherwise (both if not set or set to explicit null). +func (o *IncidentHandleDataRequest) GetRelationships() IncidentHandleRelationshipsRequest { + if o == nil || o.Relationships.Get() == nil { + var ret IncidentHandleRelationshipsRequest + return ret + } + return *o.Relationships.Get() +} + +// GetRelationshipsOk returns a tuple with the Relationships field value if set, nil otherwise +// and a boolean to check if the value has been set. +// NOTE: If the value is an explicit nil, `nil, true` will be returned. +func (o *IncidentHandleDataRequest) GetRelationshipsOk() (*IncidentHandleRelationshipsRequest, bool) { + if o == nil { + return nil, false + } + return o.Relationships.Get(), o.Relationships.IsSet() +} + +// HasRelationships returns a boolean if a field has been set. +func (o *IncidentHandleDataRequest) HasRelationships() bool { + return o != nil && o.Relationships.IsSet() +} + +// SetRelationships gets a reference to the given NullableIncidentHandleRelationshipsRequest and assigns it to the Relationships field. +func (o *IncidentHandleDataRequest) SetRelationships(v IncidentHandleRelationshipsRequest) { + o.Relationships.Set(&v) +} + +// SetRelationshipsNil sets the value for Relationships to be an explicit nil. +func (o *IncidentHandleDataRequest) SetRelationshipsNil() { + o.Relationships.Set(nil) +} + +// UnsetRelationships ensures that no value is present for Relationships, not even an explicit nil. +func (o *IncidentHandleDataRequest) UnsetRelationships() { + o.Relationships.Unset() +} + +// GetType returns the Type field value. +func (o *IncidentHandleDataRequest) GetType() IncidentHandleType { + if o == nil { + var ret IncidentHandleType + 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 *IncidentHandleDataRequest) GetTypeOk() (*IncidentHandleType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *IncidentHandleDataRequest) SetType(v IncidentHandleType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o IncidentHandleDataRequest) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["attributes"] = o.Attributes + if o.Id != nil { + toSerialize["id"] = o.Id + } + if o.Relationships.IsSet() { + toSerialize["relationships"] = o.Relationships.Get() + } + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *IncidentHandleDataRequest) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *IncidentHandleAttributesRequest `json:"attributes"` + Id *string `json:"id,omitempty"` + Relationships NullableIncidentHandleRelationshipsRequest `json:"relationships,omitempty"` + Type *IncidentHandleType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Attributes == nil { + return fmt.Errorf("required field attributes missing") + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "id", "relationships", "type"}) + } else { + return err + } + + hasInvalidField := false + if all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Attributes = *all.Attributes + o.Id = all.Id + o.Relationships = all.Relationships + if !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = *all.Type + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_incident_handle_data_response.go b/api/datadogV2/model_incident_handle_data_response.go new file mode 100644 index 00000000000..0e348842709 --- /dev/null +++ b/api/datadogV2/model_incident_handle_data_response.go @@ -0,0 +1,224 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// IncidentHandleDataResponse +type IncidentHandleDataResponse struct { + // Incident handle attributes for responses + Attributes IncidentHandleAttributesResponse `json:"attributes"` + // The ID of the incident handle + Id string `json:"id"` + // + Relationships NullableIncidentHandleRelationships `json:"relationships,omitempty"` + // Incident handle resource type + Type IncidentHandleType `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:"-"` +} + +// NewIncidentHandleDataResponse instantiates a new IncidentHandleDataResponse 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 NewIncidentHandleDataResponse(attributes IncidentHandleAttributesResponse, id string, typeVar IncidentHandleType) *IncidentHandleDataResponse { + this := IncidentHandleDataResponse{} + this.Attributes = attributes + this.Id = id + this.Type = typeVar + return &this +} + +// NewIncidentHandleDataResponseWithDefaults instantiates a new IncidentHandleDataResponse 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 NewIncidentHandleDataResponseWithDefaults() *IncidentHandleDataResponse { + this := IncidentHandleDataResponse{} + return &this +} + +// GetAttributes returns the Attributes field value. +func (o *IncidentHandleDataResponse) GetAttributes() IncidentHandleAttributesResponse { + if o == nil { + var ret IncidentHandleAttributesResponse + return ret + } + return o.Attributes +} + +// GetAttributesOk returns a tuple with the Attributes field value +// and a boolean to check if the value has been set. +func (o *IncidentHandleDataResponse) GetAttributesOk() (*IncidentHandleAttributesResponse, bool) { + if o == nil { + return nil, false + } + return &o.Attributes, true +} + +// SetAttributes sets field value. +func (o *IncidentHandleDataResponse) SetAttributes(v IncidentHandleAttributesResponse) { + o.Attributes = v +} + +// GetId returns the Id field value. +func (o *IncidentHandleDataResponse) 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 *IncidentHandleDataResponse) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Id, true +} + +// SetId sets field value. +func (o *IncidentHandleDataResponse) SetId(v string) { + o.Id = v +} + +// GetRelationships returns the Relationships field value if set, zero value otherwise (both if not set or set to explicit null). +func (o *IncidentHandleDataResponse) GetRelationships() IncidentHandleRelationships { + if o == nil || o.Relationships.Get() == nil { + var ret IncidentHandleRelationships + return ret + } + return *o.Relationships.Get() +} + +// GetRelationshipsOk returns a tuple with the Relationships field value if set, nil otherwise +// and a boolean to check if the value has been set. +// NOTE: If the value is an explicit nil, `nil, true` will be returned. +func (o *IncidentHandleDataResponse) GetRelationshipsOk() (*IncidentHandleRelationships, bool) { + if o == nil { + return nil, false + } + return o.Relationships.Get(), o.Relationships.IsSet() +} + +// HasRelationships returns a boolean if a field has been set. +func (o *IncidentHandleDataResponse) HasRelationships() bool { + return o != nil && o.Relationships.IsSet() +} + +// SetRelationships gets a reference to the given NullableIncidentHandleRelationships and assigns it to the Relationships field. +func (o *IncidentHandleDataResponse) SetRelationships(v IncidentHandleRelationships) { + o.Relationships.Set(&v) +} + +// SetRelationshipsNil sets the value for Relationships to be an explicit nil. +func (o *IncidentHandleDataResponse) SetRelationshipsNil() { + o.Relationships.Set(nil) +} + +// UnsetRelationships ensures that no value is present for Relationships, not even an explicit nil. +func (o *IncidentHandleDataResponse) UnsetRelationships() { + o.Relationships.Unset() +} + +// GetType returns the Type field value. +func (o *IncidentHandleDataResponse) GetType() IncidentHandleType { + if o == nil { + var ret IncidentHandleType + 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 *IncidentHandleDataResponse) GetTypeOk() (*IncidentHandleType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *IncidentHandleDataResponse) SetType(v IncidentHandleType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o IncidentHandleDataResponse) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["attributes"] = o.Attributes + toSerialize["id"] = o.Id + if o.Relationships.IsSet() { + toSerialize["relationships"] = o.Relationships.Get() + } + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *IncidentHandleDataResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *IncidentHandleAttributesResponse `json:"attributes"` + Id *string `json:"id"` + Relationships NullableIncidentHandleRelationships `json:"relationships,omitempty"` + Type *IncidentHandleType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Attributes == nil { + return fmt.Errorf("required field attributes missing") + } + if all.Id == nil { + return fmt.Errorf("required field id missing") + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "id", "relationships", "type"}) + } else { + return err + } + + hasInvalidField := false + if all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Attributes = *all.Attributes + o.Id = *all.Id + o.Relationships = all.Relationships + if !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = *all.Type + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_incident_handle_included_item_response.go b/api/datadogV2/model_incident_handle_included_item_response.go new file mode 100644 index 00000000000..18d73a90d42 --- /dev/null +++ b/api/datadogV2/model_incident_handle_included_item_response.go @@ -0,0 +1,105 @@ +// 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" +) + +// IncidentHandleIncludedItemResponse - +type IncidentHandleIncludedItemResponse struct { + IncidentUserData *IncidentUserData + IncidentTypeObject *IncidentTypeObject + + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject interface{} +} + +// IncidentUserDataAsIncidentHandleIncludedItemResponse is a convenience function that returns IncidentUserData wrapped in IncidentHandleIncludedItemResponse. +func IncidentUserDataAsIncidentHandleIncludedItemResponse(v *IncidentUserData) IncidentHandleIncludedItemResponse { + return IncidentHandleIncludedItemResponse{IncidentUserData: v} +} + +// IncidentTypeObjectAsIncidentHandleIncludedItemResponse is a convenience function that returns IncidentTypeObject wrapped in IncidentHandleIncludedItemResponse. +func IncidentTypeObjectAsIncidentHandleIncludedItemResponse(v *IncidentTypeObject) IncidentHandleIncludedItemResponse { + return IncidentHandleIncludedItemResponse{IncidentTypeObject: v} +} + +// UnmarshalJSON turns data into one of the pointers in the struct. +func (obj *IncidentHandleIncludedItemResponse) UnmarshalJSON(data []byte) error { + var err error + match := 0 + // try to unmarshal data into IncidentUserData + err = datadog.Unmarshal(data, &obj.IncidentUserData) + if err == nil { + if obj.IncidentUserData != nil && obj.IncidentUserData.UnparsedObject == nil { + jsonIncidentUserData, _ := datadog.Marshal(obj.IncidentUserData) + if string(jsonIncidentUserData) == "{}" && string(data) != "{}" { // empty struct + obj.IncidentUserData = nil + } else { + match++ + } + } else { + obj.IncidentUserData = nil + } + } else { + obj.IncidentUserData = nil + } + + // try to unmarshal data into IncidentTypeObject + err = datadog.Unmarshal(data, &obj.IncidentTypeObject) + if err == nil { + if obj.IncidentTypeObject != nil && obj.IncidentTypeObject.UnparsedObject == nil { + jsonIncidentTypeObject, _ := datadog.Marshal(obj.IncidentTypeObject) + if string(jsonIncidentTypeObject) == "{}" { // empty struct + obj.IncidentTypeObject = nil + } else { + match++ + } + } else { + obj.IncidentTypeObject = nil + } + } else { + obj.IncidentTypeObject = nil + } + + if match != 1 { // more than 1 match + // reset to nil + obj.IncidentUserData = nil + obj.IncidentTypeObject = nil + return datadog.Unmarshal(data, &obj.UnparsedObject) + } + return nil // exactly one match +} + +// MarshalJSON turns data from the first non-nil pointers in the struct to JSON. +func (obj IncidentHandleIncludedItemResponse) MarshalJSON() ([]byte, error) { + if obj.IncidentUserData != nil { + return datadog.Marshal(&obj.IncidentUserData) + } + + if obj.IncidentTypeObject != nil { + return datadog.Marshal(&obj.IncidentTypeObject) + } + + if obj.UnparsedObject != nil { + return datadog.Marshal(obj.UnparsedObject) + } + return nil, nil // no data in oneOf schemas +} + +// GetActualInstance returns the actual instance. +func (obj *IncidentHandleIncludedItemResponse) GetActualInstance() interface{} { + if obj.IncidentUserData != nil { + return obj.IncidentUserData + } + + if obj.IncidentTypeObject != nil { + return obj.IncidentTypeObject + } + + // all schemas are nil + return nil +} diff --git a/api/datadogV2/model_incident_handle_relationship.go b/api/datadogV2/model_incident_handle_relationship.go new file mode 100644 index 00000000000..70d6ce0cb59 --- /dev/null +++ b/api/datadogV2/model_incident_handle_relationship.go @@ -0,0 +1,110 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// IncidentHandleRelationship +type IncidentHandleRelationship struct { + // + Data IncidentHandleRelationshipData `json:"data"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewIncidentHandleRelationship instantiates a new IncidentHandleRelationship 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 NewIncidentHandleRelationship(data IncidentHandleRelationshipData) *IncidentHandleRelationship { + this := IncidentHandleRelationship{} + this.Data = data + return &this +} + +// NewIncidentHandleRelationshipWithDefaults instantiates a new IncidentHandleRelationship 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 NewIncidentHandleRelationshipWithDefaults() *IncidentHandleRelationship { + this := IncidentHandleRelationship{} + return &this +} + +// GetData returns the Data field value. +func (o *IncidentHandleRelationship) GetData() IncidentHandleRelationshipData { + if o == nil { + var ret IncidentHandleRelationshipData + return ret + } + return o.Data +} + +// GetDataOk returns a tuple with the Data field value +// and a boolean to check if the value has been set. +func (o *IncidentHandleRelationship) GetDataOk() (*IncidentHandleRelationshipData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *IncidentHandleRelationship) SetData(v IncidentHandleRelationshipData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o IncidentHandleRelationship) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["data"] = o.Data + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *IncidentHandleRelationship) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *IncidentHandleRelationshipData `json:"data"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Data == nil { + return fmt.Errorf("required field data missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + + hasInvalidField := false + if all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Data = *all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_incident_handle_relationship_data.go b/api/datadogV2/model_incident_handle_relationship_data.go new file mode 100644 index 00000000000..b76cd6dd561 --- /dev/null +++ b/api/datadogV2/model_incident_handle_relationship_data.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" +) + +// IncidentHandleRelationshipData +type IncidentHandleRelationshipData struct { + // The ID of the related resource + Id string `json:"id"` + // The type of the related resource + Type string `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:"-"` +} + +// NewIncidentHandleRelationshipData instantiates a new IncidentHandleRelationshipData 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 NewIncidentHandleRelationshipData(id string, typeVar string) *IncidentHandleRelationshipData { + this := IncidentHandleRelationshipData{} + this.Id = id + this.Type = typeVar + return &this +} + +// NewIncidentHandleRelationshipDataWithDefaults instantiates a new IncidentHandleRelationshipData 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 NewIncidentHandleRelationshipDataWithDefaults() *IncidentHandleRelationshipData { + this := IncidentHandleRelationshipData{} + return &this +} + +// GetId returns the Id field value. +func (o *IncidentHandleRelationshipData) 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 *IncidentHandleRelationshipData) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Id, true +} + +// SetId sets field value. +func (o *IncidentHandleRelationshipData) SetId(v string) { + o.Id = v +} + +// GetType returns the Type field value. +func (o *IncidentHandleRelationshipData) GetType() string { + if o == nil { + var ret string + 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 *IncidentHandleRelationshipData) GetTypeOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *IncidentHandleRelationshipData) SetType(v string) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o IncidentHandleRelationshipData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["id"] = o.Id + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *IncidentHandleRelationshipData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Id *string `json:"id"` + Type *string `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Id == nil { + return fmt.Errorf("required field id missing") + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"id", "type"}) + } else { + return err + } + o.Id = *all.Id + o.Type = *all.Type + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_incident_handle_relationships.go b/api/datadogV2/model_incident_handle_relationships.go new file mode 100644 index 00000000000..69159ac5f1e --- /dev/null +++ b/api/datadogV2/model_incident_handle_relationships.go @@ -0,0 +1,268 @@ +// 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" +) + +// IncidentHandleRelationships +type IncidentHandleRelationships struct { + // + CommanderUser *IncidentHandleRelationship `json:"commander_user,omitempty"` + // + CreatedByUser IncidentHandleRelationship `json:"created_by_user"` + // + IncidentType IncidentHandleRelationship `json:"incident_type"` + // + LastModifiedByUser IncidentHandleRelationship `json:"last_modified_by_user"` + // 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:"-"` +} + +// NewIncidentHandleRelationships instantiates a new IncidentHandleRelationships 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 NewIncidentHandleRelationships(createdByUser IncidentHandleRelationship, incidentType IncidentHandleRelationship, lastModifiedByUser IncidentHandleRelationship) *IncidentHandleRelationships { + this := IncidentHandleRelationships{} + this.CreatedByUser = createdByUser + this.IncidentType = incidentType + this.LastModifiedByUser = lastModifiedByUser + return &this +} + +// NewIncidentHandleRelationshipsWithDefaults instantiates a new IncidentHandleRelationships 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 NewIncidentHandleRelationshipsWithDefaults() *IncidentHandleRelationships { + this := IncidentHandleRelationships{} + return &this +} + +// GetCommanderUser returns the CommanderUser field value if set, zero value otherwise. +func (o *IncidentHandleRelationships) GetCommanderUser() IncidentHandleRelationship { + if o == nil || o.CommanderUser == nil { + var ret IncidentHandleRelationship + return ret + } + return *o.CommanderUser +} + +// GetCommanderUserOk returns a tuple with the CommanderUser field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *IncidentHandleRelationships) GetCommanderUserOk() (*IncidentHandleRelationship, bool) { + if o == nil || o.CommanderUser == nil { + return nil, false + } + return o.CommanderUser, true +} + +// HasCommanderUser returns a boolean if a field has been set. +func (o *IncidentHandleRelationships) HasCommanderUser() bool { + return o != nil && o.CommanderUser != nil +} + +// SetCommanderUser gets a reference to the given IncidentHandleRelationship and assigns it to the CommanderUser field. +func (o *IncidentHandleRelationships) SetCommanderUser(v IncidentHandleRelationship) { + o.CommanderUser = &v +} + +// GetCreatedByUser returns the CreatedByUser field value. +func (o *IncidentHandleRelationships) GetCreatedByUser() IncidentHandleRelationship { + if o == nil { + var ret IncidentHandleRelationship + return ret + } + return o.CreatedByUser +} + +// GetCreatedByUserOk returns a tuple with the CreatedByUser field value +// and a boolean to check if the value has been set. +func (o *IncidentHandleRelationships) GetCreatedByUserOk() (*IncidentHandleRelationship, bool) { + if o == nil { + return nil, false + } + return &o.CreatedByUser, true +} + +// SetCreatedByUser sets field value. +func (o *IncidentHandleRelationships) SetCreatedByUser(v IncidentHandleRelationship) { + o.CreatedByUser = v +} + +// GetIncidentType returns the IncidentType field value. +func (o *IncidentHandleRelationships) GetIncidentType() IncidentHandleRelationship { + if o == nil { + var ret IncidentHandleRelationship + return ret + } + return o.IncidentType +} + +// GetIncidentTypeOk returns a tuple with the IncidentType field value +// and a boolean to check if the value has been set. +func (o *IncidentHandleRelationships) GetIncidentTypeOk() (*IncidentHandleRelationship, bool) { + if o == nil { + return nil, false + } + return &o.IncidentType, true +} + +// SetIncidentType sets field value. +func (o *IncidentHandleRelationships) SetIncidentType(v IncidentHandleRelationship) { + o.IncidentType = v +} + +// GetLastModifiedByUser returns the LastModifiedByUser field value. +func (o *IncidentHandleRelationships) GetLastModifiedByUser() IncidentHandleRelationship { + if o == nil { + var ret IncidentHandleRelationship + return ret + } + return o.LastModifiedByUser +} + +// GetLastModifiedByUserOk returns a tuple with the LastModifiedByUser field value +// and a boolean to check if the value has been set. +func (o *IncidentHandleRelationships) GetLastModifiedByUserOk() (*IncidentHandleRelationship, bool) { + if o == nil { + return nil, false + } + return &o.LastModifiedByUser, true +} + +// SetLastModifiedByUser sets field value. +func (o *IncidentHandleRelationships) SetLastModifiedByUser(v IncidentHandleRelationship) { + o.LastModifiedByUser = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o IncidentHandleRelationships) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.CommanderUser != nil { + toSerialize["commander_user"] = o.CommanderUser + } + toSerialize["created_by_user"] = o.CreatedByUser + toSerialize["incident_type"] = o.IncidentType + toSerialize["last_modified_by_user"] = o.LastModifiedByUser + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *IncidentHandleRelationships) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + CommanderUser *IncidentHandleRelationship `json:"commander_user,omitempty"` + CreatedByUser *IncidentHandleRelationship `json:"created_by_user"` + IncidentType *IncidentHandleRelationship `json:"incident_type"` + LastModifiedByUser *IncidentHandleRelationship `json:"last_modified_by_user"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.CreatedByUser == nil { + return fmt.Errorf("required field created_by_user missing") + } + if all.IncidentType == nil { + return fmt.Errorf("required field incident_type missing") + } + if all.LastModifiedByUser == nil { + return fmt.Errorf("required field last_modified_by_user missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"commander_user", "created_by_user", "incident_type", "last_modified_by_user"}) + } else { + return err + } + + hasInvalidField := false + if all.CommanderUser != nil && all.CommanderUser.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.CommanderUser = all.CommanderUser + if all.CreatedByUser.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.CreatedByUser = *all.CreatedByUser + if all.IncidentType.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.IncidentType = *all.IncidentType + if all.LastModifiedByUser.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.LastModifiedByUser = *all.LastModifiedByUser + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} + +// NullableIncidentHandleRelationships handles when a null is used for IncidentHandleRelationships. +type NullableIncidentHandleRelationships struct { + value *IncidentHandleRelationships + isSet bool +} + +// Get returns the associated value. +func (v NullableIncidentHandleRelationships) Get() *IncidentHandleRelationships { + return v.value +} + +// Set changes the value and indicates it's been called. +func (v *NullableIncidentHandleRelationships) Set(val *IncidentHandleRelationships) { + v.value = val + v.isSet = true +} + +// IsSet returns whether Set has been called. +func (v NullableIncidentHandleRelationships) IsSet() bool { + return v.isSet +} + +// Unset sets the value to nil and resets the set flag/ +func (v *NullableIncidentHandleRelationships) Unset() { + v.value = nil + v.isSet = false +} + +// NewNullableIncidentHandleRelationships initializes the struct as if Set has been called. +func NewNullableIncidentHandleRelationships(val *IncidentHandleRelationships) *NullableIncidentHandleRelationships { + return &NullableIncidentHandleRelationships{value: val, isSet: true} +} + +// MarshalJSON serializes the associated value. +func (v NullableIncidentHandleRelationships) MarshalJSON() ([]byte, error) { + return datadog.Marshal(v.value) +} + +// UnmarshalJSON deserializes the payload and sets the flag as if Set has been called. +func (v *NullableIncidentHandleRelationships) UnmarshalJSON(src []byte) error { + v.isSet = true + + // this object is nullable so check if the payload is null or empty string + if string(src) == "" || string(src) == "{}" { + return nil + } + + return datadog.Unmarshal(src, &v.value) +} diff --git a/api/datadogV2/model_incident_handle_relationships_request.go b/api/datadogV2/model_incident_handle_relationships_request.go new file mode 100644 index 00000000000..74d20f215aa --- /dev/null +++ b/api/datadogV2/model_incident_handle_relationships_request.go @@ -0,0 +1,198 @@ +// 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" +) + +// IncidentHandleRelationshipsRequest +type IncidentHandleRelationshipsRequest struct { + // + CommanderUser *IncidentHandleRelationship `json:"commander_user,omitempty"` + // + IncidentType IncidentHandleRelationship `json:"incident_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:"-"` +} + +// NewIncidentHandleRelationshipsRequest instantiates a new IncidentHandleRelationshipsRequest 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 NewIncidentHandleRelationshipsRequest(incidentType IncidentHandleRelationship) *IncidentHandleRelationshipsRequest { + this := IncidentHandleRelationshipsRequest{} + this.IncidentType = incidentType + return &this +} + +// NewIncidentHandleRelationshipsRequestWithDefaults instantiates a new IncidentHandleRelationshipsRequest 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 NewIncidentHandleRelationshipsRequestWithDefaults() *IncidentHandleRelationshipsRequest { + this := IncidentHandleRelationshipsRequest{} + return &this +} + +// GetCommanderUser returns the CommanderUser field value if set, zero value otherwise. +func (o *IncidentHandleRelationshipsRequest) GetCommanderUser() IncidentHandleRelationship { + if o == nil || o.CommanderUser == nil { + var ret IncidentHandleRelationship + return ret + } + return *o.CommanderUser +} + +// GetCommanderUserOk returns a tuple with the CommanderUser field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *IncidentHandleRelationshipsRequest) GetCommanderUserOk() (*IncidentHandleRelationship, bool) { + if o == nil || o.CommanderUser == nil { + return nil, false + } + return o.CommanderUser, true +} + +// HasCommanderUser returns a boolean if a field has been set. +func (o *IncidentHandleRelationshipsRequest) HasCommanderUser() bool { + return o != nil && o.CommanderUser != nil +} + +// SetCommanderUser gets a reference to the given IncidentHandleRelationship and assigns it to the CommanderUser field. +func (o *IncidentHandleRelationshipsRequest) SetCommanderUser(v IncidentHandleRelationship) { + o.CommanderUser = &v +} + +// GetIncidentType returns the IncidentType field value. +func (o *IncidentHandleRelationshipsRequest) GetIncidentType() IncidentHandleRelationship { + if o == nil { + var ret IncidentHandleRelationship + return ret + } + return o.IncidentType +} + +// GetIncidentTypeOk returns a tuple with the IncidentType field value +// and a boolean to check if the value has been set. +func (o *IncidentHandleRelationshipsRequest) GetIncidentTypeOk() (*IncidentHandleRelationship, bool) { + if o == nil { + return nil, false + } + return &o.IncidentType, true +} + +// SetIncidentType sets field value. +func (o *IncidentHandleRelationshipsRequest) SetIncidentType(v IncidentHandleRelationship) { + o.IncidentType = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o IncidentHandleRelationshipsRequest) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.CommanderUser != nil { + toSerialize["commander_user"] = o.CommanderUser + } + toSerialize["incident_type"] = o.IncidentType + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *IncidentHandleRelationshipsRequest) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + CommanderUser *IncidentHandleRelationship `json:"commander_user,omitempty"` + IncidentType *IncidentHandleRelationship `json:"incident_type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.IncidentType == nil { + return fmt.Errorf("required field incident_type missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"commander_user", "incident_type"}) + } else { + return err + } + + hasInvalidField := false + if all.CommanderUser != nil && all.CommanderUser.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.CommanderUser = all.CommanderUser + if all.IncidentType.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.IncidentType = *all.IncidentType + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} + +// NullableIncidentHandleRelationshipsRequest handles when a null is used for IncidentHandleRelationshipsRequest. +type NullableIncidentHandleRelationshipsRequest struct { + value *IncidentHandleRelationshipsRequest + isSet bool +} + +// Get returns the associated value. +func (v NullableIncidentHandleRelationshipsRequest) Get() *IncidentHandleRelationshipsRequest { + return v.value +} + +// Set changes the value and indicates it's been called. +func (v *NullableIncidentHandleRelationshipsRequest) Set(val *IncidentHandleRelationshipsRequest) { + v.value = val + v.isSet = true +} + +// IsSet returns whether Set has been called. +func (v NullableIncidentHandleRelationshipsRequest) IsSet() bool { + return v.isSet +} + +// Unset sets the value to nil and resets the set flag/ +func (v *NullableIncidentHandleRelationshipsRequest) Unset() { + v.value = nil + v.isSet = false +} + +// NewNullableIncidentHandleRelationshipsRequest initializes the struct as if Set has been called. +func NewNullableIncidentHandleRelationshipsRequest(val *IncidentHandleRelationshipsRequest) *NullableIncidentHandleRelationshipsRequest { + return &NullableIncidentHandleRelationshipsRequest{value: val, isSet: true} +} + +// MarshalJSON serializes the associated value. +func (v NullableIncidentHandleRelationshipsRequest) MarshalJSON() ([]byte, error) { + return datadog.Marshal(v.value) +} + +// UnmarshalJSON deserializes the payload and sets the flag as if Set has been called. +func (v *NullableIncidentHandleRelationshipsRequest) UnmarshalJSON(src []byte) error { + v.isSet = true + + // this object is nullable so check if the payload is null or empty string + if string(src) == "" || string(src) == "{}" { + return nil + } + + return datadog.Unmarshal(src, &v.value) +} diff --git a/api/datadogV2/model_incident_handle_request.go b/api/datadogV2/model_incident_handle_request.go new file mode 100644 index 00000000000..bad567a170d --- /dev/null +++ b/api/datadogV2/model_incident_handle_request.go @@ -0,0 +1,110 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// IncidentHandleRequest +type IncidentHandleRequest struct { + // + Data IncidentHandleDataRequest `json:"data"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewIncidentHandleRequest instantiates a new IncidentHandleRequest 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 NewIncidentHandleRequest(data IncidentHandleDataRequest) *IncidentHandleRequest { + this := IncidentHandleRequest{} + this.Data = data + return &this +} + +// NewIncidentHandleRequestWithDefaults instantiates a new IncidentHandleRequest 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 NewIncidentHandleRequestWithDefaults() *IncidentHandleRequest { + this := IncidentHandleRequest{} + return &this +} + +// GetData returns the Data field value. +func (o *IncidentHandleRequest) GetData() IncidentHandleDataRequest { + if o == nil { + var ret IncidentHandleDataRequest + return ret + } + return o.Data +} + +// GetDataOk returns a tuple with the Data field value +// and a boolean to check if the value has been set. +func (o *IncidentHandleRequest) GetDataOk() (*IncidentHandleDataRequest, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *IncidentHandleRequest) SetData(v IncidentHandleDataRequest) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o IncidentHandleRequest) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["data"] = o.Data + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *IncidentHandleRequest) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *IncidentHandleDataRequest `json:"data"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Data == nil { + return fmt.Errorf("required field data missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + + hasInvalidField := false + if all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Data = *all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_incident_handle_response.go b/api/datadogV2/model_incident_handle_response.go new file mode 100644 index 00000000000..28ad419a321 --- /dev/null +++ b/api/datadogV2/model_incident_handle_response.go @@ -0,0 +1,145 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// IncidentHandleResponse +type IncidentHandleResponse struct { + // + Data IncidentHandleDataResponse `json:"data"` + // Included related resources + Included []IncidentHandleIncludedItemResponse `json:"included,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewIncidentHandleResponse instantiates a new IncidentHandleResponse 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 NewIncidentHandleResponse(data IncidentHandleDataResponse) *IncidentHandleResponse { + this := IncidentHandleResponse{} + this.Data = data + return &this +} + +// NewIncidentHandleResponseWithDefaults instantiates a new IncidentHandleResponse 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 NewIncidentHandleResponseWithDefaults() *IncidentHandleResponse { + this := IncidentHandleResponse{} + return &this +} + +// GetData returns the Data field value. +func (o *IncidentHandleResponse) GetData() IncidentHandleDataResponse { + if o == nil { + var ret IncidentHandleDataResponse + return ret + } + return o.Data +} + +// GetDataOk returns a tuple with the Data field value +// and a boolean to check if the value has been set. +func (o *IncidentHandleResponse) GetDataOk() (*IncidentHandleDataResponse, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *IncidentHandleResponse) SetData(v IncidentHandleDataResponse) { + o.Data = v +} + +// GetIncluded returns the Included field value if set, zero value otherwise. +func (o *IncidentHandleResponse) GetIncluded() []IncidentHandleIncludedItemResponse { + if o == nil || o.Included == nil { + var ret []IncidentHandleIncludedItemResponse + return ret + } + return o.Included +} + +// GetIncludedOk returns a tuple with the Included field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *IncidentHandleResponse) GetIncludedOk() (*[]IncidentHandleIncludedItemResponse, bool) { + if o == nil || o.Included == nil { + return nil, false + } + return &o.Included, true +} + +// HasIncluded returns a boolean if a field has been set. +func (o *IncidentHandleResponse) HasIncluded() bool { + return o != nil && o.Included != nil +} + +// SetIncluded gets a reference to the given []IncidentHandleIncludedItemResponse and assigns it to the Included field. +func (o *IncidentHandleResponse) SetIncluded(v []IncidentHandleIncludedItemResponse) { + o.Included = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o IncidentHandleResponse) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["data"] = o.Data + if o.Included != nil { + toSerialize["included"] = o.Included + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *IncidentHandleResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *IncidentHandleDataResponse `json:"data"` + Included []IncidentHandleIncludedItemResponse `json:"included,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Data == nil { + return fmt.Errorf("required field data missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data", "included"}) + } else { + return err + } + + hasInvalidField := false + if all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Data = *all.Data + o.Included = all.Included + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_incident_handle_type.go b/api/datadogV2/model_incident_handle_type.go new file mode 100644 index 00000000000..88c327d0d5d --- /dev/null +++ b/api/datadogV2/model_incident_handle_type.go @@ -0,0 +1,64 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// IncidentHandleType Incident handle resource type +type IncidentHandleType string + +// List of IncidentHandleType. +const ( + INCIDENTHANDLETYPE_INCIDENTS_HANDLES IncidentHandleType = "incidents_handles" +) + +var allowedIncidentHandleTypeEnumValues = []IncidentHandleType{ + INCIDENTHANDLETYPE_INCIDENTS_HANDLES, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *IncidentHandleType) GetAllowedValues() []IncidentHandleType { + return allowedIncidentHandleTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *IncidentHandleType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = IncidentHandleType(value) + return nil +} + +// NewIncidentHandleTypeFromValue returns a pointer to a valid IncidentHandleType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewIncidentHandleTypeFromValue(v string) (*IncidentHandleType, error) { + ev := IncidentHandleType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for IncidentHandleType: valid values are %v", v, allowedIncidentHandleTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v IncidentHandleType) IsValid() bool { + for _, existing := range allowedIncidentHandleTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to IncidentHandleType value. +func (v IncidentHandleType) Ptr() *IncidentHandleType { + return &v +} diff --git a/api/datadogV2/model_incident_handles_response.go b/api/datadogV2/model_incident_handles_response.go new file mode 100644 index 00000000000..37b9a57445e --- /dev/null +++ b/api/datadogV2/model_incident_handles_response.go @@ -0,0 +1,136 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// IncidentHandlesResponse +type IncidentHandlesResponse struct { + // + Data []IncidentHandleDataResponse `json:"data"` + // Included related resources + Included []IncidentHandleIncludedItemResponse `json:"included,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewIncidentHandlesResponse instantiates a new IncidentHandlesResponse 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 NewIncidentHandlesResponse(data []IncidentHandleDataResponse) *IncidentHandlesResponse { + this := IncidentHandlesResponse{} + this.Data = data + return &this +} + +// NewIncidentHandlesResponseWithDefaults instantiates a new IncidentHandlesResponse 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 NewIncidentHandlesResponseWithDefaults() *IncidentHandlesResponse { + this := IncidentHandlesResponse{} + return &this +} + +// GetData returns the Data field value. +func (o *IncidentHandlesResponse) GetData() []IncidentHandleDataResponse { + if o == nil { + var ret []IncidentHandleDataResponse + return ret + } + return o.Data +} + +// GetDataOk returns a tuple with the Data field value +// and a boolean to check if the value has been set. +func (o *IncidentHandlesResponse) GetDataOk() (*[]IncidentHandleDataResponse, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *IncidentHandlesResponse) SetData(v []IncidentHandleDataResponse) { + o.Data = v +} + +// GetIncluded returns the Included field value if set, zero value otherwise. +func (o *IncidentHandlesResponse) GetIncluded() []IncidentHandleIncludedItemResponse { + if o == nil || o.Included == nil { + var ret []IncidentHandleIncludedItemResponse + return ret + } + return o.Included +} + +// GetIncludedOk returns a tuple with the Included field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *IncidentHandlesResponse) GetIncludedOk() (*[]IncidentHandleIncludedItemResponse, bool) { + if o == nil || o.Included == nil { + return nil, false + } + return &o.Included, true +} + +// HasIncluded returns a boolean if a field has been set. +func (o *IncidentHandlesResponse) HasIncluded() bool { + return o != nil && o.Included != nil +} + +// SetIncluded gets a reference to the given []IncidentHandleIncludedItemResponse and assigns it to the Included field. +func (o *IncidentHandlesResponse) SetIncluded(v []IncidentHandleIncludedItemResponse) { + o.Included = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o IncidentHandlesResponse) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["data"] = o.Data + if o.Included != nil { + toSerialize["included"] = o.Included + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *IncidentHandlesResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *[]IncidentHandleDataResponse `json:"data"` + Included []IncidentHandleIncludedItemResponse `json:"included,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Data == nil { + return fmt.Errorf("required field data missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data", "included"}) + } else { + return err + } + o.Data = *all.Data + o.Included = all.Included + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/examples/v1/dashboards/CreateDashboard_1259346254.go b/examples/v1/dashboards/CreateDashboard_1259346254.go new file mode 100644 index 00000000000..30b5ef91d42 --- /dev/null +++ b/examples/v1/dashboards/CreateDashboard_1259346254.go @@ -0,0 +1,51 @@ +// Create a new dashboard with timeseries widget using order_by values + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV1" +) + +func main() { + body := datadogV1.Dashboard{ + LayoutType: datadogV1.DASHBOARDLAYOUTTYPE_ORDERED, + Title: "Example-Dashboard with order_by values", + Widgets: []datadogV1.Widget{ + { + Definition: datadogV1.WidgetDefinition{ + TimeseriesWidgetDefinition: &datadogV1.TimeseriesWidgetDefinition{ + Type: datadogV1.TIMESERIESWIDGETDEFINITIONTYPE_TIMESERIES, + Requests: []datadogV1.TimeseriesWidgetRequest{ + { + Q: datadog.PtrString("avg:system.cpu.user{*} by {host}"), + Style: &datadogV1.WidgetRequestStyle{ + Palette: datadog.PtrString("warm"), + OrderBy: datadogV1.WIDGETSTYLEORDERBY_VALUES.Ptr(), + }, + DisplayType: datadogV1.WIDGETDISPLAYTYPE_LINE.Ptr(), + }, + }, + }}, + }, + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV1.NewDashboardsApi(apiClient) + resp, r, err := api.CreateDashboard(ctx, body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `DashboardsApi.CreateDashboard`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `DashboardsApi.CreateDashboard`:\n%s\n", responseContent) +} diff --git a/examples/v1/dashboards/CreateDashboard_3631423980.go b/examples/v1/dashboards/CreateDashboard_3631423980.go new file mode 100644 index 00000000000..5e401d8834b --- /dev/null +++ b/examples/v1/dashboards/CreateDashboard_3631423980.go @@ -0,0 +1,52 @@ +// Create a new dashboard with timeseries widget without order_by for backward compatibility + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV1" +) + +func main() { + body := datadogV1.Dashboard{ + LayoutType: datadogV1.DASHBOARDLAYOUTTYPE_ORDERED, + Title: "Example-Dashboard without order_by", + Widgets: []datadogV1.Widget{ + { + Definition: datadogV1.WidgetDefinition{ + TimeseriesWidgetDefinition: &datadogV1.TimeseriesWidgetDefinition{ + Type: datadogV1.TIMESERIESWIDGETDEFINITIONTYPE_TIMESERIES, + Requests: []datadogV1.TimeseriesWidgetRequest{ + { + Q: datadog.PtrString("avg:system.cpu.user{*} by {host}"), + Style: &datadogV1.WidgetRequestStyle{ + Palette: datadog.PtrString("dog_classic"), + LineType: datadogV1.WIDGETLINETYPE_SOLID.Ptr(), + LineWidth: datadogV1.WIDGETLINEWIDTH_NORMAL.Ptr(), + }, + DisplayType: datadogV1.WIDGETDISPLAYTYPE_LINE.Ptr(), + }, + }, + }}, + }, + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV1.NewDashboardsApi(apiClient) + resp, r, err := api.CreateDashboard(ctx, body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `DashboardsApi.CreateDashboard`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `DashboardsApi.CreateDashboard`:\n%s\n", responseContent) +} diff --git a/examples/v1/dashboards/CreateDashboard_416487533.go b/examples/v1/dashboards/CreateDashboard_416487533.go new file mode 100644 index 00000000000..a07c922eeed --- /dev/null +++ b/examples/v1/dashboards/CreateDashboard_416487533.go @@ -0,0 +1,51 @@ +// Create a new dashboard with timeseries widget using order_by tags + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV1" +) + +func main() { + body := datadogV1.Dashboard{ + LayoutType: datadogV1.DASHBOARDLAYOUTTYPE_ORDERED, + Title: "Example-Dashboard with order_by tags", + Widgets: []datadogV1.Widget{ + { + Definition: datadogV1.WidgetDefinition{ + TimeseriesWidgetDefinition: &datadogV1.TimeseriesWidgetDefinition{ + Type: datadogV1.TIMESERIESWIDGETDEFINITIONTYPE_TIMESERIES, + Requests: []datadogV1.TimeseriesWidgetRequest{ + { + Q: datadog.PtrString("avg:system.cpu.user{*} by {host}"), + Style: &datadogV1.WidgetRequestStyle{ + Palette: datadog.PtrString("dog_classic"), + OrderBy: datadogV1.WIDGETSTYLEORDERBY_TAGS.Ptr(), + }, + DisplayType: datadogV1.WIDGETDISPLAYTYPE_LINE.Ptr(), + }, + }, + }}, + }, + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV1.NewDashboardsApi(apiClient) + resp, r, err := api.CreateDashboard(ctx, body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `DashboardsApi.CreateDashboard`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `DashboardsApi.CreateDashboard`:\n%s\n", responseContent) +} diff --git a/examples/v2/incidents/CreateGlobalIncidentHandle.go b/examples/v2/incidents/CreateGlobalIncidentHandle.go new file mode 100644 index 00000000000..e3c7c681bca --- /dev/null +++ b/examples/v2/incidents/CreateGlobalIncidentHandle.go @@ -0,0 +1,58 @@ +// Create global incident handle returns "Created" response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + body := datadogV2.IncidentHandleRequest{ + Data: datadogV2.IncidentHandleDataRequest{ + Attributes: datadogV2.IncidentHandleAttributesRequest{ + Fields: &datadogV2.IncidentHandleAttributesFields{ + Severity: []string{ + "SEV-1", + }, + }, + Name: "@incident-sev-1", + }, + Id: datadog.PtrString("b2494081-cdf0-4205-b366-4e1dd4fdf0bf"), + Relationships: *datadogV2.NewNullableIncidentHandleRelationshipsRequest(&datadogV2.IncidentHandleRelationshipsRequest{ + CommanderUser: &datadogV2.IncidentHandleRelationship{ + Data: datadogV2.IncidentHandleRelationshipData{ + Id: "f7b538b1-ed7c-4e84-82de-fdf84a539d40", + Type: "incident_types", + }, + }, + IncidentType: datadogV2.IncidentHandleRelationship{ + Data: datadogV2.IncidentHandleRelationshipData{ + Id: "f7b538b1-ed7c-4e84-82de-fdf84a539d40", + Type: "incident_types", + }, + }, + }), + Type: datadogV2.INCIDENTHANDLETYPE_INCIDENTS_HANDLES, + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + configuration.SetUnstableOperationEnabled("v2.CreateGlobalIncidentHandle", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewIncidentsApi(apiClient) + resp, r, err := api.CreateGlobalIncidentHandle(ctx, body, *datadogV2.NewCreateGlobalIncidentHandleOptionalParameters()) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `IncidentsApi.CreateGlobalIncidentHandle`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `IncidentsApi.CreateGlobalIncidentHandle`:\n%s\n", responseContent) +} diff --git a/examples/v2/incidents/DeleteGlobalIncidentHandle.go b/examples/v2/incidents/DeleteGlobalIncidentHandle.go new file mode 100644 index 00000000000..58707747bf2 --- /dev/null +++ b/examples/v2/incidents/DeleteGlobalIncidentHandle.go @@ -0,0 +1,26 @@ +// Delete global incident handle returns "No Content" response + +package main + +import ( + "context" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + configuration.SetUnstableOperationEnabled("v2.DeleteGlobalIncidentHandle", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewIncidentsApi(apiClient) + r, err := api.DeleteGlobalIncidentHandle(ctx) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `IncidentsApi.DeleteGlobalIncidentHandle`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } +} diff --git a/examples/v2/incidents/GetGlobalIncidentSettings.go b/examples/v2/incidents/GetGlobalIncidentSettings.go new file mode 100644 index 00000000000..e0b619ea55f --- /dev/null +++ b/examples/v2/incidents/GetGlobalIncidentSettings.go @@ -0,0 +1,30 @@ +// Get global incident settings returns "OK" response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + configuration.SetUnstableOperationEnabled("v2.GetGlobalIncidentSettings", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewIncidentsApi(apiClient) + resp, r, err := api.GetGlobalIncidentSettings(ctx) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `IncidentsApi.GetGlobalIncidentSettings`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `IncidentsApi.GetGlobalIncidentSettings`:\n%s\n", responseContent) +} diff --git a/examples/v2/incidents/ListGlobalIncidentHandles.go b/examples/v2/incidents/ListGlobalIncidentHandles.go new file mode 100644 index 00000000000..3f1cac47204 --- /dev/null +++ b/examples/v2/incidents/ListGlobalIncidentHandles.go @@ -0,0 +1,30 @@ +// List global incident handles returns "OK" response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + configuration.SetUnstableOperationEnabled("v2.ListGlobalIncidentHandles", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewIncidentsApi(apiClient) + resp, r, err := api.ListGlobalIncidentHandles(ctx, *datadogV2.NewListGlobalIncidentHandlesOptionalParameters()) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `IncidentsApi.ListGlobalIncidentHandles`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `IncidentsApi.ListGlobalIncidentHandles`:\n%s\n", responseContent) +} diff --git a/examples/v2/incidents/UpdateGlobalIncidentHandle.go b/examples/v2/incidents/UpdateGlobalIncidentHandle.go new file mode 100644 index 00000000000..d501abcc239 --- /dev/null +++ b/examples/v2/incidents/UpdateGlobalIncidentHandle.go @@ -0,0 +1,58 @@ +// Update global incident handle returns "OK" response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + body := datadogV2.IncidentHandleRequest{ + Data: datadogV2.IncidentHandleDataRequest{ + Attributes: datadogV2.IncidentHandleAttributesRequest{ + Fields: &datadogV2.IncidentHandleAttributesFields{ + Severity: []string{ + "SEV-1", + }, + }, + Name: "@incident-sev-1", + }, + Id: datadog.PtrString("b2494081-cdf0-4205-b366-4e1dd4fdf0bf"), + Relationships: *datadogV2.NewNullableIncidentHandleRelationshipsRequest(&datadogV2.IncidentHandleRelationshipsRequest{ + CommanderUser: &datadogV2.IncidentHandleRelationship{ + Data: datadogV2.IncidentHandleRelationshipData{ + Id: "f7b538b1-ed7c-4e84-82de-fdf84a539d40", + Type: "incident_types", + }, + }, + IncidentType: datadogV2.IncidentHandleRelationship{ + Data: datadogV2.IncidentHandleRelationshipData{ + Id: "f7b538b1-ed7c-4e84-82de-fdf84a539d40", + Type: "incident_types", + }, + }, + }), + Type: datadogV2.INCIDENTHANDLETYPE_INCIDENTS_HANDLES, + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + configuration.SetUnstableOperationEnabled("v2.UpdateGlobalIncidentHandle", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewIncidentsApi(apiClient) + resp, r, err := api.UpdateGlobalIncidentHandle(ctx, body, *datadogV2.NewUpdateGlobalIncidentHandleOptionalParameters()) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `IncidentsApi.UpdateGlobalIncidentHandle`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `IncidentsApi.UpdateGlobalIncidentHandle`:\n%s\n", responseContent) +} diff --git a/examples/v2/incidents/UpdateGlobalIncidentSettings.go b/examples/v2/incidents/UpdateGlobalIncidentSettings.go new file mode 100644 index 00000000000..9ccbcc78437 --- /dev/null +++ b/examples/v2/incidents/UpdateGlobalIncidentSettings.go @@ -0,0 +1,38 @@ +// Update global incident settings returns "OK" response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + body := datadogV2.GlobalIncidentSettingsRequest{ + Data: datadogV2.GlobalIncidentSettingsDataRequest{ + Attributes: &datadogV2.GlobalIncidentSettingsAttributesRequest{ + AnalyticsDashboardId: datadog.PtrString("abc-123-def"), + }, + Type: datadogV2.GLOBALINCIDENTSETTINGSTYPE_INCIDENTS_GLOBAL_SETTINGS, + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + configuration.SetUnstableOperationEnabled("v2.UpdateGlobalIncidentSettings", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewIncidentsApi(apiClient) + resp, r, err := api.UpdateGlobalIncidentSettings(ctx, body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `IncidentsApi.UpdateGlobalIncidentSettings`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `IncidentsApi.UpdateGlobalIncidentSettings`:\n%s\n", responseContent) +} diff --git a/tests/scenarios/cassettes/TestScenarios/v1/Feature_Dashboards/Scenario_Create_a_new_dashboard_with_timeseries_widget_using_order_by_tags.freeze b/tests/scenarios/cassettes/TestScenarios/v1/Feature_Dashboards/Scenario_Create_a_new_dashboard_with_timeseries_widget_using_order_by_tags.freeze new file mode 100644 index 00000000000..951919f26bd --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v1/Feature_Dashboards/Scenario_Create_a_new_dashboard_with_timeseries_widget_using_order_by_tags.freeze @@ -0,0 +1 @@ +2026-01-20T23:39:22.864Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v1/Feature_Dashboards/Scenario_Create_a_new_dashboard_with_timeseries_widget_using_order_by_tags.yaml b/tests/scenarios/cassettes/TestScenarios/v1/Feature_Dashboards/Scenario_Create_a_new_dashboard_with_timeseries_widget_using_order_by_tags.yaml new file mode 100644 index 00000000000..c0464554f28 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v1/Feature_Dashboards/Scenario_Create_a_new_dashboard_with_timeseries_widget_using_order_by_tags.yaml @@ -0,0 +1,41 @@ +interactions: +- request: + body: | + {"layout_type":"ordered","title":"Test-Create_a_new_dashboard_with_timeseries_widget_using_order_by_tags-1768952362 with order_by tags","widgets":[{"definition":{"requests":[{"display_type":"line","q":"avg:system.cpu.user{*} by {host}","style":{"order_by":"tags","palette":"dog_classic"}}],"type":"timeseries"}}]} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v1/dashboard + response: + body: '{"id":"2r3-a4g-ubz","title":"Test-Create_a_new_dashboard_with_timeseries_widget_using_order_by_tags-1768952362 + with order_by tags","description":null,"author_handle":"frog@datadoghq.com","author_name":"frog","layout_type":"ordered","url":"/dashboard/2r3-a4g-ubz/test-createanewdashboardwithtimeserieswidgetusingorderbytags-1768952362-with-ord","template_variables":null,"widgets":[{"definition":{"requests":[{"display_type":"line","q":"avg:system.cpu.user{*} + by {host}","style":{"order_by":"tags","palette":"dog_classic"}}],"type":"timeseries"},"id":8704189893014651}],"notify_list":null,"created_at":"2026-01-20T23:39:22.992533+00:00","modified_at":"2026-01-20T23:39:22.992533+00:00","restricted_roles":[]}' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/json + status: 200 OK +- request: + body: '' + form: {} + headers: + Accept: + - application/json + id: 1 + method: DELETE + url: https://api.datadoghq.com/api/v1/dashboard/2r3-a4g-ubz + response: + body: '{"deleted_dashboard_id":"2r3-a4g-ubz"}' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/json + status: 200 OK +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v1/Feature_Dashboards/Scenario_Create_a_new_dashboard_with_timeseries_widget_using_order_by_values.freeze b/tests/scenarios/cassettes/TestScenarios/v1/Feature_Dashboards/Scenario_Create_a_new_dashboard_with_timeseries_widget_using_order_by_values.freeze new file mode 100644 index 00000000000..67f72333494 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v1/Feature_Dashboards/Scenario_Create_a_new_dashboard_with_timeseries_widget_using_order_by_values.freeze @@ -0,0 +1 @@ +2026-01-20T23:39:50.889Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v1/Feature_Dashboards/Scenario_Create_a_new_dashboard_with_timeseries_widget_using_order_by_values.yaml b/tests/scenarios/cassettes/TestScenarios/v1/Feature_Dashboards/Scenario_Create_a_new_dashboard_with_timeseries_widget_using_order_by_values.yaml new file mode 100644 index 00000000000..12c93d15e0b --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v1/Feature_Dashboards/Scenario_Create_a_new_dashboard_with_timeseries_widget_using_order_by_values.yaml @@ -0,0 +1,41 @@ +interactions: +- request: + body: | + {"layout_type":"ordered","title":"Test-Create_a_new_dashboard_with_timeseries_widget_using_order_by_values-1768952390 with order_by values","widgets":[{"definition":{"requests":[{"display_type":"line","q":"avg:system.cpu.user{*} by {host}","style":{"order_by":"values","palette":"warm"}}],"type":"timeseries"}}]} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v1/dashboard + response: + body: '{"id":"5ee-dqv-ruw","title":"Test-Create_a_new_dashboard_with_timeseries_widget_using_order_by_values-1768952390 + with order_by values","description":null,"author_handle":"frog@datadoghq.com","author_name":"frog","layout_type":"ordered","url":"/dashboard/5ee-dqv-ruw/test-createanewdashboardwithtimeserieswidgetusingorderbyvalues-1768952390-with-o","template_variables":null,"widgets":[{"definition":{"requests":[{"display_type":"line","q":"avg:system.cpu.user{*} + by {host}","style":{"order_by":"values","palette":"warm"}}],"type":"timeseries"},"id":8314193502199768}],"notify_list":null,"created_at":"2026-01-20T23:39:51.018015+00:00","modified_at":"2026-01-20T23:39:51.018015+00:00","restricted_roles":[]}' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/json + status: 200 OK +- request: + body: '' + form: {} + headers: + Accept: + - application/json + id: 1 + method: DELETE + url: https://api.datadoghq.com/api/v1/dashboard/5ee-dqv-ruw + response: + body: '{"deleted_dashboard_id":"5ee-dqv-ruw"}' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/json + status: 200 OK +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v1/Feature_Dashboards/Scenario_Create_a_new_dashboard_with_timeseries_widget_without_order_by_for_backward_compatibility.freeze b/tests/scenarios/cassettes/TestScenarios/v1/Feature_Dashboards/Scenario_Create_a_new_dashboard_with_timeseries_widget_without_order_by_for_backward_compatibility.freeze new file mode 100644 index 00000000000..608e803e2fa --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v1/Feature_Dashboards/Scenario_Create_a_new_dashboard_with_timeseries_widget_without_order_by_for_backward_compatibility.freeze @@ -0,0 +1 @@ +2026-01-20T23:40:15.566Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v1/Feature_Dashboards/Scenario_Create_a_new_dashboard_with_timeseries_widget_without_order_by_for_backward_compatibility.yaml b/tests/scenarios/cassettes/TestScenarios/v1/Feature_Dashboards/Scenario_Create_a_new_dashboard_with_timeseries_widget_without_order_by_for_backward_compatibility.yaml new file mode 100644 index 00000000000..79d7d892f84 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v1/Feature_Dashboards/Scenario_Create_a_new_dashboard_with_timeseries_widget_without_order_by_for_backward_compatibility.yaml @@ -0,0 +1,41 @@ +interactions: +- request: + body: | + {"layout_type":"ordered","title":"Test-Create_a_new_dashboard_with_timeseries_widget_without_order_by_for_backward_compatibility-1768952415 without order_by","widgets":[{"definition":{"requests":[{"display_type":"line","q":"avg:system.cpu.user{*} by {host}","style":{"line_type":"solid","line_width":"normal","palette":"dog_classic"}}],"type":"timeseries"}}]} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v1/dashboard + response: + body: '{"id":"6bg-rgq-fxc","title":"Test-Create_a_new_dashboard_with_timeseries_widget_without_order_by_for_backward_compatibility-1768952415 + without order_by","description":null,"author_handle":"frog@datadoghq.com","author_name":"frog","layout_type":"ordered","url":"/dashboard/6bg-rgq-fxc/test-createanewdashboardwithtimeserieswidgetwithoutorderbyforbackwardcompatibili","template_variables":null,"widgets":[{"definition":{"requests":[{"display_type":"line","q":"avg:system.cpu.user{*} + by {host}","style":{"line_type":"solid","line_width":"normal","palette":"dog_classic"}}],"type":"timeseries"},"id":2503785343641105}],"notify_list":null,"created_at":"2026-01-20T23:40:15.937647+00:00","modified_at":"2026-01-20T23:40:15.937647+00:00","restricted_roles":[]}' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/json + status: 200 OK +- request: + body: '' + form: {} + headers: + Accept: + - application/json + id: 1 + method: DELETE + url: https://api.datadoghq.com/api/v1/dashboard/6bg-rgq-fxc + response: + body: '{"deleted_dashboard_id":"6bg-rgq-fxc"}' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/json + status: 200 OK +version: 2 diff --git a/tests/scenarios/features/v1/dashboards.feature b/tests/scenarios/features/v1/dashboards.feature index 6b67bc65044..349f7de6f9d 100644 --- a/tests/scenarios/features/v1/dashboards.feature +++ b/tests/scenarios/features/v1/dashboards.feature @@ -946,6 +946,24 @@ Feature: Dashboards And the response "widgets[0].definition.requests[0].display_type" is equal to "bars" And the response "widgets[0].definition.requests[0].q" is equal to "sum:trace.test.errors{env:prod,service:datadog-api-spec} by {resource_name}.as_count()" + @team:DataDog/dashboards-backend + Scenario: Create a new dashboard with timeseries widget using order_by tags + Given new "CreateDashboard" request + And body with value {"layout_type": "ordered", "title": "{{ unique }} with order_by tags","widgets": [{"definition": {"type": "timeseries","requests": [{"q": "avg:system.cpu.user{*} by {host}","style": {"palette": "dog_classic","order_by": "tags"},"display_type": "line"}]}}]} + When the request is sent + Then the response status is 200 OK + And the response "widgets[0].definition.requests[0].style.order_by" is equal to "tags" + And the response "widgets[0].definition.requests[0].style.palette" is equal to "dog_classic" + + @team:DataDog/dashboards-backend + Scenario: Create a new dashboard with timeseries widget using order_by values + Given new "CreateDashboard" request + And body with value {"layout_type": "ordered", "title": "{{ unique }} with order_by values","widgets": [{"definition": {"type": "timeseries","requests": [{"q": "avg:system.cpu.user{*} by {host}","style": {"palette": "warm","order_by": "values"},"display_type": "line"}]}}]} + When the request is sent + Then the response status is 200 OK + And the response "widgets[0].definition.requests[0].style.order_by" is equal to "values" + And the response "widgets[0].definition.requests[0].style.palette" is equal to "warm" + @team:DataDog/dashboards-backend Scenario: Create a new dashboard with timeseries widget with custom_unit Given new "CreateDashboard" request @@ -958,6 +976,16 @@ Feature: Dashboards And the response "widgets[0].definition.requests[0].formulas[0].number_format.unit.type" is equal to "canonical_unit" And the response "widgets[0].definition.requests[0].formulas[0].number_format.unit.unit_name" is equal to "fraction" + @team:DataDog/dashboards-backend + Scenario: Create a new dashboard with timeseries widget without order_by for backward compatibility + Given new "CreateDashboard" request + And body with value {"layout_type": "ordered", "title": "{{ unique }} without order_by","widgets": [{"definition": {"type": "timeseries","requests": [{"q": "avg:system.cpu.user{*} by {host}","style": {"palette": "dog_classic","line_type": "solid","line_width": "normal"},"display_type": "line"}]}}]} + When the request is sent + Then the response status is 200 OK + And the response "widgets[0].definition.requests[0].style.palette" is equal to "dog_classic" + And the response "widgets[0].definition.requests[0].style.line_type" is equal to "solid" + And the response "widgets[0].definition.requests[0].style.line_width" is equal to "normal" + @team:DataDog/dashboards-backend Scenario: Create a new dashboard with toplist widget Given new "CreateDashboard" request diff --git a/tests/scenarios/features/v2/incidents.feature b/tests/scenarios/features/v2/incidents.feature index ad60148dd7d..db706355841 100644 --- a/tests/scenarios/features/v2/incidents.feature +++ b/tests/scenarios/features/v2/incidents.feature @@ -186,6 +186,22 @@ Feature: Incidents When the request is sent Then the response status is 404 Not Found + @generated @skip @team:DataDog/incident-app + Scenario: Create global incident handle returns "Bad Request" response + Given operation "CreateGlobalIncidentHandle" enabled + And new "CreateGlobalIncidentHandle" request + And body with value {"data": {"attributes": {"fields": {"severity": ["SEV-1"]}, "name": "@incident-sev-1"}, "id": "b2494081-cdf0-4205-b366-4e1dd4fdf0bf", "relationships": {"commander_user": {"data": {"id": "f7b538b1-ed7c-4e84-82de-fdf84a539d40", "type": "incident_types"}}, "incident_type": {"data": {"id": "f7b538b1-ed7c-4e84-82de-fdf84a539d40", "type": "incident_types"}}}, "type": "incidents_handles"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/incident-app + Scenario: Create global incident handle returns "Created" response + Given operation "CreateGlobalIncidentHandle" enabled + And new "CreateGlobalIncidentHandle" request + And body with value {"data": {"attributes": {"fields": {"severity": ["SEV-1"]}, "name": "@incident-sev-1"}, "id": "b2494081-cdf0-4205-b366-4e1dd4fdf0bf", "relationships": {"commander_user": {"data": {"id": "f7b538b1-ed7c-4e84-82de-fdf84a539d40", "type": "incident_types"}}, "incident_type": {"data": {"id": "f7b538b1-ed7c-4e84-82de-fdf84a539d40", "type": "incident_types"}}}, "type": "incidents_handles"}} + When the request is sent + Then the response status is 201 Created + @skip @team:DataDog/incident-app Scenario: Create incident attachment returns "Bad Request" response Given operation "CreateIncidentAttachment" enabled @@ -450,6 +466,20 @@ Feature: Incidents When the request is sent Then the response status is 204 OK + @generated @skip @team:DataDog/incident-app + Scenario: Delete global incident handle returns "Bad Request" response + Given operation "DeleteGlobalIncidentHandle" enabled + And new "DeleteGlobalIncidentHandle" request + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/incident-app + Scenario: Delete global incident handle returns "No Content" response + Given operation "DeleteGlobalIncidentHandle" enabled + And new "DeleteGlobalIncidentHandle" request + When the request is sent + Then the response status is 204 No Content + @skip @team:DataDog/incident-app Scenario: Delete incident attachment returns "Bad Request" response Given operation "DeleteIncidentAttachment" enabled @@ -633,6 +663,20 @@ Feature: Incidents When the request is sent Then the response status is 200 OK + @generated @skip @team:DataDog/incident-app + Scenario: Get global incident settings returns "Bad Request" response + Given operation "GetGlobalIncidentSettings" enabled + And new "GetGlobalIncidentSettings" request + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/incident-app + Scenario: Get global incident settings returns "OK" response + Given operation "GetGlobalIncidentSettings" enabled + And new "GetGlobalIncidentSettings" request + When the request is sent + Then the response status is 200 OK + @generated @skip @team:DataDog/incident-app Scenario: Get incident integration metadata details returns "Bad Request" response Given operation "GetIncidentIntegration" enabled @@ -816,6 +860,20 @@ Feature: Incidents When the request is sent Then the response status is 200 OK + @generated @skip @team:DataDog/incident-app + Scenario: List global incident handles returns "Bad Request" response + Given operation "ListGlobalIncidentHandles" enabled + And new "ListGlobalIncidentHandles" request + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/incident-app + Scenario: List global incident handles returns "OK" response + Given operation "ListGlobalIncidentHandles" enabled + And new "ListGlobalIncidentHandles" request + When the request is sent + Then the response status is 200 OK + @skip @team:DataDog/incident-app Scenario: List incident attachments returns "Bad Request" response Given operation "ListIncidentAttachments" enabled @@ -1081,6 +1139,38 @@ Feature: Incidents When the request is sent Then the response status is 200 OK + @generated @skip @team:DataDog/incident-app + Scenario: Update global incident handle returns "Bad Request" response + Given operation "UpdateGlobalIncidentHandle" enabled + And new "UpdateGlobalIncidentHandle" request + And body with value {"data": {"attributes": {"fields": {"severity": ["SEV-1"]}, "name": "@incident-sev-1"}, "id": "b2494081-cdf0-4205-b366-4e1dd4fdf0bf", "relationships": {"commander_user": {"data": {"id": "f7b538b1-ed7c-4e84-82de-fdf84a539d40", "type": "incident_types"}}, "incident_type": {"data": {"id": "f7b538b1-ed7c-4e84-82de-fdf84a539d40", "type": "incident_types"}}}, "type": "incidents_handles"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/incident-app + Scenario: Update global incident handle returns "OK" response + Given operation "UpdateGlobalIncidentHandle" enabled + And new "UpdateGlobalIncidentHandle" request + And body with value {"data": {"attributes": {"fields": {"severity": ["SEV-1"]}, "name": "@incident-sev-1"}, "id": "b2494081-cdf0-4205-b366-4e1dd4fdf0bf", "relationships": {"commander_user": {"data": {"id": "f7b538b1-ed7c-4e84-82de-fdf84a539d40", "type": "incident_types"}}, "incident_type": {"data": {"id": "f7b538b1-ed7c-4e84-82de-fdf84a539d40", "type": "incident_types"}}}, "type": "incidents_handles"}} + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:DataDog/incident-app + Scenario: Update global incident settings returns "Bad Request" response + Given operation "UpdateGlobalIncidentSettings" enabled + And new "UpdateGlobalIncidentSettings" request + And body with value {"data": {"attributes": {"analytics_dashboard_id": "abc-123-def"}, "type": "incidents_global_settings"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/incident-app + Scenario: Update global incident settings returns "OK" response + Given operation "UpdateGlobalIncidentSettings" enabled + And new "UpdateGlobalIncidentSettings" request + And body with value {"data": {"attributes": {"analytics_dashboard_id": "abc-123-def"}, "type": "incidents_global_settings"}} + When the request is sent + Then the response status is 200 OK + @skip @team:DataDog/incident-app Scenario: Update incident attachment returns "Bad Request" response Given operation "UpdateIncidentAttachment" enabled diff --git a/tests/scenarios/features/v2/undo.json b/tests/scenarios/features/v2/undo.json index 7619933d2f8..b8d90f223ac 100644 --- a/tests/scenarios/features/v2/undo.json +++ b/tests/scenarios/features/v2/undo.json @@ -1602,6 +1602,44 @@ "type": "unsafe" } }, + "DeleteGlobalIncidentHandle": { + "tag": "Incidents", + "undo": { + "type": "idempotent" + } + }, + "ListGlobalIncidentHandles": { + "tag": "Incidents", + "undo": { + "type": "safe" + } + }, + "CreateGlobalIncidentHandle": { + "tag": "Incidents", + "undo": { + "operationId": "DeleteGlobalIncidentHandle", + "parameters": [], + "type": "unsafe" + } + }, + "UpdateGlobalIncidentHandle": { + "tag": "Incidents", + "undo": { + "type": "idempotent" + } + }, + "GetGlobalIncidentSettings": { + "tag": "Incidents", + "undo": { + "type": "safe" + } + }, + "UpdateGlobalIncidentSettings": { + "tag": "Incidents", + "undo": { + "type": "idempotent" + } + }, "ListIncidentNotificationRules": { "tag": "Incidents", "undo": {