diff --git a/.apigentools-info b/.apigentools-info index 1cc94236a2f7..93581101d8d1 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.6.2", - "regenerated": "2022-03-10 14:36:07.244745", - "spec_repo_commit": "6503cfbf" + "regenerated": "2022-03-10 15:21:17.780517", + "spec_repo_commit": "4474d6e5" }, "v2": { "apigentools_version": "1.6.2", - "regenerated": "2022-03-10 14:36:07.264756", - "spec_repo_commit": "6503cfbf" + "regenerated": "2022-03-10 15:21:17.799828", + "spec_repo_commit": "4474d6e5" } } } \ No newline at end of file diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 7c2cc345068c..e73a02e07a9c 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -624,6 +624,223 @@ components: type: string x-enum-varnames: - APPLICATION_KEYS + AuditLogsEvent: + description: Object description of an Audit Logs event after it is processed + and stored by Datadog. + properties: + attributes: + $ref: '#/components/schemas/AuditLogsEventAttributes' + id: + description: Unique ID of the event. + example: AAAAAWgN8Xwgr1vKDQAAAABBV2dOOFh3ZzZobm1mWXJFYTR0OA + type: string + type: + $ref: '#/components/schemas/AuditLogsEventType' + type: object + AuditLogsEventAttributes: + description: JSON object containing all event attributes and their associated + values. + properties: + attributes: + additionalProperties: {} + description: JSON object of attributes from Audit Logs events. + example: + customAttribute: 123 + duration: 2345 + type: object + service: + description: 'Name of the application or service generating Audit Logs events. + + This name is used to correlate Audit Logs to APM, so make sure you specify + the same + + value when you use both products.' + example: web-app + type: string + tags: + description: Array of tags associated with your event. + example: + - team:A + items: + description: Tag associated with your event. + type: string + type: array + timestamp: + description: Timestamp of your event. + example: '2019-01-02T09:42:36.320Z' + format: date-time + type: string + type: object + AuditLogsEventType: + default: audit + description: Type of the event. + enum: + - audit + example: audit + type: string + x-enum-varnames: + - Audit + AuditLogsEventsResponse: + description: Response object with all events matching the request and pagination + information. + properties: + data: + description: Array of events matching the request. + items: + $ref: '#/components/schemas/AuditLogsEvent' + type: array + links: + $ref: '#/components/schemas/AuditLogsResponseLinks' + meta: + $ref: '#/components/schemas/AuditLogsResponseMetadata' + type: object + AuditLogsQueryFilter: + description: Search and filter query settings. + properties: + from: + default: now-15m + description: Minimum time for the requested events. Supports date, math, + and regular timestamps (in milliseconds). + example: now-15m + type: string + query: + default: '*' + description: Search query following the Audit Logs search syntax. + example: '@type:session AND @session.type:user' + type: string + to: + default: now + description: Maximum time for the requested events. Supports date, math, + and regular timestamps (in milliseconds). + example: now + type: string + type: object + AuditLogsQueryOptions: + description: 'Global query options that are used during the query. + + Note: Specify either timezone or time offset, not both. Otherwise, the query + fails.' + properties: + time_offset: + description: Time offset (in seconds) to apply to the query. + format: int64 + type: integer + timezone: + default: UTC + description: 'Timezone code. Can be specified as an offset, for example: + "UTC+03:00".' + example: GMT + type: string + type: object + AuditLogsQueryPageOptions: + description: Paging attributes for listing events. + properties: + cursor: + description: List following results with a cursor provided in the previous + query. + example: eyJzdGFydEF0IjoiQVFBQUFYS2tMS3pPbm40NGV3QUFBQUJCV0V0clRFdDZVbG8zY3pCRmNsbHJiVmxDWlEifQ== + type: string + limit: + default: 10 + description: Maximum number of events in the response. + example: 25 + format: int32 + maximum: 1000 + type: integer + type: object + AuditLogsResponseLinks: + description: Links attributes. + properties: + next: + description: 'Link for the next set of results. Note that the request can + also be made using the + + POST endpoint.' + example: https://app.datadoghq.com/api/v2/audit/event?filter[query]=foo&page[cursor]=eyJzdGFydEF0IjoiQVFBQUFYS2tMS3pPbm40NGV3QUFBQUJCV0V0clRFdDZVbG8zY3pCRmNsbHJiVmxDWlEifQ== + type: string + type: object + AuditLogsResponseMetadata: + description: The metadata associated with a request. + properties: + elapsed: + description: Time elapsed in milliseconds. + example: 132 + format: int64 + type: integer + page: + $ref: '#/components/schemas/AuditLogsResponsePage' + request_id: + description: The identifier of the request. + example: MWlFUjVaWGZTTTZPYzM0VXp1OXU2d3xLSVpEMjZKQ0VKUTI0dEYtM3RSOFVR + type: string + status: + $ref: '#/components/schemas/AuditLogsResponseStatus' + warnings: + description: 'A list of warnings (non-fatal errors) encountered. Partial + results may return if + + warnings are present in the response.' + items: + $ref: '#/components/schemas/AuditLogsWarning' + type: array + type: object + AuditLogsResponsePage: + description: Paging attributes. + properties: + after: + description: The cursor to use to get the next results, if any. To make + the next request, use the same parameters with the addition of `page[cursor]`. + example: eyJzdGFydEF0IjoiQVFBQUFYS2tMS3pPbm40NGV3QUFBQUJCV0V0clRFdDZVbG8zY3pCRmNsbHJiVmxDWlEifQ== + type: string + type: object + AuditLogsResponseStatus: + description: The status of the response. + enum: + - done + - timeout + example: done + type: string + x-enum-varnames: + - DONE + - TIMEOUT + AuditLogsSearchEventsRequest: + description: The request for a Audit Logs events list. + properties: + filter: + $ref: '#/components/schemas/AuditLogsQueryFilter' + options: + $ref: '#/components/schemas/AuditLogsQueryOptions' + page: + $ref: '#/components/schemas/AuditLogsQueryPageOptions' + sort: + $ref: '#/components/schemas/AuditLogsSort' + type: object + AuditLogsSort: + description: Sort parameters when querying events. + enum: + - timestamp + - -timestamp + type: string + x-enum-varnames: + - TIMESTAMP_ASCENDING + - TIMESTAMP_DESCENDING + AuditLogsWarning: + description: Warning message indicating something that went wrong with the query. + properties: + code: + description: Unique code for this type of warning. + example: unknown_index + type: string + detail: + description: Detailed explanation of this specific warning. + example: 'indexes: foo, bar' + type: string + title: + description: Short human-readable summary of the warning. + example: One or several indexes are missing or invalid, results hold data + from the other indexes + type: string + type: object AuthNMapping: description: The AuthN Mapping object returned by API. properties: @@ -6619,6 +6836,124 @@ paths: x-codegen-request-body-name: body x-undo: type: idempotent + /api/v2/audit/events: + get: + description: 'List endpoint returns events that match a Audit Logs search query. + + [Results are paginated][1]. + + + Use this endpoint to see your latest Audit Logs events. + + + [1]: https://docs.datadoghq.com/logs/guide/collect-multiple-logs-with-pagination' + operationId: ListAuditLogs + parameters: + - description: Search query following Audit Logs syntax. + example: '@type:session @application_id:xxxx' + in: query + name: filter[query] + required: false + schema: + type: string + - description: Minimum timestamp for requested events. + example: '2019-01-02T09:42:36.320Z' + in: query + name: filter[from] + required: false + schema: + format: date-time + type: string + - description: Maximum timestamp for requested events. + example: '2019-01-03T09:42:36.320Z' + in: query + name: filter[to] + required: false + schema: + format: date-time + type: string + - description: Order of events in results. + in: query + name: sort + required: false + schema: + $ref: '#/components/schemas/AuditLogsSort' + - description: List following results with a cursor provided in the previous + query. + example: eyJzdGFydEF0IjoiQVFBQUFYS2tMS3pPbm40NGV3QUFBQUJCV0V0clRFdDZVbG8zY3pCRmNsbHJiVmxDWlEifQ== + in: query + name: page[cursor] + required: false + schema: + type: string + - description: Maximum number of events in the response. + example: 25 + in: query + name: page[limit] + required: false + schema: + default: 10 + format: int32 + maximum: 1000 + type: integer + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/AuditLogsEventsResponse' + description: OK + '400': + $ref: '#/components/responses/BadRequestResponse' + '403': + $ref: '#/components/responses/NotAuthorizedResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: Get a list of Audit Logs events + tags: + - Audit + x-menu-order: 2 + x-undo: + type: safe + /api/v2/audit/events/search: + post: + description: 'List endpoint returns Audit Logs events that match an Audit search + query. + + [Results are paginated][1]. + + + Use this endpoint to build complex Audit Logs events filtering and search. + + + [1]: https://docs.datadoghq.com/logs/guide/collect-multiple-logs-with-pagination' + operationId: SearchAuditLogs + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/AuditLogsSearchEventsRequest' + required: false + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/AuditLogsEventsResponse' + description: OK + '400': + $ref: '#/components/responses/BadRequestResponse' + '403': + $ref: '#/components/responses/NotAuthorizedResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: Search Audit Logs events + tags: + - Audit + x-codegen-request-body-name: body + x-menu-order: 1 + x-undo: + type: safe /api/v2/authn_mappings: get: description: List all AuthN Mappings in the org. @@ -11649,6 +11984,8 @@ servers: default: api description: The subdomain where the API is deployed. tags: +- description: Search your Audit Logs events over HTTP. + name: Audit - description: '[AuthN Mappings API] (https://docs.datadoghq.com/account_management/authn_mapping/?tab=example) is used to automatically map group of users to roles in Datadog using attributes diff --git a/cassettes/features/v2/audit/Get-a-list-of-Audit-Logs-events-returns-OK-response.frozen b/cassettes/features/v2/audit/Get-a-list-of-Audit-Logs-events-returns-OK-response.frozen new file mode 100644 index 000000000000..b36b46857382 --- /dev/null +++ b/cassettes/features/v2/audit/Get-a-list-of-Audit-Logs-events-returns-OK-response.frozen @@ -0,0 +1 @@ +2022-03-10T12:51:27.148Z \ No newline at end of file diff --git a/cassettes/features/v2/audit/Get-a-list-of-Audit-Logs-events-returns-OK-response.yml b/cassettes/features/v2/audit/Get-a-list-of-Audit-Logs-events-returns-OK-response.yml new file mode 100644 index 000000000000..a932c1fc5131 --- /dev/null +++ b/cassettes/features/v2/audit/Get-a-list-of-Audit-Logs-events-returns-OK-response.yml @@ -0,0 +1,17 @@ +http_interactions: +- recorded_at: Thu, 10 Mar 2022 12:51:27 GMT + request: + body: null + headers: + Content-Type: + - application/json + method: GET + uri: https://api.datadoghq.com/api/v2/audit/events + response: + body: + encoding: UTF-8 + string: '{"data":[]}' + status: + code: 200 + message: OK +recorded_with: VCR 6.0.0 diff --git a/cassettes/features/v2/audit/Search-Audit-Logs-events-returns-OK-response.frozen b/cassettes/features/v2/audit/Search-Audit-Logs-events-returns-OK-response.frozen new file mode 100644 index 000000000000..0598f2dcf0fc --- /dev/null +++ b/cassettes/features/v2/audit/Search-Audit-Logs-events-returns-OK-response.frozen @@ -0,0 +1 @@ +2022-03-10T12:51:27.702Z \ No newline at end of file diff --git a/cassettes/features/v2/audit/Search-Audit-Logs-events-returns-OK-response.yml b/cassettes/features/v2/audit/Search-Audit-Logs-events-returns-OK-response.yml new file mode 100644 index 000000000000..1e649f53a353 --- /dev/null +++ b/cassettes/features/v2/audit/Search-Audit-Logs-events-returns-OK-response.yml @@ -0,0 +1,19 @@ +http_interactions: +- recorded_at: Thu, 10 Mar 2022 12:51:27 GMT + request: + body: + encoding: UTF-8 + string: '{"filter":{"from":"now-15m","query":"@type:session AND @session.type:user","to":"now"},"options":{"time_offset":0,"timezone":"GMT"},"page":{"limit":25},"sort":"timestamp"}' + headers: + Content-Type: + - application/json + method: POST + uri: https://api.datadoghq.com/api/v2/audit/events/search + response: + body: + encoding: UTF-8 + string: '{"data":[]}' + status: + code: 200 + message: OK +recorded_with: VCR 6.0.0 diff --git a/examples/v2/audit/ListAuditLogs.rb b/examples/v2/audit/ListAuditLogs.rb new file mode 100644 index 000000000000..dcad1ace4255 --- /dev/null +++ b/examples/v2/audit/ListAuditLogs.rb @@ -0,0 +1,5 @@ +# Get a list of Audit Logs events returns "OK" response + +require "datadog_api_client" +api_instance = DatadogAPIClient::V2::AuditAPI.new +p api_instance.list_audit_logs() diff --git a/examples/v2/audit/SearchAuditLogs.rb b/examples/v2/audit/SearchAuditLogs.rb new file mode 100644 index 000000000000..9611c3d2e033 --- /dev/null +++ b/examples/v2/audit/SearchAuditLogs.rb @@ -0,0 +1,24 @@ +# Search Audit Logs events returns "OK" response + +require "datadog_api_client" +api_instance = DatadogAPIClient::V2::AuditAPI.new + +body = DatadogAPIClient::V2::AuditLogsSearchEventsRequest.new({ + filter: DatadogAPIClient::V2::AuditLogsQueryFilter.new({ + from: "now-15m", + query: "@type:session AND @session.type:user", + to: "now", + }), + options: DatadogAPIClient::V2::AuditLogsQueryOptions.new({ + time_offset: 0, + timezone: "GMT", + }), + page: DatadogAPIClient::V2::AuditLogsQueryPageOptions.new({ + limit: 25, + }), + sort: DatadogAPIClient::V2::AuditLogsSort::TIMESTAMP_ASCENDING, +}) +opts = { + body: body, +} +p api_instance.search_audit_logs(opts) diff --git a/features/v2/audit.feature b/features/v2/audit.feature new file mode 100644 index 000000000000..2aaa60ac2b33 --- /dev/null +++ b/features/v2/audit.feature @@ -0,0 +1,34 @@ +@endpoint(audit) @endpoint(audit-v2) +Feature: Audit + Search your Audit Logs events over HTTP. + + Background: + Given a valid "apiKeyAuth" key in the system + And a valid "appKeyAuth" key in the system + And an instance of "Audit" API + + @generated @skip @team:DataDog/team-aaa + Scenario: Get a list of Audit Logs events returns "Bad Request" response + Given new "ListAuditLogs" request + When the request is sent + Then the response status is 400 Bad Request + + @team:DataDog/team-aaa + Scenario: Get a list of Audit Logs events returns "OK" response + Given new "ListAuditLogs" request + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:DataDog/team-aaa + Scenario: Search Audit Logs events returns "Bad Request" response + Given new "SearchAuditLogs" request + And body with value {"filter": {"from": "now-15m", "query": "@type:session AND @session.type:user", "to": "now"}, "options": {"time_offset": null, "timezone": "GMT"}, "page": {"cursor": "eyJzdGFydEF0IjoiQVFBQUFYS2tMS3pPbm40NGV3QUFBQUJCV0V0clRFdDZVbG8zY3pCRmNsbHJiVmxDWlEifQ==", "limit": 25}, "sort": "timestamp"} + When the request is sent + Then the response status is 400 Bad Request + + @team:DataDog/team-aaa + Scenario: Search Audit Logs events returns "OK" response + Given new "SearchAuditLogs" request + And body with value {"filter": {"from": "now-15m", "query": "@type:session AND @session.type:user", "to": "now"}, "options": {"time_offset": 0, "timezone": "GMT"}, "page": {"limit": 25}, "sort": "timestamp"} + When the request is sent + Then the response status is 200 OK diff --git a/features/v2/undo.json b/features/v2/undo.json index d9b00c3ad947..ee2dcdfc927d 100644 --- a/features/v2/undo.json +++ b/features/v2/undo.json @@ -60,6 +60,18 @@ "type": "idempotent" } }, + "ListAuditLogs": { + "tag": "Audit", + "undo": { + "type": "safe" + } + }, + "SearchAuditLogs": { + "tag": "Audit", + "undo": { + "type": "safe" + } + }, "ListAuthNMappings": { "tag": "AuthN Mappings", "undo": { diff --git a/lib/datadog_api_client/v2.rb b/lib/datadog_api_client/v2.rb index 65617c8d3c18..bb8895e1cbf5 100644 --- a/lib/datadog_api_client/v2.rb +++ b/lib/datadog_api_client/v2.rb @@ -45,6 +45,20 @@ require 'datadog_api_client/v2/models/application_key_update_attributes' require 'datadog_api_client/v2/models/application_key_update_data' require 'datadog_api_client/v2/models/application_key_update_request' +require 'datadog_api_client/v2/models/audit_logs_event' +require 'datadog_api_client/v2/models/audit_logs_event_attributes' +require 'datadog_api_client/v2/models/audit_logs_events_response' +require 'datadog_api_client/v2/models/audit_logs_event_type' +require 'datadog_api_client/v2/models/audit_logs_query_filter' +require 'datadog_api_client/v2/models/audit_logs_query_options' +require 'datadog_api_client/v2/models/audit_logs_query_page_options' +require 'datadog_api_client/v2/models/audit_logs_response_links' +require 'datadog_api_client/v2/models/audit_logs_response_metadata' +require 'datadog_api_client/v2/models/audit_logs_response_page' +require 'datadog_api_client/v2/models/audit_logs_response_status' +require 'datadog_api_client/v2/models/audit_logs_search_events_request' +require 'datadog_api_client/v2/models/audit_logs_sort' +require 'datadog_api_client/v2/models/audit_logs_warning' require 'datadog_api_client/v2/models/auth_n_mapping' require 'datadog_api_client/v2/models/auth_n_mapping_attributes' require 'datadog_api_client/v2/models/auth_n_mapping_create_attributes' @@ -418,6 +432,7 @@ require 'datadog_api_client/v2/models/user_update_request' # APIs +require 'datadog_api_client/v2/api/audit_api' require 'datadog_api_client/v2/api/auth_n_mappings_api' require 'datadog_api_client/v2/api/cloud_workload_security_api' require 'datadog_api_client/v2/api/dashboard_lists_api' diff --git a/lib/datadog_api_client/v2/api/audit_api.rb b/lib/datadog_api_client/v2/api/audit_api.rb new file mode 100644 index 000000000000..3b7a404cab20 --- /dev/null +++ b/lib/datadog_api_client/v2/api/audit_api.rb @@ -0,0 +1,209 @@ +=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 'cgi' + +module DatadogAPIClient::V2 + class AuditAPI + attr_accessor :api_client + + def initialize(api_client = APIClient.default) + @api_client = api_client + end + + # Get a list of Audit Logs events + # List endpoint returns events that match a Audit Logs search query. + # [Results are paginated][1]. + # + # Use this endpoint to see your latest Audit Logs events. + # + # [1]: https://docs.datadoghq.com/logs/guide/collect-multiple-logs-with-pagination + # @param opts [Hash] the optional parameters + # @option opts [String] :filter_query Search query following Audit Logs syntax. + # @option opts [Time] :filter_from Minimum timestamp for requested events. + # @option opts [Time] :filter_to Maximum timestamp for requested events. + # @option opts [AuditLogsSort] :sort Order of events in results. + # @option opts [String] :page_cursor List following results with a cursor provided in the previous query. + # @option opts [Integer] :page_limit Maximum number of events in the response. + # @return [AuditLogsEventsResponse] + def list_audit_logs(opts = {}) + data, _status_code, _headers = list_audit_logs_with_http_info(opts) + data + end + + # Get a list of Audit Logs events + # List endpoint returns events that match a Audit Logs search query. + # [Results are paginated][1]. + # + # Use this endpoint to see your latest Audit Logs events. + # + # [1]: https://docs.datadoghq.com/logs/guide/collect-multiple-logs-with-pagination + # @param opts [Hash] the optional parameters + # @option opts [String] :filter_query Search query following Audit Logs syntax. + # @option opts [Time] :filter_from Minimum timestamp for requested events. + # @option opts [Time] :filter_to Maximum timestamp for requested events. + # @option opts [AuditLogsSort] :sort Order of events in results. + # @option opts [String] :page_cursor List following results with a cursor provided in the previous query. + # @option opts [Integer] :page_limit Maximum number of events in the response. + # @return [Array<(AuditLogsEventsResponse, Integer, Hash)>] AuditLogsEventsResponse data, response status code and response headers + def list_audit_logs_with_http_info(opts = {}) + + if @api_client.config.unstable_operations.has_key?(:list_audit_logs) + unstable_enabled = @api_client.config.unstable_operations[:list_audit_logs] + if unstable_enabled + @api_client.config.logger.warn format("Using unstable operation '%s'", "list_audit_logs") + else + raise APIError.new(message: format("Unstable operation '%s' is disabled", "list_audit_logs")) + end + end + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: AuditAPI.list_audit_logs ...' + end + allowable_values = ['timestamp', '-timestamp'] + if @api_client.config.client_side_validation && opts[:'sort'] && !allowable_values.include?(opts[:'sort']) + fail ArgumentError, "invalid value for \"sort\", must be one of #{allowable_values}" + end + if @api_client.config.client_side_validation && !opts[:'page_limit'].nil? && opts[:'page_limit'] > 1000 + fail ArgumentError, 'invalid value for "opts[:"page_limit"]" when calling AuditAPI.list_audit_logs, must be smaller than or equal to 1000.' + end + # resource path + local_var_path = '/api/v2/audit/events' + + # query parameters + query_params = opts[:query_params] || {} + query_params[:'filter[query]'] = opts[:'filter_query'] if !opts[:'filter_query'].nil? + query_params[:'filter[from]'] = opts[:'filter_from'] if !opts[:'filter_from'].nil? + query_params[:'filter[to]'] = opts[:'filter_to'] if !opts[:'filter_to'].nil? + query_params[:'sort'] = opts[:'sort'] if !opts[:'sort'].nil? + query_params[:'page[cursor]'] = opts[:'page_cursor'] if !opts[:'page_cursor'].nil? + query_params[:'page[limit]'] = opts[:'page_limit'] if !opts[:'page_limit'].nil? + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'AuditLogsEventsResponse' + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth] + + new_options = opts.merge( + :operation => :list_audit_logs, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type + ) + + data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: AuditAPI#list_audit_logs\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Search Audit Logs events + # List endpoint returns Audit Logs events that match an Audit search query. + # [Results are paginated][1]. + # + # Use this endpoint to build complex Audit Logs events filtering and search. + # + # [1]: https://docs.datadoghq.com/logs/guide/collect-multiple-logs-with-pagination + # @param opts [Hash] the optional parameters + # @option opts [AuditLogsSearchEventsRequest] :body + # @return [AuditLogsEventsResponse] + def search_audit_logs(opts = {}) + data, _status_code, _headers = search_audit_logs_with_http_info(opts) + data + end + + # Search Audit Logs events + # List endpoint returns Audit Logs events that match an Audit search query. + # [Results are paginated][1]. + # + # Use this endpoint to build complex Audit Logs events filtering and search. + # + # [1]: https://docs.datadoghq.com/logs/guide/collect-multiple-logs-with-pagination + # @param opts [Hash] the optional parameters + # @option opts [AuditLogsSearchEventsRequest] :body + # @return [Array<(AuditLogsEventsResponse, Integer, Hash)>] AuditLogsEventsResponse data, response status code and response headers + def search_audit_logs_with_http_info(opts = {}) + + if @api_client.config.unstable_operations.has_key?(:search_audit_logs) + unstable_enabled = @api_client.config.unstable_operations[:search_audit_logs] + if unstable_enabled + @api_client.config.logger.warn format("Using unstable operation '%s'", "search_audit_logs") + else + raise APIError.new(message: format("Unstable operation '%s' is disabled", "search_audit_logs")) + end + end + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: AuditAPI.search_audit_logs ...' + end + # resource path + local_var_path = '/api/v2/audit/events/search' + + # 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(opts[:'body']) + + # return_type + return_type = opts[:debug_return_type] || 'AuditLogsEventsResponse' + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth] + + new_options = opts.merge( + :operation => :search_audit_logs, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type + ) + + data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: AuditAPI#search_audit_logs\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + end +end diff --git a/lib/datadog_api_client/v2/models/audit_logs_event.rb b/lib/datadog_api_client/v2/models/audit_logs_event.rb new file mode 100644 index 000000000000..1a4f6f1dd7a3 --- /dev/null +++ b/lib/datadog_api_client/v2/models/audit_logs_event.rb @@ -0,0 +1,141 @@ +=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 description of an Audit Logs event after it is processed and stored by Datadog. + class AuditLogsEvent + include BaseGenericModel + + # Whether the object has unparsed attributes + # @!visibility private + attr_accessor :_unparsed + + # JSON object containing all event attributes and their associated values. + attr_accessor :attributes + + # Unique ID of the event. + attr_accessor :id + + # Type of the event. + attr_accessor :type + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'attributes' => :'attributes', + :'id' => :'id', + :'type' => :'type' + } + end + + # Returns all the JSON keys this model knows about + # @!visibility private + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'attributes' => :'AuditLogsEventAttributes', + :'id' => :'String', + :'type' => :'AuditLogsEventType' + } + end + + # List of attributes with nullable: true + # @!visibility private + def self.openapi_nullable + Set.new([ + ]) + 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::AuditLogsEvent` initialize method" + end + + # 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)) + fail ArgumentError, "`#{k}` is not a valid attribute in `DatadogAPIClient::V2::AuditLogsEvent`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'attributes') + self.attributes = attributes[:'attributes'] + end + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + else + self.type = 'audit' + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + # @!visibility private + def list_invalid_properties + invalid_properties = Array.new + invalid_properties + 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? + true + 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 && + id == o.id && + type == o.type + end + + # @see the `==` method + # @param o [Object] Object to be compared + # @!visibility private + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [attributes, id, type].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/audit_logs_event_attributes.rb b/lib/datadog_api_client/v2/models/audit_logs_event_attributes.rb new file mode 100644 index 000000000000..e5d00925295d --- /dev/null +++ b/lib/datadog_api_client/v2/models/audit_logs_event_attributes.rb @@ -0,0 +1,153 @@ +=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 event attributes and their associated values. + class AuditLogsEventAttributes + include BaseGenericModel + + # Whether the object has unparsed attributes + # @!visibility private + attr_accessor :_unparsed + + # JSON object of attributes from Audit Logs events. + attr_accessor :attributes + + # Name of the application or service generating Audit Logs events. + # This name is used to correlate Audit Logs to APM, so make sure you specify the same + # value when you use both products. + attr_accessor :service + + # Array of tags associated with your event. + attr_accessor :tags + + # Timestamp of your event. + attr_accessor :timestamp + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'attributes' => :'attributes', + :'service' => :'service', + :'tags' => :'tags', + :'timestamp' => :'timestamp' + } + end + + # Returns all the JSON keys this model knows about + # @!visibility private + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'attributes' => :'Hash', + :'service' => :'String', + :'tags' => :'Array', + :'timestamp' => :'Time' + } + end + + # List of attributes with nullable: true + # @!visibility private + def self.openapi_nullable + Set.new([ + ]) + 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::AuditLogsEventAttributes` initialize method" + end + + # 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)) + fail ArgumentError, "`#{k}` is not a valid attribute in `DatadogAPIClient::V2::AuditLogsEventAttributes`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'attributes') + self.attributes = attributes[:'attributes'] + end + + if attributes.key?(:'service') + self.service = attributes[:'service'] + 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 + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + # @!visibility private + def list_invalid_properties + invalid_properties = Array.new + invalid_properties + 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? + true + 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 && + service == o.service && + tags == o.tags && + timestamp == o.timestamp + end + + # @see the `==` method + # @param o [Object] Object to be compared + # @!visibility private + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [attributes, service, tags, timestamp].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/audit_logs_event_type.rb b/lib/datadog_api_client/v2/models/audit_logs_event_type.rb new file mode 100644 index 000000000000..dab847c4bacd --- /dev/null +++ b/lib/datadog_api_client/v2/models/audit_logs_event_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 + # Type of the event. + class AuditLogsEventType + include BaseEnumModel + + Audit = "audit".freeze + end +end diff --git a/lib/datadog_api_client/v2/models/audit_logs_events_response.rb b/lib/datadog_api_client/v2/models/audit_logs_events_response.rb new file mode 100644 index 000000000000..293dd899d463 --- /dev/null +++ b/lib/datadog_api_client/v2/models/audit_logs_events_response.rb @@ -0,0 +1,141 @@ +=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 object with all events matching the request and pagination information. + class AuditLogsEventsResponse + include BaseGenericModel + + # Whether the object has unparsed attributes + # @!visibility private + attr_accessor :_unparsed + + # Array of events matching the request. + attr_accessor :data + + # Links attributes. + attr_accessor :links + + # The metadata associated with a request. + attr_accessor :meta + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'data' => :'data', + :'links' => :'links', + :'meta' => :'meta' + } + end + + # Returns all the JSON keys this model knows about + # @!visibility private + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'data' => :'Array', + :'links' => :'AuditLogsResponseLinks', + :'meta' => :'AuditLogsResponseMetadata' + } + end + + # List of attributes with nullable: true + # @!visibility private + def self.openapi_nullable + Set.new([ + ]) + 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::AuditLogsEventsResponse` initialize method" + end + + # 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)) + fail ArgumentError, "`#{k}` is not a valid attribute in `DatadogAPIClient::V2::AuditLogsEventsResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'data') + if (value = attributes[:'data']).is_a?(Array) + self.data = value + end + end + + if attributes.key?(:'links') + self.links = attributes[:'links'] + end + + if attributes.key?(:'meta') + self.meta = attributes[:'meta'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + # @!visibility private + def list_invalid_properties + invalid_properties = Array.new + invalid_properties + 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? + true + 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 && + links == o.links && + meta == o.meta + end + + # @see the `==` method + # @param o [Object] Object to be compared + # @!visibility private + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [data, links, meta].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/audit_logs_query_filter.rb b/lib/datadog_api_client/v2/models/audit_logs_query_filter.rb new file mode 100644 index 000000000000..0f77740c762c --- /dev/null +++ b/lib/datadog_api_client/v2/models/audit_logs_query_filter.rb @@ -0,0 +1,145 @@ +=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 + # Search and filter query settings. + class AuditLogsQueryFilter + include BaseGenericModel + + # Whether the object has unparsed attributes + # @!visibility private + attr_accessor :_unparsed + + # Minimum time for the requested events. Supports date, math, and regular timestamps (in milliseconds). + attr_accessor :from + + # Search query following the Audit Logs search syntax. + attr_accessor :query + + # Maximum time for the requested events. Supports date, math, and regular timestamps (in milliseconds). + attr_accessor :to + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'from' => :'from', + :'query' => :'query', + :'to' => :'to' + } + end + + # Returns all the JSON keys this model knows about + # @!visibility private + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'from' => :'String', + :'query' => :'String', + :'to' => :'String' + } + end + + # List of attributes with nullable: true + # @!visibility private + def self.openapi_nullable + Set.new([ + ]) + 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::AuditLogsQueryFilter` initialize method" + end + + # 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)) + fail ArgumentError, "`#{k}` is not a valid attribute in `DatadogAPIClient::V2::AuditLogsQueryFilter`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'from') + self.from = attributes[:'from'] + else + self.from = 'now-15m' + end + + if attributes.key?(:'query') + self.query = attributes[:'query'] + else + self.query = '*' + end + + if attributes.key?(:'to') + self.to = attributes[:'to'] + else + self.to = 'now' + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + # @!visibility private + def list_invalid_properties + invalid_properties = Array.new + invalid_properties + 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? + true + 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 && + from == o.from && + query == o.query && + to == o.to + end + + # @see the `==` method + # @param o [Object] Object to be compared + # @!visibility private + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [from, query, to].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/audit_logs_query_options.rb b/lib/datadog_api_client/v2/models/audit_logs_query_options.rb new file mode 100644 index 000000000000..82418ed4e5a6 --- /dev/null +++ b/lib/datadog_api_client/v2/models/audit_logs_query_options.rb @@ -0,0 +1,132 @@ +=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 + # Global query options that are used during the query. + # Note: Specify either timezone or time offset, not both. Otherwise, the query fails. + class AuditLogsQueryOptions + include BaseGenericModel + + # Whether the object has unparsed attributes + # @!visibility private + attr_accessor :_unparsed + + # Time offset (in seconds) to apply to the query. + attr_accessor :time_offset + + # Timezone code. Can be specified as an offset, for example: "UTC+03:00". + attr_accessor :timezone + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'time_offset' => :'time_offset', + :'timezone' => :'timezone' + } + end + + # Returns all the JSON keys this model knows about + # @!visibility private + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'time_offset' => :'Integer', + :'timezone' => :'String' + } + end + + # List of attributes with nullable: true + # @!visibility private + def self.openapi_nullable + Set.new([ + ]) + 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::AuditLogsQueryOptions` initialize method" + end + + # 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)) + fail ArgumentError, "`#{k}` is not a valid attribute in `DatadogAPIClient::V2::AuditLogsQueryOptions`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'time_offset') + self.time_offset = attributes[:'time_offset'] + end + + if attributes.key?(:'timezone') + self.timezone = attributes[:'timezone'] + else + self.timezone = 'UTC' + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + # @!visibility private + def list_invalid_properties + invalid_properties = Array.new + invalid_properties + 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? + true + 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 && + time_offset == o.time_offset && + timezone == o.timezone + end + + # @see the `==` method + # @param o [Object] Object to be compared + # @!visibility private + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [time_offset, timezone].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/audit_logs_query_page_options.rb b/lib/datadog_api_client/v2/models/audit_logs_query_page_options.rb new file mode 100644 index 000000000000..4d56834c868c --- /dev/null +++ b/lib/datadog_api_client/v2/models/audit_logs_query_page_options.rb @@ -0,0 +1,145 @@ +=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 + # Paging attributes for listing events. + class AuditLogsQueryPageOptions + include BaseGenericModel + + # Whether the object has unparsed attributes + # @!visibility private + attr_accessor :_unparsed + + # List following results with a cursor provided in the previous query. + attr_accessor :cursor + + # Maximum number of events in the response. + attr_accessor :limit + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'cursor' => :'cursor', + :'limit' => :'limit' + } + end + + # Returns all the JSON keys this model knows about + # @!visibility private + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'cursor' => :'String', + :'limit' => :'Integer' + } + end + + # List of attributes with nullable: true + # @!visibility private + def self.openapi_nullable + Set.new([ + ]) + 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::AuditLogsQueryPageOptions` initialize method" + end + + # 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)) + fail ArgumentError, "`#{k}` is not a valid attribute in `DatadogAPIClient::V2::AuditLogsQueryPageOptions`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'cursor') + self.cursor = attributes[:'cursor'] + end + + if attributes.key?(:'limit') + self.limit = attributes[:'limit'] + else + self.limit = 10 + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + # @!visibility private + def list_invalid_properties + invalid_properties = Array.new + if !@limit.nil? && @limit > 1000 + invalid_properties.push('invalid value for "limit", must be smaller than or equal to 1000.') + end + invalid_properties + 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 !@limit.nil? && @limit > 1000 + true + end + + # Custom attribute writer method with validation + # @param limit [Object] Object to be assigned + # @!visibility private + def limit=(limit) + if !limit.nil? && limit > 1000 + fail ArgumentError, 'invalid value for "limit", must be smaller than or equal to 1000.' + end + @limit = limit + 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 && + cursor == o.cursor && + limit == o.limit + end + + # @see the `==` method + # @param o [Object] Object to be compared + # @!visibility private + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [cursor, limit].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/audit_logs_response_links.rb b/lib/datadog_api_client/v2/models/audit_logs_response_links.rb new file mode 100644 index 000000000000..41a342be250c --- /dev/null +++ b/lib/datadog_api_client/v2/models/audit_logs_response_links.rb @@ -0,0 +1,120 @@ +=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 + # Links attributes. + class AuditLogsResponseLinks + include BaseGenericModel + + # Whether the object has unparsed attributes + # @!visibility private + attr_accessor :_unparsed + + # Link for the next set of results. Note that the request can also be made using the + # POST endpoint. + attr_accessor :_next + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'_next' => :'next' + } + end + + # Returns all the JSON keys this model knows about + # @!visibility private + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'_next' => :'String' + } + end + + # List of attributes with nullable: true + # @!visibility private + def self.openapi_nullable + Set.new([ + ]) + 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::AuditLogsResponseLinks` initialize method" + end + + # 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)) + fail ArgumentError, "`#{k}` is not a valid attribute in `DatadogAPIClient::V2::AuditLogsResponseLinks`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'_next') + self._next = attributes[:'_next'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + # @!visibility private + def list_invalid_properties + invalid_properties = Array.new + invalid_properties + 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? + true + 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 && + _next == o._next + end + + # @see the `==` method + # @param o [Object] Object to be compared + # @!visibility private + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [_next].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/audit_logs_response_metadata.rb b/lib/datadog_api_client/v2/models/audit_logs_response_metadata.rb new file mode 100644 index 000000000000..1a2322894124 --- /dev/null +++ b/lib/datadog_api_client/v2/models/audit_logs_response_metadata.rb @@ -0,0 +1,162 @@ +=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 + # The metadata associated with a request. + class AuditLogsResponseMetadata + include BaseGenericModel + + # Whether the object has unparsed attributes + # @!visibility private + attr_accessor :_unparsed + + # Time elapsed in milliseconds. + attr_accessor :elapsed + + # Paging attributes. + attr_accessor :page + + # The identifier of the request. + attr_accessor :request_id + + # The status of the response. + attr_accessor :status + + # A list of warnings (non-fatal errors) encountered. Partial results may return if + # warnings are present in the response. + attr_accessor :warnings + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'elapsed' => :'elapsed', + :'page' => :'page', + :'request_id' => :'request_id', + :'status' => :'status', + :'warnings' => :'warnings' + } + end + + # Returns all the JSON keys this model knows about + # @!visibility private + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'elapsed' => :'Integer', + :'page' => :'AuditLogsResponsePage', + :'request_id' => :'String', + :'status' => :'AuditLogsResponseStatus', + :'warnings' => :'Array' + } + end + + # List of attributes with nullable: true + # @!visibility private + def self.openapi_nullable + Set.new([ + ]) + 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::AuditLogsResponseMetadata` initialize method" + end + + # 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)) + fail ArgumentError, "`#{k}` is not a valid attribute in `DatadogAPIClient::V2::AuditLogsResponseMetadata`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'elapsed') + self.elapsed = attributes[:'elapsed'] + end + + if attributes.key?(:'page') + self.page = attributes[:'page'] + end + + if attributes.key?(:'request_id') + self.request_id = attributes[:'request_id'] + end + + if attributes.key?(:'status') + self.status = attributes[:'status'] + end + + if attributes.key?(:'warnings') + if (value = attributes[:'warnings']).is_a?(Array) + self.warnings = value + end + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + # @!visibility private + def list_invalid_properties + invalid_properties = Array.new + invalid_properties + 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? + true + 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 && + elapsed == o.elapsed && + page == o.page && + request_id == o.request_id && + status == o.status && + warnings == o.warnings + end + + # @see the `==` method + # @param o [Object] Object to be compared + # @!visibility private + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [elapsed, page, request_id, status, warnings].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/audit_logs_response_page.rb b/lib/datadog_api_client/v2/models/audit_logs_response_page.rb new file mode 100644 index 000000000000..ff2230c9f596 --- /dev/null +++ b/lib/datadog_api_client/v2/models/audit_logs_response_page.rb @@ -0,0 +1,119 @@ +=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 + # Paging attributes. + class AuditLogsResponsePage + include BaseGenericModel + + # Whether the object has unparsed attributes + # @!visibility private + attr_accessor :_unparsed + + # The cursor to use to get the next results, if any. To make the next request, use the same parameters with the addition of `page[cursor]`. + attr_accessor :after + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'after' => :'after' + } + end + + # Returns all the JSON keys this model knows about + # @!visibility private + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'after' => :'String' + } + end + + # List of attributes with nullable: true + # @!visibility private + def self.openapi_nullable + Set.new([ + ]) + 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::AuditLogsResponsePage` initialize method" + end + + # 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)) + fail ArgumentError, "`#{k}` is not a valid attribute in `DatadogAPIClient::V2::AuditLogsResponsePage`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'after') + self.after = attributes[:'after'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + # @!visibility private + def list_invalid_properties + invalid_properties = Array.new + invalid_properties + 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? + true + 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 && + after == o.after + end + + # @see the `==` method + # @param o [Object] Object to be compared + # @!visibility private + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [after].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/audit_logs_response_status.rb b/lib/datadog_api_client/v2/models/audit_logs_response_status.rb new file mode 100644 index 000000000000..e4c1ffc18080 --- /dev/null +++ b/lib/datadog_api_client/v2/models/audit_logs_response_status.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 + # The status of the response. + class AuditLogsResponseStatus + include BaseEnumModel + + DONE = "done".freeze + TIMEOUT = "timeout".freeze + end +end diff --git a/lib/datadog_api_client/v2/models/audit_logs_search_events_request.rb b/lib/datadog_api_client/v2/models/audit_logs_search_events_request.rb new file mode 100644 index 000000000000..80c9865f6b8a --- /dev/null +++ b/lib/datadog_api_client/v2/models/audit_logs_search_events_request.rb @@ -0,0 +1,150 @@ +=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 + # The request for a Audit Logs events list. + class AuditLogsSearchEventsRequest + include BaseGenericModel + + # Whether the object has unparsed attributes + # @!visibility private + attr_accessor :_unparsed + + # Search and filter query settings. + attr_accessor :filter + + # Global query options that are used during the query. + # Note: Specify either timezone or time offset, not both. Otherwise, the query fails. + attr_accessor :options + + # Paging attributes for listing events. + attr_accessor :page + + # Sort parameters when querying events. + attr_accessor :sort + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'filter' => :'filter', + :'options' => :'options', + :'page' => :'page', + :'sort' => :'sort' + } + end + + # Returns all the JSON keys this model knows about + # @!visibility private + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'filter' => :'AuditLogsQueryFilter', + :'options' => :'AuditLogsQueryOptions', + :'page' => :'AuditLogsQueryPageOptions', + :'sort' => :'AuditLogsSort' + } + end + + # List of attributes with nullable: true + # @!visibility private + def self.openapi_nullable + Set.new([ + ]) + 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::AuditLogsSearchEventsRequest` initialize method" + end + + # 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)) + fail ArgumentError, "`#{k}` is not a valid attribute in `DatadogAPIClient::V2::AuditLogsSearchEventsRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'filter') + self.filter = attributes[:'filter'] + end + + if attributes.key?(:'options') + self.options = attributes[:'options'] + end + + if attributes.key?(:'page') + self.page = attributes[:'page'] + end + + if attributes.key?(:'sort') + self.sort = attributes[:'sort'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + # @!visibility private + def list_invalid_properties + invalid_properties = Array.new + invalid_properties + 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? + true + 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 && + filter == o.filter && + options == o.options && + page == o.page && + sort == o.sort + end + + # @see the `==` method + # @param o [Object] Object to be compared + # @!visibility private + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [filter, options, page, sort].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/audit_logs_sort.rb b/lib/datadog_api_client/v2/models/audit_logs_sort.rb new file mode 100644 index 000000000000..76164370d385 --- /dev/null +++ b/lib/datadog_api_client/v2/models/audit_logs_sort.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 + # Sort parameters when querying events. + class AuditLogsSort + include BaseEnumModel + + TIMESTAMP_ASCENDING = "timestamp".freeze + TIMESTAMP_DESCENDING = "-timestamp".freeze + end +end diff --git a/lib/datadog_api_client/v2/models/audit_logs_warning.rb b/lib/datadog_api_client/v2/models/audit_logs_warning.rb new file mode 100644 index 000000000000..4ab23e803872 --- /dev/null +++ b/lib/datadog_api_client/v2/models/audit_logs_warning.rb @@ -0,0 +1,139 @@ +=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 + # Warning message indicating something that went wrong with the query. + class AuditLogsWarning + include BaseGenericModel + + # Whether the object has unparsed attributes + # @!visibility private + attr_accessor :_unparsed + + # Unique code for this type of warning. + attr_accessor :code + + # Detailed explanation of this specific warning. + attr_accessor :detail + + # Short human-readable summary of the warning. + attr_accessor :title + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'code' => :'code', + :'detail' => :'detail', + :'title' => :'title' + } + end + + # Returns all the JSON keys this model knows about + # @!visibility private + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'code' => :'String', + :'detail' => :'String', + :'title' => :'String' + } + end + + # List of attributes with nullable: true + # @!visibility private + def self.openapi_nullable + Set.new([ + ]) + 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::AuditLogsWarning` initialize method" + end + + # 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)) + fail ArgumentError, "`#{k}` is not a valid attribute in `DatadogAPIClient::V2::AuditLogsWarning`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'code') + self.code = attributes[:'code'] + end + + if attributes.key?(:'detail') + self.detail = attributes[:'detail'] + end + + if attributes.key?(:'title') + self.title = attributes[:'title'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + # @!visibility private + def list_invalid_properties + invalid_properties = Array.new + invalid_properties + 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? + true + 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 && + code == o.code && + detail == o.detail && + title == o.title + end + + # @see the `==` method + # @param o [Object] Object to be compared + # @!visibility private + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [code, detail, title].hash + end + end +end