From 2d40a99ad5a273120740b3b26d786def65f80064 Mon Sep 17 00:00:00 2001 From: "ci.datadog-api-spec" Date: Tue, 12 Nov 2024 22:27:43 +0000 Subject: [PATCH] Regenerate client from commit 76402fb2 of spec repo --- .apigentools-info | 8 +- .generator/schemas/v2/openapi.yaml | 278 +++++++++++++++ api/datadogV2/api_events.go | 81 +++++ api/datadogV2/doc.go | 1 + .../model_change_event_custom_attributes.go | 289 ++++++++++++++++ ...l_change_event_custom_attributes_author.go | 143 ++++++++ ...nge_event_custom_attributes_author_type.go | 66 ++++ ...vent_custom_attributes_changed_resource.go | 143 ++++++++ ...custom_attributes_changed_resource_type.go | 64 ++++ ...tom_attributes_impacted_resources_items.go | 143 ++++++++ ...ttributes_impacted_resources_items_type.go | 64 ++++ api/datadogV2/model_event_category.go | 64 ++++ api/datadogV2/model_event_create_request.go | 150 +++++++++ .../model_event_create_request_payload.go | 111 ++++++ .../model_event_create_request_type.go | 64 ++++ api/datadogV2/model_event_create_response.go | 146 ++++++++ .../model_event_create_response_attributes.go | 111 ++++++ ...t_create_response_attributes_attributes.go | 111 ++++++ ...eate_response_attributes_attributes_evt.go | 102 ++++++ .../model_event_create_response_payload.go | 111 ++++++ api/datadogV2/model_event_payload.go | 318 ++++++++++++++++++ .../model_event_payload_attributes.go | 73 ++++ examples/v2/events/CreateEvent.go | 73 ++++ tests/scenarios/features/v2/events.feature | 36 +- tests/scenarios/features/v2/undo.json | 6 + 25 files changed, 2744 insertions(+), 12 deletions(-) create mode 100644 api/datadogV2/model_change_event_custom_attributes.go create mode 100644 api/datadogV2/model_change_event_custom_attributes_author.go create mode 100644 api/datadogV2/model_change_event_custom_attributes_author_type.go create mode 100644 api/datadogV2/model_change_event_custom_attributes_changed_resource.go create mode 100644 api/datadogV2/model_change_event_custom_attributes_changed_resource_type.go create mode 100644 api/datadogV2/model_change_event_custom_attributes_impacted_resources_items.go create mode 100644 api/datadogV2/model_change_event_custom_attributes_impacted_resources_items_type.go create mode 100644 api/datadogV2/model_event_category.go create mode 100644 api/datadogV2/model_event_create_request.go create mode 100644 api/datadogV2/model_event_create_request_payload.go create mode 100644 api/datadogV2/model_event_create_request_type.go create mode 100644 api/datadogV2/model_event_create_response.go create mode 100644 api/datadogV2/model_event_create_response_attributes.go create mode 100644 api/datadogV2/model_event_create_response_attributes_attributes.go create mode 100644 api/datadogV2/model_event_create_response_attributes_attributes_evt.go create mode 100644 api/datadogV2/model_event_create_response_payload.go create mode 100644 api/datadogV2/model_event_payload.go create mode 100644 api/datadogV2/model_event_payload_attributes.go create mode 100644 examples/v2/events/CreateEvent.go diff --git a/.apigentools-info b/.apigentools-info index 324aea97d01..d1533476cea 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.6.6", - "regenerated": "2024-11-12 20:16:39.887967", - "spec_repo_commit": "9a869b6b" + "regenerated": "2024-11-12 22:26:13.473237", + "spec_repo_commit": "76402fb2" }, "v2": { "apigentools_version": "1.6.6", - "regenerated": "2024-11-12 20:16:39.908526", - "spec_repo_commit": "9a869b6b" + "regenerated": "2024-11-12 22:26:13.496889", + "spec_repo_commit": "76402fb2" } } } \ No newline at end of file diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index ad1dba70f7c..4cf6ab418a7 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -4556,6 +4556,127 @@ components: format: int64 type: integer type: object + ChangeEventCustomAttributes: + description: Object representing custom change event attributes. + properties: + author: + $ref: '#/components/schemas/ChangeEventCustomAttributesAuthor' + change_metadata: + additionalProperties: {} + description: Free form object with information related to the `change` event. + Can be arbitrarily nested and contain any valid JSON. + example: + dd: + team: datadog_team + user_email: datadog@datadog.com + user_id: datadog_user_id + user_name: datadog_username + resource_link: datadog.com/feature/fallback_payments_test + type: object + changed_resource: + $ref: '#/components/schemas/ChangeEventCustomAttributesChangedResource' + impacted_resources: + description: 'A list of resources impacted by this change. It is recommended + to provide an impacted resource to display + + the change event at the right location. Only resources of type `service` + are supported.' + example: + - name: payments_api + type: service + items: + $ref: '#/components/schemas/ChangeEventCustomAttributesImpactedResourcesItems' + type: array + new_value: + additionalProperties: {} + description: Free form object to track new value of the changed resource. + example: + enabled: true + percentage: 50% + rule: + datacenter: devcycle.us1.prod + type: object + prev_value: + additionalProperties: {} + description: Free form object to track previous value of the changed resource. + example: + enabled: true + percentage: 10% + rule: + datacenter: devcycle.us1.prod + type: object + required: + - changed_resource + type: object + ChangeEventCustomAttributesAuthor: + description: Object representing the entity which made the change. Optional + field but if provided should include `type` and `name`. + properties: + name: + description: Author's name. Limited to 128 characters. + example: datadog@datadog.com + maxLength: 128 + type: string + type: + $ref: '#/components/schemas/ChangeEventCustomAttributesAuthorType' + required: + - name + - type + type: object + ChangeEventCustomAttributesAuthorType: + description: Author's type. + enum: + - user + - system + example: user + type: string + x-enum-varnames: + - USER + - SYSTEM + ChangeEventCustomAttributesChangedResource: + description: Object representing a uniquely identified resource. Only the resource + type `feature_flag` is supported. + properties: + name: + description: Resource's name. + example: fallback_payments_test + type: string + type: + $ref: '#/components/schemas/ChangeEventCustomAttributesChangedResourceType' + required: + - type + - name + type: object + ChangeEventCustomAttributesChangedResourceType: + description: Resource's type. + enum: + - feature_flag + example: feature_flag + type: string + x-enum-varnames: + - FEATURE_FLAG + ChangeEventCustomAttributesImpactedResourcesItems: + description: Object representing a uniquely identified resource. Only the resource + type `service` is supported. + properties: + name: + description: Resource's name. + example: payments_api + type: string + type: + $ref: '#/components/schemas/ChangeEventCustomAttributesImpactedResourcesItemsType' + required: + - type + - name + type: object + ChangeEventCustomAttributesImpactedResourcesItemsType: + description: Resource's type. + enum: + - service + example: service + type: string + x-enum-varnames: + - SERVICE ChargebackBreakdown: description: Charges breakdown. properties: @@ -9335,6 +9456,125 @@ components: example: Oh boy! type: string type: object + EventCategory: + description: Event category to identify the type of event. Only the value `change` + is supported. Support for other categories are coming. please reach out to + datadog support if you're interested. + enum: + - change + example: change + type: string + x-enum-varnames: + - CHANGE + EventCreateRequest: + description: Object representing an event creation request. + properties: + attributes: + $ref: '#/components/schemas/EventPayload' + type: + $ref: '#/components/schemas/EventCreateRequestType' + type: object + EventCreateRequestPayload: + description: Payload for creating an event. + properties: + data: + $ref: '#/components/schemas/EventCreateRequest' + type: object + EventCreateRequestType: + description: Entity type. + enum: + - event + example: event + type: string + x-enum-varnames: + - EVENT + EventCreateResponse: + description: Object containing an event response. + properties: + attributes: + $ref: '#/components/schemas/EventCreateResponseAttributes' + type: + description: Event type + example: event + type: string + type: object + EventCreateResponseAttributes: + description: JSON object containing all events attributes and their associated + values. + properties: + attributes: + $ref: '#/components/schemas/EventCreateResponseAttributesAttributes' + type: object + EventCreateResponseAttributesAttributes: + description: JSON object of attributes from your events. + properties: + evt: + $ref: '#/components/schemas/EventCreateResponseAttributesAttributesEvt' + type: object + EventCreateResponseAttributesAttributesEvt: + description: JSON object of event system attributes. + properties: + id: + description: Event id + type: string + type: object + EventCreateResponsePayload: + description: Response containing information about created event. + properties: + data: + $ref: '#/components/schemas/EventCreateResponse' + type: object + EventPayload: + description: Event attributes. + properties: + aggregation_key: + description: An arbitrary string to use for aggregation when correlating + events. Limited to 100 characters. + maxLength: 100 + type: string + attributes: + $ref: '#/components/schemas/EventPayloadAttributes' + category: + $ref: '#/components/schemas/EventCategory' + message: + description: The body of the event. Limited to 4000 characters. + example: payment_processed feature flag has been enabled + maxLength: 4000 + type: string + tags: + description: 'A list of tags to apply to the event. + + Refer to [Tags docs](https://docs.datadoghq.com/getting_started/tagging/).' + example: + - environment:test + items: + description: A tag. + type: string + type: array + timestamp: + description: 'Timestamp when the event occurred. Must follow [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) + format. + + For example `"2017-01-15T01:30:15.010000Z"`. + + Defaults to the timestamp of receipt. Limited to values no older than + 18 hours.' + type: string + title: + description: The event title. Limited to 500 characters. + example: payment_processed feature flag updated + maxLength: 500 + type: string + required: + - title + - category + - attributes + type: object + EventPayloadAttributes: + description: JSON object for custom attributes. Schema are different per each + event category. + oneOf: + - $ref: '#/components/schemas/ChangeEventCustomAttributes' EventPriority: description: The priority of the event's monitor. For example, `normal` or `low`. enum: @@ -31191,6 +31431,44 @@ paths: operator: OR permissions: - events_read + post: + description: This endpoint allows you to post events. Only events with `change` + category are under General Availability. + operationId: CreateEvent + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/EventCreateRequestPayload' + description: Event request object + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/EventCreateResponsePayload' + description: OK + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Bad request + '403': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Forbidden + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + summary: Post an event + tags: + - Events + x-codegen-request-body-name: body /api/v2/events/search: post: description: 'List endpoint returns events that match an events search query. diff --git a/api/datadogV2/api_events.go b/api/datadogV2/api_events.go index e5478921593..e425afd28f9 100644 --- a/api/datadogV2/api_events.go +++ b/api/datadogV2/api_events.go @@ -15,6 +15,87 @@ import ( // EventsApi service type type EventsApi datadog.Service +// CreateEvent Post an event. +// This endpoint allows you to post events. Only events with `change` category are under General Availability. +func (a *EventsApi) CreateEvent(ctx _context.Context, body EventCreateRequestPayload) (EventCreateResponsePayload, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPost + localVarPostBody interface{} + localVarReturnValue EventCreateResponsePayload + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.EventsApi.CreateEvent") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/events" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Content-Type"] = "application/json" + localVarHeaderParams["Accept"] = "application/json" + + // body params + localVarPostBody = &body + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-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 == 403 { + var v JSONAPIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + // ListEventsOptionalParameters holds optional parameters for ListEvents. type ListEventsOptionalParameters struct { FilterQuery *string diff --git a/api/datadogV2/doc.go b/api/datadogV2/doc.go index 3e9b8009b93..c0dfaf0bfca 100644 --- a/api/datadogV2/doc.go +++ b/api/datadogV2/doc.go @@ -105,6 +105,7 @@ // - [DowntimesApi.ListDowntimes] // - [DowntimesApi.ListMonitorDowntimes] // - [DowntimesApi.UpdateDowntime] +// - [EventsApi.CreateEvent] // - [EventsApi.ListEvents] // - [EventsApi.SearchEvents] // - [FastlyIntegrationApi.CreateFastlyAccount] diff --git a/api/datadogV2/model_change_event_custom_attributes.go b/api/datadogV2/model_change_event_custom_attributes.go new file mode 100644 index 00000000000..1754d850dbc --- /dev/null +++ b/api/datadogV2/model_change_event_custom_attributes.go @@ -0,0 +1,289 @@ +// 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" +) + +// ChangeEventCustomAttributes Object representing custom change event attributes. +type ChangeEventCustomAttributes struct { + // Object representing the entity which made the change. Optional field but if provided should include `type` and `name`. + Author *ChangeEventCustomAttributesAuthor `json:"author,omitempty"` + // Free form object with information related to the `change` event. Can be arbitrarily nested and contain any valid JSON. + ChangeMetadata map[string]interface{} `json:"change_metadata,omitempty"` + // Object representing a uniquely identified resource. Only the resource type `feature_flag` is supported. + ChangedResource ChangeEventCustomAttributesChangedResource `json:"changed_resource"` + // A list of resources impacted by this change. It is recommended to provide an impacted resource to display + // the change event at the right location. Only resources of type `service` are supported. + ImpactedResources []ChangeEventCustomAttributesImpactedResourcesItems `json:"impacted_resources,omitempty"` + // Free form object to track new value of the changed resource. + NewValue map[string]interface{} `json:"new_value,omitempty"` + // Free form object to track previous value of the changed resource. + PrevValue map[string]interface{} `json:"prev_value,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:"-"` +} + +// NewChangeEventCustomAttributes instantiates a new ChangeEventCustomAttributes 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 NewChangeEventCustomAttributes(changedResource ChangeEventCustomAttributesChangedResource) *ChangeEventCustomAttributes { + this := ChangeEventCustomAttributes{} + this.ChangedResource = changedResource + return &this +} + +// NewChangeEventCustomAttributesWithDefaults instantiates a new ChangeEventCustomAttributes 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 NewChangeEventCustomAttributesWithDefaults() *ChangeEventCustomAttributes { + this := ChangeEventCustomAttributes{} + return &this +} + +// GetAuthor returns the Author field value if set, zero value otherwise. +func (o *ChangeEventCustomAttributes) GetAuthor() ChangeEventCustomAttributesAuthor { + if o == nil || o.Author == nil { + var ret ChangeEventCustomAttributesAuthor + 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 *ChangeEventCustomAttributes) GetAuthorOk() (*ChangeEventCustomAttributesAuthor, 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 *ChangeEventCustomAttributes) HasAuthor() bool { + return o != nil && o.Author != nil +} + +// SetAuthor gets a reference to the given ChangeEventCustomAttributesAuthor and assigns it to the Author field. +func (o *ChangeEventCustomAttributes) SetAuthor(v ChangeEventCustomAttributesAuthor) { + o.Author = &v +} + +// GetChangeMetadata returns the ChangeMetadata field value if set, zero value otherwise. +func (o *ChangeEventCustomAttributes) GetChangeMetadata() map[string]interface{} { + if o == nil || o.ChangeMetadata == nil { + var ret map[string]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 *ChangeEventCustomAttributes) GetChangeMetadataOk() (*map[string]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 *ChangeEventCustomAttributes) HasChangeMetadata() bool { + return o != nil && o.ChangeMetadata != nil +} + +// SetChangeMetadata gets a reference to the given map[string]interface{} and assigns it to the ChangeMetadata field. +func (o *ChangeEventCustomAttributes) SetChangeMetadata(v map[string]interface{}) { + o.ChangeMetadata = v +} + +// GetChangedResource returns the ChangedResource field value. +func (o *ChangeEventCustomAttributes) GetChangedResource() ChangeEventCustomAttributesChangedResource { + if o == nil { + var ret ChangeEventCustomAttributesChangedResource + return ret + } + return o.ChangedResource +} + +// GetChangedResourceOk returns a tuple with the ChangedResource field value +// and a boolean to check if the value has been set. +func (o *ChangeEventCustomAttributes) GetChangedResourceOk() (*ChangeEventCustomAttributesChangedResource, bool) { + if o == nil { + return nil, false + } + return &o.ChangedResource, true +} + +// SetChangedResource sets field value. +func (o *ChangeEventCustomAttributes) SetChangedResource(v ChangeEventCustomAttributesChangedResource) { + o.ChangedResource = v +} + +// GetImpactedResources returns the ImpactedResources field value if set, zero value otherwise. +func (o *ChangeEventCustomAttributes) GetImpactedResources() []ChangeEventCustomAttributesImpactedResourcesItems { + if o == nil || o.ImpactedResources == nil { + var ret []ChangeEventCustomAttributesImpactedResourcesItems + 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 *ChangeEventCustomAttributes) GetImpactedResourcesOk() (*[]ChangeEventCustomAttributesImpactedResourcesItems, 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 *ChangeEventCustomAttributes) HasImpactedResources() bool { + return o != nil && o.ImpactedResources != nil +} + +// SetImpactedResources gets a reference to the given []ChangeEventCustomAttributesImpactedResourcesItems and assigns it to the ImpactedResources field. +func (o *ChangeEventCustomAttributes) SetImpactedResources(v []ChangeEventCustomAttributesImpactedResourcesItems) { + o.ImpactedResources = v +} + +// GetNewValue returns the NewValue field value if set, zero value otherwise. +func (o *ChangeEventCustomAttributes) GetNewValue() map[string]interface{} { + if o == nil || o.NewValue == nil { + var ret map[string]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 *ChangeEventCustomAttributes) GetNewValueOk() (*map[string]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 *ChangeEventCustomAttributes) HasNewValue() bool { + return o != nil && o.NewValue != nil +} + +// SetNewValue gets a reference to the given map[string]interface{} and assigns it to the NewValue field. +func (o *ChangeEventCustomAttributes) SetNewValue(v map[string]interface{}) { + o.NewValue = v +} + +// GetPrevValue returns the PrevValue field value if set, zero value otherwise. +func (o *ChangeEventCustomAttributes) GetPrevValue() map[string]interface{} { + if o == nil || o.PrevValue == nil { + var ret map[string]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 *ChangeEventCustomAttributes) GetPrevValueOk() (*map[string]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 *ChangeEventCustomAttributes) HasPrevValue() bool { + return o != nil && o.PrevValue != nil +} + +// SetPrevValue gets a reference to the given map[string]interface{} and assigns it to the PrevValue field. +func (o *ChangeEventCustomAttributes) SetPrevValue(v map[string]interface{}) { + o.PrevValue = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ChangeEventCustomAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Author != nil { + toSerialize["author"] = o.Author + } + if o.ChangeMetadata != nil { + toSerialize["change_metadata"] = o.ChangeMetadata + } + toSerialize["changed_resource"] = o.ChangedResource + 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 + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *ChangeEventCustomAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Author *ChangeEventCustomAttributesAuthor `json:"author,omitempty"` + ChangeMetadata map[string]interface{} `json:"change_metadata,omitempty"` + ChangedResource *ChangeEventCustomAttributesChangedResource `json:"changed_resource"` + ImpactedResources []ChangeEventCustomAttributesImpactedResourcesItems `json:"impacted_resources,omitempty"` + NewValue map[string]interface{} `json:"new_value,omitempty"` + PrevValue map[string]interface{} `json:"prev_value,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.ChangedResource == nil { + return fmt.Errorf("required field changed_resource missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"author", "change_metadata", "changed_resource", "impacted_resources", "new_value", "prev_value"}) + } else { + return err + } + + hasInvalidField := false + if all.Author != nil && all.Author.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Author = all.Author + o.ChangeMetadata = all.ChangeMetadata + if all.ChangedResource.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.ChangedResource = *all.ChangedResource + o.ImpactedResources = all.ImpactedResources + o.NewValue = all.NewValue + o.PrevValue = all.PrevValue + + 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_custom_attributes_author.go b/api/datadogV2/model_change_event_custom_attributes_author.go new file mode 100644 index 00000000000..d9d235e8b4b --- /dev/null +++ b/api/datadogV2/model_change_event_custom_attributes_author.go @@ -0,0 +1,143 @@ +// 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" +) + +// ChangeEventCustomAttributesAuthor Object representing the entity which made the change. Optional field but if provided should include `type` and `name`. +type ChangeEventCustomAttributesAuthor struct { + // Author's name. Limited to 128 characters. + Name string `json:"name"` + // Author's type. + Type ChangeEventCustomAttributesAuthorType `json:"type"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewChangeEventCustomAttributesAuthor instantiates a new ChangeEventCustomAttributesAuthor 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 NewChangeEventCustomAttributesAuthor(name string, typeVar ChangeEventCustomAttributesAuthorType) *ChangeEventCustomAttributesAuthor { + this := ChangeEventCustomAttributesAuthor{} + this.Name = name + this.Type = typeVar + return &this +} + +// NewChangeEventCustomAttributesAuthorWithDefaults instantiates a new ChangeEventCustomAttributesAuthor 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 NewChangeEventCustomAttributesAuthorWithDefaults() *ChangeEventCustomAttributesAuthor { + this := ChangeEventCustomAttributesAuthor{} + return &this +} + +// GetName returns the Name field value. +func (o *ChangeEventCustomAttributesAuthor) GetName() string { + if o == nil { + var ret string + return ret + } + return o.Name +} + +// GetNameOk returns a tuple with the Name field value +// and a boolean to check if the value has been set. +func (o *ChangeEventCustomAttributesAuthor) GetNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Name, true +} + +// SetName sets field value. +func (o *ChangeEventCustomAttributesAuthor) SetName(v string) { + o.Name = v +} + +// GetType returns the Type field value. +func (o *ChangeEventCustomAttributesAuthor) GetType() ChangeEventCustomAttributesAuthorType { + if o == nil { + var ret ChangeEventCustomAttributesAuthorType + return ret + } + return o.Type +} + +// GetTypeOk returns a tuple with the Type field value +// and a boolean to check if the value has been set. +func (o *ChangeEventCustomAttributesAuthor) GetTypeOk() (*ChangeEventCustomAttributesAuthorType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *ChangeEventCustomAttributesAuthor) SetType(v ChangeEventCustomAttributesAuthorType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ChangeEventCustomAttributesAuthor) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["name"] = o.Name + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *ChangeEventCustomAttributesAuthor) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Name *string `json:"name"` + Type *ChangeEventCustomAttributesAuthorType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Name == nil { + return fmt.Errorf("required field name missing") + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"name", "type"}) + } else { + return err + } + + hasInvalidField := false + o.Name = *all.Name + if !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = *all.Type + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_change_event_custom_attributes_author_type.go b/api/datadogV2/model_change_event_custom_attributes_author_type.go new file mode 100644 index 00000000000..e0a7a9a138f --- /dev/null +++ b/api/datadogV2/model_change_event_custom_attributes_author_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" +) + +// ChangeEventCustomAttributesAuthorType Author's type. +type ChangeEventCustomAttributesAuthorType string + +// List of ChangeEventCustomAttributesAuthorType. +const ( + CHANGEEVENTCUSTOMATTRIBUTESAUTHORTYPE_USER ChangeEventCustomAttributesAuthorType = "user" + CHANGEEVENTCUSTOMATTRIBUTESAUTHORTYPE_SYSTEM ChangeEventCustomAttributesAuthorType = "system" +) + +var allowedChangeEventCustomAttributesAuthorTypeEnumValues = []ChangeEventCustomAttributesAuthorType{ + CHANGEEVENTCUSTOMATTRIBUTESAUTHORTYPE_USER, + CHANGEEVENTCUSTOMATTRIBUTESAUTHORTYPE_SYSTEM, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *ChangeEventCustomAttributesAuthorType) GetAllowedValues() []ChangeEventCustomAttributesAuthorType { + return allowedChangeEventCustomAttributesAuthorTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *ChangeEventCustomAttributesAuthorType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = ChangeEventCustomAttributesAuthorType(value) + return nil +} + +// NewChangeEventCustomAttributesAuthorTypeFromValue returns a pointer to a valid ChangeEventCustomAttributesAuthorType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewChangeEventCustomAttributesAuthorTypeFromValue(v string) (*ChangeEventCustomAttributesAuthorType, error) { + ev := ChangeEventCustomAttributesAuthorType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for ChangeEventCustomAttributesAuthorType: valid values are %v", v, allowedChangeEventCustomAttributesAuthorTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v ChangeEventCustomAttributesAuthorType) IsValid() bool { + for _, existing := range allowedChangeEventCustomAttributesAuthorTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to ChangeEventCustomAttributesAuthorType value. +func (v ChangeEventCustomAttributesAuthorType) Ptr() *ChangeEventCustomAttributesAuthorType { + return &v +} diff --git a/api/datadogV2/model_change_event_custom_attributes_changed_resource.go b/api/datadogV2/model_change_event_custom_attributes_changed_resource.go new file mode 100644 index 00000000000..1c4637c2e87 --- /dev/null +++ b/api/datadogV2/model_change_event_custom_attributes_changed_resource.go @@ -0,0 +1,143 @@ +// 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" +) + +// ChangeEventCustomAttributesChangedResource Object representing a uniquely identified resource. Only the resource type `feature_flag` is supported. +type ChangeEventCustomAttributesChangedResource struct { + // Resource's name. + Name string `json:"name"` + // Resource's type. + Type ChangeEventCustomAttributesChangedResourceType `json:"type"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewChangeEventCustomAttributesChangedResource instantiates a new ChangeEventCustomAttributesChangedResource 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 NewChangeEventCustomAttributesChangedResource(name string, typeVar ChangeEventCustomAttributesChangedResourceType) *ChangeEventCustomAttributesChangedResource { + this := ChangeEventCustomAttributesChangedResource{} + this.Name = name + this.Type = typeVar + return &this +} + +// NewChangeEventCustomAttributesChangedResourceWithDefaults instantiates a new ChangeEventCustomAttributesChangedResource 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 NewChangeEventCustomAttributesChangedResourceWithDefaults() *ChangeEventCustomAttributesChangedResource { + this := ChangeEventCustomAttributesChangedResource{} + return &this +} + +// GetName returns the Name field value. +func (o *ChangeEventCustomAttributesChangedResource) GetName() string { + if o == nil { + var ret string + return ret + } + return o.Name +} + +// GetNameOk returns a tuple with the Name field value +// and a boolean to check if the value has been set. +func (o *ChangeEventCustomAttributesChangedResource) GetNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Name, true +} + +// SetName sets field value. +func (o *ChangeEventCustomAttributesChangedResource) SetName(v string) { + o.Name = v +} + +// GetType returns the Type field value. +func (o *ChangeEventCustomAttributesChangedResource) GetType() ChangeEventCustomAttributesChangedResourceType { + if o == nil { + var ret ChangeEventCustomAttributesChangedResourceType + return ret + } + return o.Type +} + +// GetTypeOk returns a tuple with the Type field value +// and a boolean to check if the value has been set. +func (o *ChangeEventCustomAttributesChangedResource) GetTypeOk() (*ChangeEventCustomAttributesChangedResourceType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *ChangeEventCustomAttributesChangedResource) SetType(v ChangeEventCustomAttributesChangedResourceType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ChangeEventCustomAttributesChangedResource) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["name"] = o.Name + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *ChangeEventCustomAttributesChangedResource) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Name *string `json:"name"` + Type *ChangeEventCustomAttributesChangedResourceType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Name == nil { + return fmt.Errorf("required field name missing") + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"name", "type"}) + } else { + return err + } + + hasInvalidField := false + o.Name = *all.Name + if !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = *all.Type + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_change_event_custom_attributes_changed_resource_type.go b/api/datadogV2/model_change_event_custom_attributes_changed_resource_type.go new file mode 100644 index 00000000000..c462649a980 --- /dev/null +++ b/api/datadogV2/model_change_event_custom_attributes_changed_resource_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" +) + +// ChangeEventCustomAttributesChangedResourceType Resource's type. +type ChangeEventCustomAttributesChangedResourceType string + +// List of ChangeEventCustomAttributesChangedResourceType. +const ( + CHANGEEVENTCUSTOMATTRIBUTESCHANGEDRESOURCETYPE_FEATURE_FLAG ChangeEventCustomAttributesChangedResourceType = "feature_flag" +) + +var allowedChangeEventCustomAttributesChangedResourceTypeEnumValues = []ChangeEventCustomAttributesChangedResourceType{ + CHANGEEVENTCUSTOMATTRIBUTESCHANGEDRESOURCETYPE_FEATURE_FLAG, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *ChangeEventCustomAttributesChangedResourceType) GetAllowedValues() []ChangeEventCustomAttributesChangedResourceType { + return allowedChangeEventCustomAttributesChangedResourceTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *ChangeEventCustomAttributesChangedResourceType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = ChangeEventCustomAttributesChangedResourceType(value) + return nil +} + +// NewChangeEventCustomAttributesChangedResourceTypeFromValue returns a pointer to a valid ChangeEventCustomAttributesChangedResourceType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewChangeEventCustomAttributesChangedResourceTypeFromValue(v string) (*ChangeEventCustomAttributesChangedResourceType, error) { + ev := ChangeEventCustomAttributesChangedResourceType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for ChangeEventCustomAttributesChangedResourceType: valid values are %v", v, allowedChangeEventCustomAttributesChangedResourceTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v ChangeEventCustomAttributesChangedResourceType) IsValid() bool { + for _, existing := range allowedChangeEventCustomAttributesChangedResourceTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to ChangeEventCustomAttributesChangedResourceType value. +func (v ChangeEventCustomAttributesChangedResourceType) Ptr() *ChangeEventCustomAttributesChangedResourceType { + return &v +} diff --git a/api/datadogV2/model_change_event_custom_attributes_impacted_resources_items.go b/api/datadogV2/model_change_event_custom_attributes_impacted_resources_items.go new file mode 100644 index 00000000000..6ce74a25468 --- /dev/null +++ b/api/datadogV2/model_change_event_custom_attributes_impacted_resources_items.go @@ -0,0 +1,143 @@ +// 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" +) + +// ChangeEventCustomAttributesImpactedResourcesItems Object representing a uniquely identified resource. Only the resource type `service` is supported. +type ChangeEventCustomAttributesImpactedResourcesItems struct { + // Resource's name. + Name string `json:"name"` + // Resource's type. + Type ChangeEventCustomAttributesImpactedResourcesItemsType `json:"type"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewChangeEventCustomAttributesImpactedResourcesItems instantiates a new ChangeEventCustomAttributesImpactedResourcesItems 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 NewChangeEventCustomAttributesImpactedResourcesItems(name string, typeVar ChangeEventCustomAttributesImpactedResourcesItemsType) *ChangeEventCustomAttributesImpactedResourcesItems { + this := ChangeEventCustomAttributesImpactedResourcesItems{} + this.Name = name + this.Type = typeVar + return &this +} + +// NewChangeEventCustomAttributesImpactedResourcesItemsWithDefaults instantiates a new ChangeEventCustomAttributesImpactedResourcesItems 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 NewChangeEventCustomAttributesImpactedResourcesItemsWithDefaults() *ChangeEventCustomAttributesImpactedResourcesItems { + this := ChangeEventCustomAttributesImpactedResourcesItems{} + return &this +} + +// GetName returns the Name field value. +func (o *ChangeEventCustomAttributesImpactedResourcesItems) GetName() string { + if o == nil { + var ret string + return ret + } + return o.Name +} + +// GetNameOk returns a tuple with the Name field value +// and a boolean to check if the value has been set. +func (o *ChangeEventCustomAttributesImpactedResourcesItems) GetNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Name, true +} + +// SetName sets field value. +func (o *ChangeEventCustomAttributesImpactedResourcesItems) SetName(v string) { + o.Name = v +} + +// GetType returns the Type field value. +func (o *ChangeEventCustomAttributesImpactedResourcesItems) GetType() ChangeEventCustomAttributesImpactedResourcesItemsType { + if o == nil { + var ret ChangeEventCustomAttributesImpactedResourcesItemsType + return ret + } + return o.Type +} + +// GetTypeOk returns a tuple with the Type field value +// and a boolean to check if the value has been set. +func (o *ChangeEventCustomAttributesImpactedResourcesItems) GetTypeOk() (*ChangeEventCustomAttributesImpactedResourcesItemsType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *ChangeEventCustomAttributesImpactedResourcesItems) SetType(v ChangeEventCustomAttributesImpactedResourcesItemsType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ChangeEventCustomAttributesImpactedResourcesItems) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["name"] = o.Name + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *ChangeEventCustomAttributesImpactedResourcesItems) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Name *string `json:"name"` + Type *ChangeEventCustomAttributesImpactedResourcesItemsType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Name == nil { + return fmt.Errorf("required field name missing") + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"name", "type"}) + } else { + return err + } + + hasInvalidField := false + o.Name = *all.Name + if !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = *all.Type + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_change_event_custom_attributes_impacted_resources_items_type.go b/api/datadogV2/model_change_event_custom_attributes_impacted_resources_items_type.go new file mode 100644 index 00000000000..69dfc09930c --- /dev/null +++ b/api/datadogV2/model_change_event_custom_attributes_impacted_resources_items_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" +) + +// ChangeEventCustomAttributesImpactedResourcesItemsType Resource's type. +type ChangeEventCustomAttributesImpactedResourcesItemsType string + +// List of ChangeEventCustomAttributesImpactedResourcesItemsType. +const ( + CHANGEEVENTCUSTOMATTRIBUTESIMPACTEDRESOURCESITEMSTYPE_SERVICE ChangeEventCustomAttributesImpactedResourcesItemsType = "service" +) + +var allowedChangeEventCustomAttributesImpactedResourcesItemsTypeEnumValues = []ChangeEventCustomAttributesImpactedResourcesItemsType{ + CHANGEEVENTCUSTOMATTRIBUTESIMPACTEDRESOURCESITEMSTYPE_SERVICE, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *ChangeEventCustomAttributesImpactedResourcesItemsType) GetAllowedValues() []ChangeEventCustomAttributesImpactedResourcesItemsType { + return allowedChangeEventCustomAttributesImpactedResourcesItemsTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *ChangeEventCustomAttributesImpactedResourcesItemsType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = ChangeEventCustomAttributesImpactedResourcesItemsType(value) + return nil +} + +// NewChangeEventCustomAttributesImpactedResourcesItemsTypeFromValue returns a pointer to a valid ChangeEventCustomAttributesImpactedResourcesItemsType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewChangeEventCustomAttributesImpactedResourcesItemsTypeFromValue(v string) (*ChangeEventCustomAttributesImpactedResourcesItemsType, error) { + ev := ChangeEventCustomAttributesImpactedResourcesItemsType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for ChangeEventCustomAttributesImpactedResourcesItemsType: valid values are %v", v, allowedChangeEventCustomAttributesImpactedResourcesItemsTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v ChangeEventCustomAttributesImpactedResourcesItemsType) IsValid() bool { + for _, existing := range allowedChangeEventCustomAttributesImpactedResourcesItemsTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to ChangeEventCustomAttributesImpactedResourcesItemsType value. +func (v ChangeEventCustomAttributesImpactedResourcesItemsType) Ptr() *ChangeEventCustomAttributesImpactedResourcesItemsType { + return &v +} diff --git a/api/datadogV2/model_event_category.go b/api/datadogV2/model_event_category.go new file mode 100644 index 00000000000..abc1ca9adb5 --- /dev/null +++ b/api/datadogV2/model_event_category.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" +) + +// EventCategory Event category to identify the type of event. Only the value `change` is supported. Support for other categories are coming. please reach out to datadog support if you're interested. +type EventCategory string + +// List of EventCategory. +const ( + EVENTCATEGORY_CHANGE EventCategory = "change" +) + +var allowedEventCategoryEnumValues = []EventCategory{ + EVENTCATEGORY_CHANGE, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *EventCategory) GetAllowedValues() []EventCategory { + return allowedEventCategoryEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *EventCategory) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = EventCategory(value) + return nil +} + +// NewEventCategoryFromValue returns a pointer to a valid EventCategory +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewEventCategoryFromValue(v string) (*EventCategory, error) { + ev := EventCategory(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for EventCategory: valid values are %v", v, allowedEventCategoryEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v EventCategory) IsValid() bool { + for _, existing := range allowedEventCategoryEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to EventCategory value. +func (v EventCategory) Ptr() *EventCategory { + return &v +} diff --git a/api/datadogV2/model_event_create_request.go b/api/datadogV2/model_event_create_request.go new file mode 100644 index 00000000000..9504cec7985 --- /dev/null +++ b/api/datadogV2/model_event_create_request.go @@ -0,0 +1,150 @@ +// 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" +) + +// EventCreateRequest Object representing an event creation request. +type EventCreateRequest struct { + // Event attributes. + Attributes *EventPayload `json:"attributes,omitempty"` + // Entity type. + Type *EventCreateRequestType `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:"-"` +} + +// NewEventCreateRequest instantiates a new EventCreateRequest 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 NewEventCreateRequest() *EventCreateRequest { + this := EventCreateRequest{} + return &this +} + +// NewEventCreateRequestWithDefaults instantiates a new EventCreateRequest 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 NewEventCreateRequestWithDefaults() *EventCreateRequest { + this := EventCreateRequest{} + return &this +} + +// GetAttributes returns the Attributes field value if set, zero value otherwise. +func (o *EventCreateRequest) GetAttributes() EventPayload { + if o == nil || o.Attributes == nil { + var ret EventPayload + 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 *EventCreateRequest) GetAttributesOk() (*EventPayload, 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 *EventCreateRequest) HasAttributes() bool { + return o != nil && o.Attributes != nil +} + +// SetAttributes gets a reference to the given EventPayload and assigns it to the Attributes field. +func (o *EventCreateRequest) SetAttributes(v EventPayload) { + o.Attributes = &v +} + +// GetType returns the Type field value if set, zero value otherwise. +func (o *EventCreateRequest) GetType() EventCreateRequestType { + if o == nil || o.Type == nil { + var ret EventCreateRequestType + 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 *EventCreateRequest) GetTypeOk() (*EventCreateRequestType, 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 *EventCreateRequest) HasType() bool { + return o != nil && o.Type != nil +} + +// SetType gets a reference to the given EventCreateRequestType and assigns it to the Type field. +func (o *EventCreateRequest) SetType(v EventCreateRequestType) { + o.Type = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o EventCreateRequest) 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.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 *EventCreateRequest) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *EventPayload `json:"attributes,omitempty"` + Type *EventCreateRequestType `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", "type"}) + } else { + return err + } + + hasInvalidField := false + if all.Attributes != nil && all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Attributes = all.Attributes + if all.Type != 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_event_create_request_payload.go b/api/datadogV2/model_event_create_request_payload.go new file mode 100644 index 00000000000..b1616503c5b --- /dev/null +++ b/api/datadogV2/model_event_create_request_payload.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" +) + +// EventCreateRequestPayload Payload for creating an event. +type EventCreateRequestPayload struct { + // Object representing an event creation request. + Data *EventCreateRequest `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:"-"` +} + +// NewEventCreateRequestPayload instantiates a new EventCreateRequestPayload 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 NewEventCreateRequestPayload() *EventCreateRequestPayload { + this := EventCreateRequestPayload{} + return &this +} + +// NewEventCreateRequestPayloadWithDefaults instantiates a new EventCreateRequestPayload 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 NewEventCreateRequestPayloadWithDefaults() *EventCreateRequestPayload { + this := EventCreateRequestPayload{} + return &this +} + +// GetData returns the Data field value if set, zero value otherwise. +func (o *EventCreateRequestPayload) GetData() EventCreateRequest { + if o == nil || o.Data == nil { + var ret EventCreateRequest + 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 *EventCreateRequestPayload) GetDataOk() (*EventCreateRequest, 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 *EventCreateRequestPayload) HasData() bool { + return o != nil && o.Data != nil +} + +// SetData gets a reference to the given EventCreateRequest and assigns it to the Data field. +func (o *EventCreateRequestPayload) SetData(v EventCreateRequest) { + o.Data = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o EventCreateRequestPayload) 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 *EventCreateRequestPayload) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *EventCreateRequest `json:"data,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + + hasInvalidField := false + if all.Data != nil && all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Data = all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_event_create_request_type.go b/api/datadogV2/model_event_create_request_type.go new file mode 100644 index 00000000000..646e80eec7f --- /dev/null +++ b/api/datadogV2/model_event_create_request_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" +) + +// EventCreateRequestType Entity type. +type EventCreateRequestType string + +// List of EventCreateRequestType. +const ( + EVENTCREATEREQUESTTYPE_EVENT EventCreateRequestType = "event" +) + +var allowedEventCreateRequestTypeEnumValues = []EventCreateRequestType{ + EVENTCREATEREQUESTTYPE_EVENT, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *EventCreateRequestType) GetAllowedValues() []EventCreateRequestType { + return allowedEventCreateRequestTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *EventCreateRequestType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = EventCreateRequestType(value) + return nil +} + +// NewEventCreateRequestTypeFromValue returns a pointer to a valid EventCreateRequestType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewEventCreateRequestTypeFromValue(v string) (*EventCreateRequestType, error) { + ev := EventCreateRequestType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for EventCreateRequestType: valid values are %v", v, allowedEventCreateRequestTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v EventCreateRequestType) IsValid() bool { + for _, existing := range allowedEventCreateRequestTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to EventCreateRequestType value. +func (v EventCreateRequestType) Ptr() *EventCreateRequestType { + return &v +} diff --git a/api/datadogV2/model_event_create_response.go b/api/datadogV2/model_event_create_response.go new file mode 100644 index 00000000000..52b979dd7ee --- /dev/null +++ b/api/datadogV2/model_event_create_response.go @@ -0,0 +1,146 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// EventCreateResponse Object containing an event response. +type EventCreateResponse struct { + // JSON object containing all events attributes and their associated values. + Attributes *EventCreateResponseAttributes `json:"attributes,omitempty"` + // Event 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:"-"` +} + +// NewEventCreateResponse instantiates a new EventCreateResponse 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 NewEventCreateResponse() *EventCreateResponse { + this := EventCreateResponse{} + return &this +} + +// NewEventCreateResponseWithDefaults instantiates a new EventCreateResponse 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 NewEventCreateResponseWithDefaults() *EventCreateResponse { + this := EventCreateResponse{} + return &this +} + +// GetAttributes returns the Attributes field value if set, zero value otherwise. +func (o *EventCreateResponse) GetAttributes() EventCreateResponseAttributes { + if o == nil || o.Attributes == nil { + var ret EventCreateResponseAttributes + 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 *EventCreateResponse) GetAttributesOk() (*EventCreateResponseAttributes, 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 *EventCreateResponse) HasAttributes() bool { + return o != nil && o.Attributes != nil +} + +// SetAttributes gets a reference to the given EventCreateResponseAttributes and assigns it to the Attributes field. +func (o *EventCreateResponse) SetAttributes(v EventCreateResponseAttributes) { + o.Attributes = &v +} + +// GetType returns the Type field value if set, zero value otherwise. +func (o *EventCreateResponse) 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 *EventCreateResponse) 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 *EventCreateResponse) 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 *EventCreateResponse) SetType(v string) { + o.Type = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o EventCreateResponse) 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.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 *EventCreateResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *EventCreateResponseAttributes `json:"attributes,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", "type"}) + } else { + return err + } + + hasInvalidField := false + if all.Attributes != nil && all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Attributes = all.Attributes + 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_event_create_response_attributes.go b/api/datadogV2/model_event_create_response_attributes.go new file mode 100644 index 00000000000..aff9c573dd7 --- /dev/null +++ b/api/datadogV2/model_event_create_response_attributes.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" +) + +// EventCreateResponseAttributes JSON object containing all events attributes and their associated values. +type EventCreateResponseAttributes struct { + // JSON object of attributes from your events. + Attributes *EventCreateResponseAttributesAttributes `json:"attributes,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:"-"` +} + +// NewEventCreateResponseAttributes instantiates a new EventCreateResponseAttributes 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 NewEventCreateResponseAttributes() *EventCreateResponseAttributes { + this := EventCreateResponseAttributes{} + return &this +} + +// NewEventCreateResponseAttributesWithDefaults instantiates a new EventCreateResponseAttributes 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 NewEventCreateResponseAttributesWithDefaults() *EventCreateResponseAttributes { + this := EventCreateResponseAttributes{} + return &this +} + +// GetAttributes returns the Attributes field value if set, zero value otherwise. +func (o *EventCreateResponseAttributes) GetAttributes() EventCreateResponseAttributesAttributes { + if o == nil || o.Attributes == nil { + var ret EventCreateResponseAttributesAttributes + 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 *EventCreateResponseAttributes) GetAttributesOk() (*EventCreateResponseAttributesAttributes, 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 *EventCreateResponseAttributes) HasAttributes() bool { + return o != nil && o.Attributes != nil +} + +// SetAttributes gets a reference to the given EventCreateResponseAttributesAttributes and assigns it to the Attributes field. +func (o *EventCreateResponseAttributes) SetAttributes(v EventCreateResponseAttributesAttributes) { + o.Attributes = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o EventCreateResponseAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Attributes != nil { + toSerialize["attributes"] = o.Attributes + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *EventCreateResponseAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *EventCreateResponseAttributesAttributes `json:"attributes,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"}) + } else { + return err + } + + hasInvalidField := false + if all.Attributes != nil && all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Attributes = all.Attributes + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_event_create_response_attributes_attributes.go b/api/datadogV2/model_event_create_response_attributes_attributes.go new file mode 100644 index 00000000000..9665fa59b23 --- /dev/null +++ b/api/datadogV2/model_event_create_response_attributes_attributes.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" +) + +// EventCreateResponseAttributesAttributes JSON object of attributes from your events. +type EventCreateResponseAttributesAttributes struct { + // JSON object of event system attributes. + Evt *EventCreateResponseAttributesAttributesEvt `json:"evt,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:"-"` +} + +// NewEventCreateResponseAttributesAttributes instantiates a new EventCreateResponseAttributesAttributes 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 NewEventCreateResponseAttributesAttributes() *EventCreateResponseAttributesAttributes { + this := EventCreateResponseAttributesAttributes{} + return &this +} + +// NewEventCreateResponseAttributesAttributesWithDefaults instantiates a new EventCreateResponseAttributesAttributes 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 NewEventCreateResponseAttributesAttributesWithDefaults() *EventCreateResponseAttributesAttributes { + this := EventCreateResponseAttributesAttributes{} + return &this +} + +// GetEvt returns the Evt field value if set, zero value otherwise. +func (o *EventCreateResponseAttributesAttributes) GetEvt() EventCreateResponseAttributesAttributesEvt { + if o == nil || o.Evt == nil { + var ret EventCreateResponseAttributesAttributesEvt + 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 *EventCreateResponseAttributesAttributes) GetEvtOk() (*EventCreateResponseAttributesAttributesEvt, 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 *EventCreateResponseAttributesAttributes) HasEvt() bool { + return o != nil && o.Evt != nil +} + +// SetEvt gets a reference to the given EventCreateResponseAttributesAttributesEvt and assigns it to the Evt field. +func (o *EventCreateResponseAttributesAttributes) SetEvt(v EventCreateResponseAttributesAttributesEvt) { + o.Evt = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o EventCreateResponseAttributesAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Evt != nil { + toSerialize["evt"] = o.Evt + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *EventCreateResponseAttributesAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Evt *EventCreateResponseAttributesAttributesEvt `json:"evt,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{"evt"}) + } else { + return err + } + + hasInvalidField := false + if all.Evt != nil && all.Evt.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Evt = all.Evt + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_event_create_response_attributes_attributes_evt.go b/api/datadogV2/model_event_create_response_attributes_attributes_evt.go new file mode 100644 index 00000000000..45ecd78c4cb --- /dev/null +++ b/api/datadogV2/model_event_create_response_attributes_attributes_evt.go @@ -0,0 +1,102 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// EventCreateResponseAttributesAttributesEvt JSON object of event system attributes. +type EventCreateResponseAttributesAttributesEvt struct { + // Event id + Id *string `json:"id,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewEventCreateResponseAttributesAttributesEvt instantiates a new EventCreateResponseAttributesAttributesEvt 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 NewEventCreateResponseAttributesAttributesEvt() *EventCreateResponseAttributesAttributesEvt { + this := EventCreateResponseAttributesAttributesEvt{} + return &this +} + +// NewEventCreateResponseAttributesAttributesEvtWithDefaults instantiates a new EventCreateResponseAttributesAttributesEvt 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 NewEventCreateResponseAttributesAttributesEvtWithDefaults() *EventCreateResponseAttributesAttributesEvt { + this := EventCreateResponseAttributesAttributesEvt{} + return &this +} + +// GetId returns the Id field value if set, zero value otherwise. +func (o *EventCreateResponseAttributesAttributesEvt) 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 *EventCreateResponseAttributesAttributesEvt) 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 *EventCreateResponseAttributesAttributesEvt) 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 *EventCreateResponseAttributesAttributesEvt) SetId(v string) { + o.Id = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o EventCreateResponseAttributesAttributesEvt) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Id != nil { + toSerialize["id"] = o.Id + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *EventCreateResponseAttributesAttributesEvt) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Id *string `json:"id,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"id"}) + } else { + return err + } + o.Id = all.Id + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_event_create_response_payload.go b/api/datadogV2/model_event_create_response_payload.go new file mode 100644 index 00000000000..6f41f2c199a --- /dev/null +++ b/api/datadogV2/model_event_create_response_payload.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" +) + +// EventCreateResponsePayload Response containing information about created event. +type EventCreateResponsePayload struct { + // Object containing an event response. + Data *EventCreateResponse `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:"-"` +} + +// NewEventCreateResponsePayload instantiates a new EventCreateResponsePayload 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 NewEventCreateResponsePayload() *EventCreateResponsePayload { + this := EventCreateResponsePayload{} + return &this +} + +// NewEventCreateResponsePayloadWithDefaults instantiates a new EventCreateResponsePayload 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 NewEventCreateResponsePayloadWithDefaults() *EventCreateResponsePayload { + this := EventCreateResponsePayload{} + return &this +} + +// GetData returns the Data field value if set, zero value otherwise. +func (o *EventCreateResponsePayload) GetData() EventCreateResponse { + if o == nil || o.Data == nil { + var ret EventCreateResponse + 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 *EventCreateResponsePayload) GetDataOk() (*EventCreateResponse, 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 *EventCreateResponsePayload) HasData() bool { + return o != nil && o.Data != nil +} + +// SetData gets a reference to the given EventCreateResponse and assigns it to the Data field. +func (o *EventCreateResponsePayload) SetData(v EventCreateResponse) { + o.Data = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o EventCreateResponsePayload) 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 *EventCreateResponsePayload) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *EventCreateResponse `json:"data,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + + hasInvalidField := false + if all.Data != nil && all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Data = all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_event_payload.go b/api/datadogV2/model_event_payload.go new file mode 100644 index 00000000000..8d10d414110 --- /dev/null +++ b/api/datadogV2/model_event_payload.go @@ -0,0 +1,318 @@ +// 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" +) + +// EventPayload Event attributes. +type EventPayload struct { + // An arbitrary string to use for aggregation when correlating events. Limited to 100 characters. + AggregationKey *string `json:"aggregation_key,omitempty"` + // JSON object for custom attributes. Schema are different per each event category. + Attributes EventPayloadAttributes `json:"attributes"` + // Event category to identify the type of event. Only the value `change` is supported. Support for other categories are coming. please reach out to datadog support if you're interested. + Category EventCategory `json:"category"` + // The body of the event. Limited to 4000 characters. + Message *string `json:"message,omitempty"` + // A list of tags to apply to the event. + // Refer to [Tags docs](https://docs.datadoghq.com/getting_started/tagging/). + Tags []string `json:"tags,omitempty"` + // Timestamp when the event occurred. Must follow [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format. + // For example `"2017-01-15T01:30:15.010000Z"`. + // Defaults to the timestamp of receipt. Limited to values no older than 18 hours. + Timestamp *string `json:"timestamp,omitempty"` + // The event title. Limited to 500 characters. + Title string `json:"title"` + // 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:"-"` +} + +// NewEventPayload instantiates a new EventPayload 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 NewEventPayload(attributes EventPayloadAttributes, category EventCategory, title string) *EventPayload { + this := EventPayload{} + this.Attributes = attributes + this.Category = category + this.Title = title + return &this +} + +// NewEventPayloadWithDefaults instantiates a new EventPayload 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 NewEventPayloadWithDefaults() *EventPayload { + this := EventPayload{} + return &this +} + +// GetAggregationKey returns the AggregationKey field value if set, zero value otherwise. +func (o *EventPayload) 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 *EventPayload) 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 *EventPayload) 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 *EventPayload) SetAggregationKey(v string) { + o.AggregationKey = &v +} + +// GetAttributes returns the Attributes field value. +func (o *EventPayload) GetAttributes() EventPayloadAttributes { + if o == nil { + var ret EventPayloadAttributes + return ret + } + return o.Attributes +} + +// GetAttributesOk returns a tuple with the Attributes field value +// and a boolean to check if the value has been set. +func (o *EventPayload) GetAttributesOk() (*EventPayloadAttributes, bool) { + if o == nil { + return nil, false + } + return &o.Attributes, true +} + +// SetAttributes sets field value. +func (o *EventPayload) SetAttributes(v EventPayloadAttributes) { + o.Attributes = v +} + +// GetCategory returns the Category field value. +func (o *EventPayload) GetCategory() EventCategory { + if o == nil { + var ret EventCategory + return ret + } + return o.Category +} + +// GetCategoryOk returns a tuple with the Category field value +// and a boolean to check if the value has been set. +func (o *EventPayload) GetCategoryOk() (*EventCategory, bool) { + if o == nil { + return nil, false + } + return &o.Category, true +} + +// SetCategory sets field value. +func (o *EventPayload) SetCategory(v EventCategory) { + o.Category = v +} + +// GetMessage returns the Message field value if set, zero value otherwise. +func (o *EventPayload) 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 *EventPayload) 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 *EventPayload) 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 *EventPayload) SetMessage(v string) { + o.Message = &v +} + +// GetTags returns the Tags field value if set, zero value otherwise. +func (o *EventPayload) 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 *EventPayload) 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 *EventPayload) 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 *EventPayload) SetTags(v []string) { + o.Tags = v +} + +// GetTimestamp returns the Timestamp field value if set, zero value otherwise. +func (o *EventPayload) 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 *EventPayload) 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 *EventPayload) 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 *EventPayload) SetTimestamp(v string) { + o.Timestamp = &v +} + +// GetTitle returns the Title field value. +func (o *EventPayload) GetTitle() string { + if o == nil { + var ret string + return ret + } + return o.Title +} + +// GetTitleOk returns a tuple with the Title field value +// and a boolean to check if the value has been set. +func (o *EventPayload) GetTitleOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Title, true +} + +// SetTitle sets field value. +func (o *EventPayload) SetTitle(v string) { + o.Title = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o EventPayload) 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 + } + toSerialize["attributes"] = o.Attributes + toSerialize["category"] = o.Category + if o.Message != nil { + toSerialize["message"] = o.Message + } + if o.Tags != nil { + toSerialize["tags"] = o.Tags + } + if o.Timestamp != nil { + toSerialize["timestamp"] = o.Timestamp + } + toSerialize["title"] = o.Title + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *EventPayload) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + AggregationKey *string `json:"aggregation_key,omitempty"` + Attributes *EventPayloadAttributes `json:"attributes"` + Category *EventCategory `json:"category"` + Message *string `json:"message,omitempty"` + Tags []string `json:"tags,omitempty"` + Timestamp *string `json:"timestamp,omitempty"` + Title *string `json:"title"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Attributes == nil { + return fmt.Errorf("required field attributes missing") + } + if all.Category == nil { + return fmt.Errorf("required field category missing") + } + if all.Title == nil { + return fmt.Errorf("required field title missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"aggregation_key", "attributes", "category", "message", "tags", "timestamp", "title"}) + } else { + return err + } + + hasInvalidField := false + o.AggregationKey = all.AggregationKey + o.Attributes = *all.Attributes + if !all.Category.IsValid() { + hasInvalidField = true + } else { + o.Category = *all.Category + } + o.Message = all.Message + o.Tags = all.Tags + 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_event_payload_attributes.go b/api/datadogV2/model_event_payload_attributes.go new file mode 100644 index 00000000000..e6b8b0a28e8 --- /dev/null +++ b/api/datadogV2/model_event_payload_attributes.go @@ -0,0 +1,73 @@ +// 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" +) + +// EventPayloadAttributes - JSON object for custom attributes. Schema are different per each event category. +type EventPayloadAttributes struct { + ChangeEventCustomAttributes *ChangeEventCustomAttributes + + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject interface{} +} + +// ChangeEventCustomAttributesAsEventPayloadAttributes is a convenience function that returns ChangeEventCustomAttributes wrapped in EventPayloadAttributes. +func ChangeEventCustomAttributesAsEventPayloadAttributes(v *ChangeEventCustomAttributes) EventPayloadAttributes { + return EventPayloadAttributes{ChangeEventCustomAttributes: v} +} + +// UnmarshalJSON turns data into one of the pointers in the struct. +func (obj *EventPayloadAttributes) UnmarshalJSON(data []byte) error { + var err error + match := 0 + // try to unmarshal data into ChangeEventCustomAttributes + err = datadog.Unmarshal(data, &obj.ChangeEventCustomAttributes) + if err == nil { + if obj.ChangeEventCustomAttributes != nil && obj.ChangeEventCustomAttributes.UnparsedObject == nil { + jsonChangeEventCustomAttributes, _ := datadog.Marshal(obj.ChangeEventCustomAttributes) + if string(jsonChangeEventCustomAttributes) == "{}" { // empty struct + obj.ChangeEventCustomAttributes = nil + } else { + match++ + } + } else { + obj.ChangeEventCustomAttributes = nil + } + } else { + obj.ChangeEventCustomAttributes = nil + } + + if match != 1 { // more than 1 match + // reset to nil + obj.ChangeEventCustomAttributes = 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 EventPayloadAttributes) MarshalJSON() ([]byte, error) { + if obj.ChangeEventCustomAttributes != nil { + return datadog.Marshal(&obj.ChangeEventCustomAttributes) + } + + if obj.UnparsedObject != nil { + return datadog.Marshal(obj.UnparsedObject) + } + return nil, nil // no data in oneOf schemas +} + +// GetActualInstance returns the actual instance. +func (obj *EventPayloadAttributes) GetActualInstance() interface{} { + if obj.ChangeEventCustomAttributes != nil { + return obj.ChangeEventCustomAttributes + } + + // all schemas are nil + return nil +} diff --git a/examples/v2/events/CreateEvent.go b/examples/v2/events/CreateEvent.go new file mode 100644 index 00000000000..cf1cf5f2c3d --- /dev/null +++ b/examples/v2/events/CreateEvent.go @@ -0,0 +1,73 @@ +// Post 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() { + body := datadogV2.EventCreateRequestPayload{ + Data: &datadogV2.EventCreateRequest{ + Attributes: &datadogV2.EventPayload{ + Attributes: datadogV2.EventPayloadAttributes{ + ChangeEventCustomAttributes: &datadogV2.ChangeEventCustomAttributes{ + Author: &datadogV2.ChangeEventCustomAttributesAuthor{ + Name: "datadog@datadog.com", + Type: datadogV2.CHANGEEVENTCUSTOMATTRIBUTESAUTHORTYPE_USER, + }, + ChangeMetadata: map[string]interface{}{ + "dd": "{'team': 'datadog_team', 'user_email': 'datadog@datadog.com', 'user_id': 'datadog_user_id', 'user_name': 'datadog_username'}", + "resource_link": "datadog.com/feature/fallback_payments_test", + }, + ChangedResource: datadogV2.ChangeEventCustomAttributesChangedResource{ + Name: "fallback_payments_test", + Type: datadogV2.CHANGEEVENTCUSTOMATTRIBUTESCHANGEDRESOURCETYPE_FEATURE_FLAG, + }, + ImpactedResources: []datadogV2.ChangeEventCustomAttributesImpactedResourcesItems{ + { + Name: "payments_api", + Type: datadogV2.CHANGEEVENTCUSTOMATTRIBUTESIMPACTEDRESOURCESITEMSTYPE_SERVICE, + }, + }, + NewValue: map[string]interface{}{ + "enabled": "True", + "percentage": "50%", + "rule": "{'datacenter': 'devcycle.us1.prod'}", + }, + PrevValue: map[string]interface{}{ + "enabled": "True", + "percentage": "10%", + "rule": "{'datacenter': 'devcycle.us1.prod'}", + }, + }}, + Category: datadogV2.EVENTCATEGORY_CHANGE, + Message: datadog.PtrString("payment_processed feature flag has been enabled"), + Tags: []string{ + "environment:test", + }, + Title: "payment_processed feature flag updated", + }, + Type: datadogV2.EVENTCREATEREQUESTTYPE_EVENT.Ptr(), + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewEventsApi(apiClient) + resp, r, err := api.CreateEvent(ctx, body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `EventsApi.CreateEvent`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `EventsApi.CreateEvent`:\n%s\n", responseContent) +} diff --git a/tests/scenarios/features/v2/events.feature b/tests/scenarios/features/v2/events.feature index 9a1c79072d1..2013c242f6c 100644 --- a/tests/scenarios/features/v2/events.feature +++ b/tests/scenarios/features/v2/events.feature @@ -7,24 +7,26 @@ Feature: Events Background: Given a valid "apiKeyAuth" key in the system - And a valid "appKeyAuth" key in the system And an instance of "Events" API @generated @skip @team:DataDog/event-management Scenario: Get a list of events returns "Bad Request" response - Given new "ListEvents" request + Given a valid "appKeyAuth" key in the system + And new "ListEvents" request When the request is sent Then the response status is 400 Bad Request @skip-validation @team:DataDog/event-management Scenario: Get a list of events returns "OK" response - Given new "ListEvents" request + Given a valid "appKeyAuth" key in the system + And new "ListEvents" request When the request is sent Then the response status is 200 OK @replay-only @skip-validation @team:DataDog/event-management @with-pagination Scenario: Get a list of events returns "OK" response with pagination - Given new "ListEvents" request + Given a valid "appKeyAuth" key in the system + And new "ListEvents" request And request contains "filter[from]" parameter with value "now-15m" And request contains "filter[to]" parameter with value "now" And request contains "page[limit]" parameter with value 2 @@ -34,7 +36,8 @@ Feature: Events @team:DataDog/event-management Scenario: Get a quick list of events returns "OK" response - Given new "ListEvents" request + Given a valid "appKeyAuth" key in the system + And new "ListEvents" request And request contains "filter[query]" parameter with value "datadog-agent" And request contains "filter[from]" parameter with value "2020-09-17T11:48:36+01:00" And request contains "filter[to]" parameter with value "2020-09-17T12:48:36+01:00" @@ -43,16 +46,32 @@ Feature: Events Then the response status is 200 OK And the response "data" has length 0 + @generated @skip @team:DataDog/event-management + Scenario: Post an event returns "Bad request" response + Given new "CreateEvent" request + And body with value {"data": {"attributes": {"attributes": {"author": {"name": "datadog@datadog.com", "type": "user"}, "change_metadata": {"dd": {"team": "datadog_team", "user_email": "datadog@datadog.com", "user_id": "datadog_user_id", "user_name": "datadog_username"}, "resource_link": "datadog.com/feature/fallback_payments_test"}, "changed_resource": {"name": "fallback_payments_test", "type": "feature_flag"}, "impacted_resources": [{"name": "payments_api", "type": "service"}], "new_value": {"enabled": true, "percentage": "50%", "rule": {"datacenter": "devcycle.us1.prod"}}, "prev_value": {"enabled": true, "percentage": "10%", "rule": {"datacenter": "devcycle.us1.prod"}}}, "category": "change", "message": "payment_processed feature flag has been enabled", "tags": ["environment:test"], "title": "payment_processed feature flag updated"}, "type": "event"}} + When the request is sent + Then the response status is 400 Bad request + + @generated @skip @team:DataDog/event-management + Scenario: Post an event returns "OK" response + Given new "CreateEvent" request + And body with value {"data": {"attributes": {"attributes": {"author": {"name": "datadog@datadog.com", "type": "user"}, "change_metadata": {"dd": {"team": "datadog_team", "user_email": "datadog@datadog.com", "user_id": "datadog_user_id", "user_name": "datadog_username"}, "resource_link": "datadog.com/feature/fallback_payments_test"}, "changed_resource": {"name": "fallback_payments_test", "type": "feature_flag"}, "impacted_resources": [{"name": "payments_api", "type": "service"}], "new_value": {"enabled": true, "percentage": "50%", "rule": {"datacenter": "devcycle.us1.prod"}}, "prev_value": {"enabled": true, "percentage": "10%", "rule": {"datacenter": "devcycle.us1.prod"}}}, "category": "change", "message": "payment_processed feature flag has been enabled", "tags": ["environment:test"], "title": "payment_processed feature flag updated"}, "type": "event"}} + When the request is sent + Then the response status is 200 OK + @team:DataDog/event-management Scenario: Search events returns "Bad Request" response - Given new "SearchEvents" request + Given a valid "appKeyAuth" key in the system + And new "SearchEvents" request And body with value {"filter": {"from": "now-15m", "query": "service:web* AND @http.status_code:[200 TO 299]", "to": "now"}, "options": {"timezone": "GMT"}, "page": {"cursor": "eyJzdGFydEF0IjoiQVFBQUFYS2tMS3pPbm40NGV3QUFBQUJCV0V0clRFdDZVbG8zY3pCRmNsbHJiVmxDWlEifQ==", "limit": 25}, "sort": "timestamp"} When the request is sent Then the response status is 400 Bad Request @team:DataDog/event-management Scenario: Search events returns "OK" response - Given new "SearchEvents" request + Given a valid "appKeyAuth" key in the system + And new "SearchEvents" request And body with value {"filter": {"query": "datadog-agent", "from": "2020-09-17T11:48:36+01:00", "to": "2020-09-17T12:48:36+01:00"}, "sort": "timestamp", "page": {"limit": 5}} When the request is sent Then the response status is 200 OK @@ -60,7 +79,8 @@ Feature: Events @replay-only @skip-validation @team:DataDog/event-management @with-pagination Scenario: Search events returns "OK" response with pagination - Given new "SearchEvents" request + Given a valid "appKeyAuth" key in the system + And new "SearchEvents" request And body with value {"filter": {"from": "now-15m", "to": "now"}, "options": {"timezone": "GMT"}, "page": {"limit": 2}, "sort": "timestamp"} When the request with pagination is sent Then the response status is 200 OK diff --git a/tests/scenarios/features/v2/undo.json b/tests/scenarios/features/v2/undo.json index dcb4deb9a78..91f554953bd 100644 --- a/tests/scenarios/features/v2/undo.json +++ b/tests/scenarios/features/v2/undo.json @@ -608,6 +608,12 @@ "type": "safe" } }, + "CreateEvent": { + "tag": "Events", + "undo": { + "type": "unsafe" + } + }, "SearchEvents": { "tag": "Events", "undo": {