From 1ac7881ca8dc878b73459dcb659da3379e60fa9f Mon Sep 17 00:00:00 2001 From: "ci.datadog-api-spec" Date: Thu, 21 Nov 2024 20:24:11 +0000 Subject: [PATCH] Regenerate client from commit ad36259c of spec repo --- .apigentools-info | 8 +- .generator/schemas/v2/openapi.yaml | 316 ++++++++++++++++++ examples/v2/events/CreateEvent.rb | 44 +++ features/scenarios_model_mapping.rb | 3 + features/v2/events.feature | 36 +- features/v2/undo.json | 6 + lib/datadog_api_client/inflector.rb | 18 + lib/datadog_api_client/v2/api/events_api.rb | 67 ++++ .../models/change_event_custom_attributes.rb | 176 ++++++++++ .../change_event_custom_attributes_author.rb | 148 ++++++++ ...nge_event_custom_attributes_author_type.rb | 27 ++ ...vent_custom_attributes_changed_resource.rb | 144 ++++++++ ...custom_attributes_changed_resource_type.rb | 26 ++ ...tom_attributes_impacted_resources_items.rb | 144 ++++++++ ...ttributes_impacted_resources_items_type.rb | 26 ++ .../v2/models/event_category.rb | 26 ++ .../v2/models/event_create_request.rb | 115 +++++++ .../v2/models/event_create_request_payload.rb | 105 ++++++ .../v2/models/event_create_request_type.rb | 26 ++ .../v2/models/event_create_response.rb | 115 +++++++ .../event_create_response_attributes.rb | 105 ++++++ ...t_create_response_attributes_attributes.rb | 105 ++++++ ...eate_response_attributes_attributes_evt.rb | 105 ++++++ .../models/event_create_response_payload.rb | 105 ++++++ .../v2/models/event_payload.rb | 236 +++++++++++++ .../v2/models/event_payload_attributes.rb | 62 ++++ 26 files changed, 2282 insertions(+), 12 deletions(-) create mode 100644 examples/v2/events/CreateEvent.rb create mode 100644 lib/datadog_api_client/v2/models/change_event_custom_attributes.rb create mode 100644 lib/datadog_api_client/v2/models/change_event_custom_attributes_author.rb create mode 100644 lib/datadog_api_client/v2/models/change_event_custom_attributes_author_type.rb create mode 100644 lib/datadog_api_client/v2/models/change_event_custom_attributes_changed_resource.rb create mode 100644 lib/datadog_api_client/v2/models/change_event_custom_attributes_changed_resource_type.rb create mode 100644 lib/datadog_api_client/v2/models/change_event_custom_attributes_impacted_resources_items.rb create mode 100644 lib/datadog_api_client/v2/models/change_event_custom_attributes_impacted_resources_items_type.rb create mode 100644 lib/datadog_api_client/v2/models/event_category.rb create mode 100644 lib/datadog_api_client/v2/models/event_create_request.rb create mode 100644 lib/datadog_api_client/v2/models/event_create_request_payload.rb create mode 100644 lib/datadog_api_client/v2/models/event_create_request_type.rb create mode 100644 lib/datadog_api_client/v2/models/event_create_response.rb create mode 100644 lib/datadog_api_client/v2/models/event_create_response_attributes.rb create mode 100644 lib/datadog_api_client/v2/models/event_create_response_attributes_attributes.rb create mode 100644 lib/datadog_api_client/v2/models/event_create_response_attributes_attributes_evt.rb create mode 100644 lib/datadog_api_client/v2/models/event_create_response_payload.rb create mode 100644 lib/datadog_api_client/v2/models/event_payload.rb create mode 100644 lib/datadog_api_client/v2/models/event_payload_attributes.rb diff --git a/.apigentools-info b/.apigentools-info index 53d724952aac..cf342edd065f 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.6.6", - "regenerated": "2024-11-20 21:48:38.093015", - "spec_repo_commit": "34905ccb" + "regenerated": "2024-11-21 20:23:36.620867", + "spec_repo_commit": "ad36259c" }, "v2": { "apigentools_version": "1.6.6", - "regenerated": "2024-11-20 21:48:38.111701", - "spec_repo_commit": "34905ccb" + "regenerated": "2024-11-21 20:23:36.640802", + "spec_repo_commit": "ad36259c" } } } \ No newline at end of file diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 91a7d81a167e..33e7c854dd4a 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: @@ -31196,6 +31436,82 @@ 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: + examples: + json-request-body: + 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 + 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/examples/v2/events/CreateEvent.rb b/examples/v2/events/CreateEvent.rb new file mode 100644 index 000000000000..a3258869ca3b --- /dev/null +++ b/examples/v2/events/CreateEvent.rb @@ -0,0 +1,44 @@ +# Post an event returns "OK" response + +require "datadog_api_client" +api_instance = DatadogAPIClient::V2::EventsAPI.new + +body = DatadogAPIClient::V2::EventCreateRequestPayload.new({ + data: DatadogAPIClient::V2::EventCreateRequest.new({ + attributes: DatadogAPIClient::V2::EventPayload.new({ + attributes: DatadogAPIClient::V2::ChangeEventCustomAttributes.new({ + author: DatadogAPIClient::V2::ChangeEventCustomAttributesAuthor.new({ + name: "datadog@datadog.com", + type: DatadogAPIClient::V2::ChangeEventCustomAttributesAuthorType::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: DatadogAPIClient::V2::ChangeEventCustomAttributesChangedResource.new({ + name: "fallback_payments_test", + type: DatadogAPIClient::V2::ChangeEventCustomAttributesChangedResourceType::FEATURE_FLAG, + }), + impacted_resources: [ + DatadogAPIClient::V2::ChangeEventCustomAttributesImpactedResourcesItems.new({ + name: "payments_api", + type: DatadogAPIClient::V2::ChangeEventCustomAttributesImpactedResourcesItemsType::SERVICE, + }), + ], + new_value: { + "enabled": "True", "percentage": "50%", "rule": "{'datacenter': 'devcycle.us1.prod'}", + }, + prev_value: { + "enabled": "True", "percentage": "10%", "rule": "{'datacenter': 'devcycle.us1.prod'}", + }, + }), + category: DatadogAPIClient::V2::EventCategory::CHANGE, + message: "payment_processed feature flag has been enabled", + tags: [ + "environment:test", + ], + title: "payment_processed feature flag updated", + }), + type: DatadogAPIClient::V2::EventCreateRequestType::EVENT, + }), +}) +p api_instance.create_event(body) diff --git a/features/scenarios_model_mapping.rb b/features/scenarios_model_mapping.rb index 0ff02c599183..4aeffbe730fe 100644 --- a/features/scenarios_model_mapping.rb +++ b/features/scenarios_model_mapping.rb @@ -1228,6 +1228,9 @@ "page_cursor" => "String", "page_limit" => "Integer", }, + "v2.CreateEvent" => { + "body" => "EventCreateRequestPayload", + }, "v2.SearchEvents" => { "body" => "EventsListRequest", }, diff --git a/features/v2/events.feature b/features/v2/events.feature index 9a1c79072d12..2013c242f6c9 100644 --- a/features/v2/events.feature +++ b/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/features/v2/undo.json b/features/v2/undo.json index dcb4deb9a783..91f554953bdf 100644 --- a/features/v2/undo.json +++ b/features/v2/undo.json @@ -608,6 +608,12 @@ "type": "safe" } }, + "CreateEvent": { + "tag": "Events", + "undo": { + "type": "unsafe" + } + }, "SearchEvents": { "tag": "Events", "undo": { diff --git a/lib/datadog_api_client/inflector.rb b/lib/datadog_api_client/inflector.rb index 3bdc3de70abc..52188f75b900 100644 --- a/lib/datadog_api_client/inflector.rb +++ b/lib/datadog_api_client/inflector.rb @@ -1085,6 +1085,13 @@ def overrides "v2.case_update_status" => "CaseUpdateStatus", "v2.case_update_status_attributes" => "CaseUpdateStatusAttributes", "v2.case_update_status_request" => "CaseUpdateStatusRequest", + "v2.change_event_custom_attributes" => "ChangeEventCustomAttributes", + "v2.change_event_custom_attributes_author" => "ChangeEventCustomAttributesAuthor", + "v2.change_event_custom_attributes_author_type" => "ChangeEventCustomAttributesAuthorType", + "v2.change_event_custom_attributes_changed_resource" => "ChangeEventCustomAttributesChangedResource", + "v2.change_event_custom_attributes_changed_resource_type" => "ChangeEventCustomAttributesChangedResourceType", + "v2.change_event_custom_attributes_impacted_resources_items" => "ChangeEventCustomAttributesImpactedResourcesItems", + "v2.change_event_custom_attributes_impacted_resources_items_type" => "ChangeEventCustomAttributesImpactedResourcesItemsType", "v2.chargeback_breakdown" => "ChargebackBreakdown", "v2.ci_app_aggregate_bucket_value" => "CIAppAggregateBucketValue", "v2.ci_app_aggregate_bucket_value_timeseries_point" => "CIAppAggregateBucketValueTimeseriesPoint", @@ -1443,6 +1450,17 @@ def overrides "v2.entity_v3_system_spec" => "EntityV3SystemSpec", "v2.event" => "Event", "v2.event_attributes" => "EventAttributes", + "v2.event_category" => "EventCategory", + "v2.event_create_request" => "EventCreateRequest", + "v2.event_create_request_payload" => "EventCreateRequestPayload", + "v2.event_create_request_type" => "EventCreateRequestType", + "v2.event_create_response" => "EventCreateResponse", + "v2.event_create_response_attributes" => "EventCreateResponseAttributes", + "v2.event_create_response_attributes_attributes" => "EventCreateResponseAttributesAttributes", + "v2.event_create_response_attributes_attributes_evt" => "EventCreateResponseAttributesAttributesEvt", + "v2.event_create_response_payload" => "EventCreateResponsePayload", + "v2.event_payload" => "EventPayload", + "v2.event_payload_attributes" => "EventPayloadAttributes", "v2.event_priority" => "EventPriority", "v2.event_response" => "EventResponse", "v2.event_response_attributes" => "EventResponseAttributes", diff --git a/lib/datadog_api_client/v2/api/events_api.rb b/lib/datadog_api_client/v2/api/events_api.rb index f6a9702988e4..adf4da4a1d79 100644 --- a/lib/datadog_api_client/v2/api/events_api.rb +++ b/lib/datadog_api_client/v2/api/events_api.rb @@ -23,6 +23,73 @@ def initialize(api_client = DatadogAPIClient::APIClient.default) @api_client = api_client end + # Post an event. + # + # @see #create_event_with_http_info + def create_event(body, opts = {}) + data, _status_code, _headers = create_event_with_http_info(body, opts) + data + end + + # Post an event. + # + # This endpoint allows you to post events. Only events with `change` category are under General Availability. + # + # @param body [EventCreateRequestPayload] Event request object + # @param opts [Hash] the optional parameters + # @return [Array<(EventCreateResponsePayload, Integer, Hash)>] EventCreateResponsePayload data, response status code and response headers + def create_event_with_http_info(body, opts = {}) + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: EventsAPI.create_event ...' + end + # verify the required parameter 'body' is set + if @api_client.config.client_side_validation && body.nil? + fail ArgumentError, "Missing the required parameter 'body' when calling EventsAPI.create_event" + end + # resource path + local_var_path = '/api/v2/events' + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + # HTTP header 'Content-Type' + header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] || @api_client.object_to_http_body(body) + + # return_type + return_type = opts[:debug_return_type] || 'EventCreateResponsePayload' + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth] + + new_options = opts.merge( + :operation => :create_event, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type, + :api_version => "V2" + ) + + data, status_code, headers = @api_client.call_api(Net::HTTP::Post, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: EventsAPI#create_event\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + # Get a list of events. # # @see #list_events_with_http_info diff --git a/lib/datadog_api_client/v2/models/change_event_custom_attributes.rb b/lib/datadog_api_client/v2/models/change_event_custom_attributes.rb new file mode 100644 index 000000000000..5b9a22d2713d --- /dev/null +++ b/lib/datadog_api_client/v2/models/change_event_custom_attributes.rb @@ -0,0 +1,176 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Object representing custom change event attributes. + class ChangeEventCustomAttributes + include BaseGenericModel + + # Object representing the entity which made the change. Optional field but if provided should include `type` and `name`. + attr_accessor :author + + # Free form object with information related to the `change` event. Can be arbitrarily nested and contain any valid JSON. + attr_accessor :change_metadata + + # Object representing a uniquely identified resource. Only the resource type `feature_flag` is supported. + attr_reader :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. + attr_accessor :impacted_resources + + # Free form object to track new value of the changed resource. + attr_accessor :new_value + + # Free form object to track previous value of the changed resource. + attr_accessor :prev_value + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'author' => :'author', + :'change_metadata' => :'change_metadata', + :'changed_resource' => :'changed_resource', + :'impacted_resources' => :'impacted_resources', + :'new_value' => :'new_value', + :'prev_value' => :'prev_value' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'author' => :'ChangeEventCustomAttributesAuthor', + :'change_metadata' => :'Hash', + :'changed_resource' => :'ChangeEventCustomAttributesChangedResource', + :'impacted_resources' => :'Array', + :'new_value' => :'Hash', + :'prev_value' => :'Hash' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::ChangeEventCustomAttributes` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'author') + self.author = attributes[:'author'] + end + + if attributes.key?(:'change_metadata') + self.change_metadata = attributes[:'change_metadata'] + end + + if attributes.key?(:'changed_resource') + self.changed_resource = attributes[:'changed_resource'] + end + + if attributes.key?(:'impacted_resources') + if (value = attributes[:'impacted_resources']).is_a?(Array) + self.impacted_resources = value + end + end + + if attributes.key?(:'new_value') + self.new_value = attributes[:'new_value'] + end + + if attributes.key?(:'prev_value') + self.prev_value = attributes[:'prev_value'] + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @changed_resource.nil? + true + end + + # Custom attribute writer method with validation + # @param changed_resource [Object] Object to be assigned + # @!visibility private + def changed_resource=(changed_resource) + if changed_resource.nil? + fail ArgumentError, 'invalid value for "changed_resource", changed_resource cannot be nil.' + end + @changed_resource = changed_resource + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + author == o.author && + change_metadata == o.change_metadata && + changed_resource == o.changed_resource && + impacted_resources == o.impacted_resources && + new_value == o.new_value && + prev_value == o.prev_value + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [author, change_metadata, changed_resource, impacted_resources, new_value, prev_value].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/change_event_custom_attributes_author.rb b/lib/datadog_api_client/v2/models/change_event_custom_attributes_author.rb new file mode 100644 index 000000000000..0b979ce3554b --- /dev/null +++ b/lib/datadog_api_client/v2/models/change_event_custom_attributes_author.rb @@ -0,0 +1,148 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Object representing the entity which made the change. Optional field but if provided should include `type` and `name`. + class ChangeEventCustomAttributesAuthor + include BaseGenericModel + + # Author's name. Limited to 128 characters. + attr_reader :name + + # Author's type. + attr_reader :type + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'name' => :'name', + :'type' => :'type' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'name' => :'String', + :'type' => :'ChangeEventCustomAttributesAuthorType' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::ChangeEventCustomAttributesAuthor` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @name.nil? + return false if @name.to_s.length > 128 + return false if @type.nil? + true + end + + # Custom attribute writer method with validation + # @param name [Object] Object to be assigned + # @!visibility private + def name=(name) + if name.nil? + fail ArgumentError, 'invalid value for "name", name cannot be nil.' + end + if name.to_s.length > 128 + fail ArgumentError, 'invalid value for "name", the character length must be smaller than or equal to 128.' + end + @name = name + end + + # Custom attribute writer method with validation + # @param type [Object] Object to be assigned + # @!visibility private + def type=(type) + if type.nil? + fail ArgumentError, 'invalid value for "type", type cannot be nil.' + end + @type = type + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + name == o.name && + type == o.type + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [name, type].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/change_event_custom_attributes_author_type.rb b/lib/datadog_api_client/v2/models/change_event_custom_attributes_author_type.rb new file mode 100644 index 000000000000..cdb818702f90 --- /dev/null +++ b/lib/datadog_api_client/v2/models/change_event_custom_attributes_author_type.rb @@ -0,0 +1,27 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Author's type. + class ChangeEventCustomAttributesAuthorType + include BaseEnumModel + + USER = "user".freeze + SYSTEM = "system".freeze + end +end diff --git a/lib/datadog_api_client/v2/models/change_event_custom_attributes_changed_resource.rb b/lib/datadog_api_client/v2/models/change_event_custom_attributes_changed_resource.rb new file mode 100644 index 000000000000..4faaf472d2ea --- /dev/null +++ b/lib/datadog_api_client/v2/models/change_event_custom_attributes_changed_resource.rb @@ -0,0 +1,144 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Object representing a uniquely identified resource. Only the resource type `feature_flag` is supported. + class ChangeEventCustomAttributesChangedResource + include BaseGenericModel + + # Resource's name. + attr_reader :name + + # Resource's type. + attr_reader :type + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'name' => :'name', + :'type' => :'type' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'name' => :'String', + :'type' => :'ChangeEventCustomAttributesChangedResourceType' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::ChangeEventCustomAttributesChangedResource` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @name.nil? + return false if @type.nil? + true + end + + # Custom attribute writer method with validation + # @param name [Object] Object to be assigned + # @!visibility private + def name=(name) + if name.nil? + fail ArgumentError, 'invalid value for "name", name cannot be nil.' + end + @name = name + end + + # Custom attribute writer method with validation + # @param type [Object] Object to be assigned + # @!visibility private + def type=(type) + if type.nil? + fail ArgumentError, 'invalid value for "type", type cannot be nil.' + end + @type = type + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + name == o.name && + type == o.type + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [name, type].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/change_event_custom_attributes_changed_resource_type.rb b/lib/datadog_api_client/v2/models/change_event_custom_attributes_changed_resource_type.rb new file mode 100644 index 000000000000..feb61467bdb6 --- /dev/null +++ b/lib/datadog_api_client/v2/models/change_event_custom_attributes_changed_resource_type.rb @@ -0,0 +1,26 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Resource's type. + class ChangeEventCustomAttributesChangedResourceType + include BaseEnumModel + + FEATURE_FLAG = "feature_flag".freeze + end +end diff --git a/lib/datadog_api_client/v2/models/change_event_custom_attributes_impacted_resources_items.rb b/lib/datadog_api_client/v2/models/change_event_custom_attributes_impacted_resources_items.rb new file mode 100644 index 000000000000..55c50b65aa87 --- /dev/null +++ b/lib/datadog_api_client/v2/models/change_event_custom_attributes_impacted_resources_items.rb @@ -0,0 +1,144 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Object representing a uniquely identified resource. Only the resource type `service` is supported. + class ChangeEventCustomAttributesImpactedResourcesItems + include BaseGenericModel + + # Resource's name. + attr_reader :name + + # Resource's type. + attr_reader :type + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'name' => :'name', + :'type' => :'type' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'name' => :'String', + :'type' => :'ChangeEventCustomAttributesImpactedResourcesItemsType' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::ChangeEventCustomAttributesImpactedResourcesItems` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @name.nil? + return false if @type.nil? + true + end + + # Custom attribute writer method with validation + # @param name [Object] Object to be assigned + # @!visibility private + def name=(name) + if name.nil? + fail ArgumentError, 'invalid value for "name", name cannot be nil.' + end + @name = name + end + + # Custom attribute writer method with validation + # @param type [Object] Object to be assigned + # @!visibility private + def type=(type) + if type.nil? + fail ArgumentError, 'invalid value for "type", type cannot be nil.' + end + @type = type + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + name == o.name && + type == o.type + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [name, type].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/change_event_custom_attributes_impacted_resources_items_type.rb b/lib/datadog_api_client/v2/models/change_event_custom_attributes_impacted_resources_items_type.rb new file mode 100644 index 000000000000..930c49b28db4 --- /dev/null +++ b/lib/datadog_api_client/v2/models/change_event_custom_attributes_impacted_resources_items_type.rb @@ -0,0 +1,26 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Resource's type. + class ChangeEventCustomAttributesImpactedResourcesItemsType + include BaseEnumModel + + SERVICE = "service".freeze + end +end diff --git a/lib/datadog_api_client/v2/models/event_category.rb b/lib/datadog_api_client/v2/models/event_category.rb new file mode 100644 index 000000000000..43b97b08f8d5 --- /dev/null +++ b/lib/datadog_api_client/v2/models/event_category.rb @@ -0,0 +1,26 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # 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. + class EventCategory + include BaseEnumModel + + CHANGE = "change".freeze + end +end diff --git a/lib/datadog_api_client/v2/models/event_create_request.rb b/lib/datadog_api_client/v2/models/event_create_request.rb new file mode 100644 index 000000000000..e9325b3ace49 --- /dev/null +++ b/lib/datadog_api_client/v2/models/event_create_request.rb @@ -0,0 +1,115 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Object representing an event creation request. + class EventCreateRequest + include BaseGenericModel + + # Event attributes. + attr_accessor :attributes + + # Entity type. + attr_accessor :type + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'attributes' => :'attributes', + :'type' => :'type' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'attributes' => :'EventPayload', + :'type' => :'EventCreateRequestType' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::EventCreateRequest` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'attributes') + self.attributes = attributes[:'attributes'] + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + end + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + attributes == o.attributes && + type == o.type + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [attributes, type].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/event_create_request_payload.rb b/lib/datadog_api_client/v2/models/event_create_request_payload.rb new file mode 100644 index 000000000000..a5e21127f646 --- /dev/null +++ b/lib/datadog_api_client/v2/models/event_create_request_payload.rb @@ -0,0 +1,105 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Payload for creating an event. + class EventCreateRequestPayload + include BaseGenericModel + + # Object representing an event creation request. + attr_accessor :data + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'data' => :'data' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'data' => :'EventCreateRequest' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::EventCreateRequestPayload` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'data') + self.data = attributes[:'data'] + end + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + data == o.data + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [data].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/event_create_request_type.rb b/lib/datadog_api_client/v2/models/event_create_request_type.rb new file mode 100644 index 000000000000..05422b7ec95e --- /dev/null +++ b/lib/datadog_api_client/v2/models/event_create_request_type.rb @@ -0,0 +1,26 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Entity type. + class EventCreateRequestType + include BaseEnumModel + + EVENT = "event".freeze + end +end diff --git a/lib/datadog_api_client/v2/models/event_create_response.rb b/lib/datadog_api_client/v2/models/event_create_response.rb new file mode 100644 index 000000000000..37cfce52d8d1 --- /dev/null +++ b/lib/datadog_api_client/v2/models/event_create_response.rb @@ -0,0 +1,115 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Object containing an event response. + class EventCreateResponse + include BaseGenericModel + + # JSON object containing all events attributes and their associated values. + attr_accessor :attributes + + # Event type + attr_accessor :type + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'attributes' => :'attributes', + :'type' => :'type' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'attributes' => :'EventCreateResponseAttributes', + :'type' => :'String' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::EventCreateResponse` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'attributes') + self.attributes = attributes[:'attributes'] + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + end + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + attributes == o.attributes && + type == o.type + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [attributes, type].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/event_create_response_attributes.rb b/lib/datadog_api_client/v2/models/event_create_response_attributes.rb new file mode 100644 index 000000000000..a0c5a6ec3368 --- /dev/null +++ b/lib/datadog_api_client/v2/models/event_create_response_attributes.rb @@ -0,0 +1,105 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # JSON object containing all events attributes and their associated values. + class EventCreateResponseAttributes + include BaseGenericModel + + # JSON object of attributes from your events. + attr_accessor :attributes + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'attributes' => :'attributes' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'attributes' => :'EventCreateResponseAttributesAttributes' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::EventCreateResponseAttributes` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'attributes') + self.attributes = attributes[:'attributes'] + end + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + attributes == o.attributes + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [attributes].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/event_create_response_attributes_attributes.rb b/lib/datadog_api_client/v2/models/event_create_response_attributes_attributes.rb new file mode 100644 index 000000000000..fa2ebbcdd0ef --- /dev/null +++ b/lib/datadog_api_client/v2/models/event_create_response_attributes_attributes.rb @@ -0,0 +1,105 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # JSON object of attributes from your events. + class EventCreateResponseAttributesAttributes + include BaseGenericModel + + # JSON object of event system attributes. + attr_accessor :evt + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'evt' => :'evt' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'evt' => :'EventCreateResponseAttributesAttributesEvt' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::EventCreateResponseAttributesAttributes` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'evt') + self.evt = attributes[:'evt'] + end + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + evt == o.evt + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [evt].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/event_create_response_attributes_attributes_evt.rb b/lib/datadog_api_client/v2/models/event_create_response_attributes_attributes_evt.rb new file mode 100644 index 000000000000..bccc6b3ccf85 --- /dev/null +++ b/lib/datadog_api_client/v2/models/event_create_response_attributes_attributes_evt.rb @@ -0,0 +1,105 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # JSON object of event system attributes. + class EventCreateResponseAttributesAttributesEvt + include BaseGenericModel + + # Event id + attr_accessor :id + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'id' => :'id' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'id' => :'String' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::EventCreateResponseAttributesAttributesEvt` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + id == o.id + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [id].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/event_create_response_payload.rb b/lib/datadog_api_client/v2/models/event_create_response_payload.rb new file mode 100644 index 000000000000..21d22a813658 --- /dev/null +++ b/lib/datadog_api_client/v2/models/event_create_response_payload.rb @@ -0,0 +1,105 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Response containing information about created event. + class EventCreateResponsePayload + include BaseGenericModel + + # Object containing an event response. + attr_accessor :data + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'data' => :'data' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'data' => :'EventCreateResponse' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::EventCreateResponsePayload` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'data') + self.data = attributes[:'data'] + end + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + data == o.data + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [data].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/event_payload.rb b/lib/datadog_api_client/v2/models/event_payload.rb new file mode 100644 index 000000000000..246776d03559 --- /dev/null +++ b/lib/datadog_api_client/v2/models/event_payload.rb @@ -0,0 +1,236 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Event attributes. + class EventPayload + include BaseGenericModel + + # An arbitrary string to use for aggregation when correlating events. Limited to 100 characters. + attr_reader :aggregation_key + + # JSON object for custom attributes. Schema are different per each event category. + attr_reader :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. + attr_reader :category + + # The body of the event. Limited to 4000 characters. + attr_reader :message + + # A list of tags to apply to the event. + # Refer to [Tags docs](https://docs.datadoghq.com/getting_started/tagging/). + attr_accessor :tags + + # 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. + attr_accessor :timestamp + + # The event title. Limited to 500 characters. + attr_reader :title + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'aggregation_key' => :'aggregation_key', + :'attributes' => :'attributes', + :'category' => :'category', + :'message' => :'message', + :'tags' => :'tags', + :'timestamp' => :'timestamp', + :'title' => :'title' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'aggregation_key' => :'String', + :'attributes' => :'EventPayloadAttributes', + :'category' => :'EventCategory', + :'message' => :'String', + :'tags' => :'Array', + :'timestamp' => :'String', + :'title' => :'String' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::EventPayload` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'aggregation_key') + self.aggregation_key = attributes[:'aggregation_key'] + end + + if attributes.key?(:'attributes') + self.attributes = attributes[:'attributes'] + end + + if attributes.key?(:'category') + self.category = attributes[:'category'] + end + + if attributes.key?(:'message') + self.message = attributes[:'message'] + end + + if attributes.key?(:'tags') + if (value = attributes[:'tags']).is_a?(Array) + self.tags = value + end + end + + if attributes.key?(:'timestamp') + self.timestamp = attributes[:'timestamp'] + end + + if attributes.key?(:'title') + self.title = attributes[:'title'] + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if !@aggregation_key.nil? && @aggregation_key.to_s.length > 100 + return false if @attributes.nil? + return false if @category.nil? + return false if !@message.nil? && @message.to_s.length > 4000 + return false if @title.nil? + return false if @title.to_s.length > 500 + true + end + + # Custom attribute writer method with validation + # @param aggregation_key [Object] Object to be assigned + # @!visibility private + def aggregation_key=(aggregation_key) + if !aggregation_key.nil? && aggregation_key.to_s.length > 100 + fail ArgumentError, 'invalid value for "aggregation_key", the character length must be smaller than or equal to 100.' + end + @aggregation_key = aggregation_key + end + + # Custom attribute writer method with validation + # @param attributes [Object] Object to be assigned + # @!visibility private + def attributes=(attributes) + if attributes.nil? + fail ArgumentError, 'invalid value for "attributes", attributes cannot be nil.' + end + @attributes = attributes + end + + # Custom attribute writer method with validation + # @param category [Object] Object to be assigned + # @!visibility private + def category=(category) + if category.nil? + fail ArgumentError, 'invalid value for "category", category cannot be nil.' + end + @category = category + end + + # Custom attribute writer method with validation + # @param message [Object] Object to be assigned + # @!visibility private + def message=(message) + if !message.nil? && message.to_s.length > 4000 + fail ArgumentError, 'invalid value for "message", the character length must be smaller than or equal to 4000.' + end + @message = message + end + + # Custom attribute writer method with validation + # @param title [Object] Object to be assigned + # @!visibility private + def title=(title) + if title.nil? + fail ArgumentError, 'invalid value for "title", title cannot be nil.' + end + if title.to_s.length > 500 + fail ArgumentError, 'invalid value for "title", the character length must be smaller than or equal to 500.' + end + @title = title + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + aggregation_key == o.aggregation_key && + attributes == o.attributes && + category == o.category && + message == o.message && + tags == o.tags && + timestamp == o.timestamp && + title == o.title + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [aggregation_key, attributes, category, message, tags, timestamp, title].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/event_payload_attributes.rb b/lib/datadog_api_client/v2/models/event_payload_attributes.rb new file mode 100644 index 000000000000..0d0225479a8a --- /dev/null +++ b/lib/datadog_api_client/v2/models/event_payload_attributes.rb @@ -0,0 +1,62 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # JSON object for custom attributes. Schema are different per each event category. + module EventPayloadAttributes + class << self + include BaseOneOfModel + include BaseOneOfModelNoDiscriminator + + # List of class defined in oneOf (OpenAPI v3) + def openapi_one_of + [ + :'ChangeEventCustomAttributes' + ] + end + # Builds the object + # @param data [Mixed] Data to be matched against the list of oneOf items + # @return [Object] Returns the model or the data itself + def build(data) + # Go through the list of oneOf items and attempt to identify the appropriate one. + # Note: + # - We do not attempt to check whether exactly one item matches. + # - No advanced validation of types in some cases (e.g. "x: { type: string }" will happily match { x: 123 }) + # due to the way the deserialization is made in the base_object template (it just casts without verifying). + # - TODO: scalar values are de facto behaving as if they were nullable. + # - TODO: logging when debugging is set. + openapi_one_of.each do |klass| + begin + next if klass == :AnyType # "nullable: true" + typed_data = find_and_cast_into_type(klass, data) + next if typed_data.respond_to?(:_unparsed) && typed_data._unparsed + return typed_data if typed_data + rescue # rescue all errors so we keep iterating even if the current item lookup raises + end + end + + if openapi_one_of.include?(:AnyType) + data + else + self._unparsed = true + DatadogAPIClient::UnparsedObject.new(data) + end + end + end + end +end