From f77fc8b240c108624c88211ca6499abd4a2d6a58 Mon Sep 17 00:00:00 2001 From: "api-clients-generation-pipeline[bot]" <54105614+api-clients-generation-pipeline[bot]@users.noreply.github.com> Date: Thu, 17 Jul 2025 12:41:29 +0000 Subject: [PATCH 1/4] Update documentation for customers clarifying that our post endpoint is avail in fed (#3224) Co-authored-by: ci.datadog-api-spec --- .generated-info | 4 ++-- .generator/schemas/v2/openapi.yaml | 4 +--- api/datadogV2/api_events.go | 2 -- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/.generated-info b/.generated-info index 8d72fb6e0fa..467045ae4d4 100644 --- a/.generated-info +++ b/.generated-info @@ -1,4 +1,4 @@ { - "spec_repo_commit": "2ffdc3f", - "generated": "2025-07-16 19:15:51.322" + "spec_repo_commit": "671ba51", + "generated": "2025-07-16 20:18:22.335" } diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 2ee20dab08f..affbc2622b2 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -48677,9 +48677,7 @@ paths: for more details.\n\n\u274C For use cases involving other event categories, use the V1 endpoint or reach out to [support](https://www.datadoghq.com/support/).\n\n\u274C Notifications are not yet supported for events sent to this endpoint. Use - the V1 endpoint for notification functionality.\n\n\u274C This endpoint is - not available for the Government (US1-FED) site. Contact your account representative - for more information." + the V1 endpoint for notification functionality." operationId: CreateEvent requestBody: content: diff --git a/api/datadogV2/api_events.go b/api/datadogV2/api_events.go index ccc713b6732..ff9dfe73606 100644 --- a/api/datadogV2/api_events.go +++ b/api/datadogV2/api_events.go @@ -25,8 +25,6 @@ type EventsApi datadog.Service // ❌ For use cases involving other event categories, use the V1 endpoint or reach out to [support](https://www.datadoghq.com/support/). // // ❌ Notifications are not yet supported for events sent to this endpoint. Use the V1 endpoint for notification functionality. -// -// ❌ This endpoint is not available for the Government (US1-FED) site. Contact your account representative for more information. func (a *EventsApi) CreateEvent(ctx _context.Context, body EventCreateRequestPayload) (EventCreateResponsePayload, *_nethttp.Response, error) { var ( localVarHTTPMethod = _nethttp.MethodPost From 82e651ee696fcce5a4e5ddbc65936d990b52dafa Mon Sep 17 00:00:00 2001 From: "api-clients-generation-pipeline[bot]" <54105614+api-clients-generation-pipeline[bot]@users.noreply.github.com> Date: Thu, 17 Jul 2025 13:24:31 +0000 Subject: [PATCH 2/4] Sync OpenAPI specification for (spec-v1-dashboard_sharing.yaml) (#3227) Co-authored-by: ci.datadog-api-spec --- .generated-info | 4 ++-- .generator/schemas/v1/openapi.yaml | 30 ++++++++++++++++++++++++------ 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/.generated-info b/.generated-info index 467045ae4d4..e1fed5f3679 100644 --- a/.generated-info +++ b/.generated-info @@ -1,4 +1,4 @@ { - "spec_repo_commit": "671ba51", - "generated": "2025-07-16 20:18:22.335" + "spec_repo_commit": "0becaa3", + "generated": "2025-07-17 13:14:29.172" } diff --git a/.generator/schemas/v1/openapi.yaml b/.generator/schemas/v1/openapi.yaml index e713722382c..6511a44e042 100644 --- a/.generator/schemas/v1/openapi.yaml +++ b/.generator/schemas/v1/openapi.yaml @@ -25773,6 +25773,10 @@ paths: appKeyAuth: [] - AuthZ: - dashboards_public_share + - AuthZ: + - dashboards_embed_share + - AuthZ: + - dashboards_invite_share summary: Create a shared dashboard tags: - Dashboards @@ -25781,6 +25785,8 @@ paths: operator: OR permissions: - dashboards_public_share + - dashboards_embed_share + - dashboards_invite_share /api/v1/dashboard/public/{token}: delete: description: Revoke the public URL for a dashboard (rendering it private) associated @@ -25819,6 +25825,10 @@ paths: appKeyAuth: [] - AuthZ: - dashboards_public_share + - AuthZ: + - dashboards_embed_share + - AuthZ: + - dashboards_invite_share summary: Revoke a shared dashboard URL tags: - Dashboards @@ -25826,6 +25836,8 @@ paths: operator: OR permissions: - dashboards_public_share + - dashboards_embed_share + - dashboards_invite_share get: description: Fetch an existing shared dashboard's sharing metadata associated with the specified token. @@ -25936,6 +25948,10 @@ paths: appKeyAuth: [] - AuthZ: - dashboards_public_share + - AuthZ: + - dashboards_embed_share + - AuthZ: + - dashboards_invite_share summary: Update a shared dashboard tags: - Dashboards @@ -25944,6 +25960,8 @@ paths: operator: OR permissions: - dashboards_public_share + - dashboards_embed_share + - dashboards_invite_share /api/v1/dashboard/public/{token}/invitation: delete: description: Revoke previously sent invitation emails and active sessions used @@ -25991,7 +26009,7 @@ paths: - apiKeyAuth: [] appKeyAuth: [] - AuthZ: - - dashboards_public_share + - dashboards_invite_share summary: Revoke shared dashboard invitations tags: - Dashboards @@ -25999,7 +26017,7 @@ paths: x-permission: operator: OR permissions: - - dashboards_public_share + - dashboards_invite_share get: description: Describe the invitations that exist for the given shared dashboard (paginated). @@ -26050,14 +26068,14 @@ paths: - apiKeyAuth: [] appKeyAuth: [] - AuthZ: - - dashboards_public_share + - dashboards_invite_share summary: Get all invitations for a shared dashboard tags: - Dashboards x-permission: operator: OR permissions: - - dashboards_public_share + - dashboards_invite_share post: description: Send emails to specified email addresses containing links to access a given authenticated shared dashboard. Email addresses must already belong @@ -26115,7 +26133,7 @@ paths: - apiKeyAuth: [] appKeyAuth: [] - AuthZ: - - dashboards_public_share + - dashboards_invite_share summary: Send shared dashboard invitation email tags: - Dashboards @@ -26123,7 +26141,7 @@ paths: x-permission: operator: OR permissions: - - dashboards_public_share + - dashboards_invite_share /api/v1/dashboard/{dashboard_id}: delete: description: Delete a dashboard using the specified ID. From ef955eaf4faf2f46497a33206c0b4f6837d0e969 Mon Sep 17 00:00:00 2001 From: "api-clients-generation-pipeline[bot]" <54105614+api-clients-generation-pipeline[bot]@users.noreply.github.com> Date: Thu, 17 Jul 2025 17:14:09 +0000 Subject: [PATCH 3/4] Create API spec for v2 get an event (#3162) Co-authored-by: ci.datadog-api-spec --- .generated-info | 4 +- .generator/schemas/v2/openapi.yaml | 334 +++++++++++++ api/datadogV2/api_events.go | 78 +++ api/datadogV2/doc.go | 1 + api/datadogV2/model_alert_event_attributes.go | 399 +++++++++++++++ ...model_alert_event_attributes_links_item.go | 182 +++++++ ...rt_event_attributes_links_item_category.go | 68 +++ .../model_alert_event_attributes_priority.go | 72 +++ .../model_alert_event_attributes_status.go | 68 +++ .../model_change_event_attributes.go | 467 ++++++++++++++++++ .../model_change_event_attributes_author.go | 147 ++++++ ...del_change_event_attributes_author_type.go | 70 +++ ...hange_event_attributes_changed_resource.go | 147 ++++++ ..._event_attributes_changed_resource_type.go | 66 +++ ...vent_attributes_impacted_resources_item.go | 147 ++++++ ...attributes_impacted_resources_item_type.go | 64 +++ .../model_event_system_attributes.go | 256 ++++++++++ .../model_event_system_attributes_category.go | 66 +++ ..._event_system_attributes_integration_id.go | 64 +++ api/datadogV2/model_v2_event.go | 181 +++++++ api/datadogV2/model_v2_event_attributes.go | 207 ++++++++ .../model_v2_event_attributes_attributes.go | 105 ++++ api/datadogV2/model_v2_event_response.go | 111 +++++ examples/v2/events/GetEvent.go | 29 ++ tests/scenarios/features/v2/events.feature | 21 + tests/scenarios/features/v2/undo.json | 6 + 26 files changed, 3358 insertions(+), 2 deletions(-) create mode 100644 api/datadogV2/model_alert_event_attributes.go create mode 100644 api/datadogV2/model_alert_event_attributes_links_item.go create mode 100644 api/datadogV2/model_alert_event_attributes_links_item_category.go create mode 100644 api/datadogV2/model_alert_event_attributes_priority.go create mode 100644 api/datadogV2/model_alert_event_attributes_status.go create mode 100644 api/datadogV2/model_change_event_attributes.go create mode 100644 api/datadogV2/model_change_event_attributes_author.go create mode 100644 api/datadogV2/model_change_event_attributes_author_type.go create mode 100644 api/datadogV2/model_change_event_attributes_changed_resource.go create mode 100644 api/datadogV2/model_change_event_attributes_changed_resource_type.go create mode 100644 api/datadogV2/model_change_event_attributes_impacted_resources_item.go create mode 100644 api/datadogV2/model_change_event_attributes_impacted_resources_item_type.go create mode 100644 api/datadogV2/model_event_system_attributes.go create mode 100644 api/datadogV2/model_event_system_attributes_category.go create mode 100644 api/datadogV2/model_event_system_attributes_integration_id.go create mode 100644 api/datadogV2/model_v2_event.go create mode 100644 api/datadogV2/model_v2_event_attributes.go create mode 100644 api/datadogV2/model_v2_event_attributes_attributes.go create mode 100644 api/datadogV2/model_v2_event_response.go create mode 100644 examples/v2/events/GetEvent.go diff --git a/.generated-info b/.generated-info index e1fed5f3679..fe7f37ba004 100644 --- a/.generated-info +++ b/.generated-info @@ -1,4 +1,4 @@ { - "spec_repo_commit": "0becaa3", - "generated": "2025-07-17 13:14:29.172" + "spec_repo_commit": "214381f", + "generated": "2025-07-17 15:38:08.123" } diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index affbc2622b2..5709841fc5c 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -2291,6 +2291,88 @@ components: - id - base_severity type: object + AlertEventAttributes: + description: Alert event attributes. + properties: + aggregation_key: + $ref: '#/components/schemas/V2EventAggregationKey' + custom: + description: JSON object of custom attributes. + example: {} + type: object + evt: + $ref: '#/components/schemas/EventSystemAttributes' + links: + description: The links related to the event. + example: + - category: runbook + title: Runbook Link + url: https://app.datadoghq.com/runbook + items: + $ref: '#/components/schemas/AlertEventAttributesLinksItem' + type: array + priority: + $ref: '#/components/schemas/AlertEventAttributesPriority' + service: + $ref: '#/components/schemas/V2EventService' + status: + $ref: '#/components/schemas/AlertEventAttributesStatus' + timestamp: + $ref: '#/components/schemas/V2EventTimestamp' + title: + $ref: '#/components/schemas/V2EventTitle' + type: object + AlertEventAttributesLinksItem: + description: A link. + properties: + category: + $ref: '#/components/schemas/AlertEventAttributesLinksItemCategory' + title: + description: The display text of the link. + type: string + url: + description: The URL of the link. + type: string + type: object + AlertEventAttributesLinksItemCategory: + description: The category of the link. + enum: + - runbook + - documentation + - dashboard + type: string + x-enum-varnames: + - RUNBOOK + - DOCUMENTATION + - DASHBOARD + AlertEventAttributesPriority: + description: The priority of the alert. + enum: + - '1' + - '2' + - '3' + - '4' + - '5' + example: '5' + type: string + x-enum-varnames: + - PRIORITY_ONE + - PRIORITY_TWO + - PRIORITY_THREE + - PRIORITY_FOUR + - PRIORITY_FIVE + AlertEventAttributesStatus: + description: The status of the alert. + enum: + - warn + - error + - ok + example: error + type: string + x-enum-varnames: + - WARN + - ERROR + - OK AlertEventCustomAttributes: additionalProperties: false description: Alert event attributes. @@ -7102,6 +7184,116 @@ components: format: int64 type: integer type: object + ChangeEventAttributes: + description: Change event attributes. + properties: + aggregation_key: + $ref: '#/components/schemas/V2EventAggregationKey' + author: + $ref: '#/components/schemas/ChangeEventAttributesAuthor' + change_metadata: + description: JSON object of change metadata. + example: + dd: + team: datadog_team + user_email: datadog@datadog.com + user_id: datadog_user_id + user_name: datadog_username + type: object + changed_resource: + $ref: '#/components/schemas/ChangeEventAttributesChangedResource' + evt: + $ref: '#/components/schemas/EventSystemAttributes' + impacted_resources: + description: A list of resources impacted by this change. + example: + - name: service-name + type: service + items: + $ref: '#/components/schemas/ChangeEventAttributesImpactedResourcesItem' + type: array + new_value: + description: The new state of the changed resource. + example: + enabled: true + percentage: 50% + rule: + datacenter: devcycle.us1.prod + type: object + prev_value: + description: The previous state of the changed resource. + example: + enabled: true + percentage: 10% + rule: + datacenter: devcycle.us1.prod + type: object + service: + $ref: '#/components/schemas/V2EventService' + timestamp: + $ref: '#/components/schemas/V2EventTimestamp' + title: + $ref: '#/components/schemas/V2EventTitle' + type: object + ChangeEventAttributesAuthor: + description: The entity that made the change. + properties: + name: + description: The name of the user or system that made the change. + example: example@datadog.com + type: string + type: + $ref: '#/components/schemas/ChangeEventAttributesAuthorType' + type: object + ChangeEventAttributesAuthorType: + description: The type of the author. + enum: + - user + - system + - api + - automation + example: user + type: string + x-enum-varnames: + - USER + - SYSTEM + - API + - AUTOMATION + ChangeEventAttributesChangedResource: + description: A uniquely identified resource. + properties: + name: + description: The name of the changed resource. + type: string + type: + $ref: '#/components/schemas/ChangeEventAttributesChangedResourceType' + type: object + ChangeEventAttributesChangedResourceType: + description: The type of the changed resource. + enum: + - feature_flag + - configuration + example: feature_flag + type: string + x-enum-varnames: + - FEATURE_FLAG + - CONFIGURATION + ChangeEventAttributesImpactedResourcesItem: + description: A uniquely identified resource. + properties: + name: + description: The name of the impacted resource. + type: string + type: + $ref: '#/components/schemas/ChangeEventAttributesImpactedResourcesItemType' + type: object + ChangeEventAttributesImpactedResourcesItemType: + description: The type of the impacted resource. + enum: + - service + type: string + x-enum-varnames: + - SERVICE ChangeEventCustomAttributes: additionalProperties: false description: Change event attributes. @@ -15189,6 +15381,44 @@ components: - USER_UPDATE - RECOMMENDATION - SNAPSHOT + EventSystemAttributes: + description: JSON object of event system attributes. + properties: + category: + $ref: '#/components/schemas/EventSystemAttributesCategory' + id: + description: Event identifier. This field is deprecated and will be removed + in a future version. Use the `uid` field instead. + type: string + integration_id: + $ref: '#/components/schemas/EventSystemAttributesIntegrationId' + source_id: + description: The source type ID of the event. + format: int64 + type: integer + uid: + description: A unique identifier for the event. You can use this identifier + to query or reference the event. + type: string + type: object + EventSystemAttributesCategory: + description: Event category identifying the type of event. + enum: + - change + - alert + example: change + type: string + x-enum-varnames: + - CHANGE + - ALERT + EventSystemAttributesIntegrationId: + description: Integration ID sourced from integration manifests. + enum: + - custom-events + example: custom-events + type: string + x-enum-varnames: + - CUSTOM_EVENTS EventType: default: event description: Type of the event. @@ -41557,6 +41787,70 @@ components: type: string x-enum-varnames: - USERS + V2Event: + description: An event object. + properties: + attributes: + $ref: '#/components/schemas/V2EventAttributes' + id: + description: The event's ID. + example: '' + type: string + type: + description: Entity type. + example: event + type: string + type: object + V2EventAggregationKey: + description: Aggregation key of the event. + example: aggregation-key + type: string + V2EventAttributes: + description: Event attributes. + properties: + attributes: + $ref: '#/components/schemas/V2EventAttributesAttributes' + message: + description: Free-form text associated with the event. + example: The event message + type: string + tags: + description: A list of tags associated with the event. + example: + - env:api_client_test + items: + description: A tag. + type: string + type: array + timestamp: + description: Timestamp when the event occurred. + example: '2017-01-15T01:30:15.010000Z' + type: string + type: object + V2EventAttributesAttributes: + description: JSON object for category-specific attributes. + oneOf: + - $ref: '#/components/schemas/ChangeEventAttributes' + - $ref: '#/components/schemas/AlertEventAttributes' + V2EventResponse: + description: Get an event response. + properties: + data: + $ref: '#/components/schemas/V2Event' + type: object + V2EventService: + description: Service that triggered the event. + example: service-name + type: string + V2EventTimestamp: + description: POSIX timestamp of the event. + example: 175019386627 + format: int64 + type: integer + V2EventTitle: + description: The title of the event. + example: The event title + type: string ValidationError: description: Represents a single validation error, including a human-readable title and metadata. @@ -48828,6 +49122,46 @@ paths: operator: OR permissions: - events_read + /api/v2/events/{event_id}: + get: + description: Get the details of an event by `event_id`. + operationId: GetEvent + parameters: + - description: The UID of the event. + in: path + name: event_id + required: true + schema: + type: string + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/V2EventResponse' + description: OK + '400': + $ref: '#/components/responses/BadRequestResponse' + '401': + $ref: '#/components/responses/UnauthorizedResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '404': + $ref: '#/components/responses/NotFoundResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - events_read + summary: Get an event + tags: + - Events + x-permission: + operator: OR + permissions: + - events_read /api/v2/incidents: get: description: Get all incidents for the user's organization. diff --git a/api/datadogV2/api_events.go b/api/datadogV2/api_events.go index ff9dfe73606..2d0ef96e119 100644 --- a/api/datadogV2/api_events.go +++ b/api/datadogV2/api_events.go @@ -112,6 +112,84 @@ func (a *EventsApi) CreateEvent(ctx _context.Context, body EventCreateRequestPay return localVarReturnValue, localVarHTTPResponse, nil } +// GetEvent Get an event. +// Get the details of an event by `event_id`. +func (a *EventsApi) GetEvent(ctx _context.Context, eventId string) (V2EventResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarReturnValue V2EventResponse + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.EventsApi.GetEvent") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/events/{event_id}" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{event_id}", _neturl.PathEscape(datadog.ParameterToString(eventId, ""))) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Accept"] = "application/json" + + if a.Client.Cfg.DelegatedTokenConfig != nil { + err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig) + if err != nil { + return localVarReturnValue, nil, err + } + } else { + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + } + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 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 +} + // ListEventsOptionalParameters holds optional parameters for ListEvents. type ListEventsOptionalParameters struct { FilterQuery *string diff --git a/api/datadogV2/doc.go b/api/datadogV2/doc.go index b0c24ac58eb..c4a711cff37 100644 --- a/api/datadogV2/doc.go +++ b/api/datadogV2/doc.go @@ -170,6 +170,7 @@ // - [DowntimesApi.ListMonitorDowntimes] // - [DowntimesApi.UpdateDowntime] // - [EventsApi.CreateEvent] +// - [EventsApi.GetEvent] // - [EventsApi.ListEvents] // - [EventsApi.SearchEvents] // - [FastlyIntegrationApi.CreateFastlyAccount] diff --git a/api/datadogV2/model_alert_event_attributes.go b/api/datadogV2/model_alert_event_attributes.go new file mode 100644 index 00000000000..5d4b490855b --- /dev/null +++ b/api/datadogV2/model_alert_event_attributes.go @@ -0,0 +1,399 @@ +// 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" +) + +// AlertEventAttributes Alert event attributes. +type AlertEventAttributes struct { + // Aggregation key of the event. + AggregationKey *string `json:"aggregation_key,omitempty"` + // JSON object of custom attributes. + Custom interface{} `json:"custom,omitempty"` + // JSON object of event system attributes. + Evt *EventSystemAttributes `json:"evt,omitempty"` + // The links related to the event. + Links []AlertEventAttributesLinksItem `json:"links,omitempty"` + // The priority of the alert. + Priority *AlertEventAttributesPriority `json:"priority,omitempty"` + // Service that triggered the event. + Service *string `json:"service,omitempty"` + // The status of the alert. + Status *AlertEventAttributesStatus `json:"status,omitempty"` + // POSIX timestamp of the event. + Timestamp *int64 `json:"timestamp,omitempty"` + // The title of the event. + Title *string `json:"title,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:"-"` +} + +// NewAlertEventAttributes instantiates a new AlertEventAttributes 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 NewAlertEventAttributes() *AlertEventAttributes { + this := AlertEventAttributes{} + return &this +} + +// NewAlertEventAttributesWithDefaults instantiates a new AlertEventAttributes 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 NewAlertEventAttributesWithDefaults() *AlertEventAttributes { + this := AlertEventAttributes{} + return &this +} + +// GetAggregationKey returns the AggregationKey field value if set, zero value otherwise. +func (o *AlertEventAttributes) GetAggregationKey() string { + if o == nil || o.AggregationKey == nil { + var ret string + return ret + } + return *o.AggregationKey +} + +// GetAggregationKeyOk returns a tuple with the AggregationKey field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *AlertEventAttributes) GetAggregationKeyOk() (*string, bool) { + if o == nil || o.AggregationKey == nil { + return nil, false + } + return o.AggregationKey, true +} + +// HasAggregationKey returns a boolean if a field has been set. +func (o *AlertEventAttributes) HasAggregationKey() bool { + return o != nil && o.AggregationKey != nil +} + +// SetAggregationKey gets a reference to the given string and assigns it to the AggregationKey field. +func (o *AlertEventAttributes) SetAggregationKey(v string) { + o.AggregationKey = &v +} + +// GetCustom returns the Custom field value if set, zero value otherwise. +func (o *AlertEventAttributes) GetCustom() interface{} { + if o == nil || o.Custom == nil { + var ret interface{} + return ret + } + return o.Custom +} + +// GetCustomOk returns a tuple with the Custom field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *AlertEventAttributes) GetCustomOk() (*interface{}, bool) { + if o == nil || o.Custom == nil { + return nil, false + } + return &o.Custom, true +} + +// HasCustom returns a boolean if a field has been set. +func (o *AlertEventAttributes) HasCustom() bool { + return o != nil && o.Custom != nil +} + +// SetCustom gets a reference to the given interface{} and assigns it to the Custom field. +func (o *AlertEventAttributes) SetCustom(v interface{}) { + o.Custom = v +} + +// GetEvt returns the Evt field value if set, zero value otherwise. +func (o *AlertEventAttributes) GetEvt() EventSystemAttributes { + if o == nil || o.Evt == nil { + var ret EventSystemAttributes + return ret + } + return *o.Evt +} + +// GetEvtOk returns a tuple with the Evt field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *AlertEventAttributes) GetEvtOk() (*EventSystemAttributes, bool) { + if o == nil || o.Evt == nil { + return nil, false + } + return o.Evt, true +} + +// HasEvt returns a boolean if a field has been set. +func (o *AlertEventAttributes) HasEvt() bool { + return o != nil && o.Evt != nil +} + +// SetEvt gets a reference to the given EventSystemAttributes and assigns it to the Evt field. +func (o *AlertEventAttributes) SetEvt(v EventSystemAttributes) { + o.Evt = &v +} + +// GetLinks returns the Links field value if set, zero value otherwise. +func (o *AlertEventAttributes) GetLinks() []AlertEventAttributesLinksItem { + if o == nil || o.Links == nil { + var ret []AlertEventAttributesLinksItem + return ret + } + return o.Links +} + +// GetLinksOk returns a tuple with the Links field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *AlertEventAttributes) GetLinksOk() (*[]AlertEventAttributesLinksItem, bool) { + if o == nil || o.Links == nil { + return nil, false + } + return &o.Links, true +} + +// HasLinks returns a boolean if a field has been set. +func (o *AlertEventAttributes) HasLinks() bool { + return o != nil && o.Links != nil +} + +// SetLinks gets a reference to the given []AlertEventAttributesLinksItem and assigns it to the Links field. +func (o *AlertEventAttributes) SetLinks(v []AlertEventAttributesLinksItem) { + o.Links = v +} + +// GetPriority returns the Priority field value if set, zero value otherwise. +func (o *AlertEventAttributes) GetPriority() AlertEventAttributesPriority { + if o == nil || o.Priority == nil { + var ret AlertEventAttributesPriority + return ret + } + return *o.Priority +} + +// GetPriorityOk returns a tuple with the Priority field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *AlertEventAttributes) GetPriorityOk() (*AlertEventAttributesPriority, bool) { + if o == nil || o.Priority == nil { + return nil, false + } + return o.Priority, true +} + +// HasPriority returns a boolean if a field has been set. +func (o *AlertEventAttributes) HasPriority() bool { + return o != nil && o.Priority != nil +} + +// SetPriority gets a reference to the given AlertEventAttributesPriority and assigns it to the Priority field. +func (o *AlertEventAttributes) SetPriority(v AlertEventAttributesPriority) { + o.Priority = &v +} + +// GetService returns the Service field value if set, zero value otherwise. +func (o *AlertEventAttributes) GetService() string { + if o == nil || o.Service == nil { + var ret string + return ret + } + return *o.Service +} + +// GetServiceOk returns a tuple with the Service field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *AlertEventAttributes) GetServiceOk() (*string, bool) { + if o == nil || o.Service == nil { + return nil, false + } + return o.Service, true +} + +// HasService returns a boolean if a field has been set. +func (o *AlertEventAttributes) HasService() bool { + return o != nil && o.Service != nil +} + +// SetService gets a reference to the given string and assigns it to the Service field. +func (o *AlertEventAttributes) SetService(v string) { + o.Service = &v +} + +// GetStatus returns the Status field value if set, zero value otherwise. +func (o *AlertEventAttributes) GetStatus() AlertEventAttributesStatus { + if o == nil || o.Status == nil { + var ret AlertEventAttributesStatus + return ret + } + return *o.Status +} + +// GetStatusOk returns a tuple with the Status field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *AlertEventAttributes) GetStatusOk() (*AlertEventAttributesStatus, bool) { + if o == nil || o.Status == nil { + return nil, false + } + return o.Status, true +} + +// HasStatus returns a boolean if a field has been set. +func (o *AlertEventAttributes) HasStatus() bool { + return o != nil && o.Status != nil +} + +// SetStatus gets a reference to the given AlertEventAttributesStatus and assigns it to the Status field. +func (o *AlertEventAttributes) SetStatus(v AlertEventAttributesStatus) { + o.Status = &v +} + +// GetTimestamp returns the Timestamp field value if set, zero value otherwise. +func (o *AlertEventAttributes) GetTimestamp() int64 { + if o == nil || o.Timestamp == nil { + var ret int64 + return ret + } + return *o.Timestamp +} + +// GetTimestampOk returns a tuple with the Timestamp field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *AlertEventAttributes) GetTimestampOk() (*int64, bool) { + if o == nil || o.Timestamp == nil { + return nil, false + } + return o.Timestamp, true +} + +// HasTimestamp returns a boolean if a field has been set. +func (o *AlertEventAttributes) HasTimestamp() bool { + return o != nil && o.Timestamp != nil +} + +// SetTimestamp gets a reference to the given int64 and assigns it to the Timestamp field. +func (o *AlertEventAttributes) SetTimestamp(v int64) { + o.Timestamp = &v +} + +// GetTitle returns the Title field value if set, zero value otherwise. +func (o *AlertEventAttributes) GetTitle() string { + if o == nil || o.Title == nil { + var ret string + return ret + } + return *o.Title +} + +// GetTitleOk returns a tuple with the Title field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *AlertEventAttributes) GetTitleOk() (*string, bool) { + if o == nil || o.Title == nil { + return nil, false + } + return o.Title, true +} + +// HasTitle returns a boolean if a field has been set. +func (o *AlertEventAttributes) HasTitle() bool { + return o != nil && o.Title != nil +} + +// SetTitle gets a reference to the given string and assigns it to the Title field. +func (o *AlertEventAttributes) SetTitle(v string) { + o.Title = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o AlertEventAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.AggregationKey != nil { + toSerialize["aggregation_key"] = o.AggregationKey + } + if o.Custom != nil { + toSerialize["custom"] = o.Custom + } + if o.Evt != nil { + toSerialize["evt"] = o.Evt + } + if o.Links != nil { + toSerialize["links"] = o.Links + } + if o.Priority != nil { + toSerialize["priority"] = o.Priority + } + if o.Service != nil { + toSerialize["service"] = o.Service + } + if o.Status != nil { + toSerialize["status"] = o.Status + } + if o.Timestamp != nil { + toSerialize["timestamp"] = o.Timestamp + } + if o.Title != nil { + toSerialize["title"] = o.Title + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *AlertEventAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + AggregationKey *string `json:"aggregation_key,omitempty"` + Custom interface{} `json:"custom,omitempty"` + Evt *EventSystemAttributes `json:"evt,omitempty"` + Links []AlertEventAttributesLinksItem `json:"links,omitempty"` + Priority *AlertEventAttributesPriority `json:"priority,omitempty"` + Service *string `json:"service,omitempty"` + Status *AlertEventAttributesStatus `json:"status,omitempty"` + Timestamp *int64 `json:"timestamp,omitempty"` + Title *string `json:"title,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{"aggregation_key", "custom", "evt", "links", "priority", "service", "status", "timestamp", "title"}) + } else { + return err + } + + hasInvalidField := false + o.AggregationKey = all.AggregationKey + o.Custom = all.Custom + if all.Evt != nil && all.Evt.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Evt = all.Evt + o.Links = all.Links + if all.Priority != nil && !all.Priority.IsValid() { + hasInvalidField = true + } else { + o.Priority = all.Priority + } + o.Service = all.Service + if all.Status != nil && !all.Status.IsValid() { + hasInvalidField = true + } else { + o.Status = all.Status + } + o.Timestamp = all.Timestamp + o.Title = all.Title + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_alert_event_attributes_links_item.go b/api/datadogV2/model_alert_event_attributes_links_item.go new file mode 100644 index 00000000000..f19257f48e4 --- /dev/null +++ b/api/datadogV2/model_alert_event_attributes_links_item.go @@ -0,0 +1,182 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// AlertEventAttributesLinksItem A link. +type AlertEventAttributesLinksItem struct { + // The category of the link. + Category *AlertEventAttributesLinksItemCategory `json:"category,omitempty"` + // The display text of the link. + Title *string `json:"title,omitempty"` + // The URL of the link. + Url *string `json:"url,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:"-"` +} + +// NewAlertEventAttributesLinksItem instantiates a new AlertEventAttributesLinksItem 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 NewAlertEventAttributesLinksItem() *AlertEventAttributesLinksItem { + this := AlertEventAttributesLinksItem{} + return &this +} + +// NewAlertEventAttributesLinksItemWithDefaults instantiates a new AlertEventAttributesLinksItem 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 NewAlertEventAttributesLinksItemWithDefaults() *AlertEventAttributesLinksItem { + this := AlertEventAttributesLinksItem{} + return &this +} + +// GetCategory returns the Category field value if set, zero value otherwise. +func (o *AlertEventAttributesLinksItem) GetCategory() AlertEventAttributesLinksItemCategory { + if o == nil || o.Category == nil { + var ret AlertEventAttributesLinksItemCategory + return ret + } + return *o.Category +} + +// GetCategoryOk returns a tuple with the Category field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *AlertEventAttributesLinksItem) GetCategoryOk() (*AlertEventAttributesLinksItemCategory, bool) { + if o == nil || o.Category == nil { + return nil, false + } + return o.Category, true +} + +// HasCategory returns a boolean if a field has been set. +func (o *AlertEventAttributesLinksItem) HasCategory() bool { + return o != nil && o.Category != nil +} + +// SetCategory gets a reference to the given AlertEventAttributesLinksItemCategory and assigns it to the Category field. +func (o *AlertEventAttributesLinksItem) SetCategory(v AlertEventAttributesLinksItemCategory) { + o.Category = &v +} + +// GetTitle returns the Title field value if set, zero value otherwise. +func (o *AlertEventAttributesLinksItem) GetTitle() string { + if o == nil || o.Title == nil { + var ret string + return ret + } + return *o.Title +} + +// GetTitleOk returns a tuple with the Title field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *AlertEventAttributesLinksItem) GetTitleOk() (*string, bool) { + if o == nil || o.Title == nil { + return nil, false + } + return o.Title, true +} + +// HasTitle returns a boolean if a field has been set. +func (o *AlertEventAttributesLinksItem) HasTitle() bool { + return o != nil && o.Title != nil +} + +// SetTitle gets a reference to the given string and assigns it to the Title field. +func (o *AlertEventAttributesLinksItem) SetTitle(v string) { + o.Title = &v +} + +// GetUrl returns the Url field value if set, zero value otherwise. +func (o *AlertEventAttributesLinksItem) GetUrl() string { + if o == nil || o.Url == nil { + var ret string + return ret + } + return *o.Url +} + +// GetUrlOk returns a tuple with the Url field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *AlertEventAttributesLinksItem) GetUrlOk() (*string, bool) { + if o == nil || o.Url == nil { + return nil, false + } + return o.Url, true +} + +// HasUrl returns a boolean if a field has been set. +func (o *AlertEventAttributesLinksItem) HasUrl() bool { + return o != nil && o.Url != nil +} + +// SetUrl gets a reference to the given string and assigns it to the Url field. +func (o *AlertEventAttributesLinksItem) SetUrl(v string) { + o.Url = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o AlertEventAttributesLinksItem) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Category != nil { + toSerialize["category"] = o.Category + } + if o.Title != nil { + toSerialize["title"] = o.Title + } + if o.Url != nil { + toSerialize["url"] = o.Url + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *AlertEventAttributesLinksItem) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Category *AlertEventAttributesLinksItemCategory `json:"category,omitempty"` + Title *string `json:"title,omitempty"` + Url *string `json:"url,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{"category", "title", "url"}) + } else { + return err + } + + hasInvalidField := false + if all.Category != nil && !all.Category.IsValid() { + hasInvalidField = true + } else { + o.Category = all.Category + } + o.Title = all.Title + o.Url = all.Url + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_alert_event_attributes_links_item_category.go b/api/datadogV2/model_alert_event_attributes_links_item_category.go new file mode 100644 index 00000000000..47d1f96bf3c --- /dev/null +++ b/api/datadogV2/model_alert_event_attributes_links_item_category.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 datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// AlertEventAttributesLinksItemCategory The category of the link. +type AlertEventAttributesLinksItemCategory string + +// List of AlertEventAttributesLinksItemCategory. +const ( + ALERTEVENTATTRIBUTESLINKSITEMCATEGORY_RUNBOOK AlertEventAttributesLinksItemCategory = "runbook" + ALERTEVENTATTRIBUTESLINKSITEMCATEGORY_DOCUMENTATION AlertEventAttributesLinksItemCategory = "documentation" + ALERTEVENTATTRIBUTESLINKSITEMCATEGORY_DASHBOARD AlertEventAttributesLinksItemCategory = "dashboard" +) + +var allowedAlertEventAttributesLinksItemCategoryEnumValues = []AlertEventAttributesLinksItemCategory{ + ALERTEVENTATTRIBUTESLINKSITEMCATEGORY_RUNBOOK, + ALERTEVENTATTRIBUTESLINKSITEMCATEGORY_DOCUMENTATION, + ALERTEVENTATTRIBUTESLINKSITEMCATEGORY_DASHBOARD, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *AlertEventAttributesLinksItemCategory) GetAllowedValues() []AlertEventAttributesLinksItemCategory { + return allowedAlertEventAttributesLinksItemCategoryEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *AlertEventAttributesLinksItemCategory) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = AlertEventAttributesLinksItemCategory(value) + return nil +} + +// NewAlertEventAttributesLinksItemCategoryFromValue returns a pointer to a valid AlertEventAttributesLinksItemCategory +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewAlertEventAttributesLinksItemCategoryFromValue(v string) (*AlertEventAttributesLinksItemCategory, error) { + ev := AlertEventAttributesLinksItemCategory(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for AlertEventAttributesLinksItemCategory: valid values are %v", v, allowedAlertEventAttributesLinksItemCategoryEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v AlertEventAttributesLinksItemCategory) IsValid() bool { + for _, existing := range allowedAlertEventAttributesLinksItemCategoryEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to AlertEventAttributesLinksItemCategory value. +func (v AlertEventAttributesLinksItemCategory) Ptr() *AlertEventAttributesLinksItemCategory { + return &v +} diff --git a/api/datadogV2/model_alert_event_attributes_priority.go b/api/datadogV2/model_alert_event_attributes_priority.go new file mode 100644 index 00000000000..a026abf2009 --- /dev/null +++ b/api/datadogV2/model_alert_event_attributes_priority.go @@ -0,0 +1,72 @@ +// 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" +) + +// AlertEventAttributesPriority The priority of the alert. +type AlertEventAttributesPriority string + +// List of AlertEventAttributesPriority. +const ( + ALERTEVENTATTRIBUTESPRIORITY_PRIORITY_ONE AlertEventAttributesPriority = "1" + ALERTEVENTATTRIBUTESPRIORITY_PRIORITY_TWO AlertEventAttributesPriority = "2" + ALERTEVENTATTRIBUTESPRIORITY_PRIORITY_THREE AlertEventAttributesPriority = "3" + ALERTEVENTATTRIBUTESPRIORITY_PRIORITY_FOUR AlertEventAttributesPriority = "4" + ALERTEVENTATTRIBUTESPRIORITY_PRIORITY_FIVE AlertEventAttributesPriority = "5" +) + +var allowedAlertEventAttributesPriorityEnumValues = []AlertEventAttributesPriority{ + ALERTEVENTATTRIBUTESPRIORITY_PRIORITY_ONE, + ALERTEVENTATTRIBUTESPRIORITY_PRIORITY_TWO, + ALERTEVENTATTRIBUTESPRIORITY_PRIORITY_THREE, + ALERTEVENTATTRIBUTESPRIORITY_PRIORITY_FOUR, + ALERTEVENTATTRIBUTESPRIORITY_PRIORITY_FIVE, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *AlertEventAttributesPriority) GetAllowedValues() []AlertEventAttributesPriority { + return allowedAlertEventAttributesPriorityEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *AlertEventAttributesPriority) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = AlertEventAttributesPriority(value) + return nil +} + +// NewAlertEventAttributesPriorityFromValue returns a pointer to a valid AlertEventAttributesPriority +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewAlertEventAttributesPriorityFromValue(v string) (*AlertEventAttributesPriority, error) { + ev := AlertEventAttributesPriority(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for AlertEventAttributesPriority: valid values are %v", v, allowedAlertEventAttributesPriorityEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v AlertEventAttributesPriority) IsValid() bool { + for _, existing := range allowedAlertEventAttributesPriorityEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to AlertEventAttributesPriority value. +func (v AlertEventAttributesPriority) Ptr() *AlertEventAttributesPriority { + return &v +} diff --git a/api/datadogV2/model_alert_event_attributes_status.go b/api/datadogV2/model_alert_event_attributes_status.go new file mode 100644 index 00000000000..a120544e60e --- /dev/null +++ b/api/datadogV2/model_alert_event_attributes_status.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 datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// AlertEventAttributesStatus The status of the alert. +type AlertEventAttributesStatus string + +// List of AlertEventAttributesStatus. +const ( + ALERTEVENTATTRIBUTESSTATUS_WARN AlertEventAttributesStatus = "warn" + ALERTEVENTATTRIBUTESSTATUS_ERROR AlertEventAttributesStatus = "error" + ALERTEVENTATTRIBUTESSTATUS_OK AlertEventAttributesStatus = "ok" +) + +var allowedAlertEventAttributesStatusEnumValues = []AlertEventAttributesStatus{ + ALERTEVENTATTRIBUTESSTATUS_WARN, + ALERTEVENTATTRIBUTESSTATUS_ERROR, + ALERTEVENTATTRIBUTESSTATUS_OK, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *AlertEventAttributesStatus) GetAllowedValues() []AlertEventAttributesStatus { + return allowedAlertEventAttributesStatusEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *AlertEventAttributesStatus) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = AlertEventAttributesStatus(value) + return nil +} + +// NewAlertEventAttributesStatusFromValue returns a pointer to a valid AlertEventAttributesStatus +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewAlertEventAttributesStatusFromValue(v string) (*AlertEventAttributesStatus, error) { + ev := AlertEventAttributesStatus(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for AlertEventAttributesStatus: valid values are %v", v, allowedAlertEventAttributesStatusEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v AlertEventAttributesStatus) IsValid() bool { + for _, existing := range allowedAlertEventAttributesStatusEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to AlertEventAttributesStatus value. +func (v AlertEventAttributesStatus) Ptr() *AlertEventAttributesStatus { + return &v +} diff --git a/api/datadogV2/model_change_event_attributes.go b/api/datadogV2/model_change_event_attributes.go new file mode 100644 index 00000000000..01b145770eb --- /dev/null +++ b/api/datadogV2/model_change_event_attributes.go @@ -0,0 +1,467 @@ +// 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" +) + +// ChangeEventAttributes Change event attributes. +type ChangeEventAttributes struct { + // Aggregation key of the event. + AggregationKey *string `json:"aggregation_key,omitempty"` + // The entity that made the change. + Author *ChangeEventAttributesAuthor `json:"author,omitempty"` + // JSON object of change metadata. + ChangeMetadata interface{} `json:"change_metadata,omitempty"` + // A uniquely identified resource. + ChangedResource *ChangeEventAttributesChangedResource `json:"changed_resource,omitempty"` + // JSON object of event system attributes. + Evt *EventSystemAttributes `json:"evt,omitempty"` + // A list of resources impacted by this change. + ImpactedResources []ChangeEventAttributesImpactedResourcesItem `json:"impacted_resources,omitempty"` + // The new state of the changed resource. + NewValue interface{} `json:"new_value,omitempty"` + // The previous state of the changed resource. + PrevValue interface{} `json:"prev_value,omitempty"` + // Service that triggered the event. + Service *string `json:"service,omitempty"` + // POSIX timestamp of the event. + Timestamp *int64 `json:"timestamp,omitempty"` + // The title of the event. + Title *string `json:"title,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:"-"` +} + +// NewChangeEventAttributes instantiates a new ChangeEventAttributes 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 NewChangeEventAttributes() *ChangeEventAttributes { + this := ChangeEventAttributes{} + return &this +} + +// NewChangeEventAttributesWithDefaults instantiates a new ChangeEventAttributes 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 NewChangeEventAttributesWithDefaults() *ChangeEventAttributes { + this := ChangeEventAttributes{} + return &this +} + +// GetAggregationKey returns the AggregationKey field value if set, zero value otherwise. +func (o *ChangeEventAttributes) GetAggregationKey() string { + if o == nil || o.AggregationKey == nil { + var ret string + return ret + } + return *o.AggregationKey +} + +// GetAggregationKeyOk returns a tuple with the AggregationKey field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ChangeEventAttributes) GetAggregationKeyOk() (*string, bool) { + if o == nil || o.AggregationKey == nil { + return nil, false + } + return o.AggregationKey, true +} + +// HasAggregationKey returns a boolean if a field has been set. +func (o *ChangeEventAttributes) HasAggregationKey() bool { + return o != nil && o.AggregationKey != nil +} + +// SetAggregationKey gets a reference to the given string and assigns it to the AggregationKey field. +func (o *ChangeEventAttributes) SetAggregationKey(v string) { + o.AggregationKey = &v +} + +// GetAuthor returns the Author field value if set, zero value otherwise. +func (o *ChangeEventAttributes) GetAuthor() ChangeEventAttributesAuthor { + if o == nil || o.Author == nil { + var ret ChangeEventAttributesAuthor + return ret + } + return *o.Author +} + +// GetAuthorOk returns a tuple with the Author field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ChangeEventAttributes) GetAuthorOk() (*ChangeEventAttributesAuthor, bool) { + if o == nil || o.Author == nil { + return nil, false + } + return o.Author, true +} + +// HasAuthor returns a boolean if a field has been set. +func (o *ChangeEventAttributes) HasAuthor() bool { + return o != nil && o.Author != nil +} + +// SetAuthor gets a reference to the given ChangeEventAttributesAuthor and assigns it to the Author field. +func (o *ChangeEventAttributes) SetAuthor(v ChangeEventAttributesAuthor) { + o.Author = &v +} + +// GetChangeMetadata returns the ChangeMetadata field value if set, zero value otherwise. +func (o *ChangeEventAttributes) GetChangeMetadata() interface{} { + if o == nil || o.ChangeMetadata == nil { + var ret interface{} + return ret + } + return o.ChangeMetadata +} + +// GetChangeMetadataOk returns a tuple with the ChangeMetadata field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ChangeEventAttributes) GetChangeMetadataOk() (*interface{}, bool) { + if o == nil || o.ChangeMetadata == nil { + return nil, false + } + return &o.ChangeMetadata, true +} + +// HasChangeMetadata returns a boolean if a field has been set. +func (o *ChangeEventAttributes) HasChangeMetadata() bool { + return o != nil && o.ChangeMetadata != nil +} + +// SetChangeMetadata gets a reference to the given interface{} and assigns it to the ChangeMetadata field. +func (o *ChangeEventAttributes) SetChangeMetadata(v interface{}) { + o.ChangeMetadata = v +} + +// GetChangedResource returns the ChangedResource field value if set, zero value otherwise. +func (o *ChangeEventAttributes) GetChangedResource() ChangeEventAttributesChangedResource { + if o == nil || o.ChangedResource == nil { + var ret ChangeEventAttributesChangedResource + return ret + } + return *o.ChangedResource +} + +// GetChangedResourceOk returns a tuple with the ChangedResource field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ChangeEventAttributes) GetChangedResourceOk() (*ChangeEventAttributesChangedResource, bool) { + if o == nil || o.ChangedResource == nil { + return nil, false + } + return o.ChangedResource, true +} + +// HasChangedResource returns a boolean if a field has been set. +func (o *ChangeEventAttributes) HasChangedResource() bool { + return o != nil && o.ChangedResource != nil +} + +// SetChangedResource gets a reference to the given ChangeEventAttributesChangedResource and assigns it to the ChangedResource field. +func (o *ChangeEventAttributes) SetChangedResource(v ChangeEventAttributesChangedResource) { + o.ChangedResource = &v +} + +// GetEvt returns the Evt field value if set, zero value otherwise. +func (o *ChangeEventAttributes) GetEvt() EventSystemAttributes { + if o == nil || o.Evt == nil { + var ret EventSystemAttributes + return ret + } + return *o.Evt +} + +// GetEvtOk returns a tuple with the Evt field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ChangeEventAttributes) GetEvtOk() (*EventSystemAttributes, bool) { + if o == nil || o.Evt == nil { + return nil, false + } + return o.Evt, true +} + +// HasEvt returns a boolean if a field has been set. +func (o *ChangeEventAttributes) HasEvt() bool { + return o != nil && o.Evt != nil +} + +// SetEvt gets a reference to the given EventSystemAttributes and assigns it to the Evt field. +func (o *ChangeEventAttributes) SetEvt(v EventSystemAttributes) { + o.Evt = &v +} + +// GetImpactedResources returns the ImpactedResources field value if set, zero value otherwise. +func (o *ChangeEventAttributes) GetImpactedResources() []ChangeEventAttributesImpactedResourcesItem { + if o == nil || o.ImpactedResources == nil { + var ret []ChangeEventAttributesImpactedResourcesItem + return ret + } + return o.ImpactedResources +} + +// GetImpactedResourcesOk returns a tuple with the ImpactedResources field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ChangeEventAttributes) GetImpactedResourcesOk() (*[]ChangeEventAttributesImpactedResourcesItem, bool) { + if o == nil || o.ImpactedResources == nil { + return nil, false + } + return &o.ImpactedResources, true +} + +// HasImpactedResources returns a boolean if a field has been set. +func (o *ChangeEventAttributes) HasImpactedResources() bool { + return o != nil && o.ImpactedResources != nil +} + +// SetImpactedResources gets a reference to the given []ChangeEventAttributesImpactedResourcesItem and assigns it to the ImpactedResources field. +func (o *ChangeEventAttributes) SetImpactedResources(v []ChangeEventAttributesImpactedResourcesItem) { + o.ImpactedResources = v +} + +// GetNewValue returns the NewValue field value if set, zero value otherwise. +func (o *ChangeEventAttributes) GetNewValue() interface{} { + if o == nil || o.NewValue == nil { + var ret interface{} + return ret + } + return o.NewValue +} + +// GetNewValueOk returns a tuple with the NewValue field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ChangeEventAttributes) GetNewValueOk() (*interface{}, bool) { + if o == nil || o.NewValue == nil { + return nil, false + } + return &o.NewValue, true +} + +// HasNewValue returns a boolean if a field has been set. +func (o *ChangeEventAttributes) HasNewValue() bool { + return o != nil && o.NewValue != nil +} + +// SetNewValue gets a reference to the given interface{} and assigns it to the NewValue field. +func (o *ChangeEventAttributes) SetNewValue(v interface{}) { + o.NewValue = v +} + +// GetPrevValue returns the PrevValue field value if set, zero value otherwise. +func (o *ChangeEventAttributes) GetPrevValue() interface{} { + if o == nil || o.PrevValue == nil { + var ret interface{} + return ret + } + return o.PrevValue +} + +// GetPrevValueOk returns a tuple with the PrevValue field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ChangeEventAttributes) GetPrevValueOk() (*interface{}, bool) { + if o == nil || o.PrevValue == nil { + return nil, false + } + return &o.PrevValue, true +} + +// HasPrevValue returns a boolean if a field has been set. +func (o *ChangeEventAttributes) HasPrevValue() bool { + return o != nil && o.PrevValue != nil +} + +// SetPrevValue gets a reference to the given interface{} and assigns it to the PrevValue field. +func (o *ChangeEventAttributes) SetPrevValue(v interface{}) { + o.PrevValue = v +} + +// GetService returns the Service field value if set, zero value otherwise. +func (o *ChangeEventAttributes) GetService() string { + if o == nil || o.Service == nil { + var ret string + return ret + } + return *o.Service +} + +// GetServiceOk returns a tuple with the Service field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ChangeEventAttributes) GetServiceOk() (*string, bool) { + if o == nil || o.Service == nil { + return nil, false + } + return o.Service, true +} + +// HasService returns a boolean if a field has been set. +func (o *ChangeEventAttributes) HasService() bool { + return o != nil && o.Service != nil +} + +// SetService gets a reference to the given string and assigns it to the Service field. +func (o *ChangeEventAttributes) SetService(v string) { + o.Service = &v +} + +// GetTimestamp returns the Timestamp field value if set, zero value otherwise. +func (o *ChangeEventAttributes) GetTimestamp() int64 { + if o == nil || o.Timestamp == nil { + var ret int64 + return ret + } + return *o.Timestamp +} + +// GetTimestampOk returns a tuple with the Timestamp field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ChangeEventAttributes) GetTimestampOk() (*int64, bool) { + if o == nil || o.Timestamp == nil { + return nil, false + } + return o.Timestamp, true +} + +// HasTimestamp returns a boolean if a field has been set. +func (o *ChangeEventAttributes) HasTimestamp() bool { + return o != nil && o.Timestamp != nil +} + +// SetTimestamp gets a reference to the given int64 and assigns it to the Timestamp field. +func (o *ChangeEventAttributes) SetTimestamp(v int64) { + o.Timestamp = &v +} + +// GetTitle returns the Title field value if set, zero value otherwise. +func (o *ChangeEventAttributes) GetTitle() string { + if o == nil || o.Title == nil { + var ret string + return ret + } + return *o.Title +} + +// GetTitleOk returns a tuple with the Title field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ChangeEventAttributes) GetTitleOk() (*string, bool) { + if o == nil || o.Title == nil { + return nil, false + } + return o.Title, true +} + +// HasTitle returns a boolean if a field has been set. +func (o *ChangeEventAttributes) HasTitle() bool { + return o != nil && o.Title != nil +} + +// SetTitle gets a reference to the given string and assigns it to the Title field. +func (o *ChangeEventAttributes) SetTitle(v string) { + o.Title = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ChangeEventAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.AggregationKey != nil { + toSerialize["aggregation_key"] = o.AggregationKey + } + if o.Author != nil { + toSerialize["author"] = o.Author + } + if o.ChangeMetadata != nil { + toSerialize["change_metadata"] = o.ChangeMetadata + } + if o.ChangedResource != nil { + toSerialize["changed_resource"] = o.ChangedResource + } + if o.Evt != nil { + toSerialize["evt"] = o.Evt + } + if o.ImpactedResources != nil { + toSerialize["impacted_resources"] = o.ImpactedResources + } + if o.NewValue != nil { + toSerialize["new_value"] = o.NewValue + } + if o.PrevValue != nil { + toSerialize["prev_value"] = o.PrevValue + } + if o.Service != nil { + toSerialize["service"] = o.Service + } + if o.Timestamp != nil { + toSerialize["timestamp"] = o.Timestamp + } + if o.Title != nil { + toSerialize["title"] = o.Title + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *ChangeEventAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + AggregationKey *string `json:"aggregation_key,omitempty"` + Author *ChangeEventAttributesAuthor `json:"author,omitempty"` + ChangeMetadata interface{} `json:"change_metadata,omitempty"` + ChangedResource *ChangeEventAttributesChangedResource `json:"changed_resource,omitempty"` + Evt *EventSystemAttributes `json:"evt,omitempty"` + ImpactedResources []ChangeEventAttributesImpactedResourcesItem `json:"impacted_resources,omitempty"` + NewValue interface{} `json:"new_value,omitempty"` + PrevValue interface{} `json:"prev_value,omitempty"` + Service *string `json:"service,omitempty"` + Timestamp *int64 `json:"timestamp,omitempty"` + Title *string `json:"title,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{"aggregation_key", "author", "change_metadata", "changed_resource", "evt", "impacted_resources", "new_value", "prev_value", "service", "timestamp", "title"}) + } else { + return err + } + + hasInvalidField := false + o.AggregationKey = all.AggregationKey + if all.Author != nil && all.Author.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Author = all.Author + o.ChangeMetadata = all.ChangeMetadata + if all.ChangedResource != nil && all.ChangedResource.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.ChangedResource = all.ChangedResource + if all.Evt != nil && all.Evt.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Evt = all.Evt + o.ImpactedResources = all.ImpactedResources + o.NewValue = all.NewValue + o.PrevValue = all.PrevValue + o.Service = all.Service + o.Timestamp = all.Timestamp + o.Title = all.Title + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_change_event_attributes_author.go b/api/datadogV2/model_change_event_attributes_author.go new file mode 100644 index 00000000000..308ec79d0bd --- /dev/null +++ b/api/datadogV2/model_change_event_attributes_author.go @@ -0,0 +1,147 @@ +// 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" +) + +// ChangeEventAttributesAuthor The entity that made the change. +type ChangeEventAttributesAuthor struct { + // The name of the user or system that made the change. + Name *string `json:"name,omitempty"` + // The type of the author. + Type *ChangeEventAttributesAuthorType `json:"type,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:"-"` +} + +// NewChangeEventAttributesAuthor instantiates a new ChangeEventAttributesAuthor 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 NewChangeEventAttributesAuthor() *ChangeEventAttributesAuthor { + this := ChangeEventAttributesAuthor{} + return &this +} + +// NewChangeEventAttributesAuthorWithDefaults instantiates a new ChangeEventAttributesAuthor 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 NewChangeEventAttributesAuthorWithDefaults() *ChangeEventAttributesAuthor { + this := ChangeEventAttributesAuthor{} + return &this +} + +// GetName returns the Name field value if set, zero value otherwise. +func (o *ChangeEventAttributesAuthor) GetName() string { + if o == nil || o.Name == nil { + var ret string + return ret + } + return *o.Name +} + +// GetNameOk returns a tuple with the Name field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ChangeEventAttributesAuthor) GetNameOk() (*string, bool) { + if o == nil || o.Name == nil { + return nil, false + } + return o.Name, true +} + +// HasName returns a boolean if a field has been set. +func (o *ChangeEventAttributesAuthor) HasName() bool { + return o != nil && o.Name != nil +} + +// SetName gets a reference to the given string and assigns it to the Name field. +func (o *ChangeEventAttributesAuthor) SetName(v string) { + o.Name = &v +} + +// GetType returns the Type field value if set, zero value otherwise. +func (o *ChangeEventAttributesAuthor) GetType() ChangeEventAttributesAuthorType { + if o == nil || o.Type == nil { + var ret ChangeEventAttributesAuthorType + return ret + } + return *o.Type +} + +// GetTypeOk returns a tuple with the Type field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ChangeEventAttributesAuthor) GetTypeOk() (*ChangeEventAttributesAuthorType, bool) { + if o == nil || o.Type == nil { + return nil, false + } + return o.Type, true +} + +// HasType returns a boolean if a field has been set. +func (o *ChangeEventAttributesAuthor) HasType() bool { + return o != nil && o.Type != nil +} + +// SetType gets a reference to the given ChangeEventAttributesAuthorType and assigns it to the Type field. +func (o *ChangeEventAttributesAuthor) SetType(v ChangeEventAttributesAuthorType) { + o.Type = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ChangeEventAttributesAuthor) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Name != nil { + toSerialize["name"] = o.Name + } + if o.Type != nil { + toSerialize["type"] = o.Type + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *ChangeEventAttributesAuthor) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Name *string `json:"name,omitempty"` + Type *ChangeEventAttributesAuthorType `json:"type,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{"name", "type"}) + } else { + return err + } + + hasInvalidField := false + o.Name = all.Name + if all.Type != nil && !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_change_event_attributes_author_type.go b/api/datadogV2/model_change_event_attributes_author_type.go new file mode 100644 index 00000000000..0b54452da04 --- /dev/null +++ b/api/datadogV2/model_change_event_attributes_author_type.go @@ -0,0 +1,70 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// ChangeEventAttributesAuthorType The type of the author. +type ChangeEventAttributesAuthorType string + +// List of ChangeEventAttributesAuthorType. +const ( + CHANGEEVENTATTRIBUTESAUTHORTYPE_USER ChangeEventAttributesAuthorType = "user" + CHANGEEVENTATTRIBUTESAUTHORTYPE_SYSTEM ChangeEventAttributesAuthorType = "system" + CHANGEEVENTATTRIBUTESAUTHORTYPE_API ChangeEventAttributesAuthorType = "api" + CHANGEEVENTATTRIBUTESAUTHORTYPE_AUTOMATION ChangeEventAttributesAuthorType = "automation" +) + +var allowedChangeEventAttributesAuthorTypeEnumValues = []ChangeEventAttributesAuthorType{ + CHANGEEVENTATTRIBUTESAUTHORTYPE_USER, + CHANGEEVENTATTRIBUTESAUTHORTYPE_SYSTEM, + CHANGEEVENTATTRIBUTESAUTHORTYPE_API, + CHANGEEVENTATTRIBUTESAUTHORTYPE_AUTOMATION, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *ChangeEventAttributesAuthorType) GetAllowedValues() []ChangeEventAttributesAuthorType { + return allowedChangeEventAttributesAuthorTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *ChangeEventAttributesAuthorType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = ChangeEventAttributesAuthorType(value) + return nil +} + +// NewChangeEventAttributesAuthorTypeFromValue returns a pointer to a valid ChangeEventAttributesAuthorType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewChangeEventAttributesAuthorTypeFromValue(v string) (*ChangeEventAttributesAuthorType, error) { + ev := ChangeEventAttributesAuthorType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for ChangeEventAttributesAuthorType: valid values are %v", v, allowedChangeEventAttributesAuthorTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v ChangeEventAttributesAuthorType) IsValid() bool { + for _, existing := range allowedChangeEventAttributesAuthorTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to ChangeEventAttributesAuthorType value. +func (v ChangeEventAttributesAuthorType) Ptr() *ChangeEventAttributesAuthorType { + return &v +} diff --git a/api/datadogV2/model_change_event_attributes_changed_resource.go b/api/datadogV2/model_change_event_attributes_changed_resource.go new file mode 100644 index 00000000000..452f90f95be --- /dev/null +++ b/api/datadogV2/model_change_event_attributes_changed_resource.go @@ -0,0 +1,147 @@ +// 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" +) + +// ChangeEventAttributesChangedResource A uniquely identified resource. +type ChangeEventAttributesChangedResource struct { + // The name of the changed resource. + Name *string `json:"name,omitempty"` + // The type of the changed resource. + Type *ChangeEventAttributesChangedResourceType `json:"type,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:"-"` +} + +// NewChangeEventAttributesChangedResource instantiates a new ChangeEventAttributesChangedResource 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 NewChangeEventAttributesChangedResource() *ChangeEventAttributesChangedResource { + this := ChangeEventAttributesChangedResource{} + return &this +} + +// NewChangeEventAttributesChangedResourceWithDefaults instantiates a new ChangeEventAttributesChangedResource 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 NewChangeEventAttributesChangedResourceWithDefaults() *ChangeEventAttributesChangedResource { + this := ChangeEventAttributesChangedResource{} + return &this +} + +// GetName returns the Name field value if set, zero value otherwise. +func (o *ChangeEventAttributesChangedResource) GetName() string { + if o == nil || o.Name == nil { + var ret string + return ret + } + return *o.Name +} + +// GetNameOk returns a tuple with the Name field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ChangeEventAttributesChangedResource) GetNameOk() (*string, bool) { + if o == nil || o.Name == nil { + return nil, false + } + return o.Name, true +} + +// HasName returns a boolean if a field has been set. +func (o *ChangeEventAttributesChangedResource) HasName() bool { + return o != nil && o.Name != nil +} + +// SetName gets a reference to the given string and assigns it to the Name field. +func (o *ChangeEventAttributesChangedResource) SetName(v string) { + o.Name = &v +} + +// GetType returns the Type field value if set, zero value otherwise. +func (o *ChangeEventAttributesChangedResource) GetType() ChangeEventAttributesChangedResourceType { + if o == nil || o.Type == nil { + var ret ChangeEventAttributesChangedResourceType + return ret + } + return *o.Type +} + +// GetTypeOk returns a tuple with the Type field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ChangeEventAttributesChangedResource) GetTypeOk() (*ChangeEventAttributesChangedResourceType, bool) { + if o == nil || o.Type == nil { + return nil, false + } + return o.Type, true +} + +// HasType returns a boolean if a field has been set. +func (o *ChangeEventAttributesChangedResource) HasType() bool { + return o != nil && o.Type != nil +} + +// SetType gets a reference to the given ChangeEventAttributesChangedResourceType and assigns it to the Type field. +func (o *ChangeEventAttributesChangedResource) SetType(v ChangeEventAttributesChangedResourceType) { + o.Type = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ChangeEventAttributesChangedResource) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Name != nil { + toSerialize["name"] = o.Name + } + if o.Type != nil { + toSerialize["type"] = o.Type + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *ChangeEventAttributesChangedResource) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Name *string `json:"name,omitempty"` + Type *ChangeEventAttributesChangedResourceType `json:"type,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{"name", "type"}) + } else { + return err + } + + hasInvalidField := false + o.Name = all.Name + if all.Type != nil && !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_change_event_attributes_changed_resource_type.go b/api/datadogV2/model_change_event_attributes_changed_resource_type.go new file mode 100644 index 00000000000..69bfe80a0d2 --- /dev/null +++ b/api/datadogV2/model_change_event_attributes_changed_resource_type.go @@ -0,0 +1,66 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// ChangeEventAttributesChangedResourceType The type of the changed resource. +type ChangeEventAttributesChangedResourceType string + +// List of ChangeEventAttributesChangedResourceType. +const ( + CHANGEEVENTATTRIBUTESCHANGEDRESOURCETYPE_FEATURE_FLAG ChangeEventAttributesChangedResourceType = "feature_flag" + CHANGEEVENTATTRIBUTESCHANGEDRESOURCETYPE_CONFIGURATION ChangeEventAttributesChangedResourceType = "configuration" +) + +var allowedChangeEventAttributesChangedResourceTypeEnumValues = []ChangeEventAttributesChangedResourceType{ + CHANGEEVENTATTRIBUTESCHANGEDRESOURCETYPE_FEATURE_FLAG, + CHANGEEVENTATTRIBUTESCHANGEDRESOURCETYPE_CONFIGURATION, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *ChangeEventAttributesChangedResourceType) GetAllowedValues() []ChangeEventAttributesChangedResourceType { + return allowedChangeEventAttributesChangedResourceTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *ChangeEventAttributesChangedResourceType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = ChangeEventAttributesChangedResourceType(value) + return nil +} + +// NewChangeEventAttributesChangedResourceTypeFromValue returns a pointer to a valid ChangeEventAttributesChangedResourceType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewChangeEventAttributesChangedResourceTypeFromValue(v string) (*ChangeEventAttributesChangedResourceType, error) { + ev := ChangeEventAttributesChangedResourceType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for ChangeEventAttributesChangedResourceType: valid values are %v", v, allowedChangeEventAttributesChangedResourceTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v ChangeEventAttributesChangedResourceType) IsValid() bool { + for _, existing := range allowedChangeEventAttributesChangedResourceTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to ChangeEventAttributesChangedResourceType value. +func (v ChangeEventAttributesChangedResourceType) Ptr() *ChangeEventAttributesChangedResourceType { + return &v +} diff --git a/api/datadogV2/model_change_event_attributes_impacted_resources_item.go b/api/datadogV2/model_change_event_attributes_impacted_resources_item.go new file mode 100644 index 00000000000..4563b141ecd --- /dev/null +++ b/api/datadogV2/model_change_event_attributes_impacted_resources_item.go @@ -0,0 +1,147 @@ +// 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" +) + +// ChangeEventAttributesImpactedResourcesItem A uniquely identified resource. +type ChangeEventAttributesImpactedResourcesItem struct { + // The name of the impacted resource. + Name *string `json:"name,omitempty"` + // The type of the impacted resource. + Type *ChangeEventAttributesImpactedResourcesItemType `json:"type,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:"-"` +} + +// NewChangeEventAttributesImpactedResourcesItem instantiates a new ChangeEventAttributesImpactedResourcesItem 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 NewChangeEventAttributesImpactedResourcesItem() *ChangeEventAttributesImpactedResourcesItem { + this := ChangeEventAttributesImpactedResourcesItem{} + return &this +} + +// NewChangeEventAttributesImpactedResourcesItemWithDefaults instantiates a new ChangeEventAttributesImpactedResourcesItem 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 NewChangeEventAttributesImpactedResourcesItemWithDefaults() *ChangeEventAttributesImpactedResourcesItem { + this := ChangeEventAttributesImpactedResourcesItem{} + return &this +} + +// GetName returns the Name field value if set, zero value otherwise. +func (o *ChangeEventAttributesImpactedResourcesItem) GetName() string { + if o == nil || o.Name == nil { + var ret string + return ret + } + return *o.Name +} + +// GetNameOk returns a tuple with the Name field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ChangeEventAttributesImpactedResourcesItem) GetNameOk() (*string, bool) { + if o == nil || o.Name == nil { + return nil, false + } + return o.Name, true +} + +// HasName returns a boolean if a field has been set. +func (o *ChangeEventAttributesImpactedResourcesItem) HasName() bool { + return o != nil && o.Name != nil +} + +// SetName gets a reference to the given string and assigns it to the Name field. +func (o *ChangeEventAttributesImpactedResourcesItem) SetName(v string) { + o.Name = &v +} + +// GetType returns the Type field value if set, zero value otherwise. +func (o *ChangeEventAttributesImpactedResourcesItem) GetType() ChangeEventAttributesImpactedResourcesItemType { + if o == nil || o.Type == nil { + var ret ChangeEventAttributesImpactedResourcesItemType + return ret + } + return *o.Type +} + +// GetTypeOk returns a tuple with the Type field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ChangeEventAttributesImpactedResourcesItem) GetTypeOk() (*ChangeEventAttributesImpactedResourcesItemType, bool) { + if o == nil || o.Type == nil { + return nil, false + } + return o.Type, true +} + +// HasType returns a boolean if a field has been set. +func (o *ChangeEventAttributesImpactedResourcesItem) HasType() bool { + return o != nil && o.Type != nil +} + +// SetType gets a reference to the given ChangeEventAttributesImpactedResourcesItemType and assigns it to the Type field. +func (o *ChangeEventAttributesImpactedResourcesItem) SetType(v ChangeEventAttributesImpactedResourcesItemType) { + o.Type = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ChangeEventAttributesImpactedResourcesItem) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Name != nil { + toSerialize["name"] = o.Name + } + if o.Type != nil { + toSerialize["type"] = o.Type + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *ChangeEventAttributesImpactedResourcesItem) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Name *string `json:"name,omitempty"` + Type *ChangeEventAttributesImpactedResourcesItemType `json:"type,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{"name", "type"}) + } else { + return err + } + + hasInvalidField := false + o.Name = all.Name + if all.Type != nil && !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_change_event_attributes_impacted_resources_item_type.go b/api/datadogV2/model_change_event_attributes_impacted_resources_item_type.go new file mode 100644 index 00000000000..2f41a1acc8c --- /dev/null +++ b/api/datadogV2/model_change_event_attributes_impacted_resources_item_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" +) + +// ChangeEventAttributesImpactedResourcesItemType The type of the impacted resource. +type ChangeEventAttributesImpactedResourcesItemType string + +// List of ChangeEventAttributesImpactedResourcesItemType. +const ( + CHANGEEVENTATTRIBUTESIMPACTEDRESOURCESITEMTYPE_SERVICE ChangeEventAttributesImpactedResourcesItemType = "service" +) + +var allowedChangeEventAttributesImpactedResourcesItemTypeEnumValues = []ChangeEventAttributesImpactedResourcesItemType{ + CHANGEEVENTATTRIBUTESIMPACTEDRESOURCESITEMTYPE_SERVICE, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *ChangeEventAttributesImpactedResourcesItemType) GetAllowedValues() []ChangeEventAttributesImpactedResourcesItemType { + return allowedChangeEventAttributesImpactedResourcesItemTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *ChangeEventAttributesImpactedResourcesItemType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = ChangeEventAttributesImpactedResourcesItemType(value) + return nil +} + +// NewChangeEventAttributesImpactedResourcesItemTypeFromValue returns a pointer to a valid ChangeEventAttributesImpactedResourcesItemType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewChangeEventAttributesImpactedResourcesItemTypeFromValue(v string) (*ChangeEventAttributesImpactedResourcesItemType, error) { + ev := ChangeEventAttributesImpactedResourcesItemType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for ChangeEventAttributesImpactedResourcesItemType: valid values are %v", v, allowedChangeEventAttributesImpactedResourcesItemTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v ChangeEventAttributesImpactedResourcesItemType) IsValid() bool { + for _, existing := range allowedChangeEventAttributesImpactedResourcesItemTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to ChangeEventAttributesImpactedResourcesItemType value. +func (v ChangeEventAttributesImpactedResourcesItemType) Ptr() *ChangeEventAttributesImpactedResourcesItemType { + return &v +} diff --git a/api/datadogV2/model_event_system_attributes.go b/api/datadogV2/model_event_system_attributes.go new file mode 100644 index 00000000000..c3be4e46172 --- /dev/null +++ b/api/datadogV2/model_event_system_attributes.go @@ -0,0 +1,256 @@ +// 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" +) + +// EventSystemAttributes JSON object of event system attributes. +type EventSystemAttributes struct { + // Event category identifying the type of event. + Category *EventSystemAttributesCategory `json:"category,omitempty"` + // Event identifier. This field is deprecated and will be removed in a future version. Use the `uid` field instead. + Id *string `json:"id,omitempty"` + // Integration ID sourced from integration manifests. + IntegrationId *EventSystemAttributesIntegrationId `json:"integration_id,omitempty"` + // The source type ID of the event. + SourceId *int64 `json:"source_id,omitempty"` + // A unique identifier for the event. You can use this identifier to query or reference the event. + Uid *string `json:"uid,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:"-"` +} + +// NewEventSystemAttributes instantiates a new EventSystemAttributes 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 NewEventSystemAttributes() *EventSystemAttributes { + this := EventSystemAttributes{} + return &this +} + +// NewEventSystemAttributesWithDefaults instantiates a new EventSystemAttributes 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 NewEventSystemAttributesWithDefaults() *EventSystemAttributes { + this := EventSystemAttributes{} + return &this +} + +// GetCategory returns the Category field value if set, zero value otherwise. +func (o *EventSystemAttributes) GetCategory() EventSystemAttributesCategory { + if o == nil || o.Category == nil { + var ret EventSystemAttributesCategory + return ret + } + return *o.Category +} + +// GetCategoryOk returns a tuple with the Category field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *EventSystemAttributes) GetCategoryOk() (*EventSystemAttributesCategory, bool) { + if o == nil || o.Category == nil { + return nil, false + } + return o.Category, true +} + +// HasCategory returns a boolean if a field has been set. +func (o *EventSystemAttributes) HasCategory() bool { + return o != nil && o.Category != nil +} + +// SetCategory gets a reference to the given EventSystemAttributesCategory and assigns it to the Category field. +func (o *EventSystemAttributes) SetCategory(v EventSystemAttributesCategory) { + o.Category = &v +} + +// GetId returns the Id field value if set, zero value otherwise. +func (o *EventSystemAttributes) 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 *EventSystemAttributes) 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 *EventSystemAttributes) 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 *EventSystemAttributes) SetId(v string) { + o.Id = &v +} + +// GetIntegrationId returns the IntegrationId field value if set, zero value otherwise. +func (o *EventSystemAttributes) GetIntegrationId() EventSystemAttributesIntegrationId { + if o == nil || o.IntegrationId == nil { + var ret EventSystemAttributesIntegrationId + return ret + } + return *o.IntegrationId +} + +// GetIntegrationIdOk returns a tuple with the IntegrationId field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *EventSystemAttributes) GetIntegrationIdOk() (*EventSystemAttributesIntegrationId, bool) { + if o == nil || o.IntegrationId == nil { + return nil, false + } + return o.IntegrationId, true +} + +// HasIntegrationId returns a boolean if a field has been set. +func (o *EventSystemAttributes) HasIntegrationId() bool { + return o != nil && o.IntegrationId != nil +} + +// SetIntegrationId gets a reference to the given EventSystemAttributesIntegrationId and assigns it to the IntegrationId field. +func (o *EventSystemAttributes) SetIntegrationId(v EventSystemAttributesIntegrationId) { + o.IntegrationId = &v +} + +// GetSourceId returns the SourceId field value if set, zero value otherwise. +func (o *EventSystemAttributes) GetSourceId() int64 { + if o == nil || o.SourceId == nil { + var ret int64 + return ret + } + return *o.SourceId +} + +// GetSourceIdOk returns a tuple with the SourceId field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *EventSystemAttributes) GetSourceIdOk() (*int64, bool) { + if o == nil || o.SourceId == nil { + return nil, false + } + return o.SourceId, true +} + +// HasSourceId returns a boolean if a field has been set. +func (o *EventSystemAttributes) HasSourceId() bool { + return o != nil && o.SourceId != nil +} + +// SetSourceId gets a reference to the given int64 and assigns it to the SourceId field. +func (o *EventSystemAttributes) SetSourceId(v int64) { + o.SourceId = &v +} + +// GetUid returns the Uid field value if set, zero value otherwise. +func (o *EventSystemAttributes) GetUid() string { + if o == nil || o.Uid == nil { + var ret string + return ret + } + return *o.Uid +} + +// GetUidOk returns a tuple with the Uid field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *EventSystemAttributes) GetUidOk() (*string, bool) { + if o == nil || o.Uid == nil { + return nil, false + } + return o.Uid, true +} + +// HasUid returns a boolean if a field has been set. +func (o *EventSystemAttributes) HasUid() bool { + return o != nil && o.Uid != nil +} + +// SetUid gets a reference to the given string and assigns it to the Uid field. +func (o *EventSystemAttributes) SetUid(v string) { + o.Uid = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o EventSystemAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Category != nil { + toSerialize["category"] = o.Category + } + if o.Id != nil { + toSerialize["id"] = o.Id + } + if o.IntegrationId != nil { + toSerialize["integration_id"] = o.IntegrationId + } + if o.SourceId != nil { + toSerialize["source_id"] = o.SourceId + } + if o.Uid != nil { + toSerialize["uid"] = o.Uid + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *EventSystemAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Category *EventSystemAttributesCategory `json:"category,omitempty"` + Id *string `json:"id,omitempty"` + IntegrationId *EventSystemAttributesIntegrationId `json:"integration_id,omitempty"` + SourceId *int64 `json:"source_id,omitempty"` + Uid *string `json:"uid,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{"category", "id", "integration_id", "source_id", "uid"}) + } else { + return err + } + + hasInvalidField := false + if all.Category != nil && !all.Category.IsValid() { + hasInvalidField = true + } else { + o.Category = all.Category + } + o.Id = all.Id + if all.IntegrationId != nil && !all.IntegrationId.IsValid() { + hasInvalidField = true + } else { + o.IntegrationId = all.IntegrationId + } + o.SourceId = all.SourceId + o.Uid = all.Uid + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_event_system_attributes_category.go b/api/datadogV2/model_event_system_attributes_category.go new file mode 100644 index 00000000000..775147d713a --- /dev/null +++ b/api/datadogV2/model_event_system_attributes_category.go @@ -0,0 +1,66 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// EventSystemAttributesCategory Event category identifying the type of event. +type EventSystemAttributesCategory string + +// List of EventSystemAttributesCategory. +const ( + EVENTSYSTEMATTRIBUTESCATEGORY_CHANGE EventSystemAttributesCategory = "change" + EVENTSYSTEMATTRIBUTESCATEGORY_ALERT EventSystemAttributesCategory = "alert" +) + +var allowedEventSystemAttributesCategoryEnumValues = []EventSystemAttributesCategory{ + EVENTSYSTEMATTRIBUTESCATEGORY_CHANGE, + EVENTSYSTEMATTRIBUTESCATEGORY_ALERT, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *EventSystemAttributesCategory) GetAllowedValues() []EventSystemAttributesCategory { + return allowedEventSystemAttributesCategoryEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *EventSystemAttributesCategory) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = EventSystemAttributesCategory(value) + return nil +} + +// NewEventSystemAttributesCategoryFromValue returns a pointer to a valid EventSystemAttributesCategory +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewEventSystemAttributesCategoryFromValue(v string) (*EventSystemAttributesCategory, error) { + ev := EventSystemAttributesCategory(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for EventSystemAttributesCategory: valid values are %v", v, allowedEventSystemAttributesCategoryEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v EventSystemAttributesCategory) IsValid() bool { + for _, existing := range allowedEventSystemAttributesCategoryEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to EventSystemAttributesCategory value. +func (v EventSystemAttributesCategory) Ptr() *EventSystemAttributesCategory { + return &v +} diff --git a/api/datadogV2/model_event_system_attributes_integration_id.go b/api/datadogV2/model_event_system_attributes_integration_id.go new file mode 100644 index 00000000000..5b1aeb491c4 --- /dev/null +++ b/api/datadogV2/model_event_system_attributes_integration_id.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" +) + +// EventSystemAttributesIntegrationId Integration ID sourced from integration manifests. +type EventSystemAttributesIntegrationId string + +// List of EventSystemAttributesIntegrationId. +const ( + EVENTSYSTEMATTRIBUTESINTEGRATIONID_CUSTOM_EVENTS EventSystemAttributesIntegrationId = "custom-events" +) + +var allowedEventSystemAttributesIntegrationIdEnumValues = []EventSystemAttributesIntegrationId{ + EVENTSYSTEMATTRIBUTESINTEGRATIONID_CUSTOM_EVENTS, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *EventSystemAttributesIntegrationId) GetAllowedValues() []EventSystemAttributesIntegrationId { + return allowedEventSystemAttributesIntegrationIdEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *EventSystemAttributesIntegrationId) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = EventSystemAttributesIntegrationId(value) + return nil +} + +// NewEventSystemAttributesIntegrationIdFromValue returns a pointer to a valid EventSystemAttributesIntegrationId +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewEventSystemAttributesIntegrationIdFromValue(v string) (*EventSystemAttributesIntegrationId, error) { + ev := EventSystemAttributesIntegrationId(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for EventSystemAttributesIntegrationId: valid values are %v", v, allowedEventSystemAttributesIntegrationIdEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v EventSystemAttributesIntegrationId) IsValid() bool { + for _, existing := range allowedEventSystemAttributesIntegrationIdEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to EventSystemAttributesIntegrationId value. +func (v EventSystemAttributesIntegrationId) Ptr() *EventSystemAttributesIntegrationId { + return &v +} diff --git a/api/datadogV2/model_v2_event.go b/api/datadogV2/model_v2_event.go new file mode 100644 index 00000000000..9a7bf34c4dd --- /dev/null +++ b/api/datadogV2/model_v2_event.go @@ -0,0 +1,181 @@ +// 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" +) + +// V2Event An event object. +type V2Event struct { + // Event attributes. + Attributes *V2EventAttributes `json:"attributes,omitempty"` + // The event's ID. + Id *string `json:"id,omitempty"` + // Entity type. + Type *string `json:"type,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:"-"` +} + +// NewV2Event instantiates a new V2Event 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 NewV2Event() *V2Event { + this := V2Event{} + return &this +} + +// NewV2EventWithDefaults instantiates a new V2Event 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 NewV2EventWithDefaults() *V2Event { + this := V2Event{} + return &this +} + +// GetAttributes returns the Attributes field value if set, zero value otherwise. +func (o *V2Event) GetAttributes() V2EventAttributes { + if o == nil || o.Attributes == nil { + var ret V2EventAttributes + 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 *V2Event) GetAttributesOk() (*V2EventAttributes, 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 *V2Event) HasAttributes() bool { + return o != nil && o.Attributes != nil +} + +// SetAttributes gets a reference to the given V2EventAttributes and assigns it to the Attributes field. +func (o *V2Event) SetAttributes(v V2EventAttributes) { + o.Attributes = &v +} + +// GetId returns the Id field value if set, zero value otherwise. +func (o *V2Event) 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 *V2Event) 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 *V2Event) 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 *V2Event) SetId(v string) { + o.Id = &v +} + +// GetType returns the Type field value if set, zero value otherwise. +func (o *V2Event) GetType() string { + if o == nil || o.Type == nil { + var ret string + return ret + } + return *o.Type +} + +// GetTypeOk returns a tuple with the Type field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *V2Event) GetTypeOk() (*string, bool) { + if o == nil || o.Type == nil { + return nil, false + } + return o.Type, true +} + +// HasType returns a boolean if a field has been set. +func (o *V2Event) HasType() bool { + return o != nil && o.Type != nil +} + +// SetType gets a reference to the given string and assigns it to the Type field. +func (o *V2Event) SetType(v string) { + o.Type = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o V2Event) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Attributes != nil { + toSerialize["attributes"] = o.Attributes + } + if o.Id != nil { + toSerialize["id"] = o.Id + } + if o.Type != nil { + toSerialize["type"] = o.Type + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *V2Event) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *V2EventAttributes `json:"attributes,omitempty"` + Id *string `json:"id,omitempty"` + Type *string `json:"type,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{"attributes", "id", "type"}) + } else { + return err + } + + hasInvalidField := false + if all.Attributes != nil && all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Attributes = all.Attributes + o.Id = all.Id + 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_v2_event_attributes.go b/api/datadogV2/model_v2_event_attributes.go new file mode 100644 index 00000000000..7df5294fbc6 --- /dev/null +++ b/api/datadogV2/model_v2_event_attributes.go @@ -0,0 +1,207 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// V2EventAttributes Event attributes. +type V2EventAttributes struct { + // JSON object for category-specific attributes. + Attributes *V2EventAttributesAttributes `json:"attributes,omitempty"` + // Free-form text associated with the event. + Message *string `json:"message,omitempty"` + // A list of tags associated with the event. + Tags []string `json:"tags,omitempty"` + // Timestamp when the event occurred. + Timestamp *string `json:"timestamp,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:"-"` +} + +// NewV2EventAttributes instantiates a new V2EventAttributes 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 NewV2EventAttributes() *V2EventAttributes { + this := V2EventAttributes{} + return &this +} + +// NewV2EventAttributesWithDefaults instantiates a new V2EventAttributes 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 NewV2EventAttributesWithDefaults() *V2EventAttributes { + this := V2EventAttributes{} + return &this +} + +// GetAttributes returns the Attributes field value if set, zero value otherwise. +func (o *V2EventAttributes) GetAttributes() V2EventAttributesAttributes { + if o == nil || o.Attributes == nil { + var ret V2EventAttributesAttributes + 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 *V2EventAttributes) GetAttributesOk() (*V2EventAttributesAttributes, 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 *V2EventAttributes) HasAttributes() bool { + return o != nil && o.Attributes != nil +} + +// SetAttributes gets a reference to the given V2EventAttributesAttributes and assigns it to the Attributes field. +func (o *V2EventAttributes) SetAttributes(v V2EventAttributesAttributes) { + o.Attributes = &v +} + +// GetMessage returns the Message field value if set, zero value otherwise. +func (o *V2EventAttributes) GetMessage() string { + if o == nil || o.Message == nil { + var ret string + return ret + } + return *o.Message +} + +// GetMessageOk returns a tuple with the Message field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *V2EventAttributes) GetMessageOk() (*string, bool) { + if o == nil || o.Message == nil { + return nil, false + } + return o.Message, true +} + +// HasMessage returns a boolean if a field has been set. +func (o *V2EventAttributes) HasMessage() bool { + return o != nil && o.Message != nil +} + +// SetMessage gets a reference to the given string and assigns it to the Message field. +func (o *V2EventAttributes) SetMessage(v string) { + o.Message = &v +} + +// GetTags returns the Tags field value if set, zero value otherwise. +func (o *V2EventAttributes) GetTags() []string { + if o == nil || o.Tags == nil { + var ret []string + return ret + } + return o.Tags +} + +// GetTagsOk returns a tuple with the Tags field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *V2EventAttributes) GetTagsOk() (*[]string, bool) { + if o == nil || o.Tags == nil { + return nil, false + } + return &o.Tags, true +} + +// HasTags returns a boolean if a field has been set. +func (o *V2EventAttributes) HasTags() bool { + return o != nil && o.Tags != nil +} + +// SetTags gets a reference to the given []string and assigns it to the Tags field. +func (o *V2EventAttributes) SetTags(v []string) { + o.Tags = v +} + +// GetTimestamp returns the Timestamp field value if set, zero value otherwise. +func (o *V2EventAttributes) GetTimestamp() string { + if o == nil || o.Timestamp == nil { + var ret string + return ret + } + return *o.Timestamp +} + +// GetTimestampOk returns a tuple with the Timestamp field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *V2EventAttributes) GetTimestampOk() (*string, bool) { + if o == nil || o.Timestamp == nil { + return nil, false + } + return o.Timestamp, true +} + +// HasTimestamp returns a boolean if a field has been set. +func (o *V2EventAttributes) HasTimestamp() bool { + return o != nil && o.Timestamp != nil +} + +// SetTimestamp gets a reference to the given string and assigns it to the Timestamp field. +func (o *V2EventAttributes) SetTimestamp(v string) { + o.Timestamp = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o V2EventAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Attributes != nil { + toSerialize["attributes"] = o.Attributes + } + if o.Message != nil { + toSerialize["message"] = o.Message + } + if o.Tags != nil { + toSerialize["tags"] = o.Tags + } + if o.Timestamp != nil { + toSerialize["timestamp"] = o.Timestamp + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *V2EventAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *V2EventAttributesAttributes `json:"attributes,omitempty"` + Message *string `json:"message,omitempty"` + Tags []string `json:"tags,omitempty"` + Timestamp *string `json:"timestamp,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{"attributes", "message", "tags", "timestamp"}) + } else { + return err + } + o.Attributes = all.Attributes + o.Message = all.Message + o.Tags = all.Tags + o.Timestamp = all.Timestamp + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_v2_event_attributes_attributes.go b/api/datadogV2/model_v2_event_attributes_attributes.go new file mode 100644 index 00000000000..d8920245203 --- /dev/null +++ b/api/datadogV2/model_v2_event_attributes_attributes.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" +) + +// V2EventAttributesAttributes - JSON object for category-specific attributes. +type V2EventAttributesAttributes struct { + ChangeEventAttributes *ChangeEventAttributes + AlertEventAttributes *AlertEventAttributes + + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject interface{} +} + +// ChangeEventAttributesAsV2EventAttributesAttributes is a convenience function that returns ChangeEventAttributes wrapped in V2EventAttributesAttributes. +func ChangeEventAttributesAsV2EventAttributesAttributes(v *ChangeEventAttributes) V2EventAttributesAttributes { + return V2EventAttributesAttributes{ChangeEventAttributes: v} +} + +// AlertEventAttributesAsV2EventAttributesAttributes is a convenience function that returns AlertEventAttributes wrapped in V2EventAttributesAttributes. +func AlertEventAttributesAsV2EventAttributesAttributes(v *AlertEventAttributes) V2EventAttributesAttributes { + return V2EventAttributesAttributes{AlertEventAttributes: v} +} + +// UnmarshalJSON turns data into one of the pointers in the struct. +func (obj *V2EventAttributesAttributes) UnmarshalJSON(data []byte) error { + var err error + match := 0 + // try to unmarshal data into ChangeEventAttributes + err = datadog.Unmarshal(data, &obj.ChangeEventAttributes) + if err == nil { + if obj.ChangeEventAttributes != nil && obj.ChangeEventAttributes.UnparsedObject == nil { + jsonChangeEventAttributes, _ := datadog.Marshal(obj.ChangeEventAttributes) + if string(jsonChangeEventAttributes) == "{}" && string(data) != "{}" { // empty struct + obj.ChangeEventAttributes = nil + } else { + match++ + } + } else { + obj.ChangeEventAttributes = nil + } + } else { + obj.ChangeEventAttributes = nil + } + + // try to unmarshal data into AlertEventAttributes + err = datadog.Unmarshal(data, &obj.AlertEventAttributes) + if err == nil { + if obj.AlertEventAttributes != nil && obj.AlertEventAttributes.UnparsedObject == nil { + jsonAlertEventAttributes, _ := datadog.Marshal(obj.AlertEventAttributes) + if string(jsonAlertEventAttributes) == "{}" && string(data) != "{}" { // empty struct + obj.AlertEventAttributes = nil + } else { + match++ + } + } else { + obj.AlertEventAttributes = nil + } + } else { + obj.AlertEventAttributes = nil + } + + if match != 1 { // more than 1 match + // reset to nil + obj.ChangeEventAttributes = nil + obj.AlertEventAttributes = 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 V2EventAttributesAttributes) MarshalJSON() ([]byte, error) { + if obj.ChangeEventAttributes != nil { + return datadog.Marshal(&obj.ChangeEventAttributes) + } + + if obj.AlertEventAttributes != nil { + return datadog.Marshal(&obj.AlertEventAttributes) + } + + if obj.UnparsedObject != nil { + return datadog.Marshal(obj.UnparsedObject) + } + return nil, nil // no data in oneOf schemas +} + +// GetActualInstance returns the actual instance. +func (obj *V2EventAttributesAttributes) GetActualInstance() interface{} { + if obj.ChangeEventAttributes != nil { + return obj.ChangeEventAttributes + } + + if obj.AlertEventAttributes != nil { + return obj.AlertEventAttributes + } + + // all schemas are nil + return nil +} diff --git a/api/datadogV2/model_v2_event_response.go b/api/datadogV2/model_v2_event_response.go new file mode 100644 index 00000000000..f36d3f0d566 --- /dev/null +++ b/api/datadogV2/model_v2_event_response.go @@ -0,0 +1,111 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// V2EventResponse Get an event response. +type V2EventResponse struct { + // An event object. + Data *V2Event `json:"data,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewV2EventResponse instantiates a new V2EventResponse 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 NewV2EventResponse() *V2EventResponse { + this := V2EventResponse{} + return &this +} + +// NewV2EventResponseWithDefaults instantiates a new V2EventResponse 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 NewV2EventResponseWithDefaults() *V2EventResponse { + this := V2EventResponse{} + return &this +} + +// GetData returns the Data field value if set, zero value otherwise. +func (o *V2EventResponse) GetData() V2Event { + if o == nil || o.Data == nil { + var ret V2Event + return ret + } + return *o.Data +} + +// GetDataOk returns a tuple with the Data field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *V2EventResponse) GetDataOk() (*V2Event, bool) { + if o == nil || o.Data == nil { + return nil, false + } + return o.Data, true +} + +// HasData returns a boolean if a field has been set. +func (o *V2EventResponse) HasData() bool { + return o != nil && o.Data != nil +} + +// SetData gets a reference to the given V2Event and assigns it to the Data field. +func (o *V2EventResponse) SetData(v V2Event) { + o.Data = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o V2EventResponse) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Data != nil { + toSerialize["data"] = o.Data + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *V2EventResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *V2Event `json:"data,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + + hasInvalidField := false + if all.Data != nil && all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Data = all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/examples/v2/events/GetEvent.go b/examples/v2/events/GetEvent.go new file mode 100644 index 00000000000..b1249e2eb91 --- /dev/null +++ b/examples/v2/events/GetEvent.go @@ -0,0 +1,29 @@ +// Get an event 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() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewEventsApi(apiClient) + resp, r, err := api.GetEvent(ctx, "AZeF-nTCAABzkAgGXzYPtgAA") + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `EventsApi.GetEvent`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `EventsApi.GetEvent`:\n%s\n", responseContent) +} diff --git a/tests/scenarios/features/v2/events.feature b/tests/scenarios/features/v2/events.feature index 0a69d195201..61d824ce108 100644 --- a/tests/scenarios/features/v2/events.feature +++ b/tests/scenarios/features/v2/events.feature @@ -50,6 +50,27 @@ Feature: Events Then the response status is 200 OK And the response "data" has length 0 + @generated @skip @team:DataDog/event-management + Scenario: Get an event returns "Bad Request" response + Given new "GetEvent" request + And request contains "event_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @skip @team:DataDog/event-management + Scenario: Get an event returns "Not Found" response + Given new "GetEvent" request + And request contains "event_id" parameter with value "AAAAAAAAAAAAAAAAAAAAAAAA" + When the request is sent + Then the response status is 404 Not Found + + @skip @team:DataDog/event-management + Scenario: Get an event returns "OK" response + Given new "GetEvent" request + And request contains "event_id" parameter with value "AZeF-nTCAABzkAgGXzYPtgAA" + When the request is sent + Then the response status is 200 OK + @team:DataDog/event-management Scenario: Post an event returns "Bad request" response Given new "CreateEvent" request diff --git a/tests/scenarios/features/v2/undo.json b/tests/scenarios/features/v2/undo.json index df87d8d6c90..abe0c0b370d 100644 --- a/tests/scenarios/features/v2/undo.json +++ b/tests/scenarios/features/v2/undo.json @@ -1022,6 +1022,12 @@ "type": "safe" } }, + "GetEvent": { + "tag": "Events", + "undo": { + "type": "safe" + } + }, "ListIncidents": { "tag": "Incidents", "undo": { From 080e1eb354da00d147d1e3e43ca046fe99fddab2 Mon Sep 17 00:00:00 2001 From: "api-clients-generation-pipeline[bot]" <54105614+api-clients-generation-pipeline[bot]@users.noreply.github.com> Date: Thu, 17 Jul 2025 18:27:37 +0000 Subject: [PATCH 4/4] Backend synced security changes (#3231) Co-authored-by: ci.datadog-api-spec --- .generated-info | 4 +- .generator/schemas/v1/openapi.yaml | 29 +++--- .generator/schemas/v2/openapi.yaml | 150 ++++++++++++++++------------- 3 files changed, 100 insertions(+), 83 deletions(-) diff --git a/.generated-info b/.generated-info index fe7f37ba004..b6d3ff3d5de 100644 --- a/.generated-info +++ b/.generated-info @@ -1,4 +1,4 @@ { - "spec_repo_commit": "214381f", - "generated": "2025-07-17 15:38:08.123" + "spec_repo_commit": "ef70ddf", + "generated": "2025-07-17 17:28:30.221" } diff --git a/.generator/schemas/v1/openapi.yaml b/.generator/schemas/v1/openapi.yaml index 6511a44e042..4cfe65c3f41 100644 --- a/.generator/schemas/v1/openapi.yaml +++ b/.generator/schemas/v1/openapi.yaml @@ -29170,6 +29170,10 @@ paths: description: Authentication error '429': $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: [] summary: Search logs tags: - Logs @@ -29268,10 +29272,6 @@ paths: description: Forbidden '429': $ref: '#/components/responses/TooManyRequestsResponse' - security: - - apiKeyAuth: [] - appKeyAuth: [] - - AuthZ: [] summary: Get all indexes tags: - Logs Indexes @@ -30475,7 +30475,7 @@ paths: - apiKeyAuth: [] appKeyAuth: [] - AuthZ: - - monitors_write + - monitors_read summary: Validate a monitor tags: - Monitors @@ -30483,7 +30483,7 @@ paths: x-permission: operator: OR permissions: - - monitors_write + - monitors_read /api/v1/monitor/{monitor_id}: delete: description: Delete the specified monitor @@ -30776,7 +30776,7 @@ paths: - apiKeyAuth: [] appKeyAuth: [] - AuthZ: - - monitors_write + - monitors_read summary: Validate an existing monitor tags: - Monitors @@ -30784,7 +30784,7 @@ paths: x-permission: operator: OR permissions: - - monitors_write + - monitors_read /api/v1/monthly_custom_reports: get: deprecated: true @@ -31644,13 +31644,15 @@ paths: security: - apiKeyAuth: [] appKeyAuth: [] - - AuthZ: [] + - AuthZ: + - metrics_read summary: Search metrics tags: - Metrics x-permission: - operator: OPEN - permissions: [] + operator: OR + permissions: + - metrics_read /api/v1/security_analytics/signals/{signal_id}/add_to_incident: patch: description: Add a security signal to an incident. This makes it possible to @@ -33852,7 +33854,7 @@ paths: default: 50 format: int64 type: integer - - description: The sort order for the results (e.g., 'name,asc' or 'name,desc'). + - description: The sort order for the results (e.g., `name,asc` or `name,desc`). in: query name: sort required: false @@ -34332,6 +34334,8 @@ paths: appKeyAuth: [] - AuthZ: - synthetics_global_variable_read + - AuthZ: + - apm_api_catalog_read summary: Get all global variables tags: - Synthetics @@ -34339,6 +34343,7 @@ paths: operator: OR permissions: - synthetics_global_variable_read + - apm_api_catalog_read post: description: Create a Synthetic global variable. operationId: CreateGlobalVariable diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 5709841fc5c..aff47f4974d 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -44884,8 +44884,9 @@ paths: tags: - AuthN Mappings x-permission: - operator: OPEN - permissions: [] + operator: OR + permissions: + - user_access_read post: description: Create an AuthN Mapping. operationId: CreateAuthNMapping @@ -44990,8 +44991,9 @@ paths: tags: - AuthN Mappings x-permission: - operator: OPEN - permissions: [] + operator: OR + permissions: + - user_access_read patch: description: Edit an AuthN Mapping. operationId: UpdateAuthNMapping @@ -46038,6 +46040,8 @@ paths: appKeyAuth: [] - AuthZ: - ci_visibility_read + - AuthZ: + - test_optimization_read summary: Aggregate tests events tags: - CI Visibility Tests @@ -46046,6 +46050,7 @@ paths: operator: OR permissions: - ci_visibility_read + - test_optimization_read /api/v2/ci/tests/events: get: description: 'List endpoint returns CI Visibility test events that match a [search @@ -46122,6 +46127,8 @@ paths: appKeyAuth: [] - AuthZ: - ci_visibility_read + - AuthZ: + - test_optimization_read summary: Get a list of tests events tags: - CI Visibility Tests @@ -46134,6 +46141,7 @@ paths: operator: OR permissions: - ci_visibility_read + - test_optimization_read /api/v2/ci/tests/events/search: post: description: 'List endpoint returns CI Visibility test events that match a [search @@ -46168,6 +46176,8 @@ paths: appKeyAuth: [] - AuthZ: - ci_visibility_read + - AuthZ: + - test_optimization_read summary: Search tests events tags: - CI Visibility Tests @@ -46181,6 +46191,7 @@ paths: operator: OR permissions: - ci_visibility_read + - test_optimization_read /api/v2/cloud_security_management/custom_frameworks: post: description: Create a custom framework. @@ -47384,15 +47395,13 @@ paths: appKeyAuth: [] - AuthZ: - usage_read - - billing_read summary: Get Monthly Cost Attribution tags: - Usage Metering x-permission: - operator: AND + operator: OR permissions: - usage_read - - billing_read /api/v2/csm/onboarding/agents: get: description: Get the list of all CSM Agents running on your hosts and containers. @@ -47969,13 +47978,15 @@ paths: security: - apiKeyAuth: [] appKeyAuth: [] - - AuthZ: [] + - AuthZ: + - user_access_read summary: Get all datasets tags: - Datasets x-permission: - operator: OPEN - permissions: [] + operator: OR + permissions: + - user_access_read post: description: Create a dataset with the configurations in the request. operationId: CreateDataset @@ -48015,14 +48026,16 @@ paths: security: - apiKeyAuth: [] appKeyAuth: [] - - AuthZ: [] + - AuthZ: + - user_access_manage summary: Create a dataset tags: - Datasets x-codegen-request-body-name: body x-permission: - operator: OPEN - permissions: [] + operator: OR + permissions: + - user_access_manage /api/v2/datasets/{dataset_id}: delete: description: Deletes the dataset associated with the ID. @@ -48273,6 +48286,8 @@ paths: appKeyAuth: [] - AuthZ: - org_management + - AuthZ: + - monitors_write summary: Get Domain Allowlist tags: - Domain Allowlist @@ -48280,6 +48295,10 @@ paths: operator: OR permissions: - org_management + - monitors_write + - generate_dashboard_reports + - generate_log_reports + - manage_log_reports patch: description: Update the domain allowlist for an organization. operationId: PatchDomainAllowlist @@ -48303,6 +48322,8 @@ paths: appKeyAuth: [] - AuthZ: - org_management + - AuthZ: + - monitors_write summary: Sets Domain Allowlist tags: - Domain Allowlist @@ -48310,6 +48331,10 @@ paths: operator: OR permissions: - org_management + - monitors_write + - generate_dashboard_reports + - generate_log_reports + - manage_log_reports /api/v2/dora/deployment: post: description: 'Use this API endpoint to provide data about deployments for DORA @@ -52627,8 +52652,8 @@ paths: x-permission: operator: OR permissions: - - logs_read_data - logs_read_config + - logs_read_data post: description: Create a custom destination in your organization. operationId: CreateLogsCustomDestination @@ -52712,8 +52737,8 @@ paths: x-permission: operator: OR permissions: - - logs_read_data - logs_read_config + - logs_read_data patch: description: Update the given fields of a specific custom destination in your organization. @@ -53898,9 +53923,6 @@ paths: description: Forbidden '429': $ref: '#/components/responses/TooManyRequestsResponse' - security: - - apiKeyAuth: [] - appKeyAuth: [] summary: Create a monitor notification rule tags: - Monitors @@ -53936,9 +53958,6 @@ paths: description: Not Found '429': $ref: '#/components/responses/TooManyRequestsResponse' - security: - - apiKeyAuth: [] - appKeyAuth: [] summary: Delete a monitor notification rule tags: - Monitors @@ -54043,9 +54062,6 @@ paths: description: Not Found '429': $ref: '#/components/responses/TooManyRequestsResponse' - security: - - apiKeyAuth: [] - appKeyAuth: [] summary: Update a monitor notification rule tags: - Monitors @@ -54284,6 +54300,10 @@ paths: summary: Get all monitor user templates tags: - Monitors + x-permission: + operator: OR + permissions: + - monitors_read x-unstable: '**Note**: This endpoint is in Preview. If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' @@ -54311,12 +54331,13 @@ paths: description: Bad Request '429': $ref: '#/components/responses/TooManyRequestsResponse' - security: - - apiKeyAuth: [] - appKeyAuth: [] summary: Create a monitor user template tags: - Monitors + x-permission: + operator: OR + permissions: + - monitor_config_policy_write x-unstable: '**Note**: This endpoint is in Preview. If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' @@ -54341,12 +54362,13 @@ paths: description: Bad Request '429': $ref: '#/components/responses/TooManyRequestsResponse' - security: - - apiKeyAuth: [] - appKeyAuth: [] summary: Validate a monitor user template tags: - Monitors + x-permission: + operator: OR + permissions: + - monitor_config_policy_write x-unstable: '**Note**: This endpoint is in Preview. If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' @@ -54372,12 +54394,13 @@ paths: description: Not Found '429': $ref: '#/components/responses/TooManyRequestsResponse' - security: - - apiKeyAuth: [] - appKeyAuth: [] summary: Delete a monitor user template tags: - Monitors + x-permission: + operator: OR + permissions: + - monitor_config_policy_write x-unstable: '**Note**: This endpoint is in Preview. If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' @@ -54423,6 +54446,10 @@ paths: summary: Get a monitor user template tags: - Monitors + x-permission: + operator: OR + permissions: + - monitors_read x-unstable: '**Note**: This endpoint is in Preview. If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' @@ -54463,12 +54490,13 @@ paths: description: Not Found '429': $ref: '#/components/responses/TooManyRequestsResponse' - security: - - apiKeyAuth: [] - appKeyAuth: [] summary: Update a monitor user template to a new version tags: - Monitors + x-permission: + operator: OR + permissions: + - monitor_config_policy_write x-unstable: '**Note**: This endpoint is in Preview. If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' @@ -54508,12 +54536,13 @@ paths: description: Not Found '429': $ref: '#/components/responses/TooManyRequestsResponse' - security: - - apiKeyAuth: [] - appKeyAuth: [] summary: Validate an existing monitor user template tags: - Monitors + x-permission: + operator: OR + permissions: + - monitor_config_policy_write x-unstable: '**Note**: This endpoint is in Preview. If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' @@ -57914,17 +57943,14 @@ paths: $ref: '#/components/responses/NotAuthorizedResponse' '429': $ref: '#/components/responses/TooManyRequestsResponse' - security: - - apiKeyAuth: [] - appKeyAuth: [] - - AuthZ: [] summary: Aggregate RUM events tags: - RUM x-codegen-request-body-name: body x-permission: - operator: OPEN - permissions: [] + operator: OR + permissions: + - rum_apps_read /api/v2/rum/applications: get: description: List all the RUM applications in your organization. @@ -58430,10 +58456,6 @@ paths: $ref: '#/components/responses/NotAuthorizedResponse' '429': $ref: '#/components/responses/TooManyRequestsResponse' - security: - - apiKeyAuth: [] - appKeyAuth: [] - - AuthZ: [] summary: Get a list of RUM events tags: - RUM @@ -58443,8 +58465,9 @@ paths: limitParam: page[limit] resultsPath: data x-permission: - operator: OPEN - permissions: [] + operator: OR + permissions: + - rum_apps_read /api/v2/rum/events/search: post: description: 'List endpoint returns RUM events that match a RUM search query. @@ -58476,10 +58499,6 @@ paths: $ref: '#/components/responses/NotAuthorizedResponse' '429': $ref: '#/components/responses/TooManyRequestsResponse' - security: - - apiKeyAuth: [] - appKeyAuth: [] - - AuthZ: [] summary: Search RUM events tags: - RUM @@ -58490,8 +58509,9 @@ paths: limitParam: body.page.limit resultsPath: data x-permission: - operator: OPEN - permissions: [] + operator: OR + permissions: + - rum_apps_read /api/v2/saml_configurations/idp_metadata: post: description: 'Endpoint for uploading IdP metadata for SAML setup. @@ -64127,15 +64147,13 @@ paths: appKeyAuth: [] - AuthZ: - usage_read - - billing_read summary: Get cost across multi-org account tags: - Usage Metering x-permission: - operator: AND + operator: OR permissions: - usage_read - - billing_read /api/v2/usage/estimated_cost: get: description: 'Get estimated cost across multi-org and single root-org accounts. @@ -64233,15 +64251,13 @@ paths: appKeyAuth: [] - AuthZ: - usage_read - - billing_read summary: Get estimated cost across your account tags: - Usage Metering x-permission: - operator: AND + operator: OR permissions: - usage_read - - billing_read /api/v2/usage/historical_cost: get: description: 'Get historical cost across multi-org and single root-org accounts. @@ -64316,15 +64332,13 @@ paths: appKeyAuth: [] - AuthZ: - usage_read - - billing_read summary: Get historical cost across your account tags: - Usage Metering x-permission: - operator: AND + operator: OR permissions: - usage_read - - billing_read /api/v2/usage/hourly_usage: get: description: Get hourly usage by product family. @@ -64653,15 +64667,13 @@ paths: appKeyAuth: [] - AuthZ: - usage_read - - billing_read summary: Get projected cost across your account tags: - Usage Metering x-permission: - operator: AND + operator: OR permissions: - usage_read - - billing_read /api/v2/user_invitations: post: description: Sends emails to one or more users inviting them to join the organization.