From 96abcb1ddadf1aee39c50c90758e7e25e32744ed Mon Sep 17 00:00:00 2001 From: "ci.datadog-api-spec" Date: Fri, 6 Feb 2026 13:16:13 +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.java | 32 + .../v1/key-management/RevokeClientToken.java | 27 + .../v1/key-management/UpdateClientToken.java | 33 + .../CreatePersonalAccessToken.java | 42 + .../GetPersonalAccessToken.java | 28 + .../ListPersonalAccessTokens.java | 25 + .../RevokePersonalAccessToken.java | 25 + .../UpdatePersonalAccessToken.java | 44 + .../com/datadog/api/client/ApiClient.java | 8 + .../api/client/v1/api/KeyManagementApi.java | 449 ++++++++ .../api/client/v1/model/ClientToken.java | 375 +++++++ .../v1/model/ClientTokenCreateRequest.java | 181 ++++ .../v1/model/ClientTokenRevokeRequest.java | 143 +++ .../v1/model/ClientTokenUpdateRequest.java | 210 ++++ .../api/client/v2/api/KeyManagementApi.java | 987 +++++++++++++++++- .../v2/model/FullPersonalAccessToken.java | 245 +++++ .../FullPersonalAccessTokenAttributes.java | 287 +++++ .../client/v2/model/PersonalAccessToken.java | 241 +++++ .../model/PersonalAccessTokenAttributes.java | 263 +++++ .../PersonalAccessTokenCreateAttributes.java | 212 ++++ .../model/PersonalAccessTokenCreateData.java | 182 ++++ .../PersonalAccessTokenCreateRequest.java | 148 +++ .../model/PersonalAccessTokenGetResponse.java | 138 +++ .../PersonalAccessTokenRelationships.java | 138 +++ .../v2/model/PersonalAccessTokenResponse.java | 138 +++ .../v2/model/PersonalAccessTokenType.java | 57 + .../PersonalAccessTokenUpdateAttributes.java | 177 ++++ .../model/PersonalAccessTokenUpdateData.java | 211 ++++ .../PersonalAccessTokenUpdateRequest.java | 148 +++ .../PersonalAccessTokensListResponse.java | 181 ++++ .../PersonalAccessTokensResponseMeta.java | 138 +++ .../PersonalAccessTokensResponseMetaPage.java | 138 +++ .../v2/model/PersonalAccessTokensSort.java | 68 ++ .../api/client/v1/api/key_management.feature | 64 ++ .../com/datadog/api/client/v1/api/undo.json | 25 + .../api/client/v2/api/key_management.feature | 104 ++ .../com/datadog/api/client/v2/api/undo.json | 37 + 39 files changed, 6791 insertions(+), 37 deletions(-) create mode 100644 examples/v1/key-management/CreateClientToken.java create mode 100644 examples/v1/key-management/RevokeClientToken.java create mode 100644 examples/v1/key-management/UpdateClientToken.java create mode 100644 examples/v2/key-management/CreatePersonalAccessToken.java create mode 100644 examples/v2/key-management/GetPersonalAccessToken.java create mode 100644 examples/v2/key-management/ListPersonalAccessTokens.java create mode 100644 examples/v2/key-management/RevokePersonalAccessToken.java create mode 100644 examples/v2/key-management/UpdatePersonalAccessToken.java create mode 100644 src/main/java/com/datadog/api/client/v1/model/ClientToken.java create mode 100644 src/main/java/com/datadog/api/client/v1/model/ClientTokenCreateRequest.java create mode 100644 src/main/java/com/datadog/api/client/v1/model/ClientTokenRevokeRequest.java create mode 100644 src/main/java/com/datadog/api/client/v1/model/ClientTokenUpdateRequest.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/FullPersonalAccessToken.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/FullPersonalAccessTokenAttributes.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/PersonalAccessToken.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/PersonalAccessTokenAttributes.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/PersonalAccessTokenCreateAttributes.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/PersonalAccessTokenCreateData.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/PersonalAccessTokenCreateRequest.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/PersonalAccessTokenGetResponse.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/PersonalAccessTokenRelationships.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/PersonalAccessTokenResponse.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/PersonalAccessTokenType.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/PersonalAccessTokenUpdateAttributes.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/PersonalAccessTokenUpdateData.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/PersonalAccessTokenUpdateRequest.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/PersonalAccessTokensListResponse.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/PersonalAccessTokensResponseMeta.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/PersonalAccessTokensResponseMetaPage.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/PersonalAccessTokensSort.java diff --git a/.generator/schemas/v1/openapi.yaml b/.generator/schemas/v1/openapi.yaml index a38d274f9b8..5e187a0e142 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 e301432aca7..1d00ffc84de 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.java b/examples/v1/key-management/CreateClientToken.java new file mode 100644 index 00000000000..1870e52331d --- /dev/null +++ b/examples/v1/key-management/CreateClientToken.java @@ -0,0 +1,32 @@ +// Create client token returns "OK" response + +import com.datadog.api.client.ApiClient; +import com.datadog.api.client.ApiException; +import com.datadog.api.client.v1.api.KeyManagementApi; +import com.datadog.api.client.v1.model.ClientToken; +import com.datadog.api.client.v1.model.ClientTokenCreateRequest; +import java.util.Collections; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + defaultClient.setUnstableOperationEnabled("v1.createClientToken", true); + KeyManagementApi apiInstance = new KeyManagementApi(defaultClient); + + ClientTokenCreateRequest body = + new ClientTokenCreateRequest() + .name("Example Client Token") + .originUrls(Collections.singletonList("https://example.com")); + + try { + ClientToken result = apiInstance.createClientToken(body); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling KeyManagementApi#createClientToken"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} diff --git a/examples/v1/key-management/RevokeClientToken.java b/examples/v1/key-management/RevokeClientToken.java new file mode 100644 index 00000000000..f5fda162702 --- /dev/null +++ b/examples/v1/key-management/RevokeClientToken.java @@ -0,0 +1,27 @@ +// Revoke client token returns "No Content" response + +import com.datadog.api.client.ApiClient; +import com.datadog.api.client.ApiException; +import com.datadog.api.client.v1.api.KeyManagementApi; +import com.datadog.api.client.v1.model.ClientTokenRevokeRequest; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + defaultClient.setUnstableOperationEnabled("v1.revokeClientToken", true); + KeyManagementApi apiInstance = new KeyManagementApi(defaultClient); + + ClientTokenRevokeRequest body = + new ClientTokenRevokeRequest().hash("1234567890abcdef1234567890abcdef123"); + + try { + apiInstance.revokeClientToken(body); + } catch (ApiException e) { + System.err.println("Exception when calling KeyManagementApi#revokeClientToken"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} diff --git a/examples/v1/key-management/UpdateClientToken.java b/examples/v1/key-management/UpdateClientToken.java new file mode 100644 index 00000000000..70dda65dca2 --- /dev/null +++ b/examples/v1/key-management/UpdateClientToken.java @@ -0,0 +1,33 @@ +// Update client token returns "OK" response + +import com.datadog.api.client.ApiClient; +import com.datadog.api.client.ApiException; +import com.datadog.api.client.v1.api.KeyManagementApi; +import com.datadog.api.client.v1.model.ClientToken; +import com.datadog.api.client.v1.model.ClientTokenUpdateRequest; +import java.util.Collections; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + defaultClient.setUnstableOperationEnabled("v1.updateClientToken", true); + KeyManagementApi apiInstance = new KeyManagementApi(defaultClient); + + ClientTokenUpdateRequest body = + new ClientTokenUpdateRequest() + .hash("1234567890abcdef1234567890abcdef123") + .name("Updated Client Token Name") + .originUrls(Collections.singletonList("https://example.com")); + + try { + ClientToken result = apiInstance.updateClientToken(body); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling KeyManagementApi#updateClientToken"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} diff --git a/examples/v2/key-management/CreatePersonalAccessToken.java b/examples/v2/key-management/CreatePersonalAccessToken.java new file mode 100644 index 00000000000..35e4d859dbd --- /dev/null +++ b/examples/v2/key-management/CreatePersonalAccessToken.java @@ -0,0 +1,42 @@ +// Create personal access token returns "OK" response + +import com.datadog.api.client.ApiClient; +import com.datadog.api.client.ApiException; +import com.datadog.api.client.v2.api.KeyManagementApi; +import com.datadog.api.client.v2.model.PersonalAccessTokenCreateAttributes; +import com.datadog.api.client.v2.model.PersonalAccessTokenCreateData; +import com.datadog.api.client.v2.model.PersonalAccessTokenCreateRequest; +import com.datadog.api.client.v2.model.PersonalAccessTokenResponse; +import com.datadog.api.client.v2.model.PersonalAccessTokenType; +import java.time.OffsetDateTime; +import java.util.Arrays; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + defaultClient.setUnstableOperationEnabled("v2.createPersonalAccessToken", true); + KeyManagementApi apiInstance = new KeyManagementApi(defaultClient); + + PersonalAccessTokenCreateRequest body = + new PersonalAccessTokenCreateRequest() + .data( + new PersonalAccessTokenCreateData() + .attributes( + new PersonalAccessTokenCreateAttributes() + .expiresAt(OffsetDateTime.parse("2025-03-15T10:30:00.000000+00:00")) + .name("Example Personal Access Token") + .scopes(Arrays.asList("dashboards_read", "monitors_read"))) + .type(PersonalAccessTokenType.PERSONAL_ACCESS_TOKENS)); + + try { + PersonalAccessTokenResponse result = apiInstance.createPersonalAccessToken(body); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling KeyManagementApi#createPersonalAccessToken"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} diff --git a/examples/v2/key-management/GetPersonalAccessToken.java b/examples/v2/key-management/GetPersonalAccessToken.java new file mode 100644 index 00000000000..236be2efa1c --- /dev/null +++ b/examples/v2/key-management/GetPersonalAccessToken.java @@ -0,0 +1,28 @@ +// Get personal access token returns "OK" response + +import com.datadog.api.client.ApiClient; +import com.datadog.api.client.ApiException; +import com.datadog.api.client.v2.api.KeyManagementApi; +import com.datadog.api.client.v2.model.PersonalAccessTokenGetResponse; +import java.util.UUID; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + defaultClient.setUnstableOperationEnabled("v2.getPersonalAccessToken", true); + KeyManagementApi apiInstance = new KeyManagementApi(defaultClient); + + try { + PersonalAccessTokenGetResponse result = + apiInstance.getPersonalAccessToken( + UUID.fromString("9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d")); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling KeyManagementApi#getPersonalAccessToken"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} diff --git a/examples/v2/key-management/ListPersonalAccessTokens.java b/examples/v2/key-management/ListPersonalAccessTokens.java new file mode 100644 index 00000000000..ba9e07b7e1e --- /dev/null +++ b/examples/v2/key-management/ListPersonalAccessTokens.java @@ -0,0 +1,25 @@ +// List personal access tokens returns "OK" response + +import com.datadog.api.client.ApiClient; +import com.datadog.api.client.ApiException; +import com.datadog.api.client.v2.api.KeyManagementApi; +import com.datadog.api.client.v2.model.PersonalAccessTokensListResponse; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + defaultClient.setUnstableOperationEnabled("v2.listPersonalAccessTokens", true); + KeyManagementApi apiInstance = new KeyManagementApi(defaultClient); + + try { + PersonalAccessTokensListResponse result = apiInstance.listPersonalAccessTokens(); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling KeyManagementApi#listPersonalAccessTokens"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} diff --git a/examples/v2/key-management/RevokePersonalAccessToken.java b/examples/v2/key-management/RevokePersonalAccessToken.java new file mode 100644 index 00000000000..342b0c8f20c --- /dev/null +++ b/examples/v2/key-management/RevokePersonalAccessToken.java @@ -0,0 +1,25 @@ +// Revoke personal access token returns "No Content" response + +import com.datadog.api.client.ApiClient; +import com.datadog.api.client.ApiException; +import com.datadog.api.client.v2.api.KeyManagementApi; +import java.util.UUID; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + defaultClient.setUnstableOperationEnabled("v2.revokePersonalAccessToken", true); + KeyManagementApi apiInstance = new KeyManagementApi(defaultClient); + + try { + apiInstance.revokePersonalAccessToken( + UUID.fromString("9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d")); + } catch (ApiException e) { + System.err.println("Exception when calling KeyManagementApi#revokePersonalAccessToken"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} diff --git a/examples/v2/key-management/UpdatePersonalAccessToken.java b/examples/v2/key-management/UpdatePersonalAccessToken.java new file mode 100644 index 00000000000..9db85f86555 --- /dev/null +++ b/examples/v2/key-management/UpdatePersonalAccessToken.java @@ -0,0 +1,44 @@ +// Update personal access token returns "OK" response + +import com.datadog.api.client.ApiClient; +import com.datadog.api.client.ApiException; +import com.datadog.api.client.v2.api.KeyManagementApi; +import com.datadog.api.client.v2.model.PersonalAccessTokenGetResponse; +import com.datadog.api.client.v2.model.PersonalAccessTokenType; +import com.datadog.api.client.v2.model.PersonalAccessTokenUpdateAttributes; +import com.datadog.api.client.v2.model.PersonalAccessTokenUpdateData; +import com.datadog.api.client.v2.model.PersonalAccessTokenUpdateRequest; +import java.util.Arrays; +import java.util.UUID; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + defaultClient.setUnstableOperationEnabled("v2.updatePersonalAccessToken", true); + KeyManagementApi apiInstance = new KeyManagementApi(defaultClient); + + PersonalAccessTokenUpdateRequest body = + new PersonalAccessTokenUpdateRequest() + .data( + new PersonalAccessTokenUpdateData() + .attributes( + new PersonalAccessTokenUpdateAttributes() + .name("Updated Personal Access Token Name") + .scopes(Arrays.asList("dashboards_read", "dashboards_write"))) + .id(UUID.fromString("00000000-0000-0000-0000-000000000000")) + .type(PersonalAccessTokenType.PERSONAL_ACCESS_TOKENS)); + + try { + PersonalAccessTokenGetResponse result = + apiInstance.updatePersonalAccessToken( + UUID.fromString("9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d"), body); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling KeyManagementApi#updatePersonalAccessToken"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} diff --git a/src/main/java/com/datadog/api/client/ApiClient.java b/src/main/java/com/datadog/api/client/ApiClient.java index e1945840a66..a30675021f6 100644 --- a/src/main/java/com/datadog/api/client/ApiClient.java +++ b/src/main/java/com/datadog/api/client/ApiClient.java @@ -756,6 +756,9 @@ public class ApiClient { protected final Map unstableOperations = new HashMap() { { + put("v1.createClientToken", false); + put("v1.revokeClientToken", false); + put("v1.updateClientToken", false); put("v2.cancelFleetDeployment", false); put("v2.createFleetDeploymentConfigure", false); put("v2.createFleetDeploymentUpgrade", false); @@ -770,6 +773,11 @@ public class ApiClient { put("v2.listFleetSchedules", false); put("v2.triggerFleetSchedule", false); put("v2.updateFleetSchedule", false); + put("v2.createPersonalAccessToken", false); + put("v2.getPersonalAccessToken", false); + put("v2.listPersonalAccessTokens", false); + put("v2.revokePersonalAccessToken", false); + put("v2.updatePersonalAccessToken", false); put("v2.createOpenAPI", false); put("v2.deleteOpenAPI", false); put("v2.getOpenAPI", false); diff --git a/src/main/java/com/datadog/api/client/v1/api/KeyManagementApi.java b/src/main/java/com/datadog/api/client/v1/api/KeyManagementApi.java index 8ea04266858..944628473fc 100644 --- a/src/main/java/com/datadog/api/client/v1/api/KeyManagementApi.java +++ b/src/main/java/com/datadog/api/client/v1/api/KeyManagementApi.java @@ -10,6 +10,10 @@ import com.datadog.api.client.v1.model.ApplicationKey; import com.datadog.api.client.v1.model.ApplicationKeyListResponse; import com.datadog.api.client.v1.model.ApplicationKeyResponse; +import com.datadog.api.client.v1.model.ClientToken; +import com.datadog.api.client.v1.model.ClientTokenCreateRequest; +import com.datadog.api.client.v1.model.ClientTokenRevokeRequest; +import com.datadog.api.client.v1.model.ClientTokenUpdateRequest; import jakarta.ws.rs.client.Invocation; import jakarta.ws.rs.core.GenericType; import java.util.ArrayList; @@ -310,6 +314,155 @@ public ApiResponse createApplicationKeyWithHttpInfo(Appl new GenericType() {}); } + /** + * Create client token. + * + *

See {@link #createClientTokenWithHttpInfo}. + * + * @param body (required) + * @return ClientToken + * @throws ApiException if fails to make API call + */ + public ClientToken createClientToken(ClientTokenCreateRequest body) throws ApiException { + return createClientTokenWithHttpInfo(body).getData(); + } + + /** + * Create client token. + * + *

See {@link #createClientTokenWithHttpInfoAsync}. + * + * @param body (required) + * @return CompletableFuture<ClientToken> + */ + public CompletableFuture createClientTokenAsync(ClientTokenCreateRequest body) { + return createClientTokenWithHttpInfoAsync(body) + .thenApply( + response -> { + return response.getData(); + }); + } + + /** + * Create a new client token (public API key) to submit data from your browser or mobile + * applications to Datadog. + * + * @param body (required) + * @return ApiResponse<ClientToken> + * @throws ApiException if fails to make API call + * @http.response.details + * + * + * + * + * + * + * + *
Response details
Status Code Description Response Headers
200 OK -
400 Bad Request -
403 Forbidden -
429 Too Many Requests -
+ */ + public ApiResponse createClientTokenWithHttpInfo(ClientTokenCreateRequest body) + throws ApiException { + // Check if unstable operation is enabled + String operationId = "createClientToken"; + if (apiClient.isUnstableOperationEnabled("v1." + operationId)) { + apiClient.getLogger().warning(String.format("Using unstable operation '%s'", operationId)); + } else { + throw new ApiException(0, String.format("Unstable operation '%s' is disabled", operationId)); + } + Object localVarPostBody = body; + + // verify the required parameter 'body' is set + if (body == null) { + throw new ApiException( + 400, "Missing the required parameter 'body' when calling createClientToken"); + } + // create path and map variables + String localVarPath = "/api/v1/public_api_key"; + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder = + apiClient.createBuilder( + "v1.KeyManagementApi.createClientToken", + localVarPath, + new ArrayList(), + localVarHeaderParams, + new HashMap(), + new String[] {"application/json"}, + new String[] {"apiKeyAuth", "appKeyAuth", "AuthZ"}); + return apiClient.invokeAPI( + "POST", + builder, + localVarHeaderParams, + new String[] {"application/json"}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } + + /** + * Create client token. + * + *

See {@link #createClientTokenWithHttpInfo}. + * + * @param body (required) + * @return CompletableFuture<ApiResponse<ClientToken>> + */ + public CompletableFuture> createClientTokenWithHttpInfoAsync( + ClientTokenCreateRequest body) { + // Check if unstable operation is enabled + String operationId = "createClientToken"; + if (apiClient.isUnstableOperationEnabled("v1." + operationId)) { + apiClient.getLogger().warning(String.format("Using unstable operation '%s'", operationId)); + } else { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally( + new ApiException(0, String.format("Unstable operation '%s' is disabled", operationId))); + return result; + } + Object localVarPostBody = body; + + // verify the required parameter 'body' is set + if (body == null) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally( + new ApiException( + 400, "Missing the required parameter 'body' when calling createClientToken")); + return result; + } + // create path and map variables + String localVarPath = "/api/v1/public_api_key"; + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder; + try { + builder = + apiClient.createBuilder( + "v1.KeyManagementApi.createClientToken", + localVarPath, + new ArrayList(), + localVarHeaderParams, + new HashMap(), + new String[] {"application/json"}, + new String[] {"apiKeyAuth", "appKeyAuth", "AuthZ"}); + } catch (ApiException ex) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally(ex); + return result; + } + return apiClient.invokeAPIAsync( + "POST", + builder, + localVarHeaderParams, + new String[] {"application/json"}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } + /** * Delete an API key. * @@ -1070,6 +1223,154 @@ public ApiResponse listApplicationKeysWithHttpInfo() new GenericType() {}); } + /** + * Revoke client token. + * + *

See {@link #revokeClientTokenWithHttpInfo}. + * + * @param body (required) + * @throws ApiException if fails to make API call + */ + public void revokeClientToken(ClientTokenRevokeRequest body) throws ApiException { + revokeClientTokenWithHttpInfo(body); + } + + /** + * Revoke client token. + * + *

See {@link #revokeClientTokenWithHttpInfoAsync}. + * + * @param body (required) + * @return CompletableFuture + */ + public CompletableFuture revokeClientTokenAsync(ClientTokenRevokeRequest body) { + return revokeClientTokenWithHttpInfoAsync(body) + .thenApply( + response -> { + return response.getData(); + }); + } + + /** + * Revoke a client token (public API key). Once revoked, the token can no longer be used to submit + * data to Datadog. + * + * @param body (required) + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + * @http.response.details + * + * + * + * + * + * + * + *
Response details
Status Code Description Response Headers
204 No Content -
400 Bad Request -
404 Not Found -
429 Too Many Requests -
+ */ + public ApiResponse revokeClientTokenWithHttpInfo(ClientTokenRevokeRequest body) + throws ApiException { + // Check if unstable operation is enabled + String operationId = "revokeClientToken"; + if (apiClient.isUnstableOperationEnabled("v1." + operationId)) { + apiClient.getLogger().warning(String.format("Using unstable operation '%s'", operationId)); + } else { + throw new ApiException(0, String.format("Unstable operation '%s' is disabled", operationId)); + } + Object localVarPostBody = body; + + // verify the required parameter 'body' is set + if (body == null) { + throw new ApiException( + 400, "Missing the required parameter 'body' when calling revokeClientToken"); + } + // create path and map variables + String localVarPath = "/api/v1/public_api_key"; + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder = + apiClient.createBuilder( + "v1.KeyManagementApi.revokeClientToken", + localVarPath, + new ArrayList(), + localVarHeaderParams, + new HashMap(), + new String[] {"*/*"}, + new String[] {"apiKeyAuth", "appKeyAuth", "AuthZ"}); + return apiClient.invokeAPI( + "DELETE", + builder, + localVarHeaderParams, + new String[] {"application/json"}, + localVarPostBody, + new HashMap(), + false, + null); + } + + /** + * Revoke client token. + * + *

See {@link #revokeClientTokenWithHttpInfo}. + * + * @param body (required) + * @return CompletableFuture<ApiResponse<Void>> + */ + public CompletableFuture> revokeClientTokenWithHttpInfoAsync( + ClientTokenRevokeRequest body) { + // Check if unstable operation is enabled + String operationId = "revokeClientToken"; + if (apiClient.isUnstableOperationEnabled("v1." + operationId)) { + apiClient.getLogger().warning(String.format("Using unstable operation '%s'", operationId)); + } else { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally( + new ApiException(0, String.format("Unstable operation '%s' is disabled", operationId))); + return result; + } + Object localVarPostBody = body; + + // verify the required parameter 'body' is set + if (body == null) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally( + new ApiException( + 400, "Missing the required parameter 'body' when calling revokeClientToken")); + return result; + } + // create path and map variables + String localVarPath = "/api/v1/public_api_key"; + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder; + try { + builder = + apiClient.createBuilder( + "v1.KeyManagementApi.revokeClientToken", + localVarPath, + new ArrayList(), + localVarHeaderParams, + new HashMap(), + new String[] {"*/*"}, + new String[] {"apiKeyAuth", "appKeyAuth", "AuthZ"}); + } catch (ApiException ex) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally(ex); + return result; + } + return apiClient.invokeAPIAsync( + "DELETE", + builder, + localVarHeaderParams, + new String[] {"application/json"}, + localVarPostBody, + new HashMap(), + false, + null); + } + /** * Edit an API key. * @@ -1381,4 +1682,152 @@ public ApiResponse updateApplicationKeyWithHttpInfo( false, new GenericType() {}); } + + /** + * Update client token. + * + *

See {@link #updateClientTokenWithHttpInfo}. + * + * @param body (required) + * @return ClientToken + * @throws ApiException if fails to make API call + */ + public ClientToken updateClientToken(ClientTokenUpdateRequest body) throws ApiException { + return updateClientTokenWithHttpInfo(body).getData(); + } + + /** + * Update client token. + * + *

See {@link #updateClientTokenWithHttpInfoAsync}. + * + * @param body (required) + * @return CompletableFuture<ClientToken> + */ + public CompletableFuture updateClientTokenAsync(ClientTokenUpdateRequest body) { + return updateClientTokenWithHttpInfoAsync(body) + .thenApply( + response -> { + return response.getData(); + }); + } + + /** + * Update the name and/or origin URLs of an existing client token (public API key). + * + * @param body (required) + * @return ApiResponse<ClientToken> + * @throws ApiException if fails to make API call + * @http.response.details + * + * + * + * + * + * + * + *
Response details
Status Code Description Response Headers
200 OK -
400 Bad Request -
404 Not Found -
429 Too Many Requests -
+ */ + public ApiResponse updateClientTokenWithHttpInfo(ClientTokenUpdateRequest body) + throws ApiException { + // Check if unstable operation is enabled + String operationId = "updateClientToken"; + if (apiClient.isUnstableOperationEnabled("v1." + operationId)) { + apiClient.getLogger().warning(String.format("Using unstable operation '%s'", operationId)); + } else { + throw new ApiException(0, String.format("Unstable operation '%s' is disabled", operationId)); + } + Object localVarPostBody = body; + + // verify the required parameter 'body' is set + if (body == null) { + throw new ApiException( + 400, "Missing the required parameter 'body' when calling updateClientToken"); + } + // create path and map variables + String localVarPath = "/api/v1/public_api_key"; + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder = + apiClient.createBuilder( + "v1.KeyManagementApi.updateClientToken", + localVarPath, + new ArrayList(), + localVarHeaderParams, + new HashMap(), + new String[] {"application/json"}, + new String[] {"apiKeyAuth", "appKeyAuth", "AuthZ"}); + return apiClient.invokeAPI( + "PUT", + builder, + localVarHeaderParams, + new String[] {"application/json"}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } + + /** + * Update client token. + * + *

See {@link #updateClientTokenWithHttpInfo}. + * + * @param body (required) + * @return CompletableFuture<ApiResponse<ClientToken>> + */ + public CompletableFuture> updateClientTokenWithHttpInfoAsync( + ClientTokenUpdateRequest body) { + // Check if unstable operation is enabled + String operationId = "updateClientToken"; + if (apiClient.isUnstableOperationEnabled("v1." + operationId)) { + apiClient.getLogger().warning(String.format("Using unstable operation '%s'", operationId)); + } else { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally( + new ApiException(0, String.format("Unstable operation '%s' is disabled", operationId))); + return result; + } + Object localVarPostBody = body; + + // verify the required parameter 'body' is set + if (body == null) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally( + new ApiException( + 400, "Missing the required parameter 'body' when calling updateClientToken")); + return result; + } + // create path and map variables + String localVarPath = "/api/v1/public_api_key"; + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder; + try { + builder = + apiClient.createBuilder( + "v1.KeyManagementApi.updateClientToken", + localVarPath, + new ArrayList(), + localVarHeaderParams, + new HashMap(), + new String[] {"application/json"}, + new String[] {"apiKeyAuth", "appKeyAuth", "AuthZ"}); + } catch (ApiException ex) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally(ex); + return result; + } + return apiClient.invokeAPIAsync( + "PUT", + builder, + localVarHeaderParams, + new String[] {"application/json"}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } } diff --git a/src/main/java/com/datadog/api/client/v1/model/ClientToken.java b/src/main/java/com/datadog/api/client/v1/model/ClientToken.java new file mode 100644 index 00000000000..7d28f8d40a1 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v1/model/ClientToken.java @@ -0,0 +1,375 @@ +/* + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v1.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.time.OffsetDateTime; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.UUID; +import org.openapitools.jackson.nullable.JsonNullable; + +/** + * Client token object. Client tokens (also known as public API keys) enable you to submit data from + * your browser or mobile applications to Datadog. + */ +@JsonPropertyOrder({ + ClientToken.JSON_PROPERTY_CREATED_AT, + ClientToken.JSON_PROPERTY_CREATED_BY_HANDLE, + ClientToken.JSON_PROPERTY_CREATED_BY_UUID, + ClientToken.JSON_PROPERTY_DISABLED_AT, + ClientToken.JSON_PROPERTY_DISABLED_BY, + ClientToken.JSON_PROPERTY_DISABLED_BY_HANDLE, + ClientToken.JSON_PROPERTY_HASH, + ClientToken.JSON_PROPERTY_MODIFIED_BY, + ClientToken.JSON_PROPERTY_NAME, + ClientToken.JSON_PROPERTY_ORG_ID, + ClientToken.JSON_PROPERTY_ORIGIN_URLS +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class ClientToken { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_CREATED_AT = "created_at"; + private OffsetDateTime createdAt; + + public static final String JSON_PROPERTY_CREATED_BY_HANDLE = "created_by_handle"; + private String createdByHandle; + + public static final String JSON_PROPERTY_CREATED_BY_UUID = "created_by_uuid"; + private UUID createdByUuid; + + public static final String JSON_PROPERTY_DISABLED_AT = "disabled_at"; + private JsonNullable disabledAt = JsonNullable.undefined(); + + public static final String JSON_PROPERTY_DISABLED_BY = "disabled_by"; + private Long disabledBy; + + public static final String JSON_PROPERTY_DISABLED_BY_HANDLE = "disabled_by_handle"; + private String disabledByHandle; + + public static final String JSON_PROPERTY_HASH = "hash"; + private String hash; + + public static final String JSON_PROPERTY_MODIFIED_BY = "modified_by"; + private Long modifiedBy; + + public static final String JSON_PROPERTY_NAME = "name"; + private String name; + + public static final String JSON_PROPERTY_ORG_ID = "org_id"; + private Long orgId; + + public static final String JSON_PROPERTY_ORIGIN_URLS = "origin_urls"; + private List originUrls = new ArrayList<>(); + + public ClientToken() {} + + @JsonCreator + public ClientToken( + @JsonProperty(required = true, value = JSON_PROPERTY_ORIGIN_URLS) List originUrls) { + this.originUrls = originUrls; + } + + /** + * Creation timestamp of the client token. + * + * @return createdAt + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_CREATED_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public OffsetDateTime getCreatedAt() { + return createdAt; + } + + /** + * Handle of the user who created the client token. + * + * @return createdByHandle + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_CREATED_BY_HANDLE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getCreatedByHandle() { + return createdByHandle; + } + + /** + * UUID of the user who created the client token. + * + * @return createdByUuid + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_CREATED_BY_UUID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public UUID getCreatedByUuid() { + return createdByUuid; + } + + /** + * Timestamp when the client token was disabled. + * + * @return disabledAt + */ + @jakarta.annotation.Nullable + @JsonIgnore + public OffsetDateTime getDisabledAt() { + + if (disabledAt == null) { + disabledAt = JsonNullable.undefined(); + } + return disabledAt.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_DISABLED_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public JsonNullable getDisabledAt_JsonNullable() { + return disabledAt; + } + + @JsonProperty(JSON_PROPERTY_DISABLED_AT) + private void setDisabledAt_JsonNullable(JsonNullable disabledAt) { + this.disabledAt = disabledAt; + } + + /** + * ID of the user who disabled the client token. + * + * @return disabledBy + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_DISABLED_BY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Long getDisabledBy() { + return disabledBy; + } + + /** + * Handle of the user who disabled the client token. + * + * @return disabledByHandle + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_DISABLED_BY_HANDLE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getDisabledByHandle() { + return disabledByHandle; + } + + /** + * The hash value of the client token. This is the secret token value that should be used in your + * browser or mobile application. + * + * @return hash + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_HASH) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getHash() { + return hash; + } + + /** + * ID of the user who last modified the client token. + * + * @return modifiedBy + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_MODIFIED_BY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Long getModifiedBy() { + return modifiedBy; + } + + public ClientToken name(String name) { + this.name = name; + return this; + } + + /** + * Name of the client token. + * + * @return name + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_NAME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + /** + * Organization ID associated with the client token. + * + * @return orgId + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_ORG_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Long getOrgId() { + return orgId; + } + + public ClientToken originUrls(List originUrls) { + this.originUrls = originUrls; + return this; + } + + public ClientToken addOriginUrlsItem(String originUrlsItem) { + this.originUrls.add(originUrlsItem); + return this; + } + + /** + * List of allowed origin URLs for browser-based applications. Requests from URLs not in this list + * will be rejected. + * + * @return originUrls + */ + @JsonProperty(JSON_PROPERTY_ORIGIN_URLS) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public List getOriginUrls() { + return originUrls; + } + + public void setOriginUrls(List originUrls) { + this.originUrls = originUrls; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return ClientToken + */ + @JsonAnySetter + public ClientToken putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this ClientToken object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ClientToken clientToken = (ClientToken) o; + return Objects.equals(this.createdAt, clientToken.createdAt) + && Objects.equals(this.createdByHandle, clientToken.createdByHandle) + && Objects.equals(this.createdByUuid, clientToken.createdByUuid) + && Objects.equals(this.disabledAt, clientToken.disabledAt) + && Objects.equals(this.disabledBy, clientToken.disabledBy) + && Objects.equals(this.disabledByHandle, clientToken.disabledByHandle) + && Objects.equals(this.hash, clientToken.hash) + && Objects.equals(this.modifiedBy, clientToken.modifiedBy) + && Objects.equals(this.name, clientToken.name) + && Objects.equals(this.orgId, clientToken.orgId) + && Objects.equals(this.originUrls, clientToken.originUrls) + && Objects.equals(this.additionalProperties, clientToken.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash( + createdAt, + createdByHandle, + createdByUuid, + disabledAt, + disabledBy, + disabledByHandle, + hash, + modifiedBy, + name, + orgId, + originUrls, + additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ClientToken {\n"); + sb.append(" createdAt: ").append(toIndentedString(createdAt)).append("\n"); + sb.append(" createdByHandle: ").append(toIndentedString(createdByHandle)).append("\n"); + sb.append(" createdByUuid: ").append(toIndentedString(createdByUuid)).append("\n"); + sb.append(" disabledAt: ").append(toIndentedString(disabledAt)).append("\n"); + sb.append(" disabledBy: ").append(toIndentedString(disabledBy)).append("\n"); + sb.append(" disabledByHandle: ").append(toIndentedString(disabledByHandle)).append("\n"); + sb.append(" hash: ").append(toIndentedString(hash)).append("\n"); + sb.append(" modifiedBy: ").append(toIndentedString(modifiedBy)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" orgId: ").append(toIndentedString(orgId)).append("\n"); + sb.append(" originUrls: ").append(toIndentedString(originUrls)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v1/model/ClientTokenCreateRequest.java b/src/main/java/com/datadog/api/client/v1/model/ClientTokenCreateRequest.java new file mode 100644 index 00000000000..b8ac05ae3db --- /dev/null +++ b/src/main/java/com/datadog/api/client/v1/model/ClientTokenCreateRequest.java @@ -0,0 +1,181 @@ +/* + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v1.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** Request to create a new client token. */ +@JsonPropertyOrder({ + ClientTokenCreateRequest.JSON_PROPERTY_NAME, + ClientTokenCreateRequest.JSON_PROPERTY_ORIGIN_URLS +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class ClientTokenCreateRequest { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_NAME = "name"; + private String name; + + public static final String JSON_PROPERTY_ORIGIN_URLS = "origin_urls"; + private List originUrls = new ArrayList<>(); + + public ClientTokenCreateRequest() {} + + @JsonCreator + public ClientTokenCreateRequest( + @JsonProperty(required = true, value = JSON_PROPERTY_NAME) String name, + @JsonProperty(required = true, value = JSON_PROPERTY_ORIGIN_URLS) List originUrls) { + this.name = name; + this.originUrls = originUrls; + } + + public ClientTokenCreateRequest name(String name) { + this.name = name; + return this; + } + + /** + * Name of the client token. + * + * @return name + */ + @JsonProperty(JSON_PROPERTY_NAME) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public ClientTokenCreateRequest originUrls(List originUrls) { + this.originUrls = originUrls; + return this; + } + + public ClientTokenCreateRequest addOriginUrlsItem(String originUrlsItem) { + this.originUrls.add(originUrlsItem); + return this; + } + + /** + * List of allowed origin URLs for browser-based applications. Requests from URLs not in this list + * will be rejected. + * + * @return originUrls + */ + @JsonProperty(JSON_PROPERTY_ORIGIN_URLS) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public List getOriginUrls() { + return originUrls; + } + + public void setOriginUrls(List originUrls) { + this.originUrls = originUrls; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return ClientTokenCreateRequest + */ + @JsonAnySetter + public ClientTokenCreateRequest putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this ClientTokenCreateRequest object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ClientTokenCreateRequest clientTokenCreateRequest = (ClientTokenCreateRequest) o; + return Objects.equals(this.name, clientTokenCreateRequest.name) + && Objects.equals(this.originUrls, clientTokenCreateRequest.originUrls) + && Objects.equals(this.additionalProperties, clientTokenCreateRequest.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(name, originUrls, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ClientTokenCreateRequest {\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" originUrls: ").append(toIndentedString(originUrls)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v1/model/ClientTokenRevokeRequest.java b/src/main/java/com/datadog/api/client/v1/model/ClientTokenRevokeRequest.java new file mode 100644 index 00000000000..7dc1b287a5d --- /dev/null +++ b/src/main/java/com/datadog/api/client/v1/model/ClientTokenRevokeRequest.java @@ -0,0 +1,143 @@ +/* + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v1.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** Request to revoke a client token. */ +@JsonPropertyOrder({ClientTokenRevokeRequest.JSON_PROPERTY_HASH}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class ClientTokenRevokeRequest { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_HASH = "hash"; + private String hash; + + public ClientTokenRevokeRequest() {} + + @JsonCreator + public ClientTokenRevokeRequest( + @JsonProperty(required = true, value = JSON_PROPERTY_HASH) String hash) { + this.hash = hash; + } + + public ClientTokenRevokeRequest hash(String hash) { + this.hash = hash; + return this; + } + + /** + * Hash value of the client token to revoke. + * + * @return hash + */ + @JsonProperty(JSON_PROPERTY_HASH) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getHash() { + return hash; + } + + public void setHash(String hash) { + this.hash = hash; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return ClientTokenRevokeRequest + */ + @JsonAnySetter + public ClientTokenRevokeRequest putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this ClientTokenRevokeRequest object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ClientTokenRevokeRequest clientTokenRevokeRequest = (ClientTokenRevokeRequest) o; + return Objects.equals(this.hash, clientTokenRevokeRequest.hash) + && Objects.equals(this.additionalProperties, clientTokenRevokeRequest.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(hash, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ClientTokenRevokeRequest {\n"); + sb.append(" hash: ").append(toIndentedString(hash)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v1/model/ClientTokenUpdateRequest.java b/src/main/java/com/datadog/api/client/v1/model/ClientTokenUpdateRequest.java new file mode 100644 index 00000000000..76211908e6d --- /dev/null +++ b/src/main/java/com/datadog/api/client/v1/model/ClientTokenUpdateRequest.java @@ -0,0 +1,210 @@ +/* + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v1.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** Request to update an existing client token. */ +@JsonPropertyOrder({ + ClientTokenUpdateRequest.JSON_PROPERTY_HASH, + ClientTokenUpdateRequest.JSON_PROPERTY_NAME, + ClientTokenUpdateRequest.JSON_PROPERTY_ORIGIN_URLS +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class ClientTokenUpdateRequest { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_HASH = "hash"; + private String hash; + + public static final String JSON_PROPERTY_NAME = "name"; + private String name; + + public static final String JSON_PROPERTY_ORIGIN_URLS = "origin_urls"; + private List originUrls = null; + + public ClientTokenUpdateRequest() {} + + @JsonCreator + public ClientTokenUpdateRequest( + @JsonProperty(required = true, value = JSON_PROPERTY_HASH) String hash, + @JsonProperty(required = true, value = JSON_PROPERTY_NAME) String name) { + this.hash = hash; + this.name = name; + } + + public ClientTokenUpdateRequest hash(String hash) { + this.hash = hash; + return this; + } + + /** + * Hash value of the client token to update. + * + * @return hash + */ + @JsonProperty(JSON_PROPERTY_HASH) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getHash() { + return hash; + } + + public void setHash(String hash) { + this.hash = hash; + } + + public ClientTokenUpdateRequest name(String name) { + this.name = name; + return this; + } + + /** + * New name for the client token. + * + * @return name + */ + @JsonProperty(JSON_PROPERTY_NAME) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public ClientTokenUpdateRequest originUrls(List originUrls) { + this.originUrls = originUrls; + return this; + } + + public ClientTokenUpdateRequest addOriginUrlsItem(String originUrlsItem) { + if (this.originUrls == null) { + this.originUrls = new ArrayList<>(); + } + this.originUrls.add(originUrlsItem); + return this; + } + + /** + * New list of allowed origin URLs. If provided, this will replace the existing list. + * + * @return originUrls + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_ORIGIN_URLS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getOriginUrls() { + return originUrls; + } + + public void setOriginUrls(List originUrls) { + this.originUrls = originUrls; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return ClientTokenUpdateRequest + */ + @JsonAnySetter + public ClientTokenUpdateRequest putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this ClientTokenUpdateRequest object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ClientTokenUpdateRequest clientTokenUpdateRequest = (ClientTokenUpdateRequest) o; + return Objects.equals(this.hash, clientTokenUpdateRequest.hash) + && Objects.equals(this.name, clientTokenUpdateRequest.name) + && Objects.equals(this.originUrls, clientTokenUpdateRequest.originUrls) + && Objects.equals(this.additionalProperties, clientTokenUpdateRequest.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(hash, name, originUrls, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ClientTokenUpdateRequest {\n"); + sb.append(" hash: ").append(toIndentedString(hash)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" originUrls: ").append(toIndentedString(originUrls)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/api/KeyManagementApi.java b/src/main/java/com/datadog/api/client/v2/api/KeyManagementApi.java index 4f894589930..42a4a584190 100644 --- a/src/main/java/com/datadog/api/client/v2/api/KeyManagementApi.java +++ b/src/main/java/com/datadog/api/client/v2/api/KeyManagementApi.java @@ -14,12 +14,19 @@ import com.datadog.api.client.v2.model.ApplicationKeyUpdateRequest; import com.datadog.api.client.v2.model.ApplicationKeysSort; import com.datadog.api.client.v2.model.ListApplicationKeysResponse; +import com.datadog.api.client.v2.model.PersonalAccessTokenCreateRequest; +import com.datadog.api.client.v2.model.PersonalAccessTokenGetResponse; +import com.datadog.api.client.v2.model.PersonalAccessTokenResponse; +import com.datadog.api.client.v2.model.PersonalAccessTokenUpdateRequest; +import com.datadog.api.client.v2.model.PersonalAccessTokensListResponse; +import com.datadog.api.client.v2.model.PersonalAccessTokensSort; import jakarta.ws.rs.client.Invocation; import jakarta.ws.rs.core.GenericType; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.UUID; import java.util.concurrent.CompletableFuture; @jakarta.annotation.Generated( @@ -319,6 +326,161 @@ public ApiResponse createCurrentUserApplicationKeyWithHt new GenericType() {}); } + /** + * Create personal access token. + * + *

See {@link #createPersonalAccessTokenWithHttpInfo}. + * + * @param body (required) + * @return PersonalAccessTokenResponse + * @throws ApiException if fails to make API call + */ + public PersonalAccessTokenResponse createPersonalAccessToken( + PersonalAccessTokenCreateRequest body) throws ApiException { + return createPersonalAccessTokenWithHttpInfo(body).getData(); + } + + /** + * Create personal access token. + * + *

See {@link #createPersonalAccessTokenWithHttpInfoAsync}. + * + * @param body (required) + * @return CompletableFuture<PersonalAccessTokenResponse> + */ + public CompletableFuture createPersonalAccessTokenAsync( + PersonalAccessTokenCreateRequest body) { + return createPersonalAccessTokenWithHttpInfoAsync(body) + .thenApply( + response -> { + return response.getData(); + }); + } + + /** + * 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 (required) + * @return ApiResponse<PersonalAccessTokenResponse> + * @throws ApiException if fails to make API call + * @http.response.details + * + * + * + * + * + * + * + * + *
Response details
Status Code Description Response Headers
200 OK -
400 Bad Request -
403 Forbidden -
404 Not Found - Personal access tokens feature is not enabled -
429 Too many requests -
+ */ + public ApiResponse createPersonalAccessTokenWithHttpInfo( + PersonalAccessTokenCreateRequest body) throws ApiException { + // Check if unstable operation is enabled + String operationId = "createPersonalAccessToken"; + if (apiClient.isUnstableOperationEnabled("v2." + operationId)) { + apiClient.getLogger().warning(String.format("Using unstable operation '%s'", operationId)); + } else { + throw new ApiException(0, String.format("Unstable operation '%s' is disabled", operationId)); + } + Object localVarPostBody = body; + + // verify the required parameter 'body' is set + if (body == null) { + throw new ApiException( + 400, "Missing the required parameter 'body' when calling createPersonalAccessToken"); + } + // create path and map variables + String localVarPath = "/api/v2/personal_access_tokens"; + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder = + apiClient.createBuilder( + "v2.KeyManagementApi.createPersonalAccessToken", + localVarPath, + new ArrayList(), + localVarHeaderParams, + new HashMap(), + new String[] {"application/json"}, + new String[] {"apiKeyAuth", "appKeyAuth", "AuthZ"}); + return apiClient.invokeAPI( + "POST", + builder, + localVarHeaderParams, + new String[] {"application/json"}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } + + /** + * Create personal access token. + * + *

See {@link #createPersonalAccessTokenWithHttpInfo}. + * + * @param body (required) + * @return CompletableFuture<ApiResponse<PersonalAccessTokenResponse>> + */ + public CompletableFuture> + createPersonalAccessTokenWithHttpInfoAsync(PersonalAccessTokenCreateRequest body) { + // Check if unstable operation is enabled + String operationId = "createPersonalAccessToken"; + if (apiClient.isUnstableOperationEnabled("v2." + operationId)) { + apiClient.getLogger().warning(String.format("Using unstable operation '%s'", operationId)); + } else { + CompletableFuture> result = + new CompletableFuture<>(); + result.completeExceptionally( + new ApiException(0, String.format("Unstable operation '%s' is disabled", operationId))); + return result; + } + Object localVarPostBody = body; + + // verify the required parameter 'body' is set + if (body == null) { + CompletableFuture> result = + new CompletableFuture<>(); + result.completeExceptionally( + new ApiException( + 400, "Missing the required parameter 'body' when calling createPersonalAccessToken")); + return result; + } + // create path and map variables + String localVarPath = "/api/v2/personal_access_tokens"; + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder; + try { + builder = + apiClient.createBuilder( + "v2.KeyManagementApi.createPersonalAccessToken", + localVarPath, + new ArrayList(), + localVarHeaderParams, + new HashMap(), + new String[] {"application/json"}, + new String[] {"apiKeyAuth", "appKeyAuth", "AuthZ"}); + } catch (ApiException ex) { + CompletableFuture> result = + new CompletableFuture<>(); + result.completeExceptionally(ex); + return result; + } + return apiClient.invokeAPIAsync( + "POST", + builder, + localVarHeaderParams, + new String[] {"application/json"}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } + /** * Delete an API key. * @@ -1256,6 +1418,162 @@ public ApiResponse getCurrentUserApplicationKeyWithHttpI new GenericType() {}); } + /** + * Get personal access token. + * + *

See {@link #getPersonalAccessTokenWithHttpInfo}. + * + * @param patUuid The UUID of the personal access token. (required) + * @return PersonalAccessTokenGetResponse + * @throws ApiException if fails to make API call + */ + public PersonalAccessTokenGetResponse getPersonalAccessToken(UUID patUuid) throws ApiException { + return getPersonalAccessTokenWithHttpInfo(patUuid).getData(); + } + + /** + * Get personal access token. + * + *

See {@link #getPersonalAccessTokenWithHttpInfoAsync}. + * + * @param patUuid The UUID of the personal access token. (required) + * @return CompletableFuture<PersonalAccessTokenGetResponse> + */ + public CompletableFuture getPersonalAccessTokenAsync( + UUID patUuid) { + return getPersonalAccessTokenWithHttpInfoAsync(patUuid) + .thenApply( + response -> { + return response.getData(); + }); + } + + /** + * Get a specific personal access token by UUID. + * + * @param patUuid The UUID of the personal access token. (required) + * @return ApiResponse<PersonalAccessTokenGetResponse> + * @throws ApiException if fails to make API call + * @http.response.details + * + * + * + * + * + * + * + *
Response details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
429 Too many requests -
+ */ + public ApiResponse getPersonalAccessTokenWithHttpInfo( + UUID patUuid) throws ApiException { + // Check if unstable operation is enabled + String operationId = "getPersonalAccessToken"; + if (apiClient.isUnstableOperationEnabled("v2." + operationId)) { + apiClient.getLogger().warning(String.format("Using unstable operation '%s'", operationId)); + } else { + throw new ApiException(0, String.format("Unstable operation '%s' is disabled", operationId)); + } + Object localVarPostBody = null; + + // verify the required parameter 'patUuid' is set + if (patUuid == null) { + throw new ApiException( + 400, "Missing the required parameter 'patUuid' when calling getPersonalAccessToken"); + } + // create path and map variables + String localVarPath = + "/api/v2/personal_access_tokens/{pat_uuid}" + .replaceAll("\\{" + "pat_uuid" + "\\}", apiClient.escapeString(patUuid.toString())); + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder = + apiClient.createBuilder( + "v2.KeyManagementApi.getPersonalAccessToken", + localVarPath, + new ArrayList(), + localVarHeaderParams, + new HashMap(), + new String[] {"application/json"}, + new String[] {"apiKeyAuth", "appKeyAuth", "AuthZ"}); + return apiClient.invokeAPI( + "GET", + builder, + localVarHeaderParams, + new String[] {}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } + + /** + * Get personal access token. + * + *

See {@link #getPersonalAccessTokenWithHttpInfo}. + * + * @param patUuid The UUID of the personal access token. (required) + * @return CompletableFuture<ApiResponse<PersonalAccessTokenGetResponse>> + */ + public CompletableFuture> + getPersonalAccessTokenWithHttpInfoAsync(UUID patUuid) { + // Check if unstable operation is enabled + String operationId = "getPersonalAccessToken"; + if (apiClient.isUnstableOperationEnabled("v2." + operationId)) { + apiClient.getLogger().warning(String.format("Using unstable operation '%s'", operationId)); + } else { + CompletableFuture> result = + new CompletableFuture<>(); + result.completeExceptionally( + new ApiException(0, String.format("Unstable operation '%s' is disabled", operationId))); + return result; + } + Object localVarPostBody = null; + + // verify the required parameter 'patUuid' is set + if (patUuid == null) { + CompletableFuture> result = + new CompletableFuture<>(); + result.completeExceptionally( + new ApiException( + 400, "Missing the required parameter 'patUuid' when calling getPersonalAccessToken")); + return result; + } + // create path and map variables + String localVarPath = + "/api/v2/personal_access_tokens/{pat_uuid}" + .replaceAll("\\{" + "pat_uuid" + "\\}", apiClient.escapeString(patUuid.toString())); + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder; + try { + builder = + apiClient.createBuilder( + "v2.KeyManagementApi.getPersonalAccessToken", + localVarPath, + new ArrayList(), + localVarHeaderParams, + new HashMap(), + new String[] {"application/json"}, + new String[] {"apiKeyAuth", "appKeyAuth", "AuthZ"}); + } catch (ApiException ex) { + CompletableFuture> result = + new CompletableFuture<>(); + result.completeExceptionally(ex); + return result; + } + return apiClient.invokeAPIAsync( + "GET", + builder, + localVarHeaderParams, + new String[] {}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } + /** Manage optional parameters to listAPIKeys. */ public static class ListAPIKeysOptionalParameters { private Long pageSize; @@ -2167,45 +2485,459 @@ public ApiResponse listCurrentUserApplicationKeysWi new GenericType() {}); } - /** - * Edit an API key. - * - *

See {@link #updateAPIKeyWithHttpInfo}. - * - * @param apiKeyId The ID of the API key. (required) - * @param body (required) - * @return APIKeyResponse - * @throws ApiException if fails to make API call - */ - public APIKeyResponse updateAPIKey(String apiKeyId, APIKeyUpdateRequest body) - throws ApiException { - return updateAPIKeyWithHttpInfo(apiKeyId, body).getData(); - } + /** Manage optional parameters to listPersonalAccessTokens. */ + public static class ListPersonalAccessTokensOptionalParameters { + private Long pageSize; + private Long pageNumber; + private PersonalAccessTokensSort sort; + private String filter; + private List filterOwnerUuid; - /** - * Edit an API key. - * - *

See {@link #updateAPIKeyWithHttpInfoAsync}. - * - * @param apiKeyId The ID of the API key. (required) - * @param body (required) - * @return CompletableFuture<APIKeyResponse> - */ - public CompletableFuture updateAPIKeyAsync( - String apiKeyId, APIKeyUpdateRequest body) { - return updateAPIKeyWithHttpInfoAsync(apiKeyId, body) - .thenApply( - response -> { - return response.getData(); - }); - } + /** + * Set pageSize. + * + * @param pageSize Size for a given page. The maximum allowed value is 100. (optional, default + * to 10) + * @return ListPersonalAccessTokensOptionalParameters + */ + public ListPersonalAccessTokensOptionalParameters pageSize(Long pageSize) { + this.pageSize = pageSize; + return this; + } - /** - * Update an API key. - * - * @param apiKeyId The ID of the API key. (required) - * @param body (required) - * @return ApiResponse<APIKeyResponse> + /** + * Set pageNumber. + * + * @param pageNumber Specific page number to return. (optional, default to 0) + * @return ListPersonalAccessTokensOptionalParameters + */ + public ListPersonalAccessTokensOptionalParameters pageNumber(Long pageNumber) { + this.pageNumber = pageNumber; + return this; + } + + /** + * Set sort. + * + * @param 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. + * (optional, default to "name") + * @return ListPersonalAccessTokensOptionalParameters + */ + public ListPersonalAccessTokensOptionalParameters sort(PersonalAccessTokensSort sort) { + this.sort = sort; + return this; + } + + /** + * Set filter. + * + * @param filter Filter personal access tokens by name. (optional) + * @return ListPersonalAccessTokensOptionalParameters + */ + public ListPersonalAccessTokensOptionalParameters filter(String filter) { + this.filter = filter; + return this; + } + + /** + * Set filterOwnerUuid. + * + * @param filterOwnerUuid Filter personal access tokens by owner UUID. (optional) + * @return ListPersonalAccessTokensOptionalParameters + */ + public ListPersonalAccessTokensOptionalParameters filterOwnerUuid(List filterOwnerUuid) { + this.filterOwnerUuid = filterOwnerUuid; + return this; + } + } + + /** + * List personal access tokens. + * + *

See {@link #listPersonalAccessTokensWithHttpInfo}. + * + * @return PersonalAccessTokensListResponse + * @throws ApiException if fails to make API call + */ + public PersonalAccessTokensListResponse listPersonalAccessTokens() throws ApiException { + return listPersonalAccessTokensWithHttpInfo(new ListPersonalAccessTokensOptionalParameters()) + .getData(); + } + + /** + * List personal access tokens. + * + *

See {@link #listPersonalAccessTokensWithHttpInfoAsync}. + * + * @return CompletableFuture<PersonalAccessTokensListResponse> + */ + public CompletableFuture listPersonalAccessTokensAsync() { + return listPersonalAccessTokensWithHttpInfoAsync( + new ListPersonalAccessTokensOptionalParameters()) + .thenApply( + response -> { + return response.getData(); + }); + } + + /** + * List personal access tokens. + * + *

See {@link #listPersonalAccessTokensWithHttpInfo}. + * + * @param parameters Optional parameters for the request. + * @return PersonalAccessTokensListResponse + * @throws ApiException if fails to make API call + */ + public PersonalAccessTokensListResponse listPersonalAccessTokens( + ListPersonalAccessTokensOptionalParameters parameters) throws ApiException { + return listPersonalAccessTokensWithHttpInfo(parameters).getData(); + } + + /** + * List personal access tokens. + * + *

See {@link #listPersonalAccessTokensWithHttpInfoAsync}. + * + * @param parameters Optional parameters for the request. + * @return CompletableFuture<PersonalAccessTokensListResponse> + */ + public CompletableFuture listPersonalAccessTokensAsync( + ListPersonalAccessTokensOptionalParameters parameters) { + return listPersonalAccessTokensWithHttpInfoAsync(parameters) + .thenApply( + response -> { + return response.getData(); + }); + } + + /** + * List all personal access tokens in your organization. Supports filtering, pagination, and + * sorting. + * + * @param parameters Optional parameters for the request. + * @return ApiResponse<PersonalAccessTokensListResponse> + * @throws ApiException if fails to make API call + * @http.response.details + * + * + * + * + * + * + * + * + *
Response details
Status Code Description Response Headers
200 OK -
400 Bad Request -
403 Forbidden -
404 Not Found - Personal access tokens feature is not enabled -
429 Too many requests -
+ */ + public ApiResponse listPersonalAccessTokensWithHttpInfo( + ListPersonalAccessTokensOptionalParameters parameters) throws ApiException { + // Check if unstable operation is enabled + String operationId = "listPersonalAccessTokens"; + if (apiClient.isUnstableOperationEnabled("v2." + operationId)) { + apiClient.getLogger().warning(String.format("Using unstable operation '%s'", operationId)); + } else { + throw new ApiException(0, String.format("Unstable operation '%s' is disabled", operationId)); + } + Object localVarPostBody = null; + Long pageSize = parameters.pageSize; + Long pageNumber = parameters.pageNumber; + PersonalAccessTokensSort sort = parameters.sort; + String filter = parameters.filter; + List filterOwnerUuid = parameters.filterOwnerUuid; + // create path and map variables + String localVarPath = "/api/v2/personal_access_tokens"; + + List localVarQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + + localVarQueryParams.addAll(apiClient.parameterToPairs("", "page[size]", pageSize)); + localVarQueryParams.addAll(apiClient.parameterToPairs("", "page[number]", pageNumber)); + localVarQueryParams.addAll(apiClient.parameterToPairs("", "sort", sort)); + localVarQueryParams.addAll(apiClient.parameterToPairs("", "filter", filter)); + localVarQueryParams.addAll( + apiClient.parameterToPairs("multi", "filter[owner_uuid]", filterOwnerUuid)); + + Invocation.Builder builder = + apiClient.createBuilder( + "v2.KeyManagementApi.listPersonalAccessTokens", + localVarPath, + localVarQueryParams, + localVarHeaderParams, + new HashMap(), + new String[] {"application/json"}, + new String[] {"apiKeyAuth", "appKeyAuth", "AuthZ"}); + return apiClient.invokeAPI( + "GET", + builder, + localVarHeaderParams, + new String[] {}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } + + /** + * List personal access tokens. + * + *

See {@link #listPersonalAccessTokensWithHttpInfo}. + * + * @param parameters Optional parameters for the request. + * @return CompletableFuture<ApiResponse<PersonalAccessTokensListResponse>> + */ + public CompletableFuture> + listPersonalAccessTokensWithHttpInfoAsync( + ListPersonalAccessTokensOptionalParameters parameters) { + // Check if unstable operation is enabled + String operationId = "listPersonalAccessTokens"; + if (apiClient.isUnstableOperationEnabled("v2." + operationId)) { + apiClient.getLogger().warning(String.format("Using unstable operation '%s'", operationId)); + } else { + CompletableFuture> result = + new CompletableFuture<>(); + result.completeExceptionally( + new ApiException(0, String.format("Unstable operation '%s' is disabled", operationId))); + return result; + } + Object localVarPostBody = null; + Long pageSize = parameters.pageSize; + Long pageNumber = parameters.pageNumber; + PersonalAccessTokensSort sort = parameters.sort; + String filter = parameters.filter; + List filterOwnerUuid = parameters.filterOwnerUuid; + // create path and map variables + String localVarPath = "/api/v2/personal_access_tokens"; + + List localVarQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + + localVarQueryParams.addAll(apiClient.parameterToPairs("", "page[size]", pageSize)); + localVarQueryParams.addAll(apiClient.parameterToPairs("", "page[number]", pageNumber)); + localVarQueryParams.addAll(apiClient.parameterToPairs("", "sort", sort)); + localVarQueryParams.addAll(apiClient.parameterToPairs("", "filter", filter)); + localVarQueryParams.addAll( + apiClient.parameterToPairs("multi", "filter[owner_uuid]", filterOwnerUuid)); + + Invocation.Builder builder; + try { + builder = + apiClient.createBuilder( + "v2.KeyManagementApi.listPersonalAccessTokens", + localVarPath, + localVarQueryParams, + localVarHeaderParams, + new HashMap(), + new String[] {"application/json"}, + new String[] {"apiKeyAuth", "appKeyAuth", "AuthZ"}); + } catch (ApiException ex) { + CompletableFuture> result = + new CompletableFuture<>(); + result.completeExceptionally(ex); + return result; + } + return apiClient.invokeAPIAsync( + "GET", + builder, + localVarHeaderParams, + new String[] {}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } + + /** + * Revoke personal access token. + * + *

See {@link #revokePersonalAccessTokenWithHttpInfo}. + * + * @param patUuid The UUID of the personal access token. (required) + * @throws ApiException if fails to make API call + */ + public void revokePersonalAccessToken(UUID patUuid) throws ApiException { + revokePersonalAccessTokenWithHttpInfo(patUuid); + } + + /** + * Revoke personal access token. + * + *

See {@link #revokePersonalAccessTokenWithHttpInfoAsync}. + * + * @param patUuid The UUID of the personal access token. (required) + * @return CompletableFuture + */ + public CompletableFuture revokePersonalAccessTokenAsync(UUID patUuid) { + return revokePersonalAccessTokenWithHttpInfoAsync(patUuid) + .thenApply( + response -> { + return response.getData(); + }); + } + + /** + * Revoke a personal access token. Once revoked, the token can no longer be used to authenticate + * API requests. + * + * @param patUuid The UUID of the personal access token. (required) + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + * @http.response.details + * + * + * + * + * + * + * + *
Response details
Status Code Description Response Headers
204 No Content -
403 Forbidden -
404 Not Found -
429 Too many requests -
+ */ + public ApiResponse revokePersonalAccessTokenWithHttpInfo(UUID patUuid) throws ApiException { + // Check if unstable operation is enabled + String operationId = "revokePersonalAccessToken"; + if (apiClient.isUnstableOperationEnabled("v2." + operationId)) { + apiClient.getLogger().warning(String.format("Using unstable operation '%s'", operationId)); + } else { + throw new ApiException(0, String.format("Unstable operation '%s' is disabled", operationId)); + } + Object localVarPostBody = null; + + // verify the required parameter 'patUuid' is set + if (patUuid == null) { + throw new ApiException( + 400, "Missing the required parameter 'patUuid' when calling revokePersonalAccessToken"); + } + // create path and map variables + String localVarPath = + "/api/v2/personal_access_tokens/{pat_uuid}" + .replaceAll("\\{" + "pat_uuid" + "\\}", apiClient.escapeString(patUuid.toString())); + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder = + apiClient.createBuilder( + "v2.KeyManagementApi.revokePersonalAccessToken", + localVarPath, + new ArrayList(), + localVarHeaderParams, + new HashMap(), + new String[] {"*/*"}, + new String[] {"apiKeyAuth", "appKeyAuth", "AuthZ"}); + return apiClient.invokeAPI( + "DELETE", + builder, + localVarHeaderParams, + new String[] {}, + localVarPostBody, + new HashMap(), + false, + null); + } + + /** + * Revoke personal access token. + * + *

See {@link #revokePersonalAccessTokenWithHttpInfo}. + * + * @param patUuid The UUID of the personal access token. (required) + * @return CompletableFuture<ApiResponse<Void>> + */ + public CompletableFuture> revokePersonalAccessTokenWithHttpInfoAsync( + UUID patUuid) { + // Check if unstable operation is enabled + String operationId = "revokePersonalAccessToken"; + if (apiClient.isUnstableOperationEnabled("v2." + operationId)) { + apiClient.getLogger().warning(String.format("Using unstable operation '%s'", operationId)); + } else { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally( + new ApiException(0, String.format("Unstable operation '%s' is disabled", operationId))); + return result; + } + Object localVarPostBody = null; + + // verify the required parameter 'patUuid' is set + if (patUuid == null) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally( + new ApiException( + 400, + "Missing the required parameter 'patUuid' when calling revokePersonalAccessToken")); + return result; + } + // create path and map variables + String localVarPath = + "/api/v2/personal_access_tokens/{pat_uuid}" + .replaceAll("\\{" + "pat_uuid" + "\\}", apiClient.escapeString(patUuid.toString())); + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder; + try { + builder = + apiClient.createBuilder( + "v2.KeyManagementApi.revokePersonalAccessToken", + localVarPath, + new ArrayList(), + localVarHeaderParams, + new HashMap(), + new String[] {"*/*"}, + new String[] {"apiKeyAuth", "appKeyAuth", "AuthZ"}); + } catch (ApiException ex) { + CompletableFuture> result = new CompletableFuture<>(); + result.completeExceptionally(ex); + return result; + } + return apiClient.invokeAPIAsync( + "DELETE", + builder, + localVarHeaderParams, + new String[] {}, + localVarPostBody, + new HashMap(), + false, + null); + } + + /** + * Edit an API key. + * + *

See {@link #updateAPIKeyWithHttpInfo}. + * + * @param apiKeyId The ID of the API key. (required) + * @param body (required) + * @return APIKeyResponse + * @throws ApiException if fails to make API call + */ + public APIKeyResponse updateAPIKey(String apiKeyId, APIKeyUpdateRequest body) + throws ApiException { + return updateAPIKeyWithHttpInfo(apiKeyId, body).getData(); + } + + /** + * Edit an API key. + * + *

See {@link #updateAPIKeyWithHttpInfoAsync}. + * + * @param apiKeyId The ID of the API key. (required) + * @param body (required) + * @return CompletableFuture<APIKeyResponse> + */ + public CompletableFuture updateAPIKeyAsync( + String apiKeyId, APIKeyUpdateRequest body) { + return updateAPIKeyWithHttpInfoAsync(apiKeyId, body) + .thenApply( + response -> { + return response.getData(); + }); + } + + /** + * Update an API key. + * + * @param apiKeyId The ID of the API key. (required) + * @param body (required) + * @return ApiResponse<APIKeyResponse> * @throws ApiException if fails to make API call * @http.response.details * @@ -2646,4 +3378,185 @@ public ApiResponse updateCurrentUserApplicationKeyWithHt false, new GenericType() {}); } + + /** + * Update personal access token. + * + *

See {@link #updatePersonalAccessTokenWithHttpInfo}. + * + * @param patUuid The UUID of the personal access token. (required) + * @param body (required) + * @return PersonalAccessTokenGetResponse + * @throws ApiException if fails to make API call + */ + public PersonalAccessTokenGetResponse updatePersonalAccessToken( + UUID patUuid, PersonalAccessTokenUpdateRequest body) throws ApiException { + return updatePersonalAccessTokenWithHttpInfo(patUuid, body).getData(); + } + + /** + * Update personal access token. + * + *

See {@link #updatePersonalAccessTokenWithHttpInfoAsync}. + * + * @param patUuid The UUID of the personal access token. (required) + * @param body (required) + * @return CompletableFuture<PersonalAccessTokenGetResponse> + */ + public CompletableFuture updatePersonalAccessTokenAsync( + UUID patUuid, PersonalAccessTokenUpdateRequest body) { + return updatePersonalAccessTokenWithHttpInfoAsync(patUuid, body) + .thenApply( + response -> { + return response.getData(); + }); + } + + /** + * 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 patUuid The UUID of the personal access token. (required) + * @param body (required) + * @return ApiResponse<PersonalAccessTokenGetResponse> + * @throws ApiException if fails to make API call + * @http.response.details + *

+ * + * + * + * + * + * + * + *
Response details
Status Code Description Response Headers
200 OK -
400 Bad Request -
403 Forbidden -
404 Not Found -
429 Too many requests -
+ */ + public ApiResponse updatePersonalAccessTokenWithHttpInfo( + UUID patUuid, PersonalAccessTokenUpdateRequest body) throws ApiException { + // Check if unstable operation is enabled + String operationId = "updatePersonalAccessToken"; + if (apiClient.isUnstableOperationEnabled("v2." + operationId)) { + apiClient.getLogger().warning(String.format("Using unstable operation '%s'", operationId)); + } else { + throw new ApiException(0, String.format("Unstable operation '%s' is disabled", operationId)); + } + Object localVarPostBody = body; + + // verify the required parameter 'patUuid' is set + if (patUuid == null) { + throw new ApiException( + 400, "Missing the required parameter 'patUuid' when calling updatePersonalAccessToken"); + } + + // verify the required parameter 'body' is set + if (body == null) { + throw new ApiException( + 400, "Missing the required parameter 'body' when calling updatePersonalAccessToken"); + } + // create path and map variables + String localVarPath = + "/api/v2/personal_access_tokens/{pat_uuid}" + .replaceAll("\\{" + "pat_uuid" + "\\}", apiClient.escapeString(patUuid.toString())); + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder = + apiClient.createBuilder( + "v2.KeyManagementApi.updatePersonalAccessToken", + localVarPath, + new ArrayList(), + localVarHeaderParams, + new HashMap(), + new String[] {"application/json"}, + new String[] {"apiKeyAuth", "appKeyAuth", "AuthZ"}); + return apiClient.invokeAPI( + "PATCH", + builder, + localVarHeaderParams, + new String[] {"application/json"}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } + + /** + * Update personal access token. + * + *

See {@link #updatePersonalAccessTokenWithHttpInfo}. + * + * @param patUuid The UUID of the personal access token. (required) + * @param body (required) + * @return CompletableFuture<ApiResponse<PersonalAccessTokenGetResponse>> + */ + public CompletableFuture> + updatePersonalAccessTokenWithHttpInfoAsync( + UUID patUuid, PersonalAccessTokenUpdateRequest body) { + // Check if unstable operation is enabled + String operationId = "updatePersonalAccessToken"; + if (apiClient.isUnstableOperationEnabled("v2." + operationId)) { + apiClient.getLogger().warning(String.format("Using unstable operation '%s'", operationId)); + } else { + CompletableFuture> result = + new CompletableFuture<>(); + result.completeExceptionally( + new ApiException(0, String.format("Unstable operation '%s' is disabled", operationId))); + return result; + } + Object localVarPostBody = body; + + // verify the required parameter 'patUuid' is set + if (patUuid == null) { + CompletableFuture> result = + new CompletableFuture<>(); + result.completeExceptionally( + new ApiException( + 400, + "Missing the required parameter 'patUuid' when calling updatePersonalAccessToken")); + return result; + } + + // verify the required parameter 'body' is set + if (body == null) { + CompletableFuture> result = + new CompletableFuture<>(); + result.completeExceptionally( + new ApiException( + 400, "Missing the required parameter 'body' when calling updatePersonalAccessToken")); + return result; + } + // create path and map variables + String localVarPath = + "/api/v2/personal_access_tokens/{pat_uuid}" + .replaceAll("\\{" + "pat_uuid" + "\\}", apiClient.escapeString(patUuid.toString())); + + Map localVarHeaderParams = new HashMap(); + + Invocation.Builder builder; + try { + builder = + apiClient.createBuilder( + "v2.KeyManagementApi.updatePersonalAccessToken", + localVarPath, + new ArrayList(), + localVarHeaderParams, + new HashMap(), + new String[] {"application/json"}, + new String[] {"apiKeyAuth", "appKeyAuth", "AuthZ"}); + } catch (ApiException ex) { + CompletableFuture> result = + new CompletableFuture<>(); + result.completeExceptionally(ex); + return result; + } + return apiClient.invokeAPIAsync( + "PATCH", + builder, + localVarHeaderParams, + new String[] {"application/json"}, + localVarPostBody, + new HashMap(), + false, + new GenericType() {}); + } } diff --git a/src/main/java/com/datadog/api/client/v2/model/FullPersonalAccessToken.java b/src/main/java/com/datadog/api/client/v2/model/FullPersonalAccessToken.java new file mode 100644 index 00000000000..37d80c8a8c1 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/FullPersonalAccessToken.java @@ -0,0 +1,245 @@ +/* + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.UUID; + +/** + * Personal access token object with the secret key value. This is only returned when creating a new + * token. + */ +@JsonPropertyOrder({ + FullPersonalAccessToken.JSON_PROPERTY_ATTRIBUTES, + FullPersonalAccessToken.JSON_PROPERTY_ID, + FullPersonalAccessToken.JSON_PROPERTY_RELATIONSHIPS, + FullPersonalAccessToken.JSON_PROPERTY_TYPE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class FullPersonalAccessToken { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_ATTRIBUTES = "attributes"; + private FullPersonalAccessTokenAttributes attributes; + + public static final String JSON_PROPERTY_ID = "id"; + private UUID id; + + public static final String JSON_PROPERTY_RELATIONSHIPS = "relationships"; + private PersonalAccessTokenRelationships relationships; + + public static final String JSON_PROPERTY_TYPE = "type"; + private PersonalAccessTokenType type = PersonalAccessTokenType.PERSONAL_ACCESS_TOKENS; + + public FullPersonalAccessToken() {} + + @JsonCreator + public FullPersonalAccessToken( + @JsonProperty(required = true, value = JSON_PROPERTY_ATTRIBUTES) + FullPersonalAccessTokenAttributes attributes, + @JsonProperty(required = true, value = JSON_PROPERTY_ID) UUID id, + @JsonProperty(required = true, value = JSON_PROPERTY_RELATIONSHIPS) + PersonalAccessTokenRelationships relationships, + @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) PersonalAccessTokenType type) { + this.attributes = attributes; + this.unparsed |= attributes.unparsed; + this.id = id; + this.relationships = relationships; + this.unparsed |= relationships.unparsed; + this.type = type; + this.unparsed |= !type.isValid(); + } + + public FullPersonalAccessToken attributes(FullPersonalAccessTokenAttributes attributes) { + this.attributes = attributes; + this.unparsed |= attributes.unparsed; + return this; + } + + /** + * Attributes of a personal access token including the secret key value. This is only returned + * when creating a new token. + * + * @return attributes + */ + @JsonProperty(JSON_PROPERTY_ATTRIBUTES) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public FullPersonalAccessTokenAttributes getAttributes() { + return attributes; + } + + public void setAttributes(FullPersonalAccessTokenAttributes attributes) { + this.attributes = attributes; + } + + public FullPersonalAccessToken id(UUID id) { + this.id = id; + return this; + } + + /** + * UUID of the personal access token. + * + * @return id + */ + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public UUID getId() { + return id; + } + + public void setId(UUID id) { + this.id = id; + } + + public FullPersonalAccessToken relationships(PersonalAccessTokenRelationships relationships) { + this.relationships = relationships; + this.unparsed |= relationships.unparsed; + return this; + } + + /** + * Resources related to the personal access token. + * + * @return relationships + */ + @JsonProperty(JSON_PROPERTY_RELATIONSHIPS) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public PersonalAccessTokenRelationships getRelationships() { + return relationships; + } + + public void setRelationships(PersonalAccessTokenRelationships relationships) { + this.relationships = relationships; + } + + public FullPersonalAccessToken type(PersonalAccessTokenType type) { + this.type = type; + this.unparsed |= !type.isValid(); + return this; + } + + /** + * Personal access tokens resource type. + * + * @return type + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public PersonalAccessTokenType getType() { + return type; + } + + public void setType(PersonalAccessTokenType type) { + if (!type.isValid()) { + this.unparsed = true; + } + this.type = type; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return FullPersonalAccessToken + */ + @JsonAnySetter + public FullPersonalAccessToken putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this FullPersonalAccessToken object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + FullPersonalAccessToken fullPersonalAccessToken = (FullPersonalAccessToken) o; + return Objects.equals(this.attributes, fullPersonalAccessToken.attributes) + && Objects.equals(this.id, fullPersonalAccessToken.id) + && Objects.equals(this.relationships, fullPersonalAccessToken.relationships) + && Objects.equals(this.type, fullPersonalAccessToken.type) + && Objects.equals(this.additionalProperties, fullPersonalAccessToken.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(attributes, id, relationships, type, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class FullPersonalAccessToken {\n"); + sb.append(" attributes: ").append(toIndentedString(attributes)).append("\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" relationships: ").append(toIndentedString(relationships)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/FullPersonalAccessTokenAttributes.java b/src/main/java/com/datadog/api/client/v2/model/FullPersonalAccessTokenAttributes.java new file mode 100644 index 00000000000..d3ffad785cc --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/FullPersonalAccessTokenAttributes.java @@ -0,0 +1,287 @@ +/* + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.time.OffsetDateTime; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import org.openapitools.jackson.nullable.JsonNullable; + +/** + * Attributes of a personal access token including the secret key value. This is only returned when + * creating a new token. + */ +@JsonPropertyOrder({ + FullPersonalAccessTokenAttributes.JSON_PROPERTY_CREATED_AT, + FullPersonalAccessTokenAttributes.JSON_PROPERTY_EXPIRES_AT, + FullPersonalAccessTokenAttributes.JSON_PROPERTY_KEY, + FullPersonalAccessTokenAttributes.JSON_PROPERTY_MODIFIED_AT, + FullPersonalAccessTokenAttributes.JSON_PROPERTY_NAME, + FullPersonalAccessTokenAttributes.JSON_PROPERTY_SCOPES +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class FullPersonalAccessTokenAttributes { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_CREATED_AT = "created_at"; + private OffsetDateTime createdAt; + + public static final String JSON_PROPERTY_EXPIRES_AT = "expires_at"; + private OffsetDateTime expiresAt; + + public static final String JSON_PROPERTY_KEY = "key"; + private String key; + + public static final String JSON_PROPERTY_MODIFIED_AT = "modified_at"; + private JsonNullable modifiedAt = JsonNullable.undefined(); + + public static final String JSON_PROPERTY_NAME = "name"; + private String name; + + public static final String JSON_PROPERTY_SCOPES = "scopes"; + private List scopes = new ArrayList<>(); + + public FullPersonalAccessTokenAttributes() {} + + @JsonCreator + public FullPersonalAccessTokenAttributes( + @JsonProperty(required = true, value = JSON_PROPERTY_CREATED_AT) OffsetDateTime createdAt, + @JsonProperty(required = true, value = JSON_PROPERTY_EXPIRES_AT) OffsetDateTime expiresAt, + @JsonProperty(required = true, value = JSON_PROPERTY_KEY) String key, + @JsonProperty(required = true, value = JSON_PROPERTY_NAME) String name, + @JsonProperty(required = true, value = JSON_PROPERTY_SCOPES) List scopes) { + this.createdAt = createdAt; + this.expiresAt = expiresAt; + this.key = key; + this.name = name; + this.scopes = scopes; + } + + /** + * Creation timestamp of the personal access token. + * + * @return createdAt + */ + @JsonProperty(JSON_PROPERTY_CREATED_AT) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public OffsetDateTime getCreatedAt() { + return createdAt; + } + + public FullPersonalAccessTokenAttributes expiresAt(OffsetDateTime expiresAt) { + this.expiresAt = expiresAt; + return this; + } + + /** + * Expiration timestamp of the personal access token. + * + * @return expiresAt + */ + @JsonProperty(JSON_PROPERTY_EXPIRES_AT) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public OffsetDateTime getExpiresAt() { + return expiresAt; + } + + public void setExpiresAt(OffsetDateTime expiresAt) { + this.expiresAt = expiresAt; + } + + /** + * The secret token value. This is only returned when creating a new personal access token and + * cannot be retrieved later. + * + * @return key + */ + @JsonProperty(JSON_PROPERTY_KEY) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getKey() { + return key; + } + + /** + * Last modification timestamp of the personal access token. + * + * @return modifiedAt + */ + @jakarta.annotation.Nullable + @JsonIgnore + public OffsetDateTime getModifiedAt() { + + if (modifiedAt == null) { + modifiedAt = JsonNullable.undefined(); + } + return modifiedAt.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_MODIFIED_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public JsonNullable getModifiedAt_JsonNullable() { + return modifiedAt; + } + + @JsonProperty(JSON_PROPERTY_MODIFIED_AT) + private void setModifiedAt_JsonNullable(JsonNullable modifiedAt) { + this.modifiedAt = modifiedAt; + } + + public FullPersonalAccessTokenAttributes name(String name) { + this.name = name; + return this; + } + + /** + * Name of the personal access token. + * + * @return name + */ + @JsonProperty(JSON_PROPERTY_NAME) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public FullPersonalAccessTokenAttributes scopes(List scopes) { + this.scopes = scopes; + return this; + } + + public FullPersonalAccessTokenAttributes addScopesItem(String scopesItem) { + this.scopes.add(scopesItem); + return this; + } + + /** + * Array of scopes granted to the personal access token. These define what permissions the token + * has. + * + * @return scopes + */ + @JsonProperty(JSON_PROPERTY_SCOPES) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public List getScopes() { + return scopes; + } + + public void setScopes(List scopes) { + this.scopes = scopes; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return FullPersonalAccessTokenAttributes + */ + @JsonAnySetter + public FullPersonalAccessTokenAttributes putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this FullPersonalAccessTokenAttributes object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + FullPersonalAccessTokenAttributes fullPersonalAccessTokenAttributes = + (FullPersonalAccessTokenAttributes) o; + return Objects.equals(this.createdAt, fullPersonalAccessTokenAttributes.createdAt) + && Objects.equals(this.expiresAt, fullPersonalAccessTokenAttributes.expiresAt) + && Objects.equals(this.key, fullPersonalAccessTokenAttributes.key) + && Objects.equals(this.modifiedAt, fullPersonalAccessTokenAttributes.modifiedAt) + && Objects.equals(this.name, fullPersonalAccessTokenAttributes.name) + && Objects.equals(this.scopes, fullPersonalAccessTokenAttributes.scopes) + && Objects.equals( + this.additionalProperties, fullPersonalAccessTokenAttributes.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(createdAt, expiresAt, key, modifiedAt, name, scopes, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class FullPersonalAccessTokenAttributes {\n"); + sb.append(" createdAt: ").append(toIndentedString(createdAt)).append("\n"); + sb.append(" expiresAt: ").append(toIndentedString(expiresAt)).append("\n"); + sb.append(" key: ").append(toIndentedString(key)).append("\n"); + sb.append(" modifiedAt: ").append(toIndentedString(modifiedAt)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" scopes: ").append(toIndentedString(scopes)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/PersonalAccessToken.java b/src/main/java/com/datadog/api/client/v2/model/PersonalAccessToken.java new file mode 100644 index 00000000000..ea79c1a63df --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/PersonalAccessToken.java @@ -0,0 +1,241 @@ +/* + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.UUID; + +/** Personal access token object. */ +@JsonPropertyOrder({ + PersonalAccessToken.JSON_PROPERTY_ATTRIBUTES, + PersonalAccessToken.JSON_PROPERTY_ID, + PersonalAccessToken.JSON_PROPERTY_RELATIONSHIPS, + PersonalAccessToken.JSON_PROPERTY_TYPE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class PersonalAccessToken { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_ATTRIBUTES = "attributes"; + private PersonalAccessTokenAttributes attributes; + + public static final String JSON_PROPERTY_ID = "id"; + private UUID id; + + public static final String JSON_PROPERTY_RELATIONSHIPS = "relationships"; + private PersonalAccessTokenRelationships relationships; + + public static final String JSON_PROPERTY_TYPE = "type"; + private PersonalAccessTokenType type = PersonalAccessTokenType.PERSONAL_ACCESS_TOKENS; + + public PersonalAccessToken() {} + + @JsonCreator + public PersonalAccessToken( + @JsonProperty(required = true, value = JSON_PROPERTY_ATTRIBUTES) + PersonalAccessTokenAttributes attributes, + @JsonProperty(required = true, value = JSON_PROPERTY_ID) UUID id, + @JsonProperty(required = true, value = JSON_PROPERTY_RELATIONSHIPS) + PersonalAccessTokenRelationships relationships, + @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) PersonalAccessTokenType type) { + this.attributes = attributes; + this.unparsed |= attributes.unparsed; + this.id = id; + this.relationships = relationships; + this.unparsed |= relationships.unparsed; + this.type = type; + this.unparsed |= !type.isValid(); + } + + public PersonalAccessToken attributes(PersonalAccessTokenAttributes attributes) { + this.attributes = attributes; + this.unparsed |= attributes.unparsed; + return this; + } + + /** + * Attributes of a personal access token. + * + * @return attributes + */ + @JsonProperty(JSON_PROPERTY_ATTRIBUTES) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public PersonalAccessTokenAttributes getAttributes() { + return attributes; + } + + public void setAttributes(PersonalAccessTokenAttributes attributes) { + this.attributes = attributes; + } + + public PersonalAccessToken id(UUID id) { + this.id = id; + return this; + } + + /** + * UUID of the personal access token. + * + * @return id + */ + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public UUID getId() { + return id; + } + + public void setId(UUID id) { + this.id = id; + } + + public PersonalAccessToken relationships(PersonalAccessTokenRelationships relationships) { + this.relationships = relationships; + this.unparsed |= relationships.unparsed; + return this; + } + + /** + * Resources related to the personal access token. + * + * @return relationships + */ + @JsonProperty(JSON_PROPERTY_RELATIONSHIPS) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public PersonalAccessTokenRelationships getRelationships() { + return relationships; + } + + public void setRelationships(PersonalAccessTokenRelationships relationships) { + this.relationships = relationships; + } + + public PersonalAccessToken type(PersonalAccessTokenType type) { + this.type = type; + this.unparsed |= !type.isValid(); + return this; + } + + /** + * Personal access tokens resource type. + * + * @return type + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public PersonalAccessTokenType getType() { + return type; + } + + public void setType(PersonalAccessTokenType type) { + if (!type.isValid()) { + this.unparsed = true; + } + this.type = type; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return PersonalAccessToken + */ + @JsonAnySetter + public PersonalAccessToken putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this PersonalAccessToken object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PersonalAccessToken personalAccessToken = (PersonalAccessToken) o; + return Objects.equals(this.attributes, personalAccessToken.attributes) + && Objects.equals(this.id, personalAccessToken.id) + && Objects.equals(this.relationships, personalAccessToken.relationships) + && Objects.equals(this.type, personalAccessToken.type) + && Objects.equals(this.additionalProperties, personalAccessToken.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(attributes, id, relationships, type, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class PersonalAccessToken {\n"); + sb.append(" attributes: ").append(toIndentedString(attributes)).append("\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" relationships: ").append(toIndentedString(relationships)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/PersonalAccessTokenAttributes.java b/src/main/java/com/datadog/api/client/v2/model/PersonalAccessTokenAttributes.java new file mode 100644 index 00000000000..fd5671a7fc0 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/PersonalAccessTokenAttributes.java @@ -0,0 +1,263 @@ +/* + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.time.OffsetDateTime; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import org.openapitools.jackson.nullable.JsonNullable; + +/** Attributes of a personal access token. */ +@JsonPropertyOrder({ + PersonalAccessTokenAttributes.JSON_PROPERTY_CREATED_AT, + PersonalAccessTokenAttributes.JSON_PROPERTY_EXPIRES_AT, + PersonalAccessTokenAttributes.JSON_PROPERTY_MODIFIED_AT, + PersonalAccessTokenAttributes.JSON_PROPERTY_NAME, + PersonalAccessTokenAttributes.JSON_PROPERTY_SCOPES +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class PersonalAccessTokenAttributes { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_CREATED_AT = "created_at"; + private OffsetDateTime createdAt; + + public static final String JSON_PROPERTY_EXPIRES_AT = "expires_at"; + private OffsetDateTime expiresAt; + + public static final String JSON_PROPERTY_MODIFIED_AT = "modified_at"; + private JsonNullable modifiedAt = JsonNullable.undefined(); + + public static final String JSON_PROPERTY_NAME = "name"; + private String name; + + public static final String JSON_PROPERTY_SCOPES = "scopes"; + private List scopes = new ArrayList<>(); + + public PersonalAccessTokenAttributes() {} + + @JsonCreator + public PersonalAccessTokenAttributes( + @JsonProperty(required = true, value = JSON_PROPERTY_CREATED_AT) OffsetDateTime createdAt, + @JsonProperty(required = true, value = JSON_PROPERTY_EXPIRES_AT) OffsetDateTime expiresAt, + @JsonProperty(required = true, value = JSON_PROPERTY_NAME) String name, + @JsonProperty(required = true, value = JSON_PROPERTY_SCOPES) List scopes) { + this.createdAt = createdAt; + this.expiresAt = expiresAt; + this.name = name; + this.scopes = scopes; + } + + /** + * Creation timestamp of the personal access token. + * + * @return createdAt + */ + @JsonProperty(JSON_PROPERTY_CREATED_AT) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public OffsetDateTime getCreatedAt() { + return createdAt; + } + + public PersonalAccessTokenAttributes expiresAt(OffsetDateTime expiresAt) { + this.expiresAt = expiresAt; + return this; + } + + /** + * Expiration timestamp of the personal access token. + * + * @return expiresAt + */ + @JsonProperty(JSON_PROPERTY_EXPIRES_AT) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public OffsetDateTime getExpiresAt() { + return expiresAt; + } + + public void setExpiresAt(OffsetDateTime expiresAt) { + this.expiresAt = expiresAt; + } + + /** + * Last modification timestamp of the personal access token. + * + * @return modifiedAt + */ + @jakarta.annotation.Nullable + @JsonIgnore + public OffsetDateTime getModifiedAt() { + + if (modifiedAt == null) { + modifiedAt = JsonNullable.undefined(); + } + return modifiedAt.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_MODIFIED_AT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public JsonNullable getModifiedAt_JsonNullable() { + return modifiedAt; + } + + @JsonProperty(JSON_PROPERTY_MODIFIED_AT) + private void setModifiedAt_JsonNullable(JsonNullable modifiedAt) { + this.modifiedAt = modifiedAt; + } + + public PersonalAccessTokenAttributes name(String name) { + this.name = name; + return this; + } + + /** + * Name of the personal access token. + * + * @return name + */ + @JsonProperty(JSON_PROPERTY_NAME) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public PersonalAccessTokenAttributes scopes(List scopes) { + this.scopes = scopes; + return this; + } + + public PersonalAccessTokenAttributes addScopesItem(String scopesItem) { + this.scopes.add(scopesItem); + return this; + } + + /** + * Array of scopes granted to the personal access token. These define what permissions the token + * has. + * + * @return scopes + */ + @JsonProperty(JSON_PROPERTY_SCOPES) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public List getScopes() { + return scopes; + } + + public void setScopes(List scopes) { + this.scopes = scopes; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return PersonalAccessTokenAttributes + */ + @JsonAnySetter + public PersonalAccessTokenAttributes putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this PersonalAccessTokenAttributes object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PersonalAccessTokenAttributes personalAccessTokenAttributes = (PersonalAccessTokenAttributes) o; + return Objects.equals(this.createdAt, personalAccessTokenAttributes.createdAt) + && Objects.equals(this.expiresAt, personalAccessTokenAttributes.expiresAt) + && Objects.equals(this.modifiedAt, personalAccessTokenAttributes.modifiedAt) + && Objects.equals(this.name, personalAccessTokenAttributes.name) + && Objects.equals(this.scopes, personalAccessTokenAttributes.scopes) + && Objects.equals( + this.additionalProperties, personalAccessTokenAttributes.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(createdAt, expiresAt, modifiedAt, name, scopes, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class PersonalAccessTokenAttributes {\n"); + sb.append(" createdAt: ").append(toIndentedString(createdAt)).append("\n"); + sb.append(" expiresAt: ").append(toIndentedString(expiresAt)).append("\n"); + sb.append(" modifiedAt: ").append(toIndentedString(modifiedAt)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" scopes: ").append(toIndentedString(scopes)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/PersonalAccessTokenCreateAttributes.java b/src/main/java/com/datadog/api/client/v2/model/PersonalAccessTokenCreateAttributes.java new file mode 100644 index 00000000000..a028a7a0265 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/PersonalAccessTokenCreateAttributes.java @@ -0,0 +1,212 @@ +/* + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.time.OffsetDateTime; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** Attributes used to create a personal access token. */ +@JsonPropertyOrder({ + PersonalAccessTokenCreateAttributes.JSON_PROPERTY_EXPIRES_AT, + PersonalAccessTokenCreateAttributes.JSON_PROPERTY_NAME, + PersonalAccessTokenCreateAttributes.JSON_PROPERTY_SCOPES +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class PersonalAccessTokenCreateAttributes { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_EXPIRES_AT = "expires_at"; + private OffsetDateTime expiresAt; + + public static final String JSON_PROPERTY_NAME = "name"; + private String name; + + public static final String JSON_PROPERTY_SCOPES = "scopes"; + private List scopes = new ArrayList<>(); + + public PersonalAccessTokenCreateAttributes() {} + + @JsonCreator + public PersonalAccessTokenCreateAttributes( + @JsonProperty(required = true, value = JSON_PROPERTY_EXPIRES_AT) OffsetDateTime expiresAt, + @JsonProperty(required = true, value = JSON_PROPERTY_NAME) String name, + @JsonProperty(required = true, value = JSON_PROPERTY_SCOPES) List scopes) { + this.expiresAt = expiresAt; + this.name = name; + this.scopes = scopes; + } + + public PersonalAccessTokenCreateAttributes expiresAt(OffsetDateTime expiresAt) { + this.expiresAt = expiresAt; + return this; + } + + /** + * Expiration timestamp for the personal access token. + * + * @return expiresAt + */ + @JsonProperty(JSON_PROPERTY_EXPIRES_AT) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public OffsetDateTime getExpiresAt() { + return expiresAt; + } + + public void setExpiresAt(OffsetDateTime expiresAt) { + this.expiresAt = expiresAt; + } + + public PersonalAccessTokenCreateAttributes name(String name) { + this.name = name; + return this; + } + + /** + * Name of the personal access token. + * + * @return name + */ + @JsonProperty(JSON_PROPERTY_NAME) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public PersonalAccessTokenCreateAttributes scopes(List scopes) { + this.scopes = scopes; + return this; + } + + public PersonalAccessTokenCreateAttributes addScopesItem(String scopesItem) { + this.scopes.add(scopesItem); + return this; + } + + /** + * Array of scopes to grant the personal access token. These define what permissions the token + * will have. + * + * @return scopes + */ + @JsonProperty(JSON_PROPERTY_SCOPES) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public List getScopes() { + return scopes; + } + + public void setScopes(List scopes) { + this.scopes = scopes; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return PersonalAccessTokenCreateAttributes + */ + @JsonAnySetter + public PersonalAccessTokenCreateAttributes putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this PersonalAccessTokenCreateAttributes object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PersonalAccessTokenCreateAttributes personalAccessTokenCreateAttributes = + (PersonalAccessTokenCreateAttributes) o; + return Objects.equals(this.expiresAt, personalAccessTokenCreateAttributes.expiresAt) + && Objects.equals(this.name, personalAccessTokenCreateAttributes.name) + && Objects.equals(this.scopes, personalAccessTokenCreateAttributes.scopes) + && Objects.equals( + this.additionalProperties, personalAccessTokenCreateAttributes.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(expiresAt, name, scopes, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class PersonalAccessTokenCreateAttributes {\n"); + sb.append(" expiresAt: ").append(toIndentedString(expiresAt)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" scopes: ").append(toIndentedString(scopes)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/PersonalAccessTokenCreateData.java b/src/main/java/com/datadog/api/client/v2/model/PersonalAccessTokenCreateData.java new file mode 100644 index 00000000000..6701ae26a71 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/PersonalAccessTokenCreateData.java @@ -0,0 +1,182 @@ +/* + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** Object used to create a personal access token. */ +@JsonPropertyOrder({ + PersonalAccessTokenCreateData.JSON_PROPERTY_ATTRIBUTES, + PersonalAccessTokenCreateData.JSON_PROPERTY_TYPE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class PersonalAccessTokenCreateData { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_ATTRIBUTES = "attributes"; + private PersonalAccessTokenCreateAttributes attributes; + + public static final String JSON_PROPERTY_TYPE = "type"; + private PersonalAccessTokenType type = PersonalAccessTokenType.PERSONAL_ACCESS_TOKENS; + + public PersonalAccessTokenCreateData() {} + + @JsonCreator + public PersonalAccessTokenCreateData( + @JsonProperty(required = true, value = JSON_PROPERTY_ATTRIBUTES) + PersonalAccessTokenCreateAttributes attributes, + @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) PersonalAccessTokenType type) { + this.attributes = attributes; + this.unparsed |= attributes.unparsed; + this.type = type; + this.unparsed |= !type.isValid(); + } + + public PersonalAccessTokenCreateData attributes(PersonalAccessTokenCreateAttributes attributes) { + this.attributes = attributes; + this.unparsed |= attributes.unparsed; + return this; + } + + /** + * Attributes used to create a personal access token. + * + * @return attributes + */ + @JsonProperty(JSON_PROPERTY_ATTRIBUTES) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public PersonalAccessTokenCreateAttributes getAttributes() { + return attributes; + } + + public void setAttributes(PersonalAccessTokenCreateAttributes attributes) { + this.attributes = attributes; + } + + public PersonalAccessTokenCreateData type(PersonalAccessTokenType type) { + this.type = type; + this.unparsed |= !type.isValid(); + return this; + } + + /** + * Personal access tokens resource type. + * + * @return type + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public PersonalAccessTokenType getType() { + return type; + } + + public void setType(PersonalAccessTokenType type) { + if (!type.isValid()) { + this.unparsed = true; + } + this.type = type; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return PersonalAccessTokenCreateData + */ + @JsonAnySetter + public PersonalAccessTokenCreateData putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this PersonalAccessTokenCreateData object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PersonalAccessTokenCreateData personalAccessTokenCreateData = (PersonalAccessTokenCreateData) o; + return Objects.equals(this.attributes, personalAccessTokenCreateData.attributes) + && Objects.equals(this.type, personalAccessTokenCreateData.type) + && Objects.equals( + this.additionalProperties, personalAccessTokenCreateData.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(attributes, type, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class PersonalAccessTokenCreateData {\n"); + sb.append(" attributes: ").append(toIndentedString(attributes)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/PersonalAccessTokenCreateRequest.java b/src/main/java/com/datadog/api/client/v2/model/PersonalAccessTokenCreateRequest.java new file mode 100644 index 00000000000..67f02e7c235 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/PersonalAccessTokenCreateRequest.java @@ -0,0 +1,148 @@ +/* + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** Request to create a personal access token. */ +@JsonPropertyOrder({PersonalAccessTokenCreateRequest.JSON_PROPERTY_DATA}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class PersonalAccessTokenCreateRequest { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_DATA = "data"; + private PersonalAccessTokenCreateData data; + + public PersonalAccessTokenCreateRequest() {} + + @JsonCreator + public PersonalAccessTokenCreateRequest( + @JsonProperty(required = true, value = JSON_PROPERTY_DATA) + PersonalAccessTokenCreateData data) { + this.data = data; + this.unparsed |= data.unparsed; + } + + public PersonalAccessTokenCreateRequest data(PersonalAccessTokenCreateData data) { + this.data = data; + this.unparsed |= data.unparsed; + return this; + } + + /** + * Object used to create a personal access token. + * + * @return data + */ + @JsonProperty(JSON_PROPERTY_DATA) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public PersonalAccessTokenCreateData getData() { + return data; + } + + public void setData(PersonalAccessTokenCreateData data) { + this.data = data; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return PersonalAccessTokenCreateRequest + */ + @JsonAnySetter + public PersonalAccessTokenCreateRequest putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this PersonalAccessTokenCreateRequest object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PersonalAccessTokenCreateRequest personalAccessTokenCreateRequest = + (PersonalAccessTokenCreateRequest) o; + return Objects.equals(this.data, personalAccessTokenCreateRequest.data) + && Objects.equals( + this.additionalProperties, personalAccessTokenCreateRequest.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(data, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class PersonalAccessTokenCreateRequest {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/PersonalAccessTokenGetResponse.java b/src/main/java/com/datadog/api/client/v2/model/PersonalAccessTokenGetResponse.java new file mode 100644 index 00000000000..76438e67e8a --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/PersonalAccessTokenGetResponse.java @@ -0,0 +1,138 @@ +/* + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** Response for retrieving a personal access token. */ +@JsonPropertyOrder({PersonalAccessTokenGetResponse.JSON_PROPERTY_DATA}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class PersonalAccessTokenGetResponse { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_DATA = "data"; + private PersonalAccessToken data; + + public PersonalAccessTokenGetResponse data(PersonalAccessToken data) { + this.data = data; + this.unparsed |= data.unparsed; + return this; + } + + /** + * Personal access token object. + * + * @return data + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_DATA) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public PersonalAccessToken getData() { + return data; + } + + public void setData(PersonalAccessToken data) { + this.data = data; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return PersonalAccessTokenGetResponse + */ + @JsonAnySetter + public PersonalAccessTokenGetResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this PersonalAccessTokenGetResponse object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PersonalAccessTokenGetResponse personalAccessTokenGetResponse = + (PersonalAccessTokenGetResponse) o; + return Objects.equals(this.data, personalAccessTokenGetResponse.data) + && Objects.equals( + this.additionalProperties, personalAccessTokenGetResponse.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(data, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class PersonalAccessTokenGetResponse {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/PersonalAccessTokenRelationships.java b/src/main/java/com/datadog/api/client/v2/model/PersonalAccessTokenRelationships.java new file mode 100644 index 00000000000..ffe981bb959 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/PersonalAccessTokenRelationships.java @@ -0,0 +1,138 @@ +/* + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** Resources related to the personal access token. */ +@JsonPropertyOrder({PersonalAccessTokenRelationships.JSON_PROPERTY_OWNED_BY}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class PersonalAccessTokenRelationships { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_OWNED_BY = "owned_by"; + private RelationshipToUser ownedBy; + + public PersonalAccessTokenRelationships ownedBy(RelationshipToUser ownedBy) { + this.ownedBy = ownedBy; + this.unparsed |= ownedBy.unparsed; + return this; + } + + /** + * Relationship to user. + * + * @return ownedBy + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_OWNED_BY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public RelationshipToUser getOwnedBy() { + return ownedBy; + } + + public void setOwnedBy(RelationshipToUser ownedBy) { + this.ownedBy = ownedBy; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return PersonalAccessTokenRelationships + */ + @JsonAnySetter + public PersonalAccessTokenRelationships putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this PersonalAccessTokenRelationships object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PersonalAccessTokenRelationships personalAccessTokenRelationships = + (PersonalAccessTokenRelationships) o; + return Objects.equals(this.ownedBy, personalAccessTokenRelationships.ownedBy) + && Objects.equals( + this.additionalProperties, personalAccessTokenRelationships.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(ownedBy, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class PersonalAccessTokenRelationships {\n"); + sb.append(" ownedBy: ").append(toIndentedString(ownedBy)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/PersonalAccessTokenResponse.java b/src/main/java/com/datadog/api/client/v2/model/PersonalAccessTokenResponse.java new file mode 100644 index 00000000000..d1e72c7783e --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/PersonalAccessTokenResponse.java @@ -0,0 +1,138 @@ +/* + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** Response for creating a personal access token. */ +@JsonPropertyOrder({PersonalAccessTokenResponse.JSON_PROPERTY_DATA}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class PersonalAccessTokenResponse { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_DATA = "data"; + private FullPersonalAccessToken data; + + public PersonalAccessTokenResponse data(FullPersonalAccessToken data) { + this.data = data; + this.unparsed |= data.unparsed; + return this; + } + + /** + * Personal access token object with the secret key value. This is only returned when creating a + * new token. + * + * @return data + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_DATA) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public FullPersonalAccessToken getData() { + return data; + } + + public void setData(FullPersonalAccessToken data) { + this.data = data; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return PersonalAccessTokenResponse + */ + @JsonAnySetter + public PersonalAccessTokenResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this PersonalAccessTokenResponse object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PersonalAccessTokenResponse personalAccessTokenResponse = (PersonalAccessTokenResponse) o; + return Objects.equals(this.data, personalAccessTokenResponse.data) + && Objects.equals( + this.additionalProperties, personalAccessTokenResponse.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(data, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class PersonalAccessTokenResponse {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/PersonalAccessTokenType.java b/src/main/java/com/datadog/api/client/v2/model/PersonalAccessTokenType.java new file mode 100644 index 00000000000..1bab069445d --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/PersonalAccessTokenType.java @@ -0,0 +1,57 @@ +/* + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.datadog.api.client.ModelEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; +import java.io.IOException; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; + +/** Personal access tokens resource type. */ +@JsonSerialize(using = PersonalAccessTokenType.PersonalAccessTokenTypeSerializer.class) +public class PersonalAccessTokenType extends ModelEnum { + + private static final Set allowedValues = + new HashSet(Arrays.asList("personal_access_tokens")); + + public static final PersonalAccessTokenType PERSONAL_ACCESS_TOKENS = + new PersonalAccessTokenType("personal_access_tokens"); + + PersonalAccessTokenType(String value) { + super(value, allowedValues); + } + + public static class PersonalAccessTokenTypeSerializer + extends StdSerializer { + public PersonalAccessTokenTypeSerializer(Class t) { + super(t); + } + + public PersonalAccessTokenTypeSerializer() { + this(null); + } + + @Override + public void serialize( + PersonalAccessTokenType value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.value); + } + } + + @JsonCreator + public static PersonalAccessTokenType fromValue(String value) { + return new PersonalAccessTokenType(value); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/PersonalAccessTokenUpdateAttributes.java b/src/main/java/com/datadog/api/client/v2/model/PersonalAccessTokenUpdateAttributes.java new file mode 100644 index 00000000000..128dc6dab43 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/PersonalAccessTokenUpdateAttributes.java @@ -0,0 +1,177 @@ +/* + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** Attributes used to update a personal access token. */ +@JsonPropertyOrder({ + PersonalAccessTokenUpdateAttributes.JSON_PROPERTY_NAME, + PersonalAccessTokenUpdateAttributes.JSON_PROPERTY_SCOPES +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class PersonalAccessTokenUpdateAttributes { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_NAME = "name"; + private String name; + + public static final String JSON_PROPERTY_SCOPES = "scopes"; + private List scopes = null; + + public PersonalAccessTokenUpdateAttributes name(String name) { + this.name = name; + return this; + } + + /** + * New name for the personal access token. + * + * @return name + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_NAME) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public PersonalAccessTokenUpdateAttributes scopes(List scopes) { + this.scopes = scopes; + return this; + } + + public PersonalAccessTokenUpdateAttributes addScopesItem(String scopesItem) { + if (this.scopes == null) { + this.scopes = new ArrayList<>(); + } + this.scopes.add(scopesItem); + return this; + } + + /** + * New array of scopes for the personal access token. If provided, this will replace the existing + * scopes. + * + * @return scopes + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_SCOPES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getScopes() { + return scopes; + } + + public void setScopes(List scopes) { + this.scopes = scopes; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return PersonalAccessTokenUpdateAttributes + */ + @JsonAnySetter + public PersonalAccessTokenUpdateAttributes putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this PersonalAccessTokenUpdateAttributes object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PersonalAccessTokenUpdateAttributes personalAccessTokenUpdateAttributes = + (PersonalAccessTokenUpdateAttributes) o; + return Objects.equals(this.name, personalAccessTokenUpdateAttributes.name) + && Objects.equals(this.scopes, personalAccessTokenUpdateAttributes.scopes) + && Objects.equals( + this.additionalProperties, personalAccessTokenUpdateAttributes.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(name, scopes, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class PersonalAccessTokenUpdateAttributes {\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" scopes: ").append(toIndentedString(scopes)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/PersonalAccessTokenUpdateData.java b/src/main/java/com/datadog/api/client/v2/model/PersonalAccessTokenUpdateData.java new file mode 100644 index 00000000000..65606fd6208 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/PersonalAccessTokenUpdateData.java @@ -0,0 +1,211 @@ +/* + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.UUID; + +/** Object used to update a personal access token. */ +@JsonPropertyOrder({ + PersonalAccessTokenUpdateData.JSON_PROPERTY_ATTRIBUTES, + PersonalAccessTokenUpdateData.JSON_PROPERTY_ID, + PersonalAccessTokenUpdateData.JSON_PROPERTY_TYPE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class PersonalAccessTokenUpdateData { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_ATTRIBUTES = "attributes"; + private PersonalAccessTokenUpdateAttributes attributes; + + public static final String JSON_PROPERTY_ID = "id"; + private UUID id; + + public static final String JSON_PROPERTY_TYPE = "type"; + private PersonalAccessTokenType type = PersonalAccessTokenType.PERSONAL_ACCESS_TOKENS; + + public PersonalAccessTokenUpdateData() {} + + @JsonCreator + public PersonalAccessTokenUpdateData( + @JsonProperty(required = true, value = JSON_PROPERTY_ATTRIBUTES) + PersonalAccessTokenUpdateAttributes attributes, + @JsonProperty(required = true, value = JSON_PROPERTY_ID) UUID id, + @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) PersonalAccessTokenType type) { + this.attributes = attributes; + this.unparsed |= attributes.unparsed; + this.id = id; + this.type = type; + this.unparsed |= !type.isValid(); + } + + public PersonalAccessTokenUpdateData attributes(PersonalAccessTokenUpdateAttributes attributes) { + this.attributes = attributes; + this.unparsed |= attributes.unparsed; + return this; + } + + /** + * Attributes used to update a personal access token. + * + * @return attributes + */ + @JsonProperty(JSON_PROPERTY_ATTRIBUTES) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public PersonalAccessTokenUpdateAttributes getAttributes() { + return attributes; + } + + public void setAttributes(PersonalAccessTokenUpdateAttributes attributes) { + this.attributes = attributes; + } + + public PersonalAccessTokenUpdateData id(UUID id) { + this.id = id; + return this; + } + + /** + * UUID of the personal access token. Must match the path parameter. + * + * @return id + */ + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public UUID getId() { + return id; + } + + public void setId(UUID id) { + this.id = id; + } + + public PersonalAccessTokenUpdateData type(PersonalAccessTokenType type) { + this.type = type; + this.unparsed |= !type.isValid(); + return this; + } + + /** + * Personal access tokens resource type. + * + * @return type + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public PersonalAccessTokenType getType() { + return type; + } + + public void setType(PersonalAccessTokenType type) { + if (!type.isValid()) { + this.unparsed = true; + } + this.type = type; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return PersonalAccessTokenUpdateData + */ + @JsonAnySetter + public PersonalAccessTokenUpdateData putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this PersonalAccessTokenUpdateData object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PersonalAccessTokenUpdateData personalAccessTokenUpdateData = (PersonalAccessTokenUpdateData) o; + return Objects.equals(this.attributes, personalAccessTokenUpdateData.attributes) + && Objects.equals(this.id, personalAccessTokenUpdateData.id) + && Objects.equals(this.type, personalAccessTokenUpdateData.type) + && Objects.equals( + this.additionalProperties, personalAccessTokenUpdateData.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(attributes, id, type, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class PersonalAccessTokenUpdateData {\n"); + sb.append(" attributes: ").append(toIndentedString(attributes)).append("\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/PersonalAccessTokenUpdateRequest.java b/src/main/java/com/datadog/api/client/v2/model/PersonalAccessTokenUpdateRequest.java new file mode 100644 index 00000000000..b5d33d097b9 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/PersonalAccessTokenUpdateRequest.java @@ -0,0 +1,148 @@ +/* + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** Request to update a personal access token. */ +@JsonPropertyOrder({PersonalAccessTokenUpdateRequest.JSON_PROPERTY_DATA}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class PersonalAccessTokenUpdateRequest { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_DATA = "data"; + private PersonalAccessTokenUpdateData data; + + public PersonalAccessTokenUpdateRequest() {} + + @JsonCreator + public PersonalAccessTokenUpdateRequest( + @JsonProperty(required = true, value = JSON_PROPERTY_DATA) + PersonalAccessTokenUpdateData data) { + this.data = data; + this.unparsed |= data.unparsed; + } + + public PersonalAccessTokenUpdateRequest data(PersonalAccessTokenUpdateData data) { + this.data = data; + this.unparsed |= data.unparsed; + return this; + } + + /** + * Object used to update a personal access token. + * + * @return data + */ + @JsonProperty(JSON_PROPERTY_DATA) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public PersonalAccessTokenUpdateData getData() { + return data; + } + + public void setData(PersonalAccessTokenUpdateData data) { + this.data = data; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return PersonalAccessTokenUpdateRequest + */ + @JsonAnySetter + public PersonalAccessTokenUpdateRequest putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this PersonalAccessTokenUpdateRequest object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PersonalAccessTokenUpdateRequest personalAccessTokenUpdateRequest = + (PersonalAccessTokenUpdateRequest) o; + return Objects.equals(this.data, personalAccessTokenUpdateRequest.data) + && Objects.equals( + this.additionalProperties, personalAccessTokenUpdateRequest.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(data, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class PersonalAccessTokenUpdateRequest {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/PersonalAccessTokensListResponse.java b/src/main/java/com/datadog/api/client/v2/model/PersonalAccessTokensListResponse.java new file mode 100644 index 00000000000..47db72c3ba9 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/PersonalAccessTokensListResponse.java @@ -0,0 +1,181 @@ +/* + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** Response for a list of personal access tokens. */ +@JsonPropertyOrder({ + PersonalAccessTokensListResponse.JSON_PROPERTY_DATA, + PersonalAccessTokensListResponse.JSON_PROPERTY_META +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class PersonalAccessTokensListResponse { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_DATA = "data"; + private List data = null; + + public static final String JSON_PROPERTY_META = "meta"; + private PersonalAccessTokensResponseMeta meta; + + public PersonalAccessTokensListResponse data(List data) { + this.data = data; + for (PersonalAccessToken item : data) { + this.unparsed |= item.unparsed; + } + return this; + } + + public PersonalAccessTokensListResponse addDataItem(PersonalAccessToken dataItem) { + if (this.data == null) { + this.data = new ArrayList<>(); + } + this.data.add(dataItem); + this.unparsed |= dataItem.unparsed; + return this; + } + + /** + * Array of personal access tokens. + * + * @return data + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_DATA) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getData() { + return data; + } + + public void setData(List data) { + this.data = data; + } + + public PersonalAccessTokensListResponse meta(PersonalAccessTokensResponseMeta meta) { + this.meta = meta; + this.unparsed |= meta.unparsed; + return this; + } + + /** + * Additional information related to the personal access tokens response. + * + * @return meta + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_META) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public PersonalAccessTokensResponseMeta getMeta() { + return meta; + } + + public void setMeta(PersonalAccessTokensResponseMeta meta) { + this.meta = meta; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return PersonalAccessTokensListResponse + */ + @JsonAnySetter + public PersonalAccessTokensListResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this PersonalAccessTokensListResponse object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PersonalAccessTokensListResponse personalAccessTokensListResponse = + (PersonalAccessTokensListResponse) o; + return Objects.equals(this.data, personalAccessTokensListResponse.data) + && Objects.equals(this.meta, personalAccessTokensListResponse.meta) + && Objects.equals( + this.additionalProperties, personalAccessTokensListResponse.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(data, meta, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class PersonalAccessTokensListResponse {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/PersonalAccessTokensResponseMeta.java b/src/main/java/com/datadog/api/client/v2/model/PersonalAccessTokensResponseMeta.java new file mode 100644 index 00000000000..670c5c5c33d --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/PersonalAccessTokensResponseMeta.java @@ -0,0 +1,138 @@ +/* + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** Additional information related to the personal access tokens response. */ +@JsonPropertyOrder({PersonalAccessTokensResponseMeta.JSON_PROPERTY_PAGE}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class PersonalAccessTokensResponseMeta { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_PAGE = "page"; + private PersonalAccessTokensResponseMetaPage page; + + public PersonalAccessTokensResponseMeta page(PersonalAccessTokensResponseMetaPage page) { + this.page = page; + this.unparsed |= page.unparsed; + return this; + } + + /** + * Pagination information for personal access tokens response. + * + * @return page + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_PAGE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public PersonalAccessTokensResponseMetaPage getPage() { + return page; + } + + public void setPage(PersonalAccessTokensResponseMetaPage page) { + this.page = page; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return PersonalAccessTokensResponseMeta + */ + @JsonAnySetter + public PersonalAccessTokensResponseMeta putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this PersonalAccessTokensResponseMeta object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PersonalAccessTokensResponseMeta personalAccessTokensResponseMeta = + (PersonalAccessTokensResponseMeta) o; + return Objects.equals(this.page, personalAccessTokensResponseMeta.page) + && Objects.equals( + this.additionalProperties, personalAccessTokensResponseMeta.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(page, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class PersonalAccessTokensResponseMeta {\n"); + sb.append(" page: ").append(toIndentedString(page)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/PersonalAccessTokensResponseMetaPage.java b/src/main/java/com/datadog/api/client/v2/model/PersonalAccessTokensResponseMetaPage.java new file mode 100644 index 00000000000..3a0a053c3ce --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/PersonalAccessTokensResponseMetaPage.java @@ -0,0 +1,138 @@ +/* + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.fasterxml.jackson.annotation.JsonAnyGetter; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** Pagination information for personal access tokens response. */ +@JsonPropertyOrder({PersonalAccessTokensResponseMetaPage.JSON_PROPERTY_TOTAL_FILTERED_COUNT}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class PersonalAccessTokensResponseMetaPage { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_TOTAL_FILTERED_COUNT = "total_filtered_count"; + private Long totalFilteredCount; + + public PersonalAccessTokensResponseMetaPage totalFilteredCount(Long totalFilteredCount) { + this.totalFilteredCount = totalFilteredCount; + return this; + } + + /** + * Total filtered personal access token count. + * + * @return totalFilteredCount + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_TOTAL_FILTERED_COUNT) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public Long getTotalFilteredCount() { + return totalFilteredCount; + } + + public void setTotalFilteredCount(Long totalFilteredCount) { + this.totalFilteredCount = totalFilteredCount; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key The arbitrary key to set + * @param value The associated value + * @return PersonalAccessTokensResponseMetaPage + */ + @JsonAnySetter + public PersonalAccessTokensResponseMetaPage putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return The additional properties + */ + @JsonAnyGetter + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key The arbitrary key to get + * @return The specific additional property for the given key + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + /** Return true if this PersonalAccessTokensResponseMetaPage object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PersonalAccessTokensResponseMetaPage personalAccessTokensResponseMetaPage = + (PersonalAccessTokensResponseMetaPage) o; + return Objects.equals( + this.totalFilteredCount, personalAccessTokensResponseMetaPage.totalFilteredCount) + && Objects.equals( + this.additionalProperties, personalAccessTokensResponseMetaPage.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(totalFilteredCount, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class PersonalAccessTokensResponseMetaPage {\n"); + sb.append(" totalFilteredCount: ").append(toIndentedString(totalFilteredCount)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append('}'); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/PersonalAccessTokensSort.java b/src/main/java/com/datadog/api/client/v2/model/PersonalAccessTokensSort.java new file mode 100644 index 00000000000..49aceafddd1 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/PersonalAccessTokensSort.java @@ -0,0 +1,68 @@ +/* + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.datadog.api.client.ModelEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; +import java.io.IOException; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; + +/** Sorting options for personal access tokens. */ +@JsonSerialize(using = PersonalAccessTokensSort.PersonalAccessTokensSortSerializer.class) +public class PersonalAccessTokensSort extends ModelEnum { + + private static final Set allowedValues = + new HashSet( + Arrays.asList("name", "-name", "created_at", "-created_at", "expires_at", "-expires_at")); + + public static final PersonalAccessTokensSort NAME_ASCENDING = + new PersonalAccessTokensSort("name"); + public static final PersonalAccessTokensSort NAME_DESCENDING = + new PersonalAccessTokensSort("-name"); + public static final PersonalAccessTokensSort CREATED_AT_ASCENDING = + new PersonalAccessTokensSort("created_at"); + public static final PersonalAccessTokensSort CREATED_AT_DESCENDING = + new PersonalAccessTokensSort("-created_at"); + public static final PersonalAccessTokensSort EXPIRES_AT_ASCENDING = + new PersonalAccessTokensSort("expires_at"); + public static final PersonalAccessTokensSort EXPIRES_AT_DESCENDING = + new PersonalAccessTokensSort("-expires_at"); + + PersonalAccessTokensSort(String value) { + super(value, allowedValues); + } + + public static class PersonalAccessTokensSortSerializer + extends StdSerializer { + public PersonalAccessTokensSortSerializer(Class t) { + super(t); + } + + public PersonalAccessTokensSortSerializer() { + this(null); + } + + @Override + public void serialize( + PersonalAccessTokensSort value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.value); + } + } + + @JsonCreator + public static PersonalAccessTokensSort fromValue(String value) { + return new PersonalAccessTokensSort(value); + } +} diff --git a/src/test/resources/com/datadog/api/client/v1/api/key_management.feature b/src/test/resources/com/datadog/api/client/v1/api/key_management.feature index c3f18c2346a..7013ea44fed 100644 --- a/src/test/resources/com/datadog/api/client/v1/api/key_management.feature +++ b/src/test/resources/com/datadog/api/client/v1/api/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/src/test/resources/com/datadog/api/client/v1/api/undo.json b/src/test/resources/com/datadog/api/client/v1/api/undo.json index 341ebe6c4ee..edc3c5f6a19 100644 --- a/src/test/resources/com/datadog/api/client/v1/api/undo.json +++ b/src/test/resources/com/datadog/api/client/v1/api/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/src/test/resources/com/datadog/api/client/v2/api/key_management.feature b/src/test/resources/com/datadog/api/client/v2/api/key_management.feature index 40daf9df54f..5adb2ecc95c 100644 --- a/src/test/resources/com/datadog/api/client/v2/api/key_management.feature +++ b/src/test/resources/com/datadog/api/client/v2/api/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/src/test/resources/com/datadog/api/client/v2/api/undo.json b/src/test/resources/com/datadog/api/client/v2/api/undo.json index c77dfee3356..4828520126a 100644 --- a/src/test/resources/com/datadog/api/client/v2/api/undo.json +++ b/src/test/resources/com/datadog/api/client/v2/api/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": {