From 5d1dba8838fc8743d2ad2856ae720a6caec71de1 Mon Sep 17 00:00:00 2001 From: "ci.datadog-api-spec" Date: Fri, 6 Feb 2026 13:14:29 +0000 Subject: [PATCH] Regenerate client from commit 7fa3c84 of spec repo --- .generator/schemas/v1/openapi.yaml | 289 +++++++++ .generator/schemas/v2/openapi.yaml | 590 ++++++++++++++++++ .../v1/key-management/CreateClientToken.rb | 15 + .../v1/key-management/RevokeClientToken.rb | 12 + .../v1/key-management/UpdateClientToken.rb | 16 + .../CreatePersonalAccessToken.rb | 22 + .../key-management/GetPersonalAccessToken.rb | 8 + .../ListPersonalAccessTokens.rb | 8 + .../RevokePersonalAccessToken.rb | 8 + .../UpdatePersonalAccessToken.rb | 22 + features/scenarios_model_mapping.rb | 29 + features/v1/key_management.feature | 64 ++ features/v1/undo.json | 25 + features/v2/key_management.feature | 104 +++ features/v2/undo.json | 37 ++ lib/datadog_api_client/configuration.rb | 8 + lib/datadog_api_client/inflector.rb | 22 + .../v1/api/key_management_api.rb | 221 +++++++ .../v1/models/client_token.rb | 266 ++++++++ .../v1/models/client_token_create_request.rb | 159 +++++ .../v1/models/client_token_revoke_request.rb | 127 ++++ .../v1/models/client_token_update_request.rb | 179 ++++++ .../v2/api/key_management_api.rb | 379 +++++++++++ .../v2/models/full_personal_access_token.rb | 188 ++++++ .../full_personal_access_token_attributes.rb | 242 +++++++ .../v2/models/personal_access_token.rb | 186 ++++++ .../personal_access_token_attributes.rb | 219 +++++++ ...personal_access_token_create_attributes.rb | 180 ++++++ .../personal_access_token_create_data.rb | 144 +++++ .../personal_access_token_create_request.rb | 123 ++++ .../personal_access_token_get_response.rb | 105 ++++ .../personal_access_token_relationships.rb | 105 ++++ .../models/personal_access_token_response.rb | 106 ++++ .../v2/models/personal_access_token_type.rb | 26 + ...personal_access_token_update_attributes.rb | 151 +++++ .../personal_access_token_update_data.rb | 165 +++++ .../personal_access_token_update_request.rb | 123 ++++ .../personal_access_tokens_list_response.rb | 117 ++++ .../personal_access_tokens_response_meta.rb | 105 ++++ ...rsonal_access_tokens_response_meta_page.rb | 105 ++++ .../v2/models/personal_access_tokens_sort.rb | 31 + 41 files changed, 5031 insertions(+) create mode 100644 examples/v1/key-management/CreateClientToken.rb create mode 100644 examples/v1/key-management/RevokeClientToken.rb create mode 100644 examples/v1/key-management/UpdateClientToken.rb create mode 100644 examples/v2/key-management/CreatePersonalAccessToken.rb create mode 100644 examples/v2/key-management/GetPersonalAccessToken.rb create mode 100644 examples/v2/key-management/ListPersonalAccessTokens.rb create mode 100644 examples/v2/key-management/RevokePersonalAccessToken.rb create mode 100644 examples/v2/key-management/UpdatePersonalAccessToken.rb create mode 100644 lib/datadog_api_client/v1/models/client_token.rb create mode 100644 lib/datadog_api_client/v1/models/client_token_create_request.rb create mode 100644 lib/datadog_api_client/v1/models/client_token_revoke_request.rb create mode 100644 lib/datadog_api_client/v1/models/client_token_update_request.rb create mode 100644 lib/datadog_api_client/v2/models/full_personal_access_token.rb create mode 100644 lib/datadog_api_client/v2/models/full_personal_access_token_attributes.rb create mode 100644 lib/datadog_api_client/v2/models/personal_access_token.rb create mode 100644 lib/datadog_api_client/v2/models/personal_access_token_attributes.rb create mode 100644 lib/datadog_api_client/v2/models/personal_access_token_create_attributes.rb create mode 100644 lib/datadog_api_client/v2/models/personal_access_token_create_data.rb create mode 100644 lib/datadog_api_client/v2/models/personal_access_token_create_request.rb create mode 100644 lib/datadog_api_client/v2/models/personal_access_token_get_response.rb create mode 100644 lib/datadog_api_client/v2/models/personal_access_token_relationships.rb create mode 100644 lib/datadog_api_client/v2/models/personal_access_token_response.rb create mode 100644 lib/datadog_api_client/v2/models/personal_access_token_type.rb create mode 100644 lib/datadog_api_client/v2/models/personal_access_token_update_attributes.rb create mode 100644 lib/datadog_api_client/v2/models/personal_access_token_update_data.rb create mode 100644 lib/datadog_api_client/v2/models/personal_access_token_update_request.rb create mode 100644 lib/datadog_api_client/v2/models/personal_access_tokens_list_response.rb create mode 100644 lib/datadog_api_client/v2/models/personal_access_tokens_response_meta.rb create mode 100644 lib/datadog_api_client/v2/models/personal_access_tokens_response_meta_page.rb create mode 100644 lib/datadog_api_client/v2/models/personal_access_tokens_sort.rb diff --git a/.generator/schemas/v1/openapi.yaml b/.generator/schemas/v1/openapi.yaml index a38d274f9b8d..5e187a0e1426 100644 --- a/.generator/schemas/v1/openapi.yaml +++ b/.generator/schemas/v1/openapi.yaml @@ -1291,6 +1291,152 @@ components: type: string x-enum-varnames: - CHECK_STATUS + ClientToken: + description: 'Client token object. Client tokens (also known as public API keys) + enable you to submit + + data from your browser or mobile applications to Datadog.' + properties: + created_at: + description: Creation timestamp of the client token. + example: '2024-03-15T10:30:00.000000+00:00' + format: date-time + readOnly: true + type: string + created_by_handle: + description: Handle of the user who created the client token. + example: user@example.com + readOnly: true + type: string + created_by_uuid: + description: UUID of the user who created the client token. + example: 00000000-0000-0000-0000-000000000000 + format: uuid + readOnly: true + type: string + disabled_at: + description: Timestamp when the client token was disabled. + example: '2024-03-20T10:30:00.000000+00:00' + format: date-time + nullable: true + readOnly: true + type: string + disabled_by: + description: ID of the user who disabled the client token. + format: int64 + readOnly: true + type: integer + disabled_by_handle: + description: Handle of the user who disabled the client token. + example: user@example.com + readOnly: true + type: string + hash: + description: 'The hash value of the client token. This is the secret token + value that should be + + used in your browser or mobile application.' + example: 1234567890abcdef1234567890abcdef123 + maxLength: 35 + readOnly: true + type: string + modified_by: + description: ID of the user who last modified the client token. + format: int64 + readOnly: true + type: integer + name: + description: Name of the client token. + example: Example Client Token + maxLength: 255 + minLength: 1 + type: string + org_id: + description: Organization ID associated with the client token. + example: 12345 + format: int64 + readOnly: true + type: integer + origin_urls: + description: 'List of allowed origin URLs for browser-based applications. + Requests from URLs + + not in this list will be rejected.' + example: + - https://example.com + items: + example: https://example.com + maxLength: 2500 + type: string + maxItems: 100 + type: array + required: + - origin_urls + type: object + ClientTokenCreateRequest: + description: Request to create a new client token. + properties: + name: + description: Name of the client token. + example: Example Client Token + maxLength: 255 + minLength: 1 + type: string + origin_urls: + description: 'List of allowed origin URLs for browser-based applications. + Requests from URLs + + not in this list will be rejected.' + example: + - https://example.com + items: + example: https://example.com + maxLength: 2500 + type: string + maxItems: 100 + type: array + required: + - name + - origin_urls + type: object + ClientTokenRevokeRequest: + description: Request to revoke a client token. + properties: + hash: + description: Hash value of the client token to revoke. + example: 1234567890abcdef1234567890abcdef123 + maxLength: 35 + type: string + required: + - hash + type: object + ClientTokenUpdateRequest: + description: Request to update an existing client token. + properties: + hash: + description: Hash value of the client token to update. + example: 1234567890abcdef1234567890abcdef123 + maxLength: 35 + type: string + name: + description: New name for the client token. + example: Updated Client Token Name + maxLength: 255 + minLength: 1 + type: string + origin_urls: + description: New list of allowed origin URLs. If provided, this will replace + the existing list. + items: + example: https://example.com + maxLength: 2500 + type: string + maxItems: 100 + type: array + required: + - hash + - name + type: object ContentEncoding: description: HTTP header used to compress the media-type. enum: @@ -26206,6 +26352,7 @@ components: ci_visibility_pipelines_write: Create CI Visibility pipeline spans using the API. ci_visibility_read: View CI Visibility. + client_tokens_write: Create, edit, and delete client tokens. cloud_cost_management_read: View Cloud Cost pages and the cloud cost data source in dashboards and notebooks. For more details, see the Cloud Cost Management docs. @@ -33294,6 +33441,148 @@ paths: tags: - Organizations x-codegen-request-body-name: body + /api/v1/public_api_key: + delete: + description: 'Revoke a client token (public API key). Once revoked, the token + can no longer be used + + to submit data to Datadog.' + operationId: RevokeClientToken + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ClientTokenRevokeRequest' + required: true + responses: + '204': + description: No Content + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Bad Request + '404': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Not Found + '429': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Too Many Requests + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - client_tokens_write + summary: Revoke client token + tags: + - Key Management + x-codegen-request-body-name: body + x-unstable: '**Note**: This endpoint is in public beta and is subject to change. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + post: + description: 'Create a new client token (public API key) to submit data from + your browser or mobile + + applications to Datadog.' + operationId: CreateClientToken + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ClientTokenCreateRequest' + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/ClientToken' + description: OK + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Bad Request + '403': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Forbidden + '429': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Too Many Requests + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - client_tokens_write + summary: Create client token + tags: + - Key Management + x-codegen-request-body-name: body + x-unstable: '**Note**: This endpoint is in public beta and is subject to change. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + put: + description: Update the name and/or origin URLs of an existing client token + (public API key). + operationId: UpdateClientToken + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ClientTokenUpdateRequest' + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/ClientToken' + description: OK + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Bad Request + '404': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Not Found + '429': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Too Many Requests + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - client_tokens_write + summary: Update client token + tags: + - Key Management + x-codegen-request-body-name: body + x-unstable: '**Note**: This endpoint is in public beta and is subject to change. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' /api/v1/query: get: description: Query timeseries points. diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index e301432aca72..1d00ffc84ded 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -853,6 +853,43 @@ components: example: 10 format: int64 type: integer + PersonalAccessTokenFilterOwnerUUIDParameter: + description: Filter personal access tokens by owner UUID. + in: query + name: filter[owner_uuid] + required: false + schema: + items: + format: uuid + type: string + type: array + PersonalAccessTokenFilterParameter: + description: Filter personal access tokens by name. + in: query + name: filter + required: false + schema: + type: string + PersonalAccessTokenID: + description: The UUID of the personal access token. + in: path + name: pat_uuid + required: true + schema: + format: uuid + type: string + PersonalAccessTokenSortParameter: + description: 'Personal access token attribute used to sort results. Sort order + is ascending + + by default. In order to specify a descending sort, prefix the + + attribute with a minus sign.' + in: query + name: sort + required: false + schema: + $ref: '#/components/schemas/PersonalAccessTokensSort' ProductName: description: Name of the product to be deleted, either `logs` or `rum`. in: path @@ -25702,6 +25739,87 @@ components: - name - requirements type: object + FullPersonalAccessToken: + description: 'Personal access token object with the secret key value. This is + only + + returned when creating a new token.' + properties: + attributes: + $ref: '#/components/schemas/FullPersonalAccessTokenAttributes' + id: + description: UUID of the personal access token. + example: 00000000-0000-0000-0000-000000000000 + format: uuid + type: string + relationships: + $ref: '#/components/schemas/PersonalAccessTokenRelationships' + type: + $ref: '#/components/schemas/PersonalAccessTokenType' + required: + - id + - type + - attributes + - relationships + type: object + FullPersonalAccessTokenAttributes: + description: 'Attributes of a personal access token including the secret key + value. + + This is only returned when creating a new token.' + properties: + created_at: + description: Creation timestamp of the personal access token. + example: '2024-03-15T10:30:00.000000+00:00' + format: date-time + readOnly: true + type: string + expires_at: + description: Expiration timestamp of the personal access token. + example: '2025-03-15T10:30:00.000000+00:00' + format: date-time + type: string + key: + description: 'The secret token value. This is only returned when creating + a new personal + + access token and cannot be retrieved later.' + example: dd_pat_1234567890abcdef1234567890abcdef12345678 + readOnly: true + type: string + modified_at: + description: Last modification timestamp of the personal access token. + example: '2024-03-20T10:30:00.000000+00:00' + format: date-time + nullable: true + readOnly: true + type: string + name: + description: Name of the personal access token. + example: Example Personal Access Token + maxLength: 256 + minLength: 1 + type: string + scopes: + description: 'Array of scopes granted to the personal access token. These + define what + + permissions the token has.' + example: + - dashboards_read + - monitors_read + items: + description: Name of scope. + type: string + minItems: 1 + type: array + required: + - name + - scopes + - created_at + - expires_at + - key + type: object GCPCredentials: description: The definition of the `GCPCredentials` object. oneOf: @@ -45108,6 +45226,241 @@ components: type: string x-enum-varnames: - PERMISSIONS + PersonalAccessToken: + description: Personal access token object. + properties: + attributes: + $ref: '#/components/schemas/PersonalAccessTokenAttributes' + id: + description: UUID of the personal access token. + example: 00000000-0000-0000-0000-000000000000 + format: uuid + type: string + relationships: + $ref: '#/components/schemas/PersonalAccessTokenRelationships' + type: + $ref: '#/components/schemas/PersonalAccessTokenType' + required: + - id + - type + - attributes + - relationships + type: object + PersonalAccessTokenAttributes: + description: Attributes of a personal access token. + properties: + created_at: + description: Creation timestamp of the personal access token. + example: '2024-03-15T10:30:00.000000+00:00' + format: date-time + readOnly: true + type: string + expires_at: + description: Expiration timestamp of the personal access token. + example: '2025-03-15T10:30:00.000000+00:00' + format: date-time + type: string + modified_at: + description: Last modification timestamp of the personal access token. + example: '2024-03-20T10:30:00.000000+00:00' + format: date-time + nullable: true + readOnly: true + type: string + name: + description: Name of the personal access token. + example: Example Personal Access Token + maxLength: 256 + minLength: 1 + type: string + scopes: + description: 'Array of scopes granted to the personal access token. These + define what + + permissions the token has.' + example: + - dashboards_read + - monitors_read + items: + description: Name of scope. + type: string + minItems: 1 + type: array + required: + - name + - scopes + - created_at + - expires_at + type: object + PersonalAccessTokenCreateAttributes: + description: Attributes used to create a personal access token. + properties: + expires_at: + description: Expiration timestamp for the personal access token. + example: '2025-03-15T10:30:00.000000+00:00' + format: date-time + type: string + name: + description: Name of the personal access token. + example: Example Personal Access Token + maxLength: 256 + minLength: 1 + type: string + scopes: + description: 'Array of scopes to grant the personal access token. These + define what + + permissions the token will have.' + example: + - dashboards_read + - monitors_read + items: + description: Name of scope. + type: string + minItems: 1 + type: array + required: + - name + - scopes + - expires_at + type: object + PersonalAccessTokenCreateData: + description: Object used to create a personal access token. + properties: + attributes: + $ref: '#/components/schemas/PersonalAccessTokenCreateAttributes' + type: + $ref: '#/components/schemas/PersonalAccessTokenType' + required: + - type + - attributes + type: object + PersonalAccessTokenCreateRequest: + description: Request to create a personal access token. + properties: + data: + $ref: '#/components/schemas/PersonalAccessTokenCreateData' + required: + - data + type: object + PersonalAccessTokenGetResponse: + description: Response for retrieving a personal access token. + properties: + data: + $ref: '#/components/schemas/PersonalAccessToken' + type: object + PersonalAccessTokenRelationships: + description: Resources related to the personal access token. + properties: + owned_by: + $ref: '#/components/schemas/RelationshipToUser' + type: object + PersonalAccessTokenResponse: + description: Response for creating a personal access token. + properties: + data: + $ref: '#/components/schemas/FullPersonalAccessToken' + type: object + PersonalAccessTokenType: + default: personal_access_tokens + description: Personal access tokens resource type. + enum: + - personal_access_tokens + example: personal_access_tokens + type: string + x-enum-varnames: + - PERSONAL_ACCESS_TOKENS + PersonalAccessTokenUpdateAttributes: + description: Attributes used to update a personal access token. + properties: + name: + description: New name for the personal access token. + example: Updated Personal Access Token Name + maxLength: 256 + minLength: 1 + type: string + scopes: + description: 'New array of scopes for the personal access token. If provided, + this will + + replace the existing scopes.' + example: + - dashboards_read + - dashboards_write + items: + description: Name of scope. + type: string + minItems: 1 + type: array + type: object + PersonalAccessTokenUpdateData: + description: Object used to update a personal access token. + properties: + attributes: + $ref: '#/components/schemas/PersonalAccessTokenUpdateAttributes' + id: + description: UUID of the personal access token. Must match the path parameter. + example: 00000000-0000-0000-0000-000000000000 + format: uuid + type: string + type: + $ref: '#/components/schemas/PersonalAccessTokenType' + required: + - id + - type + - attributes + type: object + PersonalAccessTokenUpdateRequest: + description: Request to update a personal access token. + properties: + data: + $ref: '#/components/schemas/PersonalAccessTokenUpdateData' + required: + - data + type: object + PersonalAccessTokensListResponse: + description: Response for a list of personal access tokens. + properties: + data: + description: Array of personal access tokens. + items: + $ref: '#/components/schemas/PersonalAccessToken' + type: array + meta: + $ref: '#/components/schemas/PersonalAccessTokensResponseMeta' + type: object + PersonalAccessTokensResponseMeta: + description: Additional information related to the personal access tokens response. + properties: + page: + $ref: '#/components/schemas/PersonalAccessTokensResponseMetaPage' + type: object + PersonalAccessTokensResponseMetaPage: + description: Pagination information for personal access tokens response. + properties: + total_filtered_count: + description: Total filtered personal access token count. + format: int64 + type: integer + type: object + PersonalAccessTokensSort: + default: name + description: Sorting options for personal access tokens. + enum: + - name + - -name + - created_at + - -created_at + - expires_at + - -expires_at + type: string + x-enum-varnames: + - NAME_ASCENDING + - NAME_DESCENDING + - CREATED_AT_ASCENDING + - CREATED_AT_DESCENDING + - EXPIRES_AT_ASCENDING + - EXPIRES_AT_DESCENDING Playlist: properties: data: @@ -67432,6 +67785,9 @@ components: is not required to set downtimes. monitors_read: View monitors. monitors_write: Edit, delete, and resolve individual monitors. + org_app_keys_read: View personal access tokens for all users in your organization. + org_app_keys_write: Create, edit, and delete personal access tokens for + all users in your organization. org_connections_read: Read cross organization connections. org_connections_write: Create, edit, and delete cross organization connections. org_management: Edit org configurations, including authentication and @@ -67482,6 +67838,7 @@ components: user_access_manage: Disable users, manage user roles, manage SAML-to-role mappings, and configure logs restriction queries. user_access_read: View users and their roles and settings. + user_app_keys: Create, view, and manage your own personal access tokens. workflows_read: View workflows. workflows_run: Run workflows. workflows_write: Create, edit, and delete workflows. @@ -87522,6 +87879,239 @@ paths: operator: OR permissions: - user_access_read + /api/v2/personal_access_tokens: + get: + description: 'List all personal access tokens in your organization. Supports + filtering, + + pagination, and sorting.' + operationId: ListPersonalAccessTokens + parameters: + - $ref: '#/components/parameters/PageSize' + - $ref: '#/components/parameters/PageNumber' + - $ref: '#/components/parameters/PersonalAccessTokenSortParameter' + - $ref: '#/components/parameters/PersonalAccessTokenFilterParameter' + - $ref: '#/components/parameters/PersonalAccessTokenFilterOwnerUUIDParameter' + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/PersonalAccessTokensListResponse' + description: OK + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Bad Request + '403': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Forbidden + '404': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Not Found - Personal access tokens feature is not enabled + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - org_app_keys_read + summary: List personal access tokens + tags: + - Key Management + x-unstable: '**Note**: This endpoint is in public beta and is subject to change. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + post: + description: 'Create a new personal access token with fine-grained permissions. + The token value + + will be returned in the response and cannot be retrieved later. Be sure to + save it + + securely.' + operationId: CreatePersonalAccessToken + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/PersonalAccessTokenCreateRequest' + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/PersonalAccessTokenResponse' + description: OK + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Bad Request + '403': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Forbidden + '404': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Not Found - Personal access tokens feature is not enabled + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - user_app_keys + summary: Create personal access token + tags: + - Key Management + x-codegen-request-body-name: body + x-unstable: '**Note**: This endpoint is in public beta and is subject to change. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + /api/v2/personal_access_tokens/{pat_uuid}: + delete: + description: 'Revoke a personal access token. Once revoked, the token can no + longer be used + + to authenticate API requests.' + operationId: RevokePersonalAccessToken + parameters: + - $ref: '#/components/parameters/PersonalAccessTokenID' + responses: + '204': + description: No Content + '403': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Forbidden + '404': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Not Found + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - user_app_keys + - org_app_keys_write + summary: Revoke personal access token + tags: + - Key Management + x-unstable: '**Note**: This endpoint is in public beta and is subject to change. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + get: + description: Get a specific personal access token by UUID. + operationId: GetPersonalAccessToken + parameters: + - $ref: '#/components/parameters/PersonalAccessTokenID' + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/PersonalAccessTokenGetResponse' + description: OK + '403': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Forbidden + '404': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Not Found + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - org_app_keys_read + summary: Get personal access token + tags: + - Key Management + x-unstable: '**Note**: This endpoint is in public beta and is subject to change. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + patch: + description: 'Update the name and/or scopes of an existing personal access token. + The ID in the + + request body must match the UUID in the path.' + operationId: UpdatePersonalAccessToken + parameters: + - $ref: '#/components/parameters/PersonalAccessTokenID' + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/PersonalAccessTokenUpdateRequest' + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/PersonalAccessTokenGetResponse' + description: OK + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Bad Request + '403': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Forbidden + '404': + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: Not Found + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - org_app_keys_write + summary: Update personal access token + tags: + - Key Management + x-codegen-request-body-name: body + x-unstable: '**Note**: This endpoint is in public beta and is subject to change. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' /api/v2/posture_management/findings: get: description: "Get a list of findings. These include both misconfigurations and diff --git a/examples/v1/key-management/CreateClientToken.rb b/examples/v1/key-management/CreateClientToken.rb new file mode 100644 index 000000000000..ff8286d4dbb5 --- /dev/null +++ b/examples/v1/key-management/CreateClientToken.rb @@ -0,0 +1,15 @@ +# Create client token returns "OK" response + +require "datadog_api_client" +DatadogAPIClient.configure do |config| + config.unstable_operations["v1.create_client_token".to_sym] = true +end +api_instance = DatadogAPIClient::V1::KeyManagementAPI.new + +body = DatadogAPIClient::V1::ClientTokenCreateRequest.new({ + name: "Example Client Token", + origin_urls: [ + "https://example.com", + ], +}) +p api_instance.create_client_token(body) diff --git a/examples/v1/key-management/RevokeClientToken.rb b/examples/v1/key-management/RevokeClientToken.rb new file mode 100644 index 000000000000..d655657cb222 --- /dev/null +++ b/examples/v1/key-management/RevokeClientToken.rb @@ -0,0 +1,12 @@ +# Revoke client token returns "No Content" response + +require "datadog_api_client" +DatadogAPIClient.configure do |config| + config.unstable_operations["v1.revoke_client_token".to_sym] = true +end +api_instance = DatadogAPIClient::V1::KeyManagementAPI.new + +body = DatadogAPIClient::V1::ClientTokenRevokeRequest.new({ + _hash: "1234567890abcdef1234567890abcdef123", +}) +api_instance.revoke_client_token(body) diff --git a/examples/v1/key-management/UpdateClientToken.rb b/examples/v1/key-management/UpdateClientToken.rb new file mode 100644 index 000000000000..4fd76c8921d1 --- /dev/null +++ b/examples/v1/key-management/UpdateClientToken.rb @@ -0,0 +1,16 @@ +# Update client token returns "OK" response + +require "datadog_api_client" +DatadogAPIClient.configure do |config| + config.unstable_operations["v1.update_client_token".to_sym] = true +end +api_instance = DatadogAPIClient::V1::KeyManagementAPI.new + +body = DatadogAPIClient::V1::ClientTokenUpdateRequest.new({ + _hash: "1234567890abcdef1234567890abcdef123", + name: "Updated Client Token Name", + origin_urls: [ + "https://example.com", + ], +}) +p api_instance.update_client_token(body) diff --git a/examples/v2/key-management/CreatePersonalAccessToken.rb b/examples/v2/key-management/CreatePersonalAccessToken.rb new file mode 100644 index 000000000000..9bead49617e5 --- /dev/null +++ b/examples/v2/key-management/CreatePersonalAccessToken.rb @@ -0,0 +1,22 @@ +# Create personal access token returns "OK" response + +require "datadog_api_client" +DatadogAPIClient.configure do |config| + config.unstable_operations["v2.create_personal_access_token".to_sym] = true +end +api_instance = DatadogAPIClient::V2::KeyManagementAPI.new + +body = DatadogAPIClient::V2::PersonalAccessTokenCreateRequest.new({ + data: DatadogAPIClient::V2::PersonalAccessTokenCreateData.new({ + attributes: DatadogAPIClient::V2::PersonalAccessTokenCreateAttributes.new({ + expires_at: "2025-03-15T10:30:00.000000+00:00", + name: "Example Personal Access Token", + scopes: [ + "dashboards_read", + "monitors_read", + ], + }), + type: DatadogAPIClient::V2::PersonalAccessTokenType::PERSONAL_ACCESS_TOKENS, + }), +}) +p api_instance.create_personal_access_token(body) diff --git a/examples/v2/key-management/GetPersonalAccessToken.rb b/examples/v2/key-management/GetPersonalAccessToken.rb new file mode 100644 index 000000000000..90ad612fa0c0 --- /dev/null +++ b/examples/v2/key-management/GetPersonalAccessToken.rb @@ -0,0 +1,8 @@ +# Get personal access token returns "OK" response + +require "datadog_api_client" +DatadogAPIClient.configure do |config| + config.unstable_operations["v2.get_personal_access_token".to_sym] = true +end +api_instance = DatadogAPIClient::V2::KeyManagementAPI.new +p api_instance.get_personal_access_token("9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d") diff --git a/examples/v2/key-management/ListPersonalAccessTokens.rb b/examples/v2/key-management/ListPersonalAccessTokens.rb new file mode 100644 index 000000000000..282563a6096b --- /dev/null +++ b/examples/v2/key-management/ListPersonalAccessTokens.rb @@ -0,0 +1,8 @@ +# List personal access tokens returns "OK" response + +require "datadog_api_client" +DatadogAPIClient.configure do |config| + config.unstable_operations["v2.list_personal_access_tokens".to_sym] = true +end +api_instance = DatadogAPIClient::V2::KeyManagementAPI.new +p api_instance.list_personal_access_tokens() diff --git a/examples/v2/key-management/RevokePersonalAccessToken.rb b/examples/v2/key-management/RevokePersonalAccessToken.rb new file mode 100644 index 000000000000..8d84addea22d --- /dev/null +++ b/examples/v2/key-management/RevokePersonalAccessToken.rb @@ -0,0 +1,8 @@ +# Revoke personal access token returns "No Content" response + +require "datadog_api_client" +DatadogAPIClient.configure do |config| + config.unstable_operations["v2.revoke_personal_access_token".to_sym] = true +end +api_instance = DatadogAPIClient::V2::KeyManagementAPI.new +api_instance.revoke_personal_access_token("9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d") diff --git a/examples/v2/key-management/UpdatePersonalAccessToken.rb b/examples/v2/key-management/UpdatePersonalAccessToken.rb new file mode 100644 index 000000000000..2c0eb797ac42 --- /dev/null +++ b/examples/v2/key-management/UpdatePersonalAccessToken.rb @@ -0,0 +1,22 @@ +# Update personal access token returns "OK" response + +require "datadog_api_client" +DatadogAPIClient.configure do |config| + config.unstable_operations["v2.update_personal_access_token".to_sym] = true +end +api_instance = DatadogAPIClient::V2::KeyManagementAPI.new + +body = DatadogAPIClient::V2::PersonalAccessTokenUpdateRequest.new({ + data: DatadogAPIClient::V2::PersonalAccessTokenUpdateData.new({ + attributes: DatadogAPIClient::V2::PersonalAccessTokenUpdateAttributes.new({ + name: "Updated Personal Access Token Name", + scopes: [ + "dashboards_read", + "dashboards_write", + ], + }), + id: "00000000-0000-0000-0000-000000000000", + type: DatadogAPIClient::V2::PersonalAccessTokenType::PERSONAL_ACCESS_TOKENS, + }), +}) +p api_instance.update_personal_access_token("9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d", body) diff --git a/features/scenarios_model_mapping.rb b/features/scenarios_model_mapping.rb index 833c51686656..ebc94212b5c9 100644 --- a/features/scenarios_model_mapping.rb +++ b/features/scenarios_model_mapping.rb @@ -25,6 +25,15 @@ "key" => "String", "body" => "ApplicationKey", }, + "v1.RevokeClientToken" => { + "body" => "ClientTokenRevokeRequest", + }, + "v1.CreateClientToken" => { + "body" => "ClientTokenCreateRequest", + }, + "v1.UpdateClientToken" => { + "body" => "ClientTokenUpdateRequest", + }, "v1.SubmitServiceCheck" => { "body" => "Array", }, @@ -1061,6 +1070,26 @@ "app_key_id" => "String", "body" => "ApplicationKeyUpdateRequest", }, + "v2.ListPersonalAccessTokens" => { + "page_size" => "Integer", + "page_number" => "Integer", + "sort" => "PersonalAccessTokensSort", + "filter" => "String", + "filter_owner_uuid" => "Array", + }, + "v2.CreatePersonalAccessToken" => { + "body" => "PersonalAccessTokenCreateRequest", + }, + "v2.RevokePersonalAccessToken" => { + "pat_uuid" => "UUID", + }, + "v2.GetPersonalAccessToken" => { + "pat_uuid" => "UUID", + }, + "v2.UpdatePersonalAccessToken" => { + "pat_uuid" => "UUID", + "body" => "PersonalAccessTokenUpdateRequest", + }, "v2.ListAPIs" => { "query" => "String", "page_limit" => "Integer", diff --git a/features/v1/key_management.feature b/features/v1/key_management.feature index c3f18c2346a1..7013ea44fedd 100644 --- a/features/v1/key_management.feature +++ b/features/v1/key_management.feature @@ -47,6 +47,22 @@ Feature: Key Management When the request is sent Then the response status is 200 OK + @generated @skip @team:DataDog/credentials-management + Scenario: Create client token returns "Bad Request" response + Given operation "CreateClientToken" enabled + And new "CreateClientToken" request + And body with value {"name": "Example Client Token", "origin_urls": ["https://example.com"]} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/credentials-management + Scenario: Create client token returns "OK" response + Given operation "CreateClientToken" enabled + And new "CreateClientToken" request + And body with value {"name": "Example Client Token", "origin_urls": ["https://example.com"]} + When the request is sent + Then the response status is 200 OK + @generated @skip @team:DataDog/credentials-management Scenario: Delete an API key returns "Bad Request" response Given new "DeleteAPIKey" request @@ -177,3 +193,51 @@ Feature: Key Management And request contains "key" parameter from "REPLACE.ME" When the request is sent Then the response status is 200 OK + + @generated @skip @team:DataDog/credentials-management + Scenario: Revoke client token returns "Bad Request" response + Given operation "RevokeClientToken" enabled + And new "RevokeClientToken" request + And body with value {"hash": "1234567890abcdef1234567890abcdef123"} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/credentials-management + Scenario: Revoke client token returns "No Content" response + Given operation "RevokeClientToken" enabled + And new "RevokeClientToken" request + And body with value {"hash": "1234567890abcdef1234567890abcdef123"} + When the request is sent + Then the response status is 204 No Content + + @generated @skip @team:DataDog/credentials-management + Scenario: Revoke client token returns "Not Found" response + Given operation "RevokeClientToken" enabled + And new "RevokeClientToken" request + And body with value {"hash": "1234567890abcdef1234567890abcdef123"} + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/credentials-management + Scenario: Update client token returns "Bad Request" response + Given operation "UpdateClientToken" enabled + And new "UpdateClientToken" request + And body with value {"hash": "1234567890abcdef1234567890abcdef123", "name": "Updated Client Token Name", "origin_urls": ["https://example.com"]} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/credentials-management + Scenario: Update client token returns "Not Found" response + Given operation "UpdateClientToken" enabled + And new "UpdateClientToken" request + And body with value {"hash": "1234567890abcdef1234567890abcdef123", "name": "Updated Client Token Name", "origin_urls": ["https://example.com"]} + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/credentials-management + Scenario: Update client token returns "OK" response + Given operation "UpdateClientToken" enabled + And new "UpdateClientToken" request + And body with value {"hash": "1234567890abcdef1234567890abcdef123", "name": "Updated Client Token Name", "origin_urls": ["https://example.com"]} + When the request is sent + Then the response status is 200 OK diff --git a/features/v1/undo.json b/features/v1/undo.json index 341ebe6c4eed..edc3c5f6a199 100644 --- a/features/v1/undo.json +++ b/features/v1/undo.json @@ -939,6 +939,31 @@ "type": "safe" } }, + "RevokeClientToken": { + "tag": "Key Management", + "undo": { + "type": "idempotent" + } + }, + "CreateClientToken": { + "tag": "Key Management", + "undo": { + "operationId": "RevokeClientToken", + "parameters": [ + { + "name": "hash", + "source": "data.hash" + } + ], + "type": "unsafe" + } + }, + "UpdateClientToken": { + "tag": "Key Management", + "undo": { + "type": "idempotent" + } + }, "QueryMetrics": { "tag": "Metrics", "undo": { diff --git a/features/v2/key_management.feature b/features/v2/key_management.feature index 40daf9df54f4..5adb2ecc95c0 100644 --- a/features/v2/key_management.feature +++ b/features/v2/key_management.feature @@ -53,6 +53,30 @@ Feature: Key Management And the response "data.type" is equal to "application_keys" And the response "data.attributes.name" is equal to "{{ unique }}" + @generated @skip @team:DataDog/credentials-management + Scenario: Create personal access token returns "Bad Request" response + Given operation "CreatePersonalAccessToken" enabled + And new "CreatePersonalAccessToken" request + And body with value {"data": {"attributes": {"expires_at": "2025-03-15T10:30:00.000000+00:00", "name": "Example Personal Access Token", "scopes": ["dashboards_read", "monitors_read"]}, "type": "personal_access_tokens"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/credentials-management + Scenario: Create personal access token returns "Not Found - Personal access tokens feature is not enabled" response + Given operation "CreatePersonalAccessToken" enabled + And new "CreatePersonalAccessToken" request + And body with value {"data": {"attributes": {"expires_at": "2025-03-15T10:30:00.000000+00:00", "name": "Example Personal Access Token", "scopes": ["dashboards_read", "monitors_read"]}, "type": "personal_access_tokens"}} + When the request is sent + Then the response status is 404 Not Found - Personal access tokens feature is not enabled + + @generated @skip @team:DataDog/credentials-management + Scenario: Create personal access token returns "OK" response + Given operation "CreatePersonalAccessToken" enabled + And new "CreatePersonalAccessToken" request + And body with value {"data": {"attributes": {"expires_at": "2025-03-15T10:30:00.000000+00:00", "name": "Example Personal Access Token", "scopes": ["dashboards_read", "monitors_read"]}, "type": "personal_access_tokens"}} + When the request is sent + Then the response status is 200 OK + @team:DataDog/credentials-management Scenario: Delete an API key returns "No Content" response Given there is a valid "api_key" in the system @@ -301,3 +325,83 @@ Feature: Key Management And the response "data.attributes.name" is equal to "{{ application_key.data.attributes.name }}" And the response "data.attributes" has field "scopes" And the response "data.attributes" has field "last_used_at" + + @generated @skip @team:DataDog/credentials-management + Scenario: Get personal access token returns "Not Found" response + Given operation "GetPersonalAccessToken" enabled + And new "GetPersonalAccessToken" request + And request contains "pat_uuid" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/credentials-management + Scenario: Get personal access token returns "OK" response + Given operation "GetPersonalAccessToken" enabled + And new "GetPersonalAccessToken" request + And request contains "pat_uuid" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:DataDog/credentials-management + Scenario: List personal access tokens returns "Bad Request" response + Given operation "ListPersonalAccessTokens" enabled + And new "ListPersonalAccessTokens" request + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/credentials-management + Scenario: List personal access tokens returns "Not Found - Personal access tokens feature is not enabled" response + Given operation "ListPersonalAccessTokens" enabled + And new "ListPersonalAccessTokens" request + When the request is sent + Then the response status is 404 Not Found - Personal access tokens feature is not enabled + + @generated @skip @team:DataDog/credentials-management + Scenario: List personal access tokens returns "OK" response + Given operation "ListPersonalAccessTokens" enabled + And new "ListPersonalAccessTokens" request + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:DataDog/credentials-management + Scenario: Revoke personal access token returns "No Content" response + Given operation "RevokePersonalAccessToken" enabled + And new "RevokePersonalAccessToken" request + And request contains "pat_uuid" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 204 No Content + + @generated @skip @team:DataDog/credentials-management + Scenario: Revoke personal access token returns "Not Found" response + Given operation "RevokePersonalAccessToken" enabled + And new "RevokePersonalAccessToken" request + And request contains "pat_uuid" 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 personal access token returns "Bad Request" response + Given operation "UpdatePersonalAccessToken" enabled + And new "UpdatePersonalAccessToken" request + And request contains "pat_uuid" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"name": "Updated Personal Access Token Name", "scopes": ["dashboards_read", "dashboards_write"]}, "id": "00000000-0000-0000-0000-000000000000", "type": "personal_access_tokens"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/credentials-management + Scenario: Update personal access token returns "Not Found" response + Given operation "UpdatePersonalAccessToken" enabled + And new "UpdatePersonalAccessToken" request + And request contains "pat_uuid" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"name": "Updated Personal Access Token Name", "scopes": ["dashboards_read", "dashboards_write"]}, "id": "00000000-0000-0000-0000-000000000000", "type": "personal_access_tokens"}} + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/credentials-management + Scenario: Update personal access token returns "OK" response + Given operation "UpdatePersonalAccessToken" enabled + And new "UpdatePersonalAccessToken" request + And request contains "pat_uuid" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"name": "Updated Personal Access Token Name", "scopes": ["dashboards_read", "dashboards_write"]}, "id": "00000000-0000-0000-0000-000000000000", "type": "personal_access_tokens"}} + 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 c77dfee33568..4828520126af 100644 --- a/features/v2/undo.json +++ b/features/v2/undo.json @@ -3424,6 +3424,43 @@ "type": "safe" } }, + "ListPersonalAccessTokens": { + "tag": "Key Management", + "undo": { + "type": "safe" + } + }, + "CreatePersonalAccessToken": { + "tag": "Key Management", + "undo": { + "operationId": "RevokePersonalAccessToken", + "parameters": [ + { + "name": "pat_uuid", + "source": "data.id" + } + ], + "type": "unsafe" + } + }, + "RevokePersonalAccessToken": { + "tag": "Key Management", + "undo": { + "type": "idempotent" + } + }, + "GetPersonalAccessToken": { + "tag": "Key Management", + "undo": { + "type": "safe" + } + }, + "UpdatePersonalAccessToken": { + "tag": "Key Management", + "undo": { + "type": "idempotent" + } + }, "ListFindings": { "tag": "Security Monitoring", "undo": { diff --git a/lib/datadog_api_client/configuration.rb b/lib/datadog_api_client/configuration.rb index f51747c826ed..caf340ab260f 100644 --- a/lib/datadog_api_client/configuration.rb +++ b/lib/datadog_api_client/configuration.rb @@ -189,6 +189,9 @@ def initialize @http_proxypass = nil @logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT) @unstable_operations = { + "v1.create_client_token": false, + "v1.revoke_client_token": false, + "v1.update_client_token": false, "v2.cancel_fleet_deployment": false, "v2.create_fleet_deployment_configure": false, "v2.create_fleet_deployment_upgrade": false, @@ -203,6 +206,11 @@ def initialize "v2.list_fleet_schedules": false, "v2.trigger_fleet_schedule": false, "v2.update_fleet_schedule": false, + "v2.create_personal_access_token": false, + "v2.get_personal_access_token": false, + "v2.list_personal_access_tokens": false, + "v2.revoke_personal_access_token": false, + "v2.update_personal_access_token": 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 5e43080ff1dc..4d5dc4887662 100644 --- a/lib/datadog_api_client/inflector.rb +++ b/lib/datadog_api_client/inflector.rb @@ -75,6 +75,10 @@ def overrides "v1.check_can_delete_slo_response_data" => "CheckCanDeleteSLOResponseData", "v1.check_status_widget_definition" => "CheckStatusWidgetDefinition", "v1.check_status_widget_definition_type" => "CheckStatusWidgetDefinitionType", + "v1.client_token" => "ClientToken", + "v1.client_token_create_request" => "ClientTokenCreateRequest", + "v1.client_token_revoke_request" => "ClientTokenRevokeRequest", + "v1.client_token_update_request" => "ClientTokenUpdateRequest", "v1.content_encoding" => "ContentEncoding", "v1.creator" => "Creator", "v1.dashboard" => "Dashboard", @@ -2492,6 +2496,8 @@ def overrides "v2.full_application_key_attributes" => "FullApplicationKeyAttributes", "v2.full_custom_framework_data" => "FullCustomFrameworkData", "v2.full_custom_framework_data_attributes" => "FullCustomFrameworkDataAttributes", + "v2.full_personal_access_token" => "FullPersonalAccessToken", + "v2.full_personal_access_token_attributes" => "FullPersonalAccessTokenAttributes", "v2.gcp_credentials" => "GCPCredentials", "v2.gcp_credentials_update" => "GCPCredentialsUpdate", "v2.gcp_integration" => "GCPIntegration", @@ -3761,6 +3767,22 @@ def overrides "v2.permission_attributes" => "PermissionAttributes", "v2.permissions_response" => "PermissionsResponse", "v2.permissions_type" => "PermissionsType", + "v2.personal_access_token" => "PersonalAccessToken", + "v2.personal_access_token_attributes" => "PersonalAccessTokenAttributes", + "v2.personal_access_token_create_attributes" => "PersonalAccessTokenCreateAttributes", + "v2.personal_access_token_create_data" => "PersonalAccessTokenCreateData", + "v2.personal_access_token_create_request" => "PersonalAccessTokenCreateRequest", + "v2.personal_access_token_get_response" => "PersonalAccessTokenGetResponse", + "v2.personal_access_token_relationships" => "PersonalAccessTokenRelationships", + "v2.personal_access_token_response" => "PersonalAccessTokenResponse", + "v2.personal_access_tokens_list_response" => "PersonalAccessTokensListResponse", + "v2.personal_access_tokens_response_meta" => "PersonalAccessTokensResponseMeta", + "v2.personal_access_tokens_response_meta_page" => "PersonalAccessTokensResponseMetaPage", + "v2.personal_access_tokens_sort" => "PersonalAccessTokensSort", + "v2.personal_access_token_type" => "PersonalAccessTokenType", + "v2.personal_access_token_update_attributes" => "PersonalAccessTokenUpdateAttributes", + "v2.personal_access_token_update_data" => "PersonalAccessTokenUpdateData", + "v2.personal_access_token_update_request" => "PersonalAccessTokenUpdateRequest", "v2.playlist" => "Playlist", "v2.playlist_array" => "PlaylistArray", "v2.playlist_data" => "PlaylistData", diff --git a/lib/datadog_api_client/v1/api/key_management_api.rb b/lib/datadog_api_client/v1/api/key_management_api.rb index d36d55cb9043..76d666a74652 100644 --- a/lib/datadog_api_client/v1/api/key_management_api.rb +++ b/lib/datadog_api_client/v1/api/key_management_api.rb @@ -158,6 +158,80 @@ def create_application_key_with_http_info(body, opts = {}) return data, status_code, headers end + # Create client token. + # + # @see #create_client_token_with_http_info + def create_client_token(body, opts = {}) + data, _status_code, _headers = create_client_token_with_http_info(body, opts) + data + end + + # Create client token. + # + # Create a new client token (public API key) to submit data from your browser or mobile + # applications to Datadog. + # + # @param body [ClientTokenCreateRequest] + # @param opts [Hash] the optional parameters + # @return [Array<(ClientToken, Integer, Hash)>] ClientToken data, response status code and response headers + def create_client_token_with_http_info(body, opts = {}) + unstable_enabled = @api_client.config.unstable_operations["v1.create_client_token".to_sym] + if unstable_enabled + @api_client.config.logger.warn format("Using unstable operation '%s'", "v1.create_client_token") + else + raise DatadogAPIClient::APIError.new(message: format("Unstable operation '%s' is disabled", "v1.create_client_token")) + end + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: KeyManagementAPI.create_client_token ...' + end + # verify the required parameter 'body' is set + if @api_client.config.client_side_validation && body.nil? + fail ArgumentError, "Missing the required parameter 'body' when calling KeyManagementAPI.create_client_token" + end + # resource path + local_var_path = '/api/v1/public_api_key' + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + # HTTP header 'Content-Type' + header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] || @api_client.object_to_http_body(body) + + # return_type + return_type = opts[:debug_return_type] || 'ClientToken' + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth, :AuthZ] + + new_options = opts.merge( + :operation => :create_client_token, + :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 => "V1" + ) + + data, status_code, headers = @api_client.call_api(Net::HTTP::Post, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: KeyManagementAPI#create_client_token\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + # Delete an API key. # # @see #delete_api_key_with_http_info @@ -541,6 +615,80 @@ def list_application_keys_with_http_info(opts = {}) return data, status_code, headers end + # Revoke client token. + # + # @see #revoke_client_token_with_http_info + def revoke_client_token(body, opts = {}) + revoke_client_token_with_http_info(body, opts) + nil + end + + # Revoke client token. + # + # Revoke a client token (public API key). Once revoked, the token can no longer be used + # to submit data to Datadog. + # + # @param body [ClientTokenRevokeRequest] + # @param opts [Hash] the optional parameters + # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers + def revoke_client_token_with_http_info(body, opts = {}) + unstable_enabled = @api_client.config.unstable_operations["v1.revoke_client_token".to_sym] + if unstable_enabled + @api_client.config.logger.warn format("Using unstable operation '%s'", "v1.revoke_client_token") + else + raise DatadogAPIClient::APIError.new(message: format("Unstable operation '%s' is disabled", "v1.revoke_client_token")) + end + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: KeyManagementAPI.revoke_client_token ...' + end + # verify the required parameter 'body' is set + if @api_client.config.client_side_validation && body.nil? + fail ArgumentError, "Missing the required parameter 'body' when calling KeyManagementAPI.revoke_client_token" + end + # resource path + local_var_path = '/api/v1/public_api_key' + + # 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(['*/*']) + # HTTP header 'Content-Type' + header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] || @api_client.object_to_http_body(body) + + # return_type + return_type = opts[:debug_return_type] + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth, :AuthZ] + + new_options = opts.merge( + :operation => :revoke_client_token, + :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 => "V1" + ) + + data, status_code, headers = @api_client.call_api(Net::HTTP::Delete, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: KeyManagementAPI#revoke_client_token\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + # Edit an API key. # # @see #update_api_key_with_http_info @@ -685,5 +833,78 @@ def update_application_key_with_http_info(key, body, opts = {}) end return data, status_code, headers end + + # Update client token. + # + # @see #update_client_token_with_http_info + def update_client_token(body, opts = {}) + data, _status_code, _headers = update_client_token_with_http_info(body, opts) + data + end + + # Update client token. + # + # Update the name and/or origin URLs of an existing client token (public API key). + # + # @param body [ClientTokenUpdateRequest] + # @param opts [Hash] the optional parameters + # @return [Array<(ClientToken, Integer, Hash)>] ClientToken data, response status code and response headers + def update_client_token_with_http_info(body, opts = {}) + unstable_enabled = @api_client.config.unstable_operations["v1.update_client_token".to_sym] + if unstable_enabled + @api_client.config.logger.warn format("Using unstable operation '%s'", "v1.update_client_token") + else + raise DatadogAPIClient::APIError.new(message: format("Unstable operation '%s' is disabled", "v1.update_client_token")) + end + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: KeyManagementAPI.update_client_token ...' + end + # verify the required parameter 'body' is set + if @api_client.config.client_side_validation && body.nil? + fail ArgumentError, "Missing the required parameter 'body' when calling KeyManagementAPI.update_client_token" + end + # resource path + local_var_path = '/api/v1/public_api_key' + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + # HTTP header 'Content-Type' + header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] || @api_client.object_to_http_body(body) + + # return_type + return_type = opts[:debug_return_type] || 'ClientToken' + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth, :AuthZ] + + new_options = opts.merge( + :operation => :update_client_token, + :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 => "V1" + ) + + data, status_code, headers = @api_client.call_api(Net::HTTP::Put, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: KeyManagementAPI#update_client_token\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/v1/models/client_token.rb b/lib/datadog_api_client/v1/models/client_token.rb new file mode 100644 index 000000000000..acd215f0255a --- /dev/null +++ b/lib/datadog_api_client/v1/models/client_token.rb @@ -0,0 +1,266 @@ +=begin +#Datadog API V1 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::V1 + # Client token object. Client tokens (also known as public API keys) enable you to submit + # data from your browser or mobile applications to Datadog. + class ClientToken + include BaseGenericModel + + # Creation timestamp of the client token. + attr_accessor :created_at + + # Handle of the user who created the client token. + attr_accessor :created_by_handle + + # UUID of the user who created the client token. + attr_accessor :created_by_uuid + + # Timestamp when the client token was disabled. + attr_accessor :disabled_at + + # ID of the user who disabled the client token. + attr_accessor :disabled_by + + # Handle of the user who disabled the client token. + attr_accessor :disabled_by_handle + + # The hash value of the client token. This is the secret token value that should be + # used in your browser or mobile application. + attr_reader :_hash + + # ID of the user who last modified the client token. + attr_accessor :modified_by + + # Name of the client token. + attr_reader :name + + # Organization ID associated with the client token. + attr_accessor :org_id + + # List of allowed origin URLs for browser-based applications. Requests from URLs + # not in this list will be rejected. + attr_reader :origin_urls + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'created_at' => :'created_at', + :'created_by_handle' => :'created_by_handle', + :'created_by_uuid' => :'created_by_uuid', + :'disabled_at' => :'disabled_at', + :'disabled_by' => :'disabled_by', + :'disabled_by_handle' => :'disabled_by_handle', + :'_hash' => :'hash', + :'modified_by' => :'modified_by', + :'name' => :'name', + :'org_id' => :'org_id', + :'origin_urls' => :'origin_urls' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'created_at' => :'Time', + :'created_by_handle' => :'String', + :'created_by_uuid' => :'UUID', + :'disabled_at' => :'Time', + :'disabled_by' => :'Integer', + :'disabled_by_handle' => :'String', + :'_hash' => :'String', + :'modified_by' => :'Integer', + :'name' => :'String', + :'org_id' => :'Integer', + :'origin_urls' => :'Array' + } + end + + # List of attributes with nullable: true + # @!visibility private + def self.openapi_nullable + Set.new([ + :'disabled_at', + ]) + 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::V1::ClientToken` 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?(:'created_at') + self.created_at = attributes[:'created_at'] + end + + if attributes.key?(:'created_by_handle') + self.created_by_handle = attributes[:'created_by_handle'] + end + + if attributes.key?(:'created_by_uuid') + self.created_by_uuid = attributes[:'created_by_uuid'] + end + + if attributes.key?(:'disabled_at') + self.disabled_at = attributes[:'disabled_at'] + end + + if attributes.key?(:'disabled_by') + self.disabled_by = attributes[:'disabled_by'] + end + + if attributes.key?(:'disabled_by_handle') + self.disabled_by_handle = attributes[:'disabled_by_handle'] + end + + if attributes.key?(:'_hash') + self._hash = attributes[:'_hash'] + end + + if attributes.key?(:'modified_by') + self.modified_by = attributes[:'modified_by'] + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'org_id') + self.org_id = attributes[:'org_id'] + end + + if attributes.key?(:'origin_urls') + if (value = attributes[:'origin_urls']).is_a?(Array) + self.origin_urls = value + end + 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 !@_hash.nil? && @_hash.to_s.length > 35 + return false if !@name.nil? && @name.to_s.length > 255 + return false if !@name.nil? && @name.to_s.length < 1 + return false if @origin_urls.nil? + return false if @origin_urls.length > 100 + true + end + + # Custom attribute writer method with validation + # @param _hash [Object] Object to be assigned + # @!visibility private + def _hash=(_hash) + if !_hash.nil? && _hash.to_s.length > 35 + fail ArgumentError, 'invalid value for "_hash", the character length must be smaller than or equal to 35.' + end + @_hash = _hash + end + + # Custom attribute writer method with validation + # @param name [Object] Object to be assigned + # @!visibility private + def name=(name) + if !name.nil? && name.to_s.length > 255 + fail ArgumentError, 'invalid value for "name", the character length must be smaller than or equal to 255.' + end + if !name.nil? && name.to_s.length < 1 + fail ArgumentError, 'invalid value for "name", the character length must be great than or equal to 1.' + end + @name = name + end + + # Custom attribute writer method with validation + # @param origin_urls [Object] Object to be assigned + # @!visibility private + def origin_urls=(origin_urls) + if origin_urls.nil? + fail ArgumentError, 'invalid value for "origin_urls", origin_urls cannot be nil.' + end + if origin_urls.length > 100 + fail ArgumentError, 'invalid value for "origin_urls", number of items must be less than or equal to 100.' + end + @origin_urls = origin_urls + 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 && + created_at == o.created_at && + created_by_handle == o.created_by_handle && + created_by_uuid == o.created_by_uuid && + disabled_at == o.disabled_at && + disabled_by == o.disabled_by && + disabled_by_handle == o.disabled_by_handle && + _hash == o._hash && + modified_by == o.modified_by && + name == o.name && + org_id == o.org_id && + origin_urls == o.origin_urls && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [created_at, created_by_handle, created_by_uuid, disabled_at, disabled_by, disabled_by_handle, _hash, modified_by, name, org_id, origin_urls, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v1/models/client_token_create_request.rb b/lib/datadog_api_client/v1/models/client_token_create_request.rb new file mode 100644 index 000000000000..15d480f9a55b --- /dev/null +++ b/lib/datadog_api_client/v1/models/client_token_create_request.rb @@ -0,0 +1,159 @@ +=begin +#Datadog API V1 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::V1 + # Request to create a new client token. + class ClientTokenCreateRequest + include BaseGenericModel + + # Name of the client token. + attr_reader :name + + # List of allowed origin URLs for browser-based applications. Requests from URLs + # not in this list will be rejected. + attr_reader :origin_urls + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'name' => :'name', + :'origin_urls' => :'origin_urls' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'name' => :'String', + :'origin_urls' => :'Array' + } + 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::V1::ClientTokenCreateRequest` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'origin_urls') + if (value = attributes[:'origin_urls']).is_a?(Array) + self.origin_urls = value + end + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @name.nil? + return false if @name.to_s.length > 255 + return false if @name.to_s.length < 1 + return false if @origin_urls.nil? + return false if @origin_urls.length > 100 + true + end + + # Custom attribute writer method with validation + # @param name [Object] Object to be assigned + # @!visibility private + def name=(name) + if name.nil? + fail ArgumentError, 'invalid value for "name", name cannot be nil.' + end + if name.to_s.length > 255 + fail ArgumentError, 'invalid value for "name", the character length must be smaller than or equal to 255.' + end + if name.to_s.length < 1 + fail ArgumentError, 'invalid value for "name", the character length must be great than or equal to 1.' + end + @name = name + end + + # Custom attribute writer method with validation + # @param origin_urls [Object] Object to be assigned + # @!visibility private + def origin_urls=(origin_urls) + if origin_urls.nil? + fail ArgumentError, 'invalid value for "origin_urls", origin_urls cannot be nil.' + end + if origin_urls.length > 100 + fail ArgumentError, 'invalid value for "origin_urls", number of items must be less than or equal to 100.' + end + @origin_urls = origin_urls + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + name == o.name && + origin_urls == o.origin_urls && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [name, origin_urls, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v1/models/client_token_revoke_request.rb b/lib/datadog_api_client/v1/models/client_token_revoke_request.rb new file mode 100644 index 000000000000..ce57aee2271c --- /dev/null +++ b/lib/datadog_api_client/v1/models/client_token_revoke_request.rb @@ -0,0 +1,127 @@ +=begin +#Datadog API V1 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::V1 + # Request to revoke a client token. + class ClientTokenRevokeRequest + include BaseGenericModel + + # Hash value of the client token to revoke. + attr_reader :_hash + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'_hash' => :'hash' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'_hash' => :'String' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V1::ClientTokenRevokeRequest` 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?(:'_hash') + self._hash = attributes[:'_hash'] + 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 @_hash.nil? + return false if @_hash.to_s.length > 35 + true + end + + # Custom attribute writer method with validation + # @param _hash [Object] Object to be assigned + # @!visibility private + def _hash=(_hash) + if _hash.nil? + fail ArgumentError, 'invalid value for "_hash", _hash cannot be nil.' + end + if _hash.to_s.length > 35 + fail ArgumentError, 'invalid value for "_hash", the character length must be smaller than or equal to 35.' + end + @_hash = _hash + 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 && + _hash == o._hash && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [_hash, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v1/models/client_token_update_request.rb b/lib/datadog_api_client/v1/models/client_token_update_request.rb new file mode 100644 index 000000000000..de6cb35ae1cd --- /dev/null +++ b/lib/datadog_api_client/v1/models/client_token_update_request.rb @@ -0,0 +1,179 @@ +=begin +#Datadog API V1 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::V1 + # Request to update an existing client token. + class ClientTokenUpdateRequest + include BaseGenericModel + + # Hash value of the client token to update. + attr_reader :_hash + + # New name for the client token. + attr_reader :name + + # New list of allowed origin URLs. If provided, this will replace the existing list. + attr_reader :origin_urls + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'_hash' => :'hash', + :'name' => :'name', + :'origin_urls' => :'origin_urls' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'_hash' => :'String', + :'name' => :'String', + :'origin_urls' => :'Array' + } + 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::V1::ClientTokenUpdateRequest` 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?(:'_hash') + self._hash = attributes[:'_hash'] + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'origin_urls') + if (value = attributes[:'origin_urls']).is_a?(Array) + self.origin_urls = value + end + 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 @_hash.nil? + return false if @_hash.to_s.length > 35 + return false if @name.nil? + return false if @name.to_s.length > 255 + return false if @name.to_s.length < 1 + return false if !@origin_urls.nil? && @origin_urls.length > 100 + true + end + + # Custom attribute writer method with validation + # @param _hash [Object] Object to be assigned + # @!visibility private + def _hash=(_hash) + if _hash.nil? + fail ArgumentError, 'invalid value for "_hash", _hash cannot be nil.' + end + if _hash.to_s.length > 35 + fail ArgumentError, 'invalid value for "_hash", the character length must be smaller than or equal to 35.' + end + @_hash = _hash + end + + # Custom attribute writer method with validation + # @param name [Object] Object to be assigned + # @!visibility private + def name=(name) + if name.nil? + fail ArgumentError, 'invalid value for "name", name cannot be nil.' + end + if name.to_s.length > 255 + fail ArgumentError, 'invalid value for "name", the character length must be smaller than or equal to 255.' + end + if name.to_s.length < 1 + fail ArgumentError, 'invalid value for "name", the character length must be great than or equal to 1.' + end + @name = name + end + + # Custom attribute writer method with validation + # @param origin_urls [Object] Object to be assigned + # @!visibility private + def origin_urls=(origin_urls) + if !origin_urls.nil? && origin_urls.length > 100 + fail ArgumentError, 'invalid value for "origin_urls", number of items must be less than or equal to 100.' + end + @origin_urls = origin_urls + 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 && + _hash == o._hash && + name == o.name && + origin_urls == o.origin_urls && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [_hash, name, origin_urls, additional_properties].hash + end + end +end 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 76838462a2b4..431b3d43c4ea 100644 --- a/lib/datadog_api_client/v2/api/key_management_api.rb +++ b/lib/datadog_api_client/v2/api/key_management_api.rb @@ -157,6 +157,81 @@ def create_current_user_application_key_with_http_info(body, opts = {}) return data, status_code, headers end + # Create personal access token. + # + # @see #create_personal_access_token_with_http_info + def create_personal_access_token(body, opts = {}) + data, _status_code, _headers = create_personal_access_token_with_http_info(body, opts) + data + end + + # Create personal access token. + # + # Create a new personal access token with fine-grained permissions. The token value + # will be returned in the response and cannot be retrieved later. Be sure to save it + # securely. + # + # @param body [PersonalAccessTokenCreateRequest] + # @param opts [Hash] the optional parameters + # @return [Array<(PersonalAccessTokenResponse, Integer, Hash)>] PersonalAccessTokenResponse data, response status code and response headers + def create_personal_access_token_with_http_info(body, opts = {}) + unstable_enabled = @api_client.config.unstable_operations["v2.create_personal_access_token".to_sym] + if unstable_enabled + @api_client.config.logger.warn format("Using unstable operation '%s'", "v2.create_personal_access_token") + else + raise DatadogAPIClient::APIError.new(message: format("Unstable operation '%s' is disabled", "v2.create_personal_access_token")) + end + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: KeyManagementAPI.create_personal_access_token ...' + end + # verify the required parameter 'body' is set + if @api_client.config.client_side_validation && body.nil? + fail ArgumentError, "Missing the required parameter 'body' when calling KeyManagementAPI.create_personal_access_token" + end + # resource path + local_var_path = '/api/v2/personal_access_tokens' + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + # HTTP header 'Content-Type' + header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] || @api_client.object_to_http_body(body) + + # return_type + return_type = opts[:debug_return_type] || 'PersonalAccessTokenResponse' + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth, :AuthZ] + + new_options = opts.merge( + :operation => :create_personal_access_token, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type, + :api_version => "V2" + ) + + data, status_code, headers = @api_client.call_api(Net::HTTP::Post, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: KeyManagementAPI#create_personal_access_token\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + # Delete an API key. # # @see #delete_api_key_with_http_info @@ -552,6 +627,77 @@ def get_current_user_application_key_with_http_info(app_key_id, opts = {}) return data, status_code, headers end + # Get personal access token. + # + # @see #get_personal_access_token_with_http_info + def get_personal_access_token(pat_uuid, opts = {}) + data, _status_code, _headers = get_personal_access_token_with_http_info(pat_uuid, opts) + data + end + + # Get personal access token. + # + # Get a specific personal access token by UUID. + # + # @param pat_uuid [UUID] The UUID of the personal access token. + # @param opts [Hash] the optional parameters + # @return [Array<(PersonalAccessTokenGetResponse, Integer, Hash)>] PersonalAccessTokenGetResponse data, response status code and response headers + def get_personal_access_token_with_http_info(pat_uuid, opts = {}) + unstable_enabled = @api_client.config.unstable_operations["v2.get_personal_access_token".to_sym] + if unstable_enabled + @api_client.config.logger.warn format("Using unstable operation '%s'", "v2.get_personal_access_token") + else + raise DatadogAPIClient::APIError.new(message: format("Unstable operation '%s' is disabled", "v2.get_personal_access_token")) + end + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: KeyManagementAPI.get_personal_access_token ...' + end + # verify the required parameter 'pat_uuid' is set + if @api_client.config.client_side_validation && pat_uuid.nil? + fail ArgumentError, "Missing the required parameter 'pat_uuid' when calling KeyManagementAPI.get_personal_access_token" + end + # resource path + local_var_path = '/api/v2/personal_access_tokens/{pat_uuid}'.sub('{pat_uuid}', CGI.escape(pat_uuid.to_s).gsub('%2F', '/')) + + # 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] || 'PersonalAccessTokenGetResponse' + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth, :AuthZ] + + new_options = opts.merge( + :operation => :get_personal_access_token, + :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#get_personal_access_token\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + # Get all API keys. # # @see #list_api_keys_with_http_info @@ -794,6 +940,160 @@ def list_current_user_application_keys_with_http_info(opts = {}) return data, status_code, headers end + # List personal access tokens. + # + # @see #list_personal_access_tokens_with_http_info + def list_personal_access_tokens(opts = {}) + data, _status_code, _headers = list_personal_access_tokens_with_http_info(opts) + data + end + + # List personal access tokens. + # + # List all personal access tokens in your organization. Supports filtering, + # pagination, and sorting. + # + # @param opts [Hash] the optional parameters + # @option opts [Integer] :page_size Size for a given page. The maximum allowed value is 100. + # @option opts [Integer] :page_number Specific page number to return. + # @option opts [PersonalAccessTokensSort] :sort Personal access token attribute used to sort results. Sort order is ascending by default. In order to specify a descending sort, prefix the attribute with a minus sign. + # @option opts [String] :filter Filter personal access tokens by name. + # @option opts [Array] :filter_owner_uuid Filter personal access tokens by owner UUID. + # @return [Array<(PersonalAccessTokensListResponse, Integer, Hash)>] PersonalAccessTokensListResponse data, response status code and response headers + def list_personal_access_tokens_with_http_info(opts = {}) + unstable_enabled = @api_client.config.unstable_operations["v2.list_personal_access_tokens".to_sym] + if unstable_enabled + @api_client.config.logger.warn format("Using unstable operation '%s'", "v2.list_personal_access_tokens") + else + raise DatadogAPIClient::APIError.new(message: format("Unstable operation '%s' is disabled", "v2.list_personal_access_tokens")) + end + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: KeyManagementAPI.list_personal_access_tokens ...' + end + allowable_values = ['name', '-name', 'created_at', '-created_at', 'expires_at', '-expires_at'] + 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 + # resource path + local_var_path = '/api/v2/personal_access_tokens' + + # query parameters + query_params = opts[:query_params] || {} + query_params[:'page[size]'] = opts[:'page_size'] if !opts[:'page_size'].nil? + query_params[:'page[number]'] = opts[:'page_number'] if !opts[:'page_number'].nil? + query_params[:'sort'] = opts[:'sort'] if !opts[:'sort'].nil? + query_params[:'filter'] = opts[:'filter'] if !opts[:'filter'].nil? + query_params[:'filter[owner_uuid]'] = @api_client.build_collection_param(opts[:'filter_owner_uuid'], :multi) if !opts[:'filter_owner_uuid'].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] || 'PersonalAccessTokensListResponse' + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth, :AuthZ] + + new_options = opts.merge( + :operation => :list_personal_access_tokens, + :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" + ) + new_options[:query_string_normalizer] = HTTParty::Request::NON_RAILS_QUERY_STRING_NORMALIZER + + 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#list_personal_access_tokens\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + + # Revoke personal access token. + # + # @see #revoke_personal_access_token_with_http_info + def revoke_personal_access_token(pat_uuid, opts = {}) + revoke_personal_access_token_with_http_info(pat_uuid, opts) + nil + end + + # Revoke personal access token. + # + # Revoke a personal access token. Once revoked, the token can no longer be used + # to authenticate API requests. + # + # @param pat_uuid [UUID] The UUID of the personal access token. + # @param opts [Hash] the optional parameters + # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers + def revoke_personal_access_token_with_http_info(pat_uuid, opts = {}) + unstable_enabled = @api_client.config.unstable_operations["v2.revoke_personal_access_token".to_sym] + if unstable_enabled + @api_client.config.logger.warn format("Using unstable operation '%s'", "v2.revoke_personal_access_token") + else + raise DatadogAPIClient::APIError.new(message: format("Unstable operation '%s' is disabled", "v2.revoke_personal_access_token")) + end + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: KeyManagementAPI.revoke_personal_access_token ...' + end + # verify the required parameter 'pat_uuid' is set + if @api_client.config.client_side_validation && pat_uuid.nil? + fail ArgumentError, "Missing the required parameter 'pat_uuid' when calling KeyManagementAPI.revoke_personal_access_token" + end + # resource path + local_var_path = '/api/v2/personal_access_tokens/{pat_uuid}'.sub('{pat_uuid}', CGI.escape(pat_uuid.to_s).gsub('%2F', '/')) + + # 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(['*/*']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth, :AuthZ] + + new_options = opts.merge( + :operation => :revoke_personal_access_token, + :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::Delete, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: KeyManagementAPI#revoke_personal_access_token\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + # Edit an API key. # # @see #update_api_key_with_http_info @@ -1010,5 +1310,84 @@ def update_current_user_application_key_with_http_info(app_key_id, body, opts = end return data, status_code, headers end + + # Update personal access token. + # + # @see #update_personal_access_token_with_http_info + def update_personal_access_token(pat_uuid, body, opts = {}) + data, _status_code, _headers = update_personal_access_token_with_http_info(pat_uuid, body, opts) + data + end + + # Update personal access token. + # + # Update the name and/or scopes of an existing personal access token. The ID in the + # request body must match the UUID in the path. + # + # @param pat_uuid [UUID] The UUID of the personal access token. + # @param body [PersonalAccessTokenUpdateRequest] + # @param opts [Hash] the optional parameters + # @return [Array<(PersonalAccessTokenGetResponse, Integer, Hash)>] PersonalAccessTokenGetResponse data, response status code and response headers + def update_personal_access_token_with_http_info(pat_uuid, body, opts = {}) + unstable_enabled = @api_client.config.unstable_operations["v2.update_personal_access_token".to_sym] + if unstable_enabled + @api_client.config.logger.warn format("Using unstable operation '%s'", "v2.update_personal_access_token") + else + raise DatadogAPIClient::APIError.new(message: format("Unstable operation '%s' is disabled", "v2.update_personal_access_token")) + end + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: KeyManagementAPI.update_personal_access_token ...' + end + # verify the required parameter 'pat_uuid' is set + if @api_client.config.client_side_validation && pat_uuid.nil? + fail ArgumentError, "Missing the required parameter 'pat_uuid' when calling KeyManagementAPI.update_personal_access_token" + end + # verify the required parameter 'body' is set + if @api_client.config.client_side_validation && body.nil? + fail ArgumentError, "Missing the required parameter 'body' when calling KeyManagementAPI.update_personal_access_token" + end + # resource path + local_var_path = '/api/v2/personal_access_tokens/{pat_uuid}'.sub('{pat_uuid}', CGI.escape(pat_uuid.to_s).gsub('%2F', '/')) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + # HTTP header 'Content-Type' + header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] || @api_client.object_to_http_body(body) + + # return_type + return_type = opts[:debug_return_type] || 'PersonalAccessTokenGetResponse' + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth, :AuthZ] + + new_options = opts.merge( + :operation => :update_personal_access_token, + :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::Patch, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: KeyManagementAPI#update_personal_access_token\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/full_personal_access_token.rb b/lib/datadog_api_client/v2/models/full_personal_access_token.rb new file mode 100644 index 000000000000..1cd4bc44820d --- /dev/null +++ b/lib/datadog_api_client/v2/models/full_personal_access_token.rb @@ -0,0 +1,188 @@ +=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 + # Personal access token object with the secret key value. This is only + # returned when creating a new token. + class FullPersonalAccessToken + include BaseGenericModel + + # Attributes of a personal access token including the secret key value. + # This is only returned when creating a new token. + attr_reader :attributes + + # UUID of the personal access token. + attr_reader :id + + # Resources related to the personal access token. + attr_reader :relationships + + # Personal access tokens resource type. + 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', + :'relationships' => :'relationships', + :'type' => :'type' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'attributes' => :'FullPersonalAccessTokenAttributes', + :'id' => :'UUID', + :'relationships' => :'PersonalAccessTokenRelationships', + :'type' => :'PersonalAccessTokenType' + } + 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::FullPersonalAccessToken` 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?(:'relationships') + self.relationships = attributes[:'relationships'] + 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 @relationships.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 relationships [Object] Object to be assigned + # @!visibility private + def relationships=(relationships) + if relationships.nil? + fail ArgumentError, 'invalid value for "relationships", relationships cannot be nil.' + end + @relationships = relationships + 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 && + relationships == o.relationships && + 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, relationships, type, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/full_personal_access_token_attributes.rb b/lib/datadog_api_client/v2/models/full_personal_access_token_attributes.rb new file mode 100644 index 000000000000..953e5bbfec83 --- /dev/null +++ b/lib/datadog_api_client/v2/models/full_personal_access_token_attributes.rb @@ -0,0 +1,242 @@ +=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 a personal access token including the secret key value. + # This is only returned when creating a new token. + class FullPersonalAccessTokenAttributes + include BaseGenericModel + + # Creation timestamp of the personal access token. + attr_reader :created_at + + # Expiration timestamp of the personal access token. + attr_reader :expires_at + + # The secret token value. This is only returned when creating a new personal + # access token and cannot be retrieved later. + attr_reader :key + + # Last modification timestamp of the personal access token. + attr_accessor :modified_at + + # Name of the personal access token. + attr_reader :name + + # Array of scopes granted to the personal access token. These define what + # permissions the token has. + attr_reader :scopes + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'created_at' => :'created_at', + :'expires_at' => :'expires_at', + :'key' => :'key', + :'modified_at' => :'modified_at', + :'name' => :'name', + :'scopes' => :'scopes' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'created_at' => :'Time', + :'expires_at' => :'Time', + :'key' => :'String', + :'modified_at' => :'Time', + :'name' => :'String', + :'scopes' => :'Array' + } + end + + # List of attributes with nullable: true + # @!visibility private + def self.openapi_nullable + Set.new([ + :'modified_at', + ]) + 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::FullPersonalAccessTokenAttributes` 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?(:'created_at') + self.created_at = attributes[:'created_at'] + end + + if attributes.key?(:'expires_at') + self.expires_at = attributes[:'expires_at'] + end + + if attributes.key?(:'key') + self.key = attributes[:'key'] + end + + if attributes.key?(:'modified_at') + self.modified_at = attributes[:'modified_at'] + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'scopes') + if (value = attributes[:'scopes']).is_a?(Array) + self.scopes = value + end + 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 @created_at.nil? + return false if @expires_at.nil? + return false if @key.nil? + return false if @name.nil? + return false if @name.to_s.length > 256 + return false if @name.to_s.length < 1 + return false if @scopes.nil? + return false if @scopes.length < 1 + true + end + + # Custom attribute writer method with validation + # @param created_at [Object] Object to be assigned + # @!visibility private + def created_at=(created_at) + if created_at.nil? + fail ArgumentError, 'invalid value for "created_at", created_at cannot be nil.' + end + @created_at = created_at + end + + # Custom attribute writer method with validation + # @param expires_at [Object] Object to be assigned + # @!visibility private + def expires_at=(expires_at) + if expires_at.nil? + fail ArgumentError, 'invalid value for "expires_at", expires_at cannot be nil.' + end + @expires_at = expires_at + end + + # Custom attribute writer method with validation + # @param key [Object] Object to be assigned + # @!visibility private + def key=(key) + if key.nil? + fail ArgumentError, 'invalid value for "key", key cannot be nil.' + end + @key = key + end + + # Custom attribute writer method with validation + # @param name [Object] Object to be assigned + # @!visibility private + def name=(name) + if name.nil? + fail ArgumentError, 'invalid value for "name", name cannot be nil.' + end + if name.to_s.length > 256 + fail ArgumentError, 'invalid value for "name", the character length must be smaller than or equal to 256.' + end + if name.to_s.length < 1 + fail ArgumentError, 'invalid value for "name", the character length must be great than or equal to 1.' + end + @name = name + end + + # Custom attribute writer method with validation + # @param scopes [Object] Object to be assigned + # @!visibility private + def scopes=(scopes) + if scopes.nil? + fail ArgumentError, 'invalid value for "scopes", scopes cannot be nil.' + end + if scopes.length < 1 + fail ArgumentError, 'invalid value for "scopes", number of items must be greater than or equal to 1.' + end + @scopes = scopes + 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 && + created_at == o.created_at && + expires_at == o.expires_at && + key == o.key && + modified_at == o.modified_at && + name == o.name && + scopes == o.scopes && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [created_at, expires_at, key, modified_at, name, scopes, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/personal_access_token.rb b/lib/datadog_api_client/v2/models/personal_access_token.rb new file mode 100644 index 000000000000..0baab405fd4e --- /dev/null +++ b/lib/datadog_api_client/v2/models/personal_access_token.rb @@ -0,0 +1,186 @@ +=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 + # Personal access token object. + class PersonalAccessToken + include BaseGenericModel + + # Attributes of a personal access token. + attr_reader :attributes + + # UUID of the personal access token. + attr_reader :id + + # Resources related to the personal access token. + attr_reader :relationships + + # Personal access tokens resource type. + 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', + :'relationships' => :'relationships', + :'type' => :'type' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'attributes' => :'PersonalAccessTokenAttributes', + :'id' => :'UUID', + :'relationships' => :'PersonalAccessTokenRelationships', + :'type' => :'PersonalAccessTokenType' + } + 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::PersonalAccessToken` 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?(:'relationships') + self.relationships = attributes[:'relationships'] + 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 @relationships.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 relationships [Object] Object to be assigned + # @!visibility private + def relationships=(relationships) + if relationships.nil? + fail ArgumentError, 'invalid value for "relationships", relationships cannot be nil.' + end + @relationships = relationships + 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 && + relationships == o.relationships && + 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, relationships, type, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/personal_access_token_attributes.rb b/lib/datadog_api_client/v2/models/personal_access_token_attributes.rb new file mode 100644 index 000000000000..1c72fb643b89 --- /dev/null +++ b/lib/datadog_api_client/v2/models/personal_access_token_attributes.rb @@ -0,0 +1,219 @@ +=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 a personal access token. + class PersonalAccessTokenAttributes + include BaseGenericModel + + # Creation timestamp of the personal access token. + attr_reader :created_at + + # Expiration timestamp of the personal access token. + attr_reader :expires_at + + # Last modification timestamp of the personal access token. + attr_accessor :modified_at + + # Name of the personal access token. + attr_reader :name + + # Array of scopes granted to the personal access token. These define what + # permissions the token has. + attr_reader :scopes + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'created_at' => :'created_at', + :'expires_at' => :'expires_at', + :'modified_at' => :'modified_at', + :'name' => :'name', + :'scopes' => :'scopes' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'created_at' => :'Time', + :'expires_at' => :'Time', + :'modified_at' => :'Time', + :'name' => :'String', + :'scopes' => :'Array' + } + end + + # List of attributes with nullable: true + # @!visibility private + def self.openapi_nullable + Set.new([ + :'modified_at', + ]) + 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::PersonalAccessTokenAttributes` 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?(:'created_at') + self.created_at = attributes[:'created_at'] + end + + if attributes.key?(:'expires_at') + self.expires_at = attributes[:'expires_at'] + end + + if attributes.key?(:'modified_at') + self.modified_at = attributes[:'modified_at'] + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'scopes') + if (value = attributes[:'scopes']).is_a?(Array) + self.scopes = value + end + 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 @created_at.nil? + return false if @expires_at.nil? + return false if @name.nil? + return false if @name.to_s.length > 256 + return false if @name.to_s.length < 1 + return false if @scopes.nil? + return false if @scopes.length < 1 + true + end + + # Custom attribute writer method with validation + # @param created_at [Object] Object to be assigned + # @!visibility private + def created_at=(created_at) + if created_at.nil? + fail ArgumentError, 'invalid value for "created_at", created_at cannot be nil.' + end + @created_at = created_at + end + + # Custom attribute writer method with validation + # @param expires_at [Object] Object to be assigned + # @!visibility private + def expires_at=(expires_at) + if expires_at.nil? + fail ArgumentError, 'invalid value for "expires_at", expires_at cannot be nil.' + end + @expires_at = expires_at + end + + # Custom attribute writer method with validation + # @param name [Object] Object to be assigned + # @!visibility private + def name=(name) + if name.nil? + fail ArgumentError, 'invalid value for "name", name cannot be nil.' + end + if name.to_s.length > 256 + fail ArgumentError, 'invalid value for "name", the character length must be smaller than or equal to 256.' + end + if name.to_s.length < 1 + fail ArgumentError, 'invalid value for "name", the character length must be great than or equal to 1.' + end + @name = name + end + + # Custom attribute writer method with validation + # @param scopes [Object] Object to be assigned + # @!visibility private + def scopes=(scopes) + if scopes.nil? + fail ArgumentError, 'invalid value for "scopes", scopes cannot be nil.' + end + if scopes.length < 1 + fail ArgumentError, 'invalid value for "scopes", number of items must be greater than or equal to 1.' + end + @scopes = scopes + 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 && + created_at == o.created_at && + expires_at == o.expires_at && + modified_at == o.modified_at && + name == o.name && + scopes == o.scopes && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [created_at, expires_at, modified_at, name, scopes, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/personal_access_token_create_attributes.rb b/lib/datadog_api_client/v2/models/personal_access_token_create_attributes.rb new file mode 100644 index 000000000000..713e0e8864ef --- /dev/null +++ b/lib/datadog_api_client/v2/models/personal_access_token_create_attributes.rb @@ -0,0 +1,180 @@ +=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 used to create a personal access token. + class PersonalAccessTokenCreateAttributes + include BaseGenericModel + + # Expiration timestamp for the personal access token. + attr_reader :expires_at + + # Name of the personal access token. + attr_reader :name + + # Array of scopes to grant the personal access token. These define what + # permissions the token will have. + attr_reader :scopes + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'expires_at' => :'expires_at', + :'name' => :'name', + :'scopes' => :'scopes' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'expires_at' => :'Time', + :'name' => :'String', + :'scopes' => :'Array' + } + 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::PersonalAccessTokenCreateAttributes` 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?(:'expires_at') + self.expires_at = attributes[:'expires_at'] + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'scopes') + if (value = attributes[:'scopes']).is_a?(Array) + self.scopes = value + end + 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 @expires_at.nil? + return false if @name.nil? + return false if @name.to_s.length > 256 + return false if @name.to_s.length < 1 + return false if @scopes.nil? + return false if @scopes.length < 1 + true + end + + # Custom attribute writer method with validation + # @param expires_at [Object] Object to be assigned + # @!visibility private + def expires_at=(expires_at) + if expires_at.nil? + fail ArgumentError, 'invalid value for "expires_at", expires_at cannot be nil.' + end + @expires_at = expires_at + end + + # Custom attribute writer method with validation + # @param name [Object] Object to be assigned + # @!visibility private + def name=(name) + if name.nil? + fail ArgumentError, 'invalid value for "name", name cannot be nil.' + end + if name.to_s.length > 256 + fail ArgumentError, 'invalid value for "name", the character length must be smaller than or equal to 256.' + end + if name.to_s.length < 1 + fail ArgumentError, 'invalid value for "name", the character length must be great than or equal to 1.' + end + @name = name + end + + # Custom attribute writer method with validation + # @param scopes [Object] Object to be assigned + # @!visibility private + def scopes=(scopes) + if scopes.nil? + fail ArgumentError, 'invalid value for "scopes", scopes cannot be nil.' + end + if scopes.length < 1 + fail ArgumentError, 'invalid value for "scopes", number of items must be greater than or equal to 1.' + end + @scopes = scopes + 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 && + expires_at == o.expires_at && + name == o.name && + scopes == o.scopes && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [expires_at, name, scopes, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/personal_access_token_create_data.rb b/lib/datadog_api_client/v2/models/personal_access_token_create_data.rb new file mode 100644 index 000000000000..9b4c3ae0a2b3 --- /dev/null +++ b/lib/datadog_api_client/v2/models/personal_access_token_create_data.rb @@ -0,0 +1,144 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + This product includes software developed at Datadog (https://www.datadoghq.com/). + Copyright 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Object used to create a personal access token. + class PersonalAccessTokenCreateData + include BaseGenericModel + + # Attributes used to create a personal access token. + attr_reader :attributes + + # Personal access tokens resource type. + 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', + :'type' => :'type' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'attributes' => :'PersonalAccessTokenCreateAttributes', + :'type' => :'PersonalAccessTokenType' + } + 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::PersonalAccessTokenCreateData` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'attributes') + self.attributes = attributes[:'attributes'] + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + end + end + + # 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 @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 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 && + type == o.type && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [attributes, type, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/personal_access_token_create_request.rb b/lib/datadog_api_client/v2/models/personal_access_token_create_request.rb new file mode 100644 index 000000000000..97ee4c8e9d89 --- /dev/null +++ b/lib/datadog_api_client/v2/models/personal_access_token_create_request.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 + # Request to create a personal access token. + class PersonalAccessTokenCreateRequest + include BaseGenericModel + + # Object used to create a personal access token. + 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' => :'PersonalAccessTokenCreateData' + } + 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::PersonalAccessTokenCreateRequest` 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/personal_access_token_get_response.rb b/lib/datadog_api_client/v2/models/personal_access_token_get_response.rb new file mode 100644 index 000000000000..8eb20f429a83 --- /dev/null +++ b/lib/datadog_api_client/v2/models/personal_access_token_get_response.rb @@ -0,0 +1,105 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + This product includes software developed at Datadog (https://www.datadoghq.com/). + Copyright 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Response for retrieving a personal access token. + class PersonalAccessTokenGetResponse + include BaseGenericModel + + # Personal access token object. + attr_accessor :data + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'data' => :'data' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'data' => :'PersonalAccessToken' + } + 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::PersonalAccessTokenGetResponse` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'data') + self.data = attributes[:'data'] + end + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + data == o.data && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [data, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/personal_access_token_relationships.rb b/lib/datadog_api_client/v2/models/personal_access_token_relationships.rb new file mode 100644 index 000000000000..ec8646ae7c67 --- /dev/null +++ b/lib/datadog_api_client/v2/models/personal_access_token_relationships.rb @@ -0,0 +1,105 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + This product includes software developed at Datadog (https://www.datadoghq.com/). + Copyright 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Resources related to the personal access token. + class PersonalAccessTokenRelationships + include BaseGenericModel + + # Relationship to user. + attr_accessor :owned_by + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'owned_by' => :'owned_by' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'owned_by' => :'RelationshipToUser' + } + 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::PersonalAccessTokenRelationships` 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?(:'owned_by') + self.owned_by = attributes[:'owned_by'] + end + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + owned_by == o.owned_by && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [owned_by, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/personal_access_token_response.rb b/lib/datadog_api_client/v2/models/personal_access_token_response.rb new file mode 100644 index 000000000000..b820a9832358 --- /dev/null +++ b/lib/datadog_api_client/v2/models/personal_access_token_response.rb @@ -0,0 +1,106 @@ +=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 creating a personal access token. + class PersonalAccessTokenResponse + include BaseGenericModel + + # Personal access token object with the secret key value. This is only + # returned when creating a new token. + attr_accessor :data + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'data' => :'data' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'data' => :'FullPersonalAccessToken' + } + 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::PersonalAccessTokenResponse` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'data') + self.data = attributes[:'data'] + end + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + data == o.data && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [data, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/personal_access_token_type.rb b/lib/datadog_api_client/v2/models/personal_access_token_type.rb new file mode 100644 index 000000000000..10a1d31db5e4 --- /dev/null +++ b/lib/datadog_api_client/v2/models/personal_access_token_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 + # Personal access tokens resource type. + class PersonalAccessTokenType + include BaseEnumModel + + PERSONAL_ACCESS_TOKENS = "personal_access_tokens".freeze + end +end diff --git a/lib/datadog_api_client/v2/models/personal_access_token_update_attributes.rb b/lib/datadog_api_client/v2/models/personal_access_token_update_attributes.rb new file mode 100644 index 000000000000..077c23472824 --- /dev/null +++ b/lib/datadog_api_client/v2/models/personal_access_token_update_attributes.rb @@ -0,0 +1,151 @@ +=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 used to update a personal access token. + class PersonalAccessTokenUpdateAttributes + include BaseGenericModel + + # New name for the personal access token. + attr_reader :name + + # New array of scopes for the personal access token. If provided, this will + # replace the existing scopes. + attr_reader :scopes + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'name' => :'name', + :'scopes' => :'scopes' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'name' => :'String', + :'scopes' => :'Array' + } + 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::PersonalAccessTokenUpdateAttributes` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'scopes') + if (value = attributes[:'scopes']).is_a?(Array) + self.scopes = value + end + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if !@name.nil? && @name.to_s.length > 256 + return false if !@name.nil? && @name.to_s.length < 1 + return false if !@scopes.nil? && @scopes.length < 1 + true + end + + # Custom attribute writer method with validation + # @param name [Object] Object to be assigned + # @!visibility private + def name=(name) + if !name.nil? && name.to_s.length > 256 + fail ArgumentError, 'invalid value for "name", the character length must be smaller than or equal to 256.' + end + if !name.nil? && name.to_s.length < 1 + fail ArgumentError, 'invalid value for "name", the character length must be great than or equal to 1.' + end + @name = name + end + + # Custom attribute writer method with validation + # @param scopes [Object] Object to be assigned + # @!visibility private + def scopes=(scopes) + if !scopes.nil? && scopes.length < 1 + fail ArgumentError, 'invalid value for "scopes", number of items must be greater than or equal to 1.' + end + @scopes = scopes + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + name == o.name && + scopes == o.scopes && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [name, scopes, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/personal_access_token_update_data.rb b/lib/datadog_api_client/v2/models/personal_access_token_update_data.rb new file mode 100644 index 000000000000..90d09f7c6c39 --- /dev/null +++ b/lib/datadog_api_client/v2/models/personal_access_token_update_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 + # Object used to update a personal access token. + class PersonalAccessTokenUpdateData + include BaseGenericModel + + # Attributes used to update a personal access token. + attr_reader :attributes + + # UUID of the personal access token. Must match the path parameter. + attr_reader :id + + # Personal access tokens resource type. + 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' => :'PersonalAccessTokenUpdateAttributes', + :'id' => :'UUID', + :'type' => :'PersonalAccessTokenType' + } + 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::PersonalAccessTokenUpdateData` 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/personal_access_token_update_request.rb b/lib/datadog_api_client/v2/models/personal_access_token_update_request.rb new file mode 100644 index 000000000000..e8d28b7048aa --- /dev/null +++ b/lib/datadog_api_client/v2/models/personal_access_token_update_request.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 + # Request to update a personal access token. + class PersonalAccessTokenUpdateRequest + include BaseGenericModel + + # Object used to update a personal access token. + 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' => :'PersonalAccessTokenUpdateData' + } + 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::PersonalAccessTokenUpdateRequest` 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/personal_access_tokens_list_response.rb b/lib/datadog_api_client/v2/models/personal_access_tokens_list_response.rb new file mode 100644 index 000000000000..b580c3993316 --- /dev/null +++ b/lib/datadog_api_client/v2/models/personal_access_tokens_list_response.rb @@ -0,0 +1,117 @@ +=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 a list of personal access tokens. + class PersonalAccessTokensListResponse + include BaseGenericModel + + # Array of personal access tokens. + attr_accessor :data + + # Additional information related to the personal access tokens response. + attr_accessor :meta + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'data' => :'data', + :'meta' => :'meta' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'data' => :'Array', + :'meta' => :'PersonalAccessTokensResponseMeta' + } + 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::PersonalAccessTokensListResponse` 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') + if (value = attributes[:'data']).is_a?(Array) + self.data = value + end + end + + if attributes.key?(:'meta') + self.meta = attributes[:'meta'] + end + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + data == o.data && + meta == o.meta && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [data, meta, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/personal_access_tokens_response_meta.rb b/lib/datadog_api_client/v2/models/personal_access_tokens_response_meta.rb new file mode 100644 index 000000000000..501750ea3a4e --- /dev/null +++ b/lib/datadog_api_client/v2/models/personal_access_tokens_response_meta.rb @@ -0,0 +1,105 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + This product includes software developed at Datadog (https://www.datadoghq.com/). + Copyright 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Additional information related to the personal access tokens response. + class PersonalAccessTokensResponseMeta + include BaseGenericModel + + # Pagination information for personal access tokens response. + attr_accessor :page + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'page' => :'page' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'page' => :'PersonalAccessTokensResponseMetaPage' + } + 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::PersonalAccessTokensResponseMeta` 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?(:'page') + self.page = attributes[:'page'] + end + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + page == o.page && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [page, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/personal_access_tokens_response_meta_page.rb b/lib/datadog_api_client/v2/models/personal_access_tokens_response_meta_page.rb new file mode 100644 index 000000000000..03cf1d162c20 --- /dev/null +++ b/lib/datadog_api_client/v2/models/personal_access_tokens_response_meta_page.rb @@ -0,0 +1,105 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + This product includes software developed at Datadog (https://www.datadoghq.com/). + Copyright 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Pagination information for personal access tokens response. + class PersonalAccessTokensResponseMetaPage + include BaseGenericModel + + # Total filtered personal access token count. + attr_accessor :total_filtered_count + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'total_filtered_count' => :'total_filtered_count' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'total_filtered_count' => :'Integer' + } + 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::PersonalAccessTokensResponseMetaPage` 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?(:'total_filtered_count') + self.total_filtered_count = attributes[:'total_filtered_count'] + end + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + total_filtered_count == o.total_filtered_count && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [total_filtered_count, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/personal_access_tokens_sort.rb b/lib/datadog_api_client/v2/models/personal_access_tokens_sort.rb new file mode 100644 index 000000000000..45ada2ee418c --- /dev/null +++ b/lib/datadog_api_client/v2/models/personal_access_tokens_sort.rb @@ -0,0 +1,31 @@ +=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 + # Sorting options for personal access tokens. + class PersonalAccessTokensSort + include BaseEnumModel + + NAME_ASCENDING = "name".freeze + NAME_DESCENDING = "-name".freeze + CREATED_AT_ASCENDING = "created_at".freeze + CREATED_AT_DESCENDING = "-created_at".freeze + EXPIRES_AT_ASCENDING = "expires_at".freeze + EXPIRES_AT_DESCENDING = "-expires_at".freeze + end +end