From d7e9b748aa73335a60f84a484092bd087c9a8d5b Mon Sep 17 00:00:00 2001 From: "ci.datadog-api-spec" Date: Wed, 6 May 2026 18:16:24 +0000 Subject: [PATCH] Regenerate client from commit 6991a08 of spec repo --- .generator/schemas/v2/openapi.yaml | 96 ++++++++++ examples/v2/key-management/Validate.rb | 8 + features/v2/key_management.feature | 146 ++++++++++----- features/v2/undo.json | 6 + lib/datadog_api_client/configuration.rb | 1 + lib/datadog_api_client/inflector.rb | 4 + .../v2/api/key_management_api.rb | 66 +++++++ .../v2/models/validate_v2_attributes.rb | 167 ++++++++++++++++++ .../v2/models/validate_v2_data.rb | 165 +++++++++++++++++ .../v2/models/validate_v2_response.rb | 123 +++++++++++++ .../v2/models/validate_v2_type.rb | 26 +++ 11 files changed, 761 insertions(+), 47 deletions(-) create mode 100644 examples/v2/key-management/Validate.rb create mode 100644 lib/datadog_api_client/v2/models/validate_v2_attributes.rb create mode 100644 lib/datadog_api_client/v2/models/validate_v2_data.rb create mode 100644 lib/datadog_api_client/v2/models/validate_v2_response.rb create mode 100644 lib/datadog_api_client/v2/models/validate_v2_type.rb diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 2dc5dce2c0ac..0cd9056664e0 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -81946,6 +81946,61 @@ components: description: The title of the event. example: "The event title" type: string + ValidateV2Attributes: + description: Attributes of the API key validation response. + properties: + api_key_id: + description: The UUID of the API key. + example: "a1b2c3d4-e5f6-47a8-b9c0-d1e2f3a4b5c6" + type: string + api_key_scopes: + description: List of scope names associated with the API key. + example: + - "remote_config_read" + items: + type: string + type: array + valid: + description: Whether the API key is valid. + example: true + type: boolean + required: + - valid + - api_key_scopes + - api_key_id + type: object + ValidateV2Data: + description: Data object containing the API key validation result. + properties: + attributes: + $ref: "#/components/schemas/ValidateV2Attributes" + id: + description: The UUID of the organization associated with the API key. + example: "550e8400-e29b-41d4-a716-446655440000" + type: string + type: + $ref: "#/components/schemas/ValidateV2Type" + required: + - id + - type + - attributes + type: object + ValidateV2Response: + description: Response for the API key validation endpoint. + properties: + data: + $ref: "#/components/schemas/ValidateV2Data" + required: + - data + type: object + ValidateV2Type: + description: Resource type for the API key validation response. + enum: + - validate_v2 + example: validate_v2 + type: string + x-enum-varnames: + - ValidateV2 ValidationError: description: Represents a single validation error, including a human-readable title and metadata. properties: @@ -144508,6 +144563,47 @@ paths: operator: OR permissions: - teams_read + /api/v2/validate: + get: + description: Check if the API key is valid. Returns the organization UUID, API key ID, and associated scopes. + operationId: Validate + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + attributes: + api_key_id: "a1b2c3d4-e5f6-47a8-b9c0-d1e2f3a4b5c6" + api_key_scopes: + - "remote_config_read" + valid: true + id: "550e8400-e29b-41d4-a716-446655440000" + type: "validate_v2" + schema: + $ref: "#/components/schemas/ValidateV2Response" + description: OK + "403": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Forbidden + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + summary: Validate API key + tags: + - Key Management + "x-permission": + operator: OPEN + permissions: [] + x-unstable: |- + **Note**: This endpoint is in preview and is subject to change. + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). /api/v2/widgets/{experience_type}: get: description: |- diff --git a/examples/v2/key-management/Validate.rb b/examples/v2/key-management/Validate.rb new file mode 100644 index 000000000000..9f58de31d3a5 --- /dev/null +++ b/examples/v2/key-management/Validate.rb @@ -0,0 +1,8 @@ +# Validate API key returns "OK" response + +require "datadog_api_client" +DatadogAPIClient.configure do |config| + config.unstable_operations["v2.validate".to_sym] = true +end +api_instance = DatadogAPIClient::V2::KeyManagementAPI.new +p api_instance.validate() diff --git a/features/v2/key_management.feature b/features/v2/key_management.feature index 365c53ed7c27..3be38cccd51e 100644 --- a/features/v2/key_management.feature +++ b/features/v2/key_management.feature @@ -9,19 +9,20 @@ Feature: Key Management Background: Given a valid "apiKeyAuth" key in the system - And a valid "appKeyAuth" key in the system And an instance of "KeyManagement" API @generated @skip @team:DataDog/credentials-management Scenario: Create a personal access token returns "Bad Request" response - Given new "CreatePersonalAccessToken" request + Given a valid "appKeyAuth" key in the system + And new "CreatePersonalAccessToken" request And body with value {"data": {"attributes": {"expires_at": "2025-12-31T23:59:59+00:00", "name": "My Personal Access Token", "scopes": ["dashboards_read", "dashboards_write"]}, "type": "personal_access_tokens"}} When the request is sent Then the response status is 400 Bad Request @team:DataDog/credentials-management Scenario: Create a personal access token returns "Created" response - Given new "CreatePersonalAccessToken" request + Given a valid "appKeyAuth" key in the system + And new "CreatePersonalAccessToken" request And body with value {"data": {"type": "personal_access_tokens", "attributes": {"name": "{{ unique }}", "scopes": ["dashboards_read"], "expires_at": "{{ timeISO('now+365d') }}"}}} When the request is sent Then the response status is 201 Created @@ -32,14 +33,16 @@ Feature: Key Management @generated @skip @team:DataDog/credentials-management Scenario: Create an API key returns "Bad Request" response - Given new "CreateAPIKey" request + Given a valid "appKeyAuth" key in the system + And new "CreateAPIKey" request And body with value {"data": {"attributes": {"name": "API Key for submitting metrics"}, "type": "api_keys"}} When the request is sent Then the response status is 400 Bad Request @team:DataDog/credentials-management Scenario: Create an API key returns "Created" response - Given new "CreateAPIKey" request + Given a valid "appKeyAuth" key in the system + And new "CreateAPIKey" request And body with value {"data": {"type": "api_keys", "attributes": {"name": "{{ unique }}"}}} When the request is sent Then the response status is 201 Created @@ -48,7 +51,8 @@ Feature: Key Management @team:DataDog/credentials-management Scenario: Create an Application key with scopes for current user returns "Created" response - Given new "CreateCurrentUserApplicationKey" request + Given a valid "appKeyAuth" key in the system + And new "CreateCurrentUserApplicationKey" request And body with value {"data": {"type": "application_keys", "attributes": {"name": "{{ unique }}", "scopes": ["dashboards_read", "dashboards_write", "dashboards_public_share"]}}} When the request is sent Then the response status is 201 Created @@ -57,14 +61,16 @@ Feature: Key Management @generated @skip @team:DataDog/credentials-management Scenario: Create an application key for current user returns "Bad Request" response - Given new "CreateCurrentUserApplicationKey" request + Given a valid "appKeyAuth" key in the system + And new "CreateCurrentUserApplicationKey" request And body with value {"data": {"attributes": {"name": "Application Key for managing dashboards", "scopes": ["dashboards_read", "dashboards_write", "dashboards_public_share"]}, "type": "application_keys"}} When the request is sent Then the response status is 400 Bad Request @team:DataDog/credentials-management Scenario: Create an application key for current user returns "Created" response - Given new "CreateCurrentUserApplicationKey" request + Given a valid "appKeyAuth" key in the system + And new "CreateCurrentUserApplicationKey" request And body with value {"data": {"type": "application_keys", "attributes": {"name": "{{ unique }}"}}} When the request is sent Then the response status is 201 Created @@ -73,7 +79,8 @@ Feature: Key Management @team:DataDog/credentials-management Scenario: Delete an API key returns "No Content" response - Given there is a valid "api_key" in the system + Given a valid "appKeyAuth" key in the system + And there is a valid "api_key" in the system And new "DeleteAPIKey" request And request contains "api_key_id" parameter from "api_key.data.id" When the request is sent @@ -81,14 +88,16 @@ Feature: Key Management @generated @skip @team:DataDog/credentials-management Scenario: Delete an API key returns "Not Found" response - Given new "DeleteAPIKey" request + Given a valid "appKeyAuth" key in the system + And new "DeleteAPIKey" request And request contains "api_key_id" parameter from "REPLACE.ME" When the request is sent Then the response status is 404 Not Found @team:DataDog/credentials-management Scenario: Delete an application key owned by current user returns "No Content" response - Given there is a valid "application_key" in the system + Given a valid "appKeyAuth" key in the system + And there is a valid "application_key" in the system And new "DeleteCurrentUserApplicationKey" request And request contains "app_key_id" parameter from "application_key.data.id" When the request is sent @@ -96,14 +105,16 @@ Feature: Key Management @generated @skip @team:DataDog/credentials-management Scenario: Delete an application key owned by current user returns "Not Found" response - Given new "DeleteCurrentUserApplicationKey" request + Given a valid "appKeyAuth" key in the system + And new "DeleteCurrentUserApplicationKey" request And request contains "app_key_id" parameter from "REPLACE.ME" When the request is sent Then the response status is 404 Not Found @team:DataDog/credentials-management Scenario: Delete an application key returns "No Content" response - Given there is a valid "application_key" in the system + Given a valid "appKeyAuth" key in the system + And there is a valid "application_key" in the system And new "DeleteApplicationKey" request And request contains "app_key_id" parameter from "application_key.data.id" When the request is sent @@ -111,14 +122,16 @@ Feature: Key Management @generated @skip @team:DataDog/credentials-management Scenario: Delete an application key returns "Not Found" response - Given new "DeleteApplicationKey" request + Given a valid "appKeyAuth" key in the system + And new "DeleteApplicationKey" request And request contains "app_key_id" parameter from "REPLACE.ME" When the request is sent Then the response status is 404 Not Found @generated @skip @team:DataDog/credentials-management Scenario: Edit an API key returns "Bad Request" response - Given new "UpdateAPIKey" request + Given a valid "appKeyAuth" key in the system + And new "UpdateAPIKey" request And request contains "api_key_id" parameter from "REPLACE.ME" And body with value {"data": {"attributes": {"name": "API Key for submitting metrics"}, "id": "00112233-4455-6677-8899-aabbccddeeff", "type": "api_keys"}} When the request is sent @@ -126,7 +139,8 @@ Feature: Key Management @generated @skip @team:DataDog/credentials-management Scenario: Edit an API key returns "Not Found" response - Given new "UpdateAPIKey" request + Given a valid "appKeyAuth" key in the system + And new "UpdateAPIKey" request And request contains "api_key_id" parameter from "REPLACE.ME" And body with value {"data": {"attributes": {"name": "API Key for submitting metrics"}, "id": "00112233-4455-6677-8899-aabbccddeeff", "type": "api_keys"}} When the request is sent @@ -134,7 +148,8 @@ Feature: Key Management @team:DataDog/credentials-management Scenario: Edit an API key returns "OK" response - Given there is a valid "api_key" in the system + Given a valid "appKeyAuth" key in the system + And there is a valid "api_key" in the system And new "UpdateAPIKey" request And request contains "api_key_id" parameter from "api_key.data.id" And body with value {"data": {"type": "api_keys", "id": "{{ api_key.data.id }}", "attributes": {"name": "{{ unique }}"}}} @@ -146,7 +161,8 @@ Feature: Key Management @generated @skip @team:DataDog/credentials-management Scenario: Edit an application key owned by current user returns "Bad Request" response - Given new "UpdateCurrentUserApplicationKey" request + Given a valid "appKeyAuth" key in the system + And new "UpdateCurrentUserApplicationKey" request And request contains "app_key_id" parameter from "REPLACE.ME" And body with value {"data": {"attributes": {"name": "Application Key for managing dashboards", "scopes": ["dashboards_read", "dashboards_write", "dashboards_public_share"]}, "id": "00112233-4455-6677-8899-aabbccddeeff", "type": "application_keys"}} When the request is sent @@ -154,7 +170,8 @@ Feature: Key Management @generated @skip @team:DataDog/credentials-management Scenario: Edit an application key owned by current user returns "Not Found" response - Given new "UpdateCurrentUserApplicationKey" request + Given a valid "appKeyAuth" key in the system + And new "UpdateCurrentUserApplicationKey" request And request contains "app_key_id" parameter from "REPLACE.ME" And body with value {"data": {"attributes": {"name": "Application Key for managing dashboards", "scopes": ["dashboards_read", "dashboards_write", "dashboards_public_share"]}, "id": "00112233-4455-6677-8899-aabbccddeeff", "type": "application_keys"}} When the request is sent @@ -162,7 +179,8 @@ Feature: Key Management @team:DataDog/credentials-management Scenario: Edit an application key owned by current user returns "OK" response - Given there is a valid "application_key" in the system + Given a valid "appKeyAuth" key in the system + And there is a valid "application_key" in the system And new "UpdateCurrentUserApplicationKey" request And request contains "app_key_id" parameter from "application_key.data.id" And body with value {"data": {"id": "{{ application_key.data.id }}", "type": "application_keys", "attributes": {"name" : "{{ application_key.data.attributes.name }}-updated"}}} @@ -174,7 +192,8 @@ Feature: Key Management @generated @skip @team:DataDog/credentials-management Scenario: Edit an application key returns "Bad Request" response - Given new "UpdateApplicationKey" request + Given a valid "appKeyAuth" key in the system + And new "UpdateApplicationKey" request And request contains "app_key_id" parameter from "REPLACE.ME" And body with value {"data": {"attributes": {"name": "Application Key for managing dashboards", "scopes": ["dashboards_read", "dashboards_write", "dashboards_public_share"]}, "id": "00112233-4455-6677-8899-aabbccddeeff", "type": "application_keys"}} When the request is sent @@ -182,7 +201,8 @@ Feature: Key Management @generated @skip @team:DataDog/credentials-management Scenario: Edit an application key returns "Not Found" response - Given new "UpdateApplicationKey" request + Given a valid "appKeyAuth" key in the system + And new "UpdateApplicationKey" request And request contains "app_key_id" parameter from "REPLACE.ME" And body with value {"data": {"attributes": {"name": "Application Key for managing dashboards", "scopes": ["dashboards_read", "dashboards_write", "dashboards_public_share"]}, "id": "00112233-4455-6677-8899-aabbccddeeff", "type": "application_keys"}} When the request is sent @@ -190,7 +210,8 @@ Feature: Key Management @team:DataDog/credentials-management Scenario: Edit an application key returns "OK" response - Given there is a valid "application_key" in the system + Given a valid "appKeyAuth" key in the system + And there is a valid "application_key" in the system And new "UpdateApplicationKey" request And request contains "app_key_id" parameter from "application_key.data.id" And body with value {"data": {"id": "{{ application_key.data.id }}", "type": "application_keys", "attributes": {"name" : "{{ application_key.data.attributes.name }}-updated"}}} @@ -202,14 +223,16 @@ Feature: Key Management @team:DataDog/credentials-management Scenario: Get API key returns "Not Found" response - Given new "GetAPIKey" request + Given a valid "appKeyAuth" key in the system + And new "GetAPIKey" request And request contains "api_key_id" parameter with value "invalidId" When the request is sent Then the response status is 404 Not Found @team:DataDog/credentials-management Scenario: Get API key returns "OK" response - Given there is a valid "api_key" in the system + Given a valid "appKeyAuth" key in the system + And there is a valid "api_key" in the system And new "GetAPIKey" request And request contains "api_key_id" parameter from "api_key.data.id" When the request is sent @@ -220,14 +243,16 @@ Feature: Key Management @generated @skip @team:DataDog/credentials-management Scenario: Get a personal access token returns "Not Found" response - Given new "GetPersonalAccessToken" request + Given a valid "appKeyAuth" key in the system + And new "GetPersonalAccessToken" request And request contains "pat_id" parameter from "REPLACE.ME" When the request is sent Then the response status is 404 Not Found @team:DataDog/credentials-management Scenario: Get a personal access token returns "OK" response - Given there is a valid "personal_access_token" in the system + Given a valid "appKeyAuth" key in the system + And there is a valid "personal_access_token" in the system And new "GetPersonalAccessToken" request And request contains "pat_id" parameter from "personal_access_token.data.id" When the request is sent @@ -237,13 +262,15 @@ Feature: Key Management @generated @skip @team:DataDog/credentials-management Scenario: Get all API keys returns "Bad Request" response - Given new "ListAPIKeys" request + Given a valid "appKeyAuth" key in the system + And new "ListAPIKeys" request When the request is sent Then the response status is 400 Bad Request @team:DataDog/credentials-management Scenario: Get all API keys returns "OK" response - Given there is a valid "api_key" in the system + Given a valid "appKeyAuth" key in the system + And there is a valid "api_key" in the system And new "ListAPIKeys" request And request contains "filter" parameter from "api_key.data.attributes.name" When the request is sent @@ -253,19 +280,22 @@ Feature: Key Management @generated @skip @team:DataDog/credentials-management Scenario: Get all application keys owned by current user returns "Bad Request" response - Given new "ListCurrentUserApplicationKeys" request + Given a valid "appKeyAuth" key in the system + And new "ListCurrentUserApplicationKeys" request When the request is sent Then the response status is 400 Bad Request @generated @skip @team:DataDog/credentials-management Scenario: Get all application keys owned by current user returns "Not Found" response - Given new "ListCurrentUserApplicationKeys" request + Given a valid "appKeyAuth" key in the system + And new "ListCurrentUserApplicationKeys" request When the request is sent Then the response status is 404 Not Found @team:DataDog/credentials-management Scenario: Get all application keys owned by current user returns "OK" response - Given new "ListCurrentUserApplicationKeys" request + Given a valid "appKeyAuth" key in the system + And new "ListCurrentUserApplicationKeys" request When the request is sent Then the response status is 200 OK And the response "data[0].type" is equal to "application_keys" @@ -273,19 +303,22 @@ Feature: Key Management @generated @skip @team:DataDog/credentials-management Scenario: Get all application keys returns "Bad Request" response - Given new "ListApplicationKeys" request + Given a valid "appKeyAuth" key in the system + And new "ListApplicationKeys" request When the request is sent Then the response status is 400 Bad Request @generated @skip @team:DataDog/credentials-management Scenario: Get all application keys returns "Not Found" response - Given new "ListApplicationKeys" request + Given a valid "appKeyAuth" key in the system + And new "ListApplicationKeys" request When the request is sent Then the response status is 404 Not Found @team:DataDog/credentials-management Scenario: Get all application keys returns "OK" response - Given there is a valid "application_key" in the system + Given a valid "appKeyAuth" key in the system + And there is a valid "application_key" in the system And new "ListApplicationKeys" request When the request is sent Then the response status is 200 OK @@ -294,13 +327,15 @@ Feature: Key Management @generated @skip @team:DataDog/credentials-management Scenario: Get all personal access tokens returns "Bad Request" response - Given new "ListPersonalAccessTokens" request + Given a valid "appKeyAuth" key in the system + And new "ListPersonalAccessTokens" request When the request is sent Then the response status is 400 Bad Request @team:DataDog/credentials-management Scenario: Get all personal access tokens returns "OK" response - Given there is a valid "personal_access_token" in the system + Given a valid "appKeyAuth" key in the system + And there is a valid "personal_access_token" in the system And new "ListPersonalAccessTokens" request When the request is sent Then the response status is 200 OK @@ -308,21 +343,24 @@ Feature: Key Management @generated @skip @team:DataDog/credentials-management Scenario: Get an application key returns "Bad Request" response - Given new "GetApplicationKey" request + Given a valid "appKeyAuth" key in the system + And new "GetApplicationKey" request And request contains "app_key_id" parameter from "REPLACE.ME" When the request is sent Then the response status is 400 Bad Request @team:DataDog/credentials-management Scenario: Get an application key returns "Not Found" response - Given new "GetApplicationKey" request + Given a valid "appKeyAuth" key in the system + And new "GetApplicationKey" request And request contains "app_key_id" parameter with value "invalidId" When the request is sent Then the response status is 404 Not Found @team:DataDog/credentials-management Scenario: Get an application key returns "OK" response - Given there is a valid "application_key" in the system + Given a valid "appKeyAuth" key in the system + And there is a valid "application_key" in the system And new "GetApplicationKey" request And request contains "app_key_id" parameter from "application_key.data.id" When the request is sent @@ -333,14 +371,16 @@ Feature: Key Management @team:DataDog/credentials-management Scenario: Get one application key owned by current user returns "Not Found" response - Given new "GetCurrentUserApplicationKey" request + Given a valid "appKeyAuth" key in the system + And new "GetCurrentUserApplicationKey" request And request contains "app_key_id" parameter with value "incorrectId" When the request is sent Then the response status is 404 Not Found @team:DataDog/credentials-management Scenario: Get one application key owned by current user returns "OK" response - Given there is a valid "application_key" in the system + Given a valid "appKeyAuth" key in the system + And there is a valid "application_key" in the system And new "GetCurrentUserApplicationKey" request And request contains "app_key_id" parameter from "application_key.data.id" When the request is sent @@ -353,7 +393,8 @@ Feature: Key Management @team:DataDog/credentials-management Scenario: Revoke a personal access token returns "No Content" response - Given there is a valid "personal_access_token" in the system + Given a valid "appKeyAuth" key in the system + And there is a valid "personal_access_token" in the system And new "RevokePersonalAccessToken" request And request contains "pat_id" parameter from "personal_access_token.data.id" When the request is sent @@ -361,14 +402,16 @@ Feature: Key Management @generated @skip @team:DataDog/credentials-management Scenario: Revoke a personal access token returns "Not Found" response - Given new "RevokePersonalAccessToken" request + Given a valid "appKeyAuth" key in the system + And new "RevokePersonalAccessToken" request And request contains "pat_id" parameter from "REPLACE.ME" When the request is sent Then the response status is 404 Not Found @generated @skip @team:DataDog/credentials-management Scenario: Update a personal access token returns "Bad Request" response - Given new "UpdatePersonalAccessToken" request + Given a valid "appKeyAuth" key in the system + And new "UpdatePersonalAccessToken" request And request contains "pat_id" parameter from "REPLACE.ME" And body with value {"data": {"attributes": {"name": "Updated Personal Access Token", "scopes": ["dashboards_read", "dashboards_write"]}, "id": "00112233-4455-6677-8899-aabbccddeeff", "type": "personal_access_tokens"}} When the request is sent @@ -376,7 +419,8 @@ Feature: Key Management @generated @skip @team:DataDog/credentials-management Scenario: Update a personal access token returns "Not Found" response - Given new "UpdatePersonalAccessToken" request + Given a valid "appKeyAuth" key in the system + And new "UpdatePersonalAccessToken" request And request contains "pat_id" parameter from "REPLACE.ME" And body with value {"data": {"attributes": {"name": "Updated Personal Access Token", "scopes": ["dashboards_read", "dashboards_write"]}, "id": "00112233-4455-6677-8899-aabbccddeeff", "type": "personal_access_tokens"}} When the request is sent @@ -384,10 +428,18 @@ Feature: Key Management @team:DataDog/credentials-management Scenario: Update a personal access token returns "OK" response - Given there is a valid "personal_access_token" in the system + Given a valid "appKeyAuth" key in the system + And there is a valid "personal_access_token" in the system And new "UpdatePersonalAccessToken" request And request contains "pat_id" parameter from "personal_access_token.data.id" And body with value {"data": {"type": "personal_access_tokens", "id": "{{ personal_access_token.data.id }}", "attributes": {"name": "{{ unique }}-updated"}}} When the request is sent Then the response status is 200 OK And the response "data.attributes.name" is equal to "{{ unique }}-updated" + + @generated @skip @team:DataDog/identity-platform + Scenario: Validate API key returns "OK" response + Given operation "Validate" enabled + And new "Validate" request + 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 d5a8323e2702..9882d3a1b70d 100644 --- a/features/v2/undo.json +++ b/features/v2/undo.json @@ -7140,6 +7140,12 @@ "type": "safe" } }, + "Validate": { + "tag": "Key Management", + "undo": { + "type": "safe" + } + }, "SearchWidgets": { "tag": "Widgets", "undo": { diff --git a/lib/datadog_api_client/configuration.rb b/lib/datadog_api_client/configuration.rb index eb82106f5652..9ca9a234734d 100644 --- a/lib/datadog_api_client/configuration.rb +++ b/lib/datadog_api_client/configuration.rb @@ -237,6 +237,7 @@ def initialize "v2.update_llm_obs_experiment": false, "v2.update_llm_obs_project": false, "v2.anonymize_users": false, + "v2.validate": false, "v2.create_open_api": false, "v2.delete_open_api": false, "v2.get_open_api": false, diff --git a/lib/datadog_api_client/inflector.rb b/lib/datadog_api_client/inflector.rb index e9bb9ea6abc5..decd31249fac 100644 --- a/lib/datadog_api_client/inflector.rb +++ b/lib/datadog_api_client/inflector.rb @@ -6256,6 +6256,10 @@ def overrides "v2.v2_event_attributes" => "V2EventAttributes", "v2.v2_event_attributes_attributes" => "V2EventAttributesAttributes", "v2.v2_event_response" => "V2EventResponse", + "v2.validate_v2_attributes" => "ValidateV2Attributes", + "v2.validate_v2_data" => "ValidateV2Data", + "v2.validate_v2_response" => "ValidateV2Response", + "v2.validate_v2_type" => "ValidateV2Type", "v2.validation_error" => "ValidationError", "v2.validation_error_meta" => "ValidationErrorMeta", "v2.validation_response" => "ValidationResponse", diff --git a/lib/datadog_api_client/v2/api/key_management_api.rb b/lib/datadog_api_client/v2/api/key_management_api.rb index a27d81dbfd96..301a90036031 100644 --- a/lib/datadog_api_client/v2/api/key_management_api.rb +++ b/lib/datadog_api_client/v2/api/key_management_api.rb @@ -1354,5 +1354,71 @@ def update_personal_access_token_with_http_info(pat_id, body, opts = {}) end return data, status_code, headers end + + # Validate API key. + # + # @see #validate_with_http_info + def validate(opts = {}) + data, _status_code, _headers = validate_with_http_info(opts) + data + end + + # Validate API key. + # + # Check if the API key is valid. Returns the organization UUID, API key ID, and associated scopes. + # + # @param opts [Hash] the optional parameters + # @return [Array<(ValidateV2Response, Integer, Hash)>] ValidateV2Response data, response status code and response headers + def validate_with_http_info(opts = {}) + unstable_enabled = @api_client.config.unstable_operations["v2.validate".to_sym] + if unstable_enabled + @api_client.config.logger.warn format("Using unstable operation '%s'", "v2.validate") + else + raise DatadogAPIClient::APIError.new(message: format("Unstable operation '%s' is disabled", "v2.validate")) + end + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: KeyManagementAPI.validate ...' + end + # resource path + local_var_path = '/api/v2/validate' + + # 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']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'ValidateV2Response' + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth] + + new_options = opts.merge( + :operation => :validate, + :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::Get, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: KeyManagementAPI#validate\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/validate_v2_attributes.rb b/lib/datadog_api_client/v2/models/validate_v2_attributes.rb new file mode 100644 index 000000000000..9168fc2bc1d5 --- /dev/null +++ b/lib/datadog_api_client/v2/models/validate_v2_attributes.rb @@ -0,0 +1,167 @@ +=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 + # Attributes of the API key validation response. + class ValidateV2Attributes + include BaseGenericModel + + # The UUID of the API key. + attr_reader :api_key_id + + # List of scope names associated with the API key. + attr_reader :api_key_scopes + + # Whether the API key is valid. + attr_reader :valid + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'api_key_id' => :'api_key_id', + :'api_key_scopes' => :'api_key_scopes', + :'valid' => :'valid' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'api_key_id' => :'String', + :'api_key_scopes' => :'Array', + :'valid' => :'Boolean' + } + 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::ValidateV2Attributes` 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?(:'api_key_id') + self.api_key_id = attributes[:'api_key_id'] + end + + if attributes.key?(:'api_key_scopes') + if (value = attributes[:'api_key_scopes']).is_a?(Array) + self.api_key_scopes = value + end + end + + if attributes.key?(:'valid') + self.valid = attributes[:'valid'] + 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 @api_key_id.nil? + return false if @api_key_scopes.nil? + return false if @valid.nil? + true + end + + # Custom attribute writer method with validation + # @param api_key_id [Object] Object to be assigned + # @!visibility private + def api_key_id=(api_key_id) + if api_key_id.nil? + fail ArgumentError, 'invalid value for "api_key_id", api_key_id cannot be nil.' + end + @api_key_id = api_key_id + end + + # Custom attribute writer method with validation + # @param api_key_scopes [Object] Object to be assigned + # @!visibility private + def api_key_scopes=(api_key_scopes) + if api_key_scopes.nil? + fail ArgumentError, 'invalid value for "api_key_scopes", api_key_scopes cannot be nil.' + end + @api_key_scopes = api_key_scopes + end + + # Custom attribute writer method with validation + # @param valid [Object] Object to be assigned + # @!visibility private + def valid=(valid) + if valid.nil? + fail ArgumentError, 'invalid value for "valid", valid cannot be nil.' + end + @valid = valid + 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 && + api_key_id == o.api_key_id && + api_key_scopes == o.api_key_scopes && + valid == o.valid && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [api_key_id, api_key_scopes, valid, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/validate_v2_data.rb b/lib/datadog_api_client/v2/models/validate_v2_data.rb new file mode 100644 index 000000000000..ebf726e64fb1 --- /dev/null +++ b/lib/datadog_api_client/v2/models/validate_v2_data.rb @@ -0,0 +1,165 @@ +=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 + # Data object containing the API key validation result. + class ValidateV2Data + include BaseGenericModel + + # Attributes of the API key validation response. + attr_reader :attributes + + # The UUID of the organization associated with the API key. + attr_reader :id + + # Resource type for the API key validation response. + attr_reader :type + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'attributes' => :'attributes', + :'id' => :'id', + :'type' => :'type' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'attributes' => :'ValidateV2Attributes', + :'id' => :'String', + :'type' => :'ValidateV2Type' + } + 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::ValidateV2Data` 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?(:'id') + self.id = attributes[:'id'] + 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 @attributes.nil? + return false if @id.nil? + return false if @type.nil? + true + 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 id [Object] Object to be assigned + # @!visibility private + def id=(id) + if id.nil? + fail ArgumentError, 'invalid value for "id", id cannot be nil.' + end + @id = id + 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 && + attributes == o.attributes && + id == o.id && + 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, id, type, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/validate_v2_response.rb b/lib/datadog_api_client/v2/models/validate_v2_response.rb new file mode 100644 index 000000000000..f63266937360 --- /dev/null +++ b/lib/datadog_api_client/v2/models/validate_v2_response.rb @@ -0,0 +1,123 @@ +=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 for the API key validation endpoint. + class ValidateV2Response + include BaseGenericModel + + # Data object containing the API key validation result. + attr_reader :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' => :'ValidateV2Data' + } + 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::ValidateV2Response` 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 + + # 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 @data.nil? + true + end + + # Custom attribute writer method with validation + # @param data [Object] Object to be assigned + # @!visibility private + def data=(data) + if data.nil? + fail ArgumentError, 'invalid value for "data", data cannot be nil.' + end + @data = data + 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, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/validate_v2_type.rb b/lib/datadog_api_client/v2/models/validate_v2_type.rb new file mode 100644 index 000000000000..6d3905d174f6 --- /dev/null +++ b/lib/datadog_api_client/v2/models/validate_v2_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 type for the API key validation response. + class ValidateV2Type + include BaseEnumModel + + ValidateV2 = "validate_v2".freeze + end +end