From 3bcae9b0764ea0300c479d0138f08ec3aae3390f Mon Sep 17 00:00:00 2001 From: "ci.datadog-api-spec" Date: Fri, 25 Sep 2026 13:42:30 +0000 Subject: [PATCH] Regenerate client from commit 6d6f74d of spec repo --- .generator/schemas/v2/openapi.yaml | 163 +++++++- .../UpdatePersonalAccessToken.java | 4 +- .../UpdateServiceAccountAccessToken.java | 4 +- .../api/client/v2/api/KeyManagementApi.java | 142 ++++++- .../api/client/v2/api/ServiceAccountsApi.java | 159 +++++++- .../AccessTokenListItemRelationships.java | 40 +- .../AccessTokenResponseIncludedItem.java | 215 ++++++++++ .../v2/model/FullPersonalAccessToken.java | 8 +- .../FullPersonalAccessTokenRelationships.java | 141 +++++++ .../v2/model/FullServiceAccessToken.java | 8 +- .../FullServiceAccessTokenRelationships.java | 141 +++++++ .../ListPersonalAccessTokensResponse.java | 49 ++- .../ListServiceAccessTokensResponse.java | 49 ++- .../PersonalAccessTokenRelationships.java | 40 +- .../v2/model/PersonalAccessTokenResponse.java | 54 ++- ...AccessTokensIncludeQueryParameterItem.java | 63 +++ .../v2/model/PersonalAccessTokensSort.java | 8 +- .../v2/model/RelationshipToLeakedKey.java | 156 ++++++++ .../v2/model/RelationshipToLeakedKeyData.java | 179 +++++++++ .../ServiceAccessTokenRelationships.java | 40 +- .../v2/model/ServiceAccessTokenResponse.java | 54 ++- .../v2/model/UpdatedPersonalAccessToken.java | 242 ++++++++++++ ...datedPersonalAccessTokenRelationships.java | 142 +++++++ .../UpdatedPersonalAccessTokenResponse.java | 150 +++++++ .../v2/model/UpdatedServiceAccessToken.java | 242 ++++++++++++ ...pdatedServiceAccessTokenRelationships.java | 141 +++++++ .../UpdatedServiceAccessTokenResponse.java | 150 +++++++ src/test/resources/generated-test/test-server | 367 +----------------- 28 files changed, 2728 insertions(+), 423 deletions(-) create mode 100644 src/main/java/com/datadog/api/client/v2/model/AccessTokenResponseIncludedItem.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/FullPersonalAccessTokenRelationships.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/FullServiceAccessTokenRelationships.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/PersonalAccessTokensIncludeQueryParameterItem.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/RelationshipToLeakedKey.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/RelationshipToLeakedKeyData.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/UpdatedPersonalAccessToken.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/UpdatedPersonalAccessTokenRelationships.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/UpdatedPersonalAccessTokenResponse.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/UpdatedServiceAccessToken.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/UpdatedServiceAccessTokenRelationships.java create mode 100644 src/main/java/com/datadog/api/client/v2/model/UpdatedServiceAccessTokenResponse.java diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 12847a964d0..1846f886a44 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -1502,6 +1502,14 @@ components: required: true schema: type: string + PersonalAccessTokensFilterLeakedParameter: + description: When true, only return access tokens that have been detected as leaked. Has no effect when false. + in: query + name: filter[leaked] + required: false + schema: + example: true + type: boolean PersonalAccessTokensFilterOwnerIDParameter: description: Filter access tokens by the owner's ID. Supports multiple values. in: query @@ -1519,6 +1527,16 @@ components: required: false schema: type: string + PersonalAccessTokensIncludeParameter: + description: Comma-separated list of relationship objects that should be included in the response. + explode: false + in: query + name: include + required: false + schema: + items: + $ref: "#/components/schemas/PersonalAccessTokensIncludeQueryParameterItem" + type: array PersonalAccessTokensSortParameter: description: |- Access token attribute used to sort results. Sort order is ascending @@ -4227,6 +4245,8 @@ components: AccessTokenListItemRelationships: description: Resources related to the access token entry in the mixed list response. properties: + leak_information: + $ref: "#/components/schemas/RelationshipToLeakedKey" owned_by: $ref: "#/components/schemas/RelationshipToAccessTokenOwner" type: object @@ -4240,6 +4260,15 @@ components: x-enum-varnames: - USERS - SERVICE_ACCOUNT + AccessTokenResponseIncludedArray: + description: Array of objects related to the access tokens. + items: + $ref: "#/components/schemas/AccessTokenResponseIncludedItem" + type: array + AccessTokenResponseIncludedItem: + description: An object related to an access token. + oneOf: + - $ref: "#/components/schemas/LeakedKey" AccessTokensType: description: Resource type returned by the access tokens list endpoint. Includes both personal and service access tokens. enum: @@ -45649,7 +45678,7 @@ components: description: ID of the access token. type: string relationships: - $ref: "#/components/schemas/PersonalAccessTokenRelationships" + $ref: "#/components/schemas/FullPersonalAccessTokenRelationships" type: $ref: "#/components/schemas/PersonalAccessTokensType" type: object @@ -45692,6 +45721,12 @@ components: type: string type: array type: object + FullPersonalAccessTokenRelationships: + description: Resources related to the access token. + properties: + owned_by: + $ref: "#/components/schemas/RelationshipToUser" + type: object FullServiceAccessToken: description: Datadog access token, including the token key. properties: @@ -45701,7 +45736,7 @@ components: description: ID of the access token. type: string relationships: - $ref: "#/components/schemas/ServiceAccessTokenRelationships" + $ref: "#/components/schemas/FullServiceAccessTokenRelationships" type: $ref: "#/components/schemas/ServiceAccessTokensType" type: object @@ -45744,6 +45779,12 @@ components: type: string type: array type: object + FullServiceAccessTokenRelationships: + description: Resources related to the access token. + properties: + owned_by: + $ref: "#/components/schemas/RelationshipToServiceAccount" + type: object GCPCredentials: description: The definition of the `GCPCredentials` object. oneOf: @@ -67192,6 +67233,8 @@ components: items: $ref: "#/components/schemas/AccessTokenListItem" type: array + included: + $ref: "#/components/schemas/AccessTokenResponseIncludedArray" meta: $ref: "#/components/schemas/PersonalAccessTokenResponseMeta" type: object @@ -67432,6 +67475,8 @@ components: items: $ref: "#/components/schemas/ServiceAccessToken" type: array + included: + $ref: "#/components/schemas/AccessTokenResponseIncludedArray" meta: $ref: "#/components/schemas/ServiceAccessTokenResponseMeta" type: object @@ -86256,6 +86301,8 @@ components: PersonalAccessTokenRelationships: description: Resources related to the access token. properties: + leak_information: + $ref: "#/components/schemas/RelationshipToLeakedKey" owned_by: $ref: "#/components/schemas/RelationshipToUser" type: object @@ -86264,6 +86311,8 @@ components: properties: data: $ref: "#/components/schemas/PersonalAccessToken" + included: + $ref: "#/components/schemas/AccessTokenResponseIncludedArray" type: object PersonalAccessTokenResponseMeta: description: Additional information related to the access token response. @@ -86320,6 +86369,14 @@ components: required: - data type: object + PersonalAccessTokensIncludeQueryParameterItem: + description: Relationship object that should be included in the response. + enum: + - leak_information + example: "leak_information" + type: string + x-enum-varnames: + - LEAK_INFORMATION PersonalAccessTokensSort: default: name description: Sorting options @@ -86332,6 +86389,8 @@ components: - -expires_at - last_used_at - -last_used_at + - leaked + - -leaked type: string x-enum-varnames: - NAME_ASCENDING @@ -86342,6 +86401,8 @@ components: - EXPIRES_AT_DESCENDING - LAST_USED_AT_ASCENDING - LAST_USED_AT_DESCENDING + - LEAKED_ASCENDING + - LEAKED_DESCENDING PersonalAccessTokensType: default: personal_access_tokens description: Personal access tokens resource type. @@ -93325,6 +93386,28 @@ components: required: - data type: object + RelationshipToLeakedKey: + description: Relationship to the leak the access token was found in. `data` is null when the access token has not been detected as leaked. + properties: + data: + $ref: "#/components/schemas/RelationshipToLeakedKeyData" + required: + - data + type: object + RelationshipToLeakedKeyData: + description: Relationship to the leak the access token was found in. + nullable: true + properties: + id: + description: A unique identifier that represents the leak. + example: "00000000-0000-1234-0000-000000000000" + type: string + type: + $ref: "#/components/schemas/LeakedKeyType" + required: + - id + - type + type: object RelationshipToOrganization: description: Relationship to an organization. properties: @@ -108413,6 +108496,8 @@ components: ServiceAccessTokenRelationships: description: Resources related to the access token. properties: + leak_information: + $ref: "#/components/schemas/RelationshipToLeakedKey" owned_by: $ref: "#/components/schemas/RelationshipToServiceAccount" type: object @@ -108421,6 +108506,8 @@ components: properties: data: $ref: "#/components/schemas/ServiceAccessToken" + included: + $ref: "#/components/schemas/AccessTokenResponseIncludedArray" type: object ServiceAccessTokenResponseMeta: description: Additional information related to the access token response. @@ -127264,6 +127351,68 @@ components: data: $ref: "#/components/schemas/WorkflowDataUpdate" type: object + UpdatedPersonalAccessToken: + description: Datadog access token returned by the update endpoint. + properties: + attributes: + $ref: "#/components/schemas/PersonalAccessTokenAttributes" + id: + description: ID of the access token. + example: "00000000-0000-1234-0000-000000000000" + type: string + relationships: + $ref: "#/components/schemas/UpdatedPersonalAccessTokenRelationships" + type: + $ref: "#/components/schemas/PersonalAccessTokensType" + required: + - id + - type + type: object + UpdatedPersonalAccessTokenRelationships: + description: Resources related to the access token. + properties: + owned_by: + $ref: "#/components/schemas/RelationshipToUser" + type: object + UpdatedPersonalAccessTokenResponse: + description: Response for updating an access token. + properties: + data: + $ref: "#/components/schemas/UpdatedPersonalAccessToken" + required: + - data + type: object + UpdatedServiceAccessToken: + description: Datadog access token returned by the update endpoint. + properties: + attributes: + $ref: "#/components/schemas/ServiceAccessTokenAttributes" + id: + description: ID of the access token. + example: "00000000-0000-1234-0000-000000000000" + type: string + relationships: + $ref: "#/components/schemas/UpdatedServiceAccessTokenRelationships" + type: + $ref: "#/components/schemas/ServiceAccessTokensType" + required: + - id + - type + type: object + UpdatedServiceAccessTokenRelationships: + description: Resources related to the access token. + properties: + owned_by: + $ref: "#/components/schemas/RelationshipToServiceAccount" + type: object + UpdatedServiceAccessTokenResponse: + description: Response for updating an access token. + properties: + data: + $ref: "#/components/schemas/UpdatedServiceAccessToken" + required: + - data + type: object UpsertAllocationRequest: description: Request to create or update a targeting rule (allocation) for a feature flag environment. properties: @@ -191854,6 +192003,8 @@ paths: - $ref: "#/components/parameters/PersonalAccessTokensSortParameter" - $ref: "#/components/parameters/PersonalAccessTokensFilterParameter" - $ref: "#/components/parameters/PersonalAccessTokensFilterOwnerIDParameter" + - $ref: "#/components/parameters/PersonalAccessTokensFilterLeakedParameter" + - $ref: "#/components/parameters/PersonalAccessTokensIncludeParameter" responses: "200": content: @@ -191998,6 +192149,7 @@ paths: operationId: GetPersonalAccessToken parameters: - $ref: "#/components/parameters/AccessTokenID" + - $ref: "#/components/parameters/PersonalAccessTokensIncludeParameter" responses: "200": content: @@ -192080,7 +192232,7 @@ paths: id: 00000000-0000-0000-0000-000000000004 type: personal_access_tokens schema: - $ref: "#/components/schemas/PersonalAccessTokenResponse" + $ref: "#/components/schemas/UpdatedPersonalAccessTokenResponse" description: OK "400": content: @@ -215732,6 +215884,8 @@ paths: - $ref: "#/components/parameters/PageNumber" - $ref: "#/components/parameters/PersonalAccessTokensSortParameter" - $ref: "#/components/parameters/PersonalAccessTokensFilterParameter" + - $ref: "#/components/parameters/PersonalAccessTokensFilterLeakedParameter" + - $ref: "#/components/parameters/PersonalAccessTokensIncludeParameter" responses: "200": content: @@ -215889,6 +216043,7 @@ paths: parameters: - $ref: "#/components/parameters/ServiceAccountID" - $ref: "#/components/parameters/AccessTokenID" + - $ref: "#/components/parameters/PersonalAccessTokensIncludeParameter" responses: "200": content: @@ -215971,7 +216126,7 @@ paths: id: 00000000-0000-0000-0000-000000000008 type: service_access_tokens schema: - $ref: "#/components/schemas/ServiceAccessTokenResponse" + $ref: "#/components/schemas/UpdatedServiceAccessTokenResponse" description: OK "400": content: diff --git a/examples/v2/key-management/UpdatePersonalAccessToken.java b/examples/v2/key-management/UpdatePersonalAccessToken.java index 03d93c63d53..4cd9eb91eec 100644 --- a/examples/v2/key-management/UpdatePersonalAccessToken.java +++ b/examples/v2/key-management/UpdatePersonalAccessToken.java @@ -3,11 +3,11 @@ 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.PersonalAccessTokenResponse; 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 com.datadog.api.client.v2.model.PersonalAccessTokensType; +import com.datadog.api.client.v2.model.UpdatedPersonalAccessTokenResponse; public class Example { public static void main(String[] args) { @@ -29,7 +29,7 @@ public static void main(String[] args) { .name("Example-Key-Management-updated"))); try { - PersonalAccessTokenResponse result = + UpdatedPersonalAccessTokenResponse result = apiInstance.updatePersonalAccessToken(PERSONAL_ACCESS_TOKEN_DATA_ID, body); System.out.println(result); } catch (ApiException e) { diff --git a/examples/v2/service-accounts/UpdateServiceAccountAccessToken.java b/examples/v2/service-accounts/UpdateServiceAccountAccessToken.java index ad62cb7f542..328d85e646e 100644 --- a/examples/v2/service-accounts/UpdateServiceAccountAccessToken.java +++ b/examples/v2/service-accounts/UpdateServiceAccountAccessToken.java @@ -3,11 +3,11 @@ import com.datadog.api.client.ApiClient; import com.datadog.api.client.ApiException; import com.datadog.api.client.v2.api.ServiceAccountsApi; -import com.datadog.api.client.v2.model.ServiceAccessTokenResponse; import com.datadog.api.client.v2.model.ServiceAccessTokensType; import com.datadog.api.client.v2.model.ServiceAccountAccessTokenUpdateAttributes; import com.datadog.api.client.v2.model.ServiceAccountAccessTokenUpdateData; import com.datadog.api.client.v2.model.ServiceAccountAccessTokenUpdateRequest; +import com.datadog.api.client.v2.model.UpdatedServiceAccessTokenResponse; public class Example { public static void main(String[] args) { @@ -35,7 +35,7 @@ public static void main(String[] args) { .name("My Access Token-updated"))); try { - ServiceAccessTokenResponse result = + UpdatedServiceAccessTokenResponse result = apiInstance.updateServiceAccountAccessToken( SERVICE_ACCOUNT_USER_DATA_ID, SERVICE_ACCOUNT_ACCESS_TOKEN_DATA_ID, body); System.out.println(result); 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 07f67c7ed53..d991ff3b362 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 @@ -19,7 +19,9 @@ import com.datadog.api.client.v2.model.PersonalAccessTokenCreateResponse; import com.datadog.api.client.v2.model.PersonalAccessTokenResponse; import com.datadog.api.client.v2.model.PersonalAccessTokenUpdateRequest; +import com.datadog.api.client.v2.model.PersonalAccessTokensIncludeQueryParameterItem; import com.datadog.api.client.v2.model.PersonalAccessTokensSort; +import com.datadog.api.client.v2.model.UpdatedPersonalAccessTokenResponse; import com.datadog.api.client.v2.model.ValidateAPIKeyResponse; import com.datadog.api.client.v2.model.ValidateV2Response; import jakarta.ws.rs.client.Invocation; @@ -1399,6 +1401,24 @@ public ApiResponse getCurrentUserApplicationKeyWithHttpI new GenericType() {}); } + /** Manage optional parameters to getPersonalAccessToken. */ + public static class GetPersonalAccessTokenOptionalParameters { + private List include; + + /** + * Set include. + * + * @param include Comma-separated list of relationship objects that should be included in the + * response. (optional) + * @return GetPersonalAccessTokenOptionalParameters + */ + public GetPersonalAccessTokenOptionalParameters include( + List include) { + this.include = include; + return this; + } + } + /** * Get a personal access token. * @@ -1409,7 +1429,9 @@ public ApiResponse getCurrentUserApplicationKeyWithHttpI * @throws ApiException if fails to make API call */ public PersonalAccessTokenResponse getPersonalAccessToken(String tokenId) throws ApiException { - return getPersonalAccessTokenWithHttpInfo(tokenId).getData(); + return getPersonalAccessTokenWithHttpInfo( + tokenId, new GetPersonalAccessTokenOptionalParameters()) + .getData(); } /** @@ -1422,7 +1444,41 @@ public PersonalAccessTokenResponse getPersonalAccessToken(String tokenId) throws */ public CompletableFuture getPersonalAccessTokenAsync( String tokenId) { - return getPersonalAccessTokenWithHttpInfoAsync(tokenId) + return getPersonalAccessTokenWithHttpInfoAsync( + tokenId, new GetPersonalAccessTokenOptionalParameters()) + .thenApply( + response -> { + return response.getData(); + }); + } + + /** + * Get a personal access token. + * + *

See {@link #getPersonalAccessTokenWithHttpInfo}. + * + * @param tokenId The ID of the access token. (required) + * @param parameters Optional parameters for the request. + * @return PersonalAccessTokenResponse + * @throws ApiException if fails to make API call + */ + public PersonalAccessTokenResponse getPersonalAccessToken( + String tokenId, GetPersonalAccessTokenOptionalParameters parameters) throws ApiException { + return getPersonalAccessTokenWithHttpInfo(tokenId, parameters).getData(); + } + + /** + * Get a personal access token. + * + *

See {@link #getPersonalAccessTokenWithHttpInfoAsync}. + * + * @param tokenId The ID of the access token. (required) + * @param parameters Optional parameters for the request. + * @return CompletableFuture<PersonalAccessTokenResponse> + */ + public CompletableFuture getPersonalAccessTokenAsync( + String tokenId, GetPersonalAccessTokenOptionalParameters parameters) { + return getPersonalAccessTokenWithHttpInfoAsync(tokenId, parameters) .thenApply( response -> { return response.getData(); @@ -1433,6 +1489,7 @@ public CompletableFuture getPersonalAccessTokenAsyn * Get a specific personal access token by its ID. * * @param tokenId The ID of the access token. (required) + * @param parameters Optional parameters for the request. * @return ApiResponse<PersonalAccessTokenResponse> * @throws ApiException if fails to make API call * @http.response.details @@ -1445,8 +1502,8 @@ public CompletableFuture getPersonalAccessTokenAsyn * 429 Too many requests - * */ - public ApiResponse getPersonalAccessTokenWithHttpInfo(String tokenId) - throws ApiException { + public ApiResponse getPersonalAccessTokenWithHttpInfo( + String tokenId, GetPersonalAccessTokenOptionalParameters parameters) throws ApiException { Object localVarPostBody = null; // verify the required parameter 'tokenId' is set @@ -1454,18 +1511,22 @@ public ApiResponse getPersonalAccessTokenWithHttpIn throw new ApiException( 400, "Missing the required parameter 'tokenId' when calling getPersonalAccessToken"); } + List include = parameters.include; // create path and map variables String localVarPath = "/api/v2/personal_access_tokens/{token_id}" .replaceAll("\\{" + "token_id" + "\\}", apiClient.escapeString(tokenId.toString())); + List localVarQueryParams = new ArrayList(); Map localVarHeaderParams = new HashMap(); + localVarQueryParams.addAll(apiClient.parameterToPairs("csv", "include", include)); + Invocation.Builder builder = apiClient.createBuilder( "v2.KeyManagementApi.getPersonalAccessToken", localVarPath, - new ArrayList(), + localVarQueryParams, localVarHeaderParams, new HashMap(), new String[] {"application/json"}, @@ -1487,10 +1548,12 @@ public ApiResponse getPersonalAccessTokenWithHttpIn *

See {@link #getPersonalAccessTokenWithHttpInfo}. * * @param tokenId The ID of the access token. (required) + * @param parameters Optional parameters for the request. * @return CompletableFuture<ApiResponse<PersonalAccessTokenResponse>> */ public CompletableFuture> - getPersonalAccessTokenWithHttpInfoAsync(String tokenId) { + getPersonalAccessTokenWithHttpInfoAsync( + String tokenId, GetPersonalAccessTokenOptionalParameters parameters) { Object localVarPostBody = null; // verify the required parameter 'tokenId' is set @@ -1502,20 +1565,24 @@ public ApiResponse getPersonalAccessTokenWithHttpIn 400, "Missing the required parameter 'tokenId' when calling getPersonalAccessToken")); return result; } + List include = parameters.include; // create path and map variables String localVarPath = "/api/v2/personal_access_tokens/{token_id}" .replaceAll("\\{" + "token_id" + "\\}", apiClient.escapeString(tokenId.toString())); + List localVarQueryParams = new ArrayList(); Map localVarHeaderParams = new HashMap(); + localVarQueryParams.addAll(apiClient.parameterToPairs("csv", "include", include)); + Invocation.Builder builder; try { builder = apiClient.createBuilder( "v2.KeyManagementApi.getPersonalAccessToken", localVarPath, - new ArrayList(), + localVarQueryParams, localVarHeaderParams, new HashMap(), new String[] {"application/json"}, @@ -2471,6 +2538,8 @@ public static class ListPersonalAccessTokensOptionalParameters { private PersonalAccessTokensSort sort; private String filter; private List filterOwnedBy; + private Boolean filterLeaked; + private List include; /** * Set pageSize. @@ -2530,6 +2599,31 @@ public ListPersonalAccessTokensOptionalParameters filterOwnedBy(List fil this.filterOwnedBy = filterOwnedBy; return this; } + + /** + * Set filterLeaked. + * + * @param filterLeaked When true, only return access tokens that have been detected as leaked. + * Has no effect when false. (optional) + * @return ListPersonalAccessTokensOptionalParameters + */ + public ListPersonalAccessTokensOptionalParameters filterLeaked(Boolean filterLeaked) { + this.filterLeaked = filterLeaked; + return this; + } + + /** + * Set include. + * + * @param include Comma-separated list of relationship objects that should be included in the + * response. (optional) + * @return ListPersonalAccessTokensOptionalParameters + */ + public ListPersonalAccessTokensOptionalParameters include( + List include) { + this.include = include; + return this; + } } /** @@ -2616,6 +2710,8 @@ public ApiResponse listPersonalAccessTokensWit PersonalAccessTokensSort sort = parameters.sort; String filter = parameters.filter; List filterOwnedBy = parameters.filterOwnedBy; + Boolean filterLeaked = parameters.filterLeaked; + List include = parameters.include; // create path and map variables String localVarPath = "/api/v2/personal_access_tokens"; @@ -2628,6 +2724,8 @@ public ApiResponse listPersonalAccessTokensWit localVarQueryParams.addAll(apiClient.parameterToPairs("", "filter", filter)); localVarQueryParams.addAll( apiClient.parameterToPairs("multi", "filter[owned_by]", filterOwnedBy)); + localVarQueryParams.addAll(apiClient.parameterToPairs("", "filter[leaked]", filterLeaked)); + localVarQueryParams.addAll(apiClient.parameterToPairs("csv", "include", include)); Invocation.Builder builder = apiClient.createBuilder( @@ -2666,6 +2764,8 @@ public ApiResponse listPersonalAccessTokensWit PersonalAccessTokensSort sort = parameters.sort; String filter = parameters.filter; List filterOwnedBy = parameters.filterOwnedBy; + Boolean filterLeaked = parameters.filterLeaked; + List include = parameters.include; // create path and map variables String localVarPath = "/api/v2/personal_access_tokens"; @@ -2678,6 +2778,8 @@ public ApiResponse listPersonalAccessTokensWit localVarQueryParams.addAll(apiClient.parameterToPairs("", "filter", filter)); localVarQueryParams.addAll( apiClient.parameterToPairs("multi", "filter[owned_by]", filterOwnedBy)); + localVarQueryParams.addAll(apiClient.parameterToPairs("", "filter[leaked]", filterLeaked)); + localVarQueryParams.addAll(apiClient.parameterToPairs("csv", "include", include)); Invocation.Builder builder; try { @@ -3329,10 +3431,10 @@ public ApiResponse updateCurrentUserApplicationKeyWithHt * * @param tokenId The ID of the access token. (required) * @param body (required) - * @return PersonalAccessTokenResponse + * @return UpdatedPersonalAccessTokenResponse * @throws ApiException if fails to make API call */ - public PersonalAccessTokenResponse updatePersonalAccessToken( + public UpdatedPersonalAccessTokenResponse updatePersonalAccessToken( String tokenId, PersonalAccessTokenUpdateRequest body) throws ApiException { return updatePersonalAccessTokenWithHttpInfo(tokenId, body).getData(); } @@ -3344,9 +3446,9 @@ public PersonalAccessTokenResponse updatePersonalAccessToken( * * @param tokenId The ID of the access token. (required) * @param body (required) - * @return CompletableFuture<PersonalAccessTokenResponse> + * @return CompletableFuture<UpdatedPersonalAccessTokenResponse> */ - public CompletableFuture updatePersonalAccessTokenAsync( + public CompletableFuture updatePersonalAccessTokenAsync( String tokenId, PersonalAccessTokenUpdateRequest body) { return updatePersonalAccessTokenWithHttpInfoAsync(tokenId, body) .thenApply( @@ -3360,7 +3462,7 @@ public CompletableFuture updatePersonalAccessTokenA * * @param tokenId The ID of the access token. (required) * @param body (required) - * @return ApiResponse<PersonalAccessTokenResponse> + * @return ApiResponse<UpdatedPersonalAccessTokenResponse> * @throws ApiException if fails to make API call * @http.response.details * @@ -3373,7 +3475,7 @@ public CompletableFuture updatePersonalAccessTokenA * *
429 Too many requests -
*/ - public ApiResponse updatePersonalAccessTokenWithHttpInfo( + public ApiResponse updatePersonalAccessTokenWithHttpInfo( String tokenId, PersonalAccessTokenUpdateRequest body) throws ApiException { Object localVarPostBody = body; @@ -3412,7 +3514,7 @@ public ApiResponse updatePersonalAccessTokenWithHtt localVarPostBody, new HashMap(), false, - new GenericType() {}); + new GenericType() {}); } /** @@ -3422,16 +3524,16 @@ public ApiResponse updatePersonalAccessTokenWithHtt * * @param tokenId The ID of the access token. (required) * @param body (required) - * @return CompletableFuture<ApiResponse<PersonalAccessTokenResponse>> + * @return CompletableFuture<ApiResponse<UpdatedPersonalAccessTokenResponse>> */ - public CompletableFuture> + public CompletableFuture> updatePersonalAccessTokenWithHttpInfoAsync( String tokenId, PersonalAccessTokenUpdateRequest body) { Object localVarPostBody = body; // verify the required parameter 'tokenId' is set if (tokenId == null) { - CompletableFuture> result = + CompletableFuture> result = new CompletableFuture<>(); result.completeExceptionally( new ApiException( @@ -3442,7 +3544,7 @@ public ApiResponse updatePersonalAccessTokenWithHtt // verify the required parameter 'body' is set if (body == null) { - CompletableFuture> result = + CompletableFuture> result = new CompletableFuture<>(); result.completeExceptionally( new ApiException( @@ -3468,7 +3570,7 @@ public ApiResponse updatePersonalAccessTokenWithHtt new String[] {"application/json"}, new String[] {"apiKeyAuth", "appKeyAuth", "AuthZ"}); } catch (ApiException ex) { - CompletableFuture> result = + CompletableFuture> result = new CompletableFuture<>(); result.completeExceptionally(ex); return result; @@ -3481,7 +3583,7 @@ public ApiResponse updatePersonalAccessTokenWithHtt localVarPostBody, new HashMap(), false, - new GenericType() {}); + new GenericType() {}); } /** diff --git a/src/main/java/com/datadog/api/client/v2/api/ServiceAccountsApi.java b/src/main/java/com/datadog/api/client/v2/api/ServiceAccountsApi.java index 2ac0e7ee46c..bf191dbdcaf 100644 --- a/src/main/java/com/datadog/api/client/v2/api/ServiceAccountsApi.java +++ b/src/main/java/com/datadog/api/client/v2/api/ServiceAccountsApi.java @@ -11,12 +11,14 @@ import com.datadog.api.client.v2.model.ListApplicationKeysResponse; import com.datadog.api.client.v2.model.ListServiceAccessTokensResponse; import com.datadog.api.client.v2.model.PartialApplicationKeyResponse; +import com.datadog.api.client.v2.model.PersonalAccessTokensIncludeQueryParameterItem; import com.datadog.api.client.v2.model.PersonalAccessTokensSort; import com.datadog.api.client.v2.model.ServiceAccessTokenCreateResponse; import com.datadog.api.client.v2.model.ServiceAccessTokenResponse; import com.datadog.api.client.v2.model.ServiceAccountAccessTokenCreateRequest; import com.datadog.api.client.v2.model.ServiceAccountAccessTokenUpdateRequest; import com.datadog.api.client.v2.model.ServiceAccountCreateRequest; +import com.datadog.api.client.v2.model.UpdatedServiceAccessTokenResponse; import com.datadog.api.client.v2.model.UserResponse; import jakarta.ws.rs.client.Invocation; import jakarta.ws.rs.core.GenericType; @@ -698,6 +700,24 @@ public CompletableFuture> deleteServiceAccountApplicationKeyWi null); } + /** Manage optional parameters to getServiceAccountAccessToken. */ + public static class GetServiceAccountAccessTokenOptionalParameters { + private List include; + + /** + * Set include. + * + * @param include Comma-separated list of relationship objects that should be included in the + * response. (optional) + * @return GetServiceAccountAccessTokenOptionalParameters + */ + public GetServiceAccountAccessTokenOptionalParameters include( + List include) { + this.include = include; + return this; + } + } + /** * Get an access token for a service account. * @@ -710,7 +730,9 @@ public CompletableFuture> deleteServiceAccountApplicationKeyWi */ public ServiceAccessTokenResponse getServiceAccountAccessToken( String serviceAccountId, String tokenId) throws ApiException { - return getServiceAccountAccessTokenWithHttpInfo(serviceAccountId, tokenId).getData(); + return getServiceAccountAccessTokenWithHttpInfo( + serviceAccountId, tokenId, new GetServiceAccountAccessTokenOptionalParameters()) + .getData(); } /** @@ -724,7 +746,49 @@ public ServiceAccessTokenResponse getServiceAccountAccessToken( */ public CompletableFuture getServiceAccountAccessTokenAsync( String serviceAccountId, String tokenId) { - return getServiceAccountAccessTokenWithHttpInfoAsync(serviceAccountId, tokenId) + return getServiceAccountAccessTokenWithHttpInfoAsync( + serviceAccountId, tokenId, new GetServiceAccountAccessTokenOptionalParameters()) + .thenApply( + response -> { + return response.getData(); + }); + } + + /** + * Get an access token for a service account. + * + *

See {@link #getServiceAccountAccessTokenWithHttpInfo}. + * + * @param serviceAccountId The ID of the service account. (required) + * @param tokenId The ID of the access token. (required) + * @param parameters Optional parameters for the request. + * @return ServiceAccessTokenResponse + * @throws ApiException if fails to make API call + */ + public ServiceAccessTokenResponse getServiceAccountAccessToken( + String serviceAccountId, + String tokenId, + GetServiceAccountAccessTokenOptionalParameters parameters) + throws ApiException { + return getServiceAccountAccessTokenWithHttpInfo(serviceAccountId, tokenId, parameters) + .getData(); + } + + /** + * Get an access token for a service account. + * + *

See {@link #getServiceAccountAccessTokenWithHttpInfoAsync}. + * + * @param serviceAccountId The ID of the service account. (required) + * @param tokenId The ID of the access token. (required) + * @param parameters Optional parameters for the request. + * @return CompletableFuture<ServiceAccessTokenResponse> + */ + public CompletableFuture getServiceAccountAccessTokenAsync( + String serviceAccountId, + String tokenId, + GetServiceAccountAccessTokenOptionalParameters parameters) { + return getServiceAccountAccessTokenWithHttpInfoAsync(serviceAccountId, tokenId, parameters) .thenApply( response -> { return response.getData(); @@ -736,6 +800,7 @@ public CompletableFuture getServiceAccountAccessToke * * @param serviceAccountId The ID of the service account. (required) * @param tokenId The ID of the access token. (required) + * @param parameters Optional parameters for the request. * @return ApiResponse<ServiceAccessTokenResponse> * @throws ApiException if fails to make API call * @http.response.details @@ -749,7 +814,10 @@ public CompletableFuture getServiceAccountAccessToke * */ public ApiResponse getServiceAccountAccessTokenWithHttpInfo( - String serviceAccountId, String tokenId) throws ApiException { + String serviceAccountId, + String tokenId, + GetServiceAccountAccessTokenOptionalParameters parameters) + throws ApiException { Object localVarPostBody = null; // verify the required parameter 'serviceAccountId' is set @@ -766,6 +834,7 @@ public ApiResponse getServiceAccountAccessTokenWithH 400, "Missing the required parameter 'tokenId' when calling getServiceAccountAccessToken"); } + List include = parameters.include; // create path and map variables String localVarPath = "/api/v2/service_accounts/{service_account_id}/access_tokens/{token_id}" @@ -774,13 +843,16 @@ public ApiResponse getServiceAccountAccessTokenWithH apiClient.escapeString(serviceAccountId.toString())) .replaceAll("\\{" + "token_id" + "\\}", apiClient.escapeString(tokenId.toString())); + List localVarQueryParams = new ArrayList(); Map localVarHeaderParams = new HashMap(); + localVarQueryParams.addAll(apiClient.parameterToPairs("csv", "include", include)); + Invocation.Builder builder = apiClient.createBuilder( "v2.ServiceAccountsApi.getServiceAccountAccessToken", localVarPath, - new ArrayList(), + localVarQueryParams, localVarHeaderParams, new HashMap(), new String[] {"application/json"}, @@ -803,10 +875,14 @@ public ApiResponse getServiceAccountAccessTokenWithH * * @param serviceAccountId The ID of the service account. (required) * @param tokenId The ID of the access token. (required) + * @param parameters Optional parameters for the request. * @return CompletableFuture<ApiResponse<ServiceAccessTokenResponse>> */ public CompletableFuture> - getServiceAccountAccessTokenWithHttpInfoAsync(String serviceAccountId, String tokenId) { + getServiceAccountAccessTokenWithHttpInfoAsync( + String serviceAccountId, + String tokenId, + GetServiceAccountAccessTokenOptionalParameters parameters) { Object localVarPostBody = null; // verify the required parameter 'serviceAccountId' is set @@ -830,6 +906,7 @@ public ApiResponse getServiceAccountAccessTokenWithH + " getServiceAccountAccessToken")); return result; } + List include = parameters.include; // create path and map variables String localVarPath = "/api/v2/service_accounts/{service_account_id}/access_tokens/{token_id}" @@ -838,15 +915,18 @@ public ApiResponse getServiceAccountAccessTokenWithH apiClient.escapeString(serviceAccountId.toString())) .replaceAll("\\{" + "token_id" + "\\}", apiClient.escapeString(tokenId.toString())); + List localVarQueryParams = new ArrayList(); Map localVarHeaderParams = new HashMap(); + localVarQueryParams.addAll(apiClient.parameterToPairs("csv", "include", include)); + Invocation.Builder builder; try { builder = apiClient.createBuilder( "v2.ServiceAccountsApi.getServiceAccountAccessToken", localVarPath, - new ArrayList(), + localVarQueryParams, localVarHeaderParams, new HashMap(), new String[] {"application/json"}, @@ -1045,6 +1125,8 @@ public static class ListServiceAccountAccessTokensOptionalParameters { private Long pageNumber; private PersonalAccessTokensSort sort; private String filter; + private Boolean filterLeaked; + private List include; /** * Set pageSize. @@ -1092,6 +1174,31 @@ public ListServiceAccountAccessTokensOptionalParameters filter(String filter) { this.filter = filter; return this; } + + /** + * Set filterLeaked. + * + * @param filterLeaked When true, only return access tokens that have been detected as leaked. + * Has no effect when false. (optional) + * @return ListServiceAccountAccessTokensOptionalParameters + */ + public ListServiceAccountAccessTokensOptionalParameters filterLeaked(Boolean filterLeaked) { + this.filterLeaked = filterLeaked; + return this; + } + + /** + * Set include. + * + * @param include Comma-separated list of relationship objects that should be included in the + * response. (optional) + * @return ListServiceAccountAccessTokensOptionalParameters + */ + public ListServiceAccountAccessTokensOptionalParameters include( + List include) { + this.include = include; + return this; + } } /** @@ -1196,6 +1303,8 @@ public ApiResponse listServiceAccountAccessToke Long pageNumber = parameters.pageNumber; PersonalAccessTokensSort sort = parameters.sort; String filter = parameters.filter; + Boolean filterLeaked = parameters.filterLeaked; + List include = parameters.include; // create path and map variables String localVarPath = "/api/v2/service_accounts/{service_account_id}/access_tokens" @@ -1210,6 +1319,8 @@ public ApiResponse listServiceAccountAccessToke localVarQueryParams.addAll(apiClient.parameterToPairs("", "page[number]", pageNumber)); localVarQueryParams.addAll(apiClient.parameterToPairs("", "sort", sort)); localVarQueryParams.addAll(apiClient.parameterToPairs("", "filter", filter)); + localVarQueryParams.addAll(apiClient.parameterToPairs("", "filter[leaked]", filterLeaked)); + localVarQueryParams.addAll(apiClient.parameterToPairs("csv", "include", include)); Invocation.Builder builder = apiClient.createBuilder( @@ -1260,6 +1371,8 @@ public ApiResponse listServiceAccountAccessToke Long pageNumber = parameters.pageNumber; PersonalAccessTokensSort sort = parameters.sort; String filter = parameters.filter; + Boolean filterLeaked = parameters.filterLeaked; + List include = parameters.include; // create path and map variables String localVarPath = "/api/v2/service_accounts/{service_account_id}/access_tokens" @@ -1274,6 +1387,8 @@ public ApiResponse listServiceAccountAccessToke localVarQueryParams.addAll(apiClient.parameterToPairs("", "page[number]", pageNumber)); localVarQueryParams.addAll(apiClient.parameterToPairs("", "sort", sort)); localVarQueryParams.addAll(apiClient.parameterToPairs("", "filter", filter)); + localVarQueryParams.addAll(apiClient.parameterToPairs("", "filter[leaked]", filterLeaked)); + localVarQueryParams.addAll(apiClient.parameterToPairs("csv", "include", include)); Invocation.Builder builder; try { @@ -1783,10 +1898,10 @@ public CompletableFuture> revokeServiceAccountAccessTokenWithH * @param serviceAccountId The ID of the service account. (required) * @param tokenId The ID of the access token. (required) * @param body (required) - * @return ServiceAccessTokenResponse + * @return UpdatedServiceAccessTokenResponse * @throws ApiException if fails to make API call */ - public ServiceAccessTokenResponse updateServiceAccountAccessToken( + public UpdatedServiceAccessTokenResponse updateServiceAccountAccessToken( String serviceAccountId, String tokenId, ServiceAccountAccessTokenUpdateRequest body) throws ApiException { return updateServiceAccountAccessTokenWithHttpInfo(serviceAccountId, tokenId, body).getData(); @@ -1800,9 +1915,9 @@ public ServiceAccessTokenResponse updateServiceAccountAccessToken( * @param serviceAccountId The ID of the service account. (required) * @param tokenId The ID of the access token. (required) * @param body (required) - * @return CompletableFuture<ServiceAccessTokenResponse> + * @return CompletableFuture<UpdatedServiceAccessTokenResponse> */ - public CompletableFuture updateServiceAccountAccessTokenAsync( + public CompletableFuture updateServiceAccountAccessTokenAsync( String serviceAccountId, String tokenId, ServiceAccountAccessTokenUpdateRequest body) { return updateServiceAccountAccessTokenWithHttpInfoAsync(serviceAccountId, tokenId, body) .thenApply( @@ -1817,7 +1932,7 @@ public CompletableFuture updateServiceAccountAccessT * @param serviceAccountId The ID of the service account. (required) * @param tokenId The ID of the access token. (required) * @param body (required) - * @return ApiResponse<ServiceAccessTokenResponse> + * @return ApiResponse<UpdatedServiceAccessTokenResponse> * @throws ApiException if fails to make API call * @http.response.details * @@ -1830,7 +1945,7 @@ public CompletableFuture updateServiceAccountAccessT * *
429 Too many requests -
*/ - public ApiResponse updateServiceAccountAccessTokenWithHttpInfo( + public ApiResponse updateServiceAccountAccessTokenWithHttpInfo( String serviceAccountId, String tokenId, ServiceAccountAccessTokenUpdateRequest body) throws ApiException { Object localVarPostBody = body; @@ -1883,7 +1998,7 @@ public ApiResponse updateServiceAccountAccessTokenWi localVarPostBody, new HashMap(), false, - new GenericType() {}); + new GenericType() {}); } /** @@ -1894,16 +2009,17 @@ public ApiResponse updateServiceAccountAccessTokenWi * @param serviceAccountId The ID of the service account. (required) * @param tokenId The ID of the access token. (required) * @param body (required) - * @return CompletableFuture<ApiResponse<ServiceAccessTokenResponse>> + * @return CompletableFuture<ApiResponse<UpdatedServiceAccessTokenResponse>> */ - public CompletableFuture> + public CompletableFuture> updateServiceAccountAccessTokenWithHttpInfoAsync( String serviceAccountId, String tokenId, ServiceAccountAccessTokenUpdateRequest body) { Object localVarPostBody = body; // verify the required parameter 'serviceAccountId' is set if (serviceAccountId == null) { - CompletableFuture> result = new CompletableFuture<>(); + CompletableFuture> result = + new CompletableFuture<>(); result.completeExceptionally( new ApiException( 400, @@ -1914,7 +2030,8 @@ public ApiResponse updateServiceAccountAccessTokenWi // verify the required parameter 'tokenId' is set if (tokenId == null) { - CompletableFuture> result = new CompletableFuture<>(); + CompletableFuture> result = + new CompletableFuture<>(); result.completeExceptionally( new ApiException( 400, @@ -1925,7 +2042,8 @@ public ApiResponse updateServiceAccountAccessTokenWi // verify the required parameter 'body' is set if (body == null) { - CompletableFuture> result = new CompletableFuture<>(); + CompletableFuture> result = + new CompletableFuture<>(); result.completeExceptionally( new ApiException( 400, @@ -1955,7 +2073,8 @@ public ApiResponse updateServiceAccountAccessTokenWi new String[] {"application/json"}, new String[] {"apiKeyAuth", "appKeyAuth", "AuthZ"}); } catch (ApiException ex) { - CompletableFuture> result = new CompletableFuture<>(); + CompletableFuture> result = + new CompletableFuture<>(); result.completeExceptionally(ex); return result; } @@ -1967,7 +2086,7 @@ public ApiResponse updateServiceAccountAccessTokenWi localVarPostBody, new HashMap(), false, - new GenericType() {}); + new GenericType() {}); } /** diff --git a/src/main/java/com/datadog/api/client/v2/model/AccessTokenListItemRelationships.java b/src/main/java/com/datadog/api/client/v2/model/AccessTokenListItemRelationships.java index b13ea28f5d4..dff0674f65b 100644 --- a/src/main/java/com/datadog/api/client/v2/model/AccessTokenListItemRelationships.java +++ b/src/main/java/com/datadog/api/client/v2/model/AccessTokenListItemRelationships.java @@ -17,14 +17,46 @@ import java.util.Objects; /** Resources related to the access token entry in the mixed list response. */ -@JsonPropertyOrder({AccessTokenListItemRelationships.JSON_PROPERTY_OWNED_BY}) +@JsonPropertyOrder({ + AccessTokenListItemRelationships.JSON_PROPERTY_LEAK_INFORMATION, + AccessTokenListItemRelationships.JSON_PROPERTY_OWNED_BY +}) @jakarta.annotation.Generated( value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") public class AccessTokenListItemRelationships { @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_LEAK_INFORMATION = "leak_information"; + private RelationshipToLeakedKey leakInformation; + public static final String JSON_PROPERTY_OWNED_BY = "owned_by"; private RelationshipToAccessTokenOwner ownedBy; + public AccessTokenListItemRelationships leakInformation(RelationshipToLeakedKey leakInformation) { + this.leakInformation = leakInformation; + this.unparsed |= leakInformation.unparsed; + return this; + } + + /** + * Relationship to the leak the access token was found in. data is null when the + * access token has not been detected as leaked. + * + * @return leakInformation + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_LEAK_INFORMATION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public RelationshipToLeakedKey getLeakInformation() { + return leakInformation; + } + + public void setLeakInformation(RelationshipToLeakedKey leakInformation) { + this.leakInformation = leakInformation; + if (leakInformation != null) { + this.unparsed |= leakInformation.unparsed; + } + } + public AccessTokenListItemRelationships ownedBy(RelationshipToAccessTokenOwner ownedBy) { this.ownedBy = ownedBy; this.unparsed |= ownedBy.unparsed; @@ -107,20 +139,22 @@ public boolean equals(Object o) { } AccessTokenListItemRelationships accessTokenListItemRelationships = (AccessTokenListItemRelationships) o; - return Objects.equals(this.ownedBy, accessTokenListItemRelationships.ownedBy) + return Objects.equals(this.leakInformation, accessTokenListItemRelationships.leakInformation) + && Objects.equals(this.ownedBy, accessTokenListItemRelationships.ownedBy) && Objects.equals( this.additionalProperties, accessTokenListItemRelationships.additionalProperties); } @Override public int hashCode() { - return Objects.hash(ownedBy, additionalProperties); + return Objects.hash(leakInformation, ownedBy, additionalProperties); } @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class AccessTokenListItemRelationships {\n"); + sb.append(" leakInformation: ").append(toIndentedString(leakInformation)).append("\n"); sb.append(" ownedBy: ").append(toIndentedString(ownedBy)).append("\n"); sb.append(" additionalProperties: ") .append(toIndentedString(additionalProperties)) diff --git a/src/main/java/com/datadog/api/client/v2/model/AccessTokenResponseIncludedItem.java b/src/main/java/com/datadog/api/client/v2/model/AccessTokenResponseIncludedItem.java new file mode 100644 index 00000000000..e884fc244c5 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/AccessTokenResponseIncludedItem.java @@ -0,0 +1,215 @@ +/* + * 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.AbstractOpenApiSchema; +import com.datadog.api.client.JSON; +import com.datadog.api.client.UnparsedObject; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.core.JsonToken; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.MapperFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.annotation.JsonDeserialize; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.deser.std.StdDeserializer; +import com.fasterxml.jackson.databind.ser.std.StdSerializer; +import jakarta.ws.rs.core.GenericType; +import java.io.IOException; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.logging.Level; +import java.util.logging.Logger; + +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +@JsonDeserialize( + using = AccessTokenResponseIncludedItem.AccessTokenResponseIncludedItemDeserializer.class) +@JsonSerialize( + using = AccessTokenResponseIncludedItem.AccessTokenResponseIncludedItemSerializer.class) +public class AccessTokenResponseIncludedItem extends AbstractOpenApiSchema { + private static final Logger log = + Logger.getLogger(AccessTokenResponseIncludedItem.class.getName()); + + @JsonIgnore public boolean unparsed = false; + + public static class AccessTokenResponseIncludedItemSerializer + extends StdSerializer { + public AccessTokenResponseIncludedItemSerializer(Class t) { + super(t); + } + + public AccessTokenResponseIncludedItemSerializer() { + this(null); + } + + @Override + public void serialize( + AccessTokenResponseIncludedItem value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class AccessTokenResponseIncludedItemDeserializer + extends StdDeserializer { + public AccessTokenResponseIncludedItemDeserializer() { + this(AccessTokenResponseIncludedItem.class); + } + + public AccessTokenResponseIncludedItemDeserializer(Class vc) { + super(vc); + } + + @Override + public AccessTokenResponseIncludedItem deserialize(JsonParser jp, DeserializationContext ctxt) + throws IOException, JsonProcessingException { + JsonNode tree = jp.readValueAsTree(); + Object deserialized = null; + Object tmp = null; + boolean typeCoercion = ctxt.isEnabled(MapperFeature.ALLOW_COERCION_OF_SCALARS); + int match = 0; + JsonToken token = tree.traverse(jp.getCodec()).nextToken(); + // deserialize LeakedKey + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (LeakedKey.class.equals(Integer.class) + || LeakedKey.class.equals(Long.class) + || LeakedKey.class.equals(Float.class) + || LeakedKey.class.equals(Double.class) + || LeakedKey.class.equals(Boolean.class) + || LeakedKey.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((LeakedKey.class.equals(Integer.class) || LeakedKey.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((LeakedKey.class.equals(Float.class) || LeakedKey.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (LeakedKey.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (LeakedKey.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(LeakedKey.class); + // TODO: there is no validation against JSON schema constraints + // (min, max, enum, pattern...), this does not perform a strict JSON + // validation, which means the 'match' count may be higher than it should be. + if (!((LeakedKey) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log(Level.FINER, "Input data matches schema 'LeakedKey'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'LeakedKey'", e); + } + + AccessTokenResponseIncludedItem ret = new AccessTokenResponseIncludedItem(); + if (match == 1) { + ret.setActualInstance(deserialized); + } else { + Map res = + new ObjectMapper() + .readValue( + tree.traverse(jp.getCodec()).readValueAsTree().toString(), + new TypeReference>() {}); + ret.setActualInstance(new UnparsedObject(res)); + } + return ret; + } + + /** Handle deserialization of the 'null' value. */ + @Override + public AccessTokenResponseIncludedItem getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + throw new JsonMappingException( + ctxt.getParser(), "AccessTokenResponseIncludedItem cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public AccessTokenResponseIncludedItem() { + super("oneOf", Boolean.FALSE); + } + + public AccessTokenResponseIncludedItem(LeakedKey o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("LeakedKey", new GenericType() {}); + JSON.registerDescendants( + AccessTokenResponseIncludedItem.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map getSchemas() { + return AccessTokenResponseIncludedItem.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: LeakedKey + * + *

It could be an instance of the 'oneOf' schemas. The oneOf child schemas may themselves be a + * composed schema (allOf, anyOf, oneOf). + */ + @Override + public void setActualInstance(Object instance) { + if (JSON.isInstanceOf(LeakedKey.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + + if (JSON.isInstanceOf(UnparsedObject.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + throw new RuntimeException("Invalid instance type. Must be LeakedKey"); + } + + /** + * Get the actual instance, which can be the following: LeakedKey + * + * @return The actual instance (LeakedKey) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `LeakedKey`. If the actual instance is not `LeakedKey`, the + * ClassCastException will be thrown. + * + * @return The actual instance of `LeakedKey` + * @throws ClassCastException if the instance is not `LeakedKey` + */ + public LeakedKey getLeakedKey() throws ClassCastException { + return (LeakedKey) super.getActualInstance(); + } +} 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 index fcec225ed6d..a9b57a2e0bd 100644 --- a/src/main/java/com/datadog/api/client/v2/model/FullPersonalAccessToken.java +++ b/src/main/java/com/datadog/api/client/v2/model/FullPersonalAccessToken.java @@ -34,7 +34,7 @@ public class FullPersonalAccessToken { private String id; public static final String JSON_PROPERTY_RELATIONSHIPS = "relationships"; - private PersonalAccessTokenRelationships relationships; + private FullPersonalAccessTokenRelationships relationships; public static final String JSON_PROPERTY_TYPE = "type"; private PersonalAccessTokensType type = PersonalAccessTokensType.PERSONAL_ACCESS_TOKENS; @@ -85,7 +85,7 @@ public void setId(String id) { this.id = id; } - public FullPersonalAccessToken relationships(PersonalAccessTokenRelationships relationships) { + public FullPersonalAccessToken relationships(FullPersonalAccessTokenRelationships relationships) { this.relationships = relationships; this.unparsed |= relationships.unparsed; return this; @@ -99,11 +99,11 @@ public FullPersonalAccessToken relationships(PersonalAccessTokenRelationships re @jakarta.annotation.Nullable @JsonProperty(JSON_PROPERTY_RELATIONSHIPS) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public PersonalAccessTokenRelationships getRelationships() { + public FullPersonalAccessTokenRelationships getRelationships() { return relationships; } - public void setRelationships(PersonalAccessTokenRelationships relationships) { + public void setRelationships(FullPersonalAccessTokenRelationships relationships) { this.relationships = relationships; if (relationships != null) { this.unparsed |= relationships.unparsed; diff --git a/src/main/java/com/datadog/api/client/v2/model/FullPersonalAccessTokenRelationships.java b/src/main/java/com/datadog/api/client/v2/model/FullPersonalAccessTokenRelationships.java new file mode 100644 index 00000000000..56783dccd7a --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/FullPersonalAccessTokenRelationships.java @@ -0,0 +1,141 @@ +/* + * 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 access token. */ +@JsonPropertyOrder({FullPersonalAccessTokenRelationships.JSON_PROPERTY_OWNED_BY}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class FullPersonalAccessTokenRelationships { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_OWNED_BY = "owned_by"; + private RelationshipToUser ownedBy; + + public FullPersonalAccessTokenRelationships 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; + if (ownedBy != null) { + this.unparsed |= ownedBy.unparsed; + } + } + + /** + * 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 FullPersonalAccessTokenRelationships + */ + @JsonAnySetter + public FullPersonalAccessTokenRelationships 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 FullPersonalAccessTokenRelationships object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + FullPersonalAccessTokenRelationships fullPersonalAccessTokenRelationships = + (FullPersonalAccessTokenRelationships) o; + return Objects.equals(this.ownedBy, fullPersonalAccessTokenRelationships.ownedBy) + && Objects.equals( + this.additionalProperties, fullPersonalAccessTokenRelationships.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(ownedBy, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class FullPersonalAccessTokenRelationships {\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/FullServiceAccessToken.java b/src/main/java/com/datadog/api/client/v2/model/FullServiceAccessToken.java index 0bfa26bbcd5..afabc785d15 100644 --- a/src/main/java/com/datadog/api/client/v2/model/FullServiceAccessToken.java +++ b/src/main/java/com/datadog/api/client/v2/model/FullServiceAccessToken.java @@ -34,7 +34,7 @@ public class FullServiceAccessToken { private String id; public static final String JSON_PROPERTY_RELATIONSHIPS = "relationships"; - private ServiceAccessTokenRelationships relationships; + private FullServiceAccessTokenRelationships relationships; public static final String JSON_PROPERTY_TYPE = "type"; private ServiceAccessTokensType type = ServiceAccessTokensType.SERVICE_ACCESS_TOKENS; @@ -85,7 +85,7 @@ public void setId(String id) { this.id = id; } - public FullServiceAccessToken relationships(ServiceAccessTokenRelationships relationships) { + public FullServiceAccessToken relationships(FullServiceAccessTokenRelationships relationships) { this.relationships = relationships; this.unparsed |= relationships.unparsed; return this; @@ -99,11 +99,11 @@ public FullServiceAccessToken relationships(ServiceAccessTokenRelationships rela @jakarta.annotation.Nullable @JsonProperty(JSON_PROPERTY_RELATIONSHIPS) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public ServiceAccessTokenRelationships getRelationships() { + public FullServiceAccessTokenRelationships getRelationships() { return relationships; } - public void setRelationships(ServiceAccessTokenRelationships relationships) { + public void setRelationships(FullServiceAccessTokenRelationships relationships) { this.relationships = relationships; if (relationships != null) { this.unparsed |= relationships.unparsed; diff --git a/src/main/java/com/datadog/api/client/v2/model/FullServiceAccessTokenRelationships.java b/src/main/java/com/datadog/api/client/v2/model/FullServiceAccessTokenRelationships.java new file mode 100644 index 00000000000..a4011907b25 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/FullServiceAccessTokenRelationships.java @@ -0,0 +1,141 @@ +/* + * 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 access token. */ +@JsonPropertyOrder({FullServiceAccessTokenRelationships.JSON_PROPERTY_OWNED_BY}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class FullServiceAccessTokenRelationships { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_OWNED_BY = "owned_by"; + private RelationshipToServiceAccount ownedBy; + + public FullServiceAccessTokenRelationships ownedBy(RelationshipToServiceAccount ownedBy) { + this.ownedBy = ownedBy; + this.unparsed |= ownedBy.unparsed; + return this; + } + + /** + * Relationship to service account. + * + * @return ownedBy + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_OWNED_BY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public RelationshipToServiceAccount getOwnedBy() { + return ownedBy; + } + + public void setOwnedBy(RelationshipToServiceAccount ownedBy) { + this.ownedBy = ownedBy; + if (ownedBy != null) { + this.unparsed |= ownedBy.unparsed; + } + } + + /** + * 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 FullServiceAccessTokenRelationships + */ + @JsonAnySetter + public FullServiceAccessTokenRelationships 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 FullServiceAccessTokenRelationships object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + FullServiceAccessTokenRelationships fullServiceAccessTokenRelationships = + (FullServiceAccessTokenRelationships) o; + return Objects.equals(this.ownedBy, fullServiceAccessTokenRelationships.ownedBy) + && Objects.equals( + this.additionalProperties, fullServiceAccessTokenRelationships.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(ownedBy, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class FullServiceAccessTokenRelationships {\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/ListPersonalAccessTokensResponse.java b/src/main/java/com/datadog/api/client/v2/model/ListPersonalAccessTokensResponse.java index bd6f1b3c785..b770b66d7b6 100644 --- a/src/main/java/com/datadog/api/client/v2/model/ListPersonalAccessTokensResponse.java +++ b/src/main/java/com/datadog/api/client/v2/model/ListPersonalAccessTokensResponse.java @@ -21,6 +21,7 @@ /** Response for a list of access tokens. Includes both personal and service access tokens. */ @JsonPropertyOrder({ ListPersonalAccessTokensResponse.JSON_PROPERTY_DATA, + ListPersonalAccessTokensResponse.JSON_PROPERTY_INCLUDED, ListPersonalAccessTokensResponse.JSON_PROPERTY_META }) @jakarta.annotation.Generated( @@ -30,6 +31,9 @@ public class ListPersonalAccessTokensResponse { public static final String JSON_PROPERTY_DATA = "data"; private List data = null; + public static final String JSON_PROPERTY_INCLUDED = "included"; + private List included = null; + public static final String JSON_PROPERTY_META = "meta"; private PersonalAccessTokenResponseMeta meta; @@ -73,6 +77,47 @@ public void setData(List data) { } } + public ListPersonalAccessTokensResponse included(List included) { + this.included = included; + if (included != null) { + for (AccessTokenResponseIncludedItem item : included) { + this.unparsed |= item.unparsed; + } + } + return this; + } + + public ListPersonalAccessTokensResponse addIncludedItem( + AccessTokenResponseIncludedItem includedItem) { + if (this.included == null) { + this.included = new ArrayList<>(); + } + this.included.add(includedItem); + this.unparsed |= includedItem.unparsed; + return this; + } + + /** + * Array of objects related to the access tokens. + * + * @return included + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_INCLUDED) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getIncluded() { + return included; + } + + public void setIncluded(List included) { + this.included = included; + if (included != null) { + for (AccessTokenResponseIncludedItem item : included) { + this.unparsed |= item.unparsed; + } + } + } + public ListPersonalAccessTokensResponse meta(PersonalAccessTokenResponseMeta meta) { this.meta = meta; this.unparsed |= meta.unparsed; @@ -156,6 +201,7 @@ public boolean equals(Object o) { ListPersonalAccessTokensResponse listPersonalAccessTokensResponse = (ListPersonalAccessTokensResponse) o; return Objects.equals(this.data, listPersonalAccessTokensResponse.data) + && Objects.equals(this.included, listPersonalAccessTokensResponse.included) && Objects.equals(this.meta, listPersonalAccessTokensResponse.meta) && Objects.equals( this.additionalProperties, listPersonalAccessTokensResponse.additionalProperties); @@ -163,7 +209,7 @@ public boolean equals(Object o) { @Override public int hashCode() { - return Objects.hash(data, meta, additionalProperties); + return Objects.hash(data, included, meta, additionalProperties); } @Override @@ -171,6 +217,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class ListPersonalAccessTokensResponse {\n"); sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append(" included: ").append(toIndentedString(included)).append("\n"); sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); sb.append(" additionalProperties: ") .append(toIndentedString(additionalProperties)) diff --git a/src/main/java/com/datadog/api/client/v2/model/ListServiceAccessTokensResponse.java b/src/main/java/com/datadog/api/client/v2/model/ListServiceAccessTokensResponse.java index 6da35b8875b..6d87fd11fd2 100644 --- a/src/main/java/com/datadog/api/client/v2/model/ListServiceAccessTokensResponse.java +++ b/src/main/java/com/datadog/api/client/v2/model/ListServiceAccessTokensResponse.java @@ -21,6 +21,7 @@ /** Response for a list of access tokens. */ @JsonPropertyOrder({ ListServiceAccessTokensResponse.JSON_PROPERTY_DATA, + ListServiceAccessTokensResponse.JSON_PROPERTY_INCLUDED, ListServiceAccessTokensResponse.JSON_PROPERTY_META }) @jakarta.annotation.Generated( @@ -30,6 +31,9 @@ public class ListServiceAccessTokensResponse { public static final String JSON_PROPERTY_DATA = "data"; private List data = null; + public static final String JSON_PROPERTY_INCLUDED = "included"; + private List included = null; + public static final String JSON_PROPERTY_META = "meta"; private ServiceAccessTokenResponseMeta meta; @@ -73,6 +77,47 @@ public void setData(List data) { } } + public ListServiceAccessTokensResponse included(List included) { + this.included = included; + if (included != null) { + for (AccessTokenResponseIncludedItem item : included) { + this.unparsed |= item.unparsed; + } + } + return this; + } + + public ListServiceAccessTokensResponse addIncludedItem( + AccessTokenResponseIncludedItem includedItem) { + if (this.included == null) { + this.included = new ArrayList<>(); + } + this.included.add(includedItem); + this.unparsed |= includedItem.unparsed; + return this; + } + + /** + * Array of objects related to the access tokens. + * + * @return included + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_INCLUDED) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getIncluded() { + return included; + } + + public void setIncluded(List included) { + this.included = included; + if (included != null) { + for (AccessTokenResponseIncludedItem item : included) { + this.unparsed |= item.unparsed; + } + } + } + public ListServiceAccessTokensResponse meta(ServiceAccessTokenResponseMeta meta) { this.meta = meta; this.unparsed |= meta.unparsed; @@ -156,6 +201,7 @@ public boolean equals(Object o) { ListServiceAccessTokensResponse listServiceAccessTokensResponse = (ListServiceAccessTokensResponse) o; return Objects.equals(this.data, listServiceAccessTokensResponse.data) + && Objects.equals(this.included, listServiceAccessTokensResponse.included) && Objects.equals(this.meta, listServiceAccessTokensResponse.meta) && Objects.equals( this.additionalProperties, listServiceAccessTokensResponse.additionalProperties); @@ -163,7 +209,7 @@ public boolean equals(Object o) { @Override public int hashCode() { - return Objects.hash(data, meta, additionalProperties); + return Objects.hash(data, included, meta, additionalProperties); } @Override @@ -171,6 +217,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class ListServiceAccessTokensResponse {\n"); sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append(" included: ").append(toIndentedString(included)).append("\n"); sb.append(" meta: ").append(toIndentedString(meta)).append("\n"); sb.append(" additionalProperties: ") .append(toIndentedString(additionalProperties)) 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 index 2259c743805..ccca042e65e 100644 --- a/src/main/java/com/datadog/api/client/v2/model/PersonalAccessTokenRelationships.java +++ b/src/main/java/com/datadog/api/client/v2/model/PersonalAccessTokenRelationships.java @@ -17,14 +17,46 @@ import java.util.Objects; /** Resources related to the access token. */ -@JsonPropertyOrder({PersonalAccessTokenRelationships.JSON_PROPERTY_OWNED_BY}) +@JsonPropertyOrder({ + PersonalAccessTokenRelationships.JSON_PROPERTY_LEAK_INFORMATION, + 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_LEAK_INFORMATION = "leak_information"; + private RelationshipToLeakedKey leakInformation; + public static final String JSON_PROPERTY_OWNED_BY = "owned_by"; private RelationshipToUser ownedBy; + public PersonalAccessTokenRelationships leakInformation(RelationshipToLeakedKey leakInformation) { + this.leakInformation = leakInformation; + this.unparsed |= leakInformation.unparsed; + return this; + } + + /** + * Relationship to the leak the access token was found in. data is null when the + * access token has not been detected as leaked. + * + * @return leakInformation + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_LEAK_INFORMATION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public RelationshipToLeakedKey getLeakInformation() { + return leakInformation; + } + + public void setLeakInformation(RelationshipToLeakedKey leakInformation) { + this.leakInformation = leakInformation; + if (leakInformation != null) { + this.unparsed |= leakInformation.unparsed; + } + } + public PersonalAccessTokenRelationships ownedBy(RelationshipToUser ownedBy) { this.ownedBy = ownedBy; this.unparsed |= ownedBy.unparsed; @@ -107,20 +139,22 @@ public boolean equals(Object o) { } PersonalAccessTokenRelationships personalAccessTokenRelationships = (PersonalAccessTokenRelationships) o; - return Objects.equals(this.ownedBy, personalAccessTokenRelationships.ownedBy) + return Objects.equals(this.leakInformation, personalAccessTokenRelationships.leakInformation) + && Objects.equals(this.ownedBy, personalAccessTokenRelationships.ownedBy) && Objects.equals( this.additionalProperties, personalAccessTokenRelationships.additionalProperties); } @Override public int hashCode() { - return Objects.hash(ownedBy, additionalProperties); + return Objects.hash(leakInformation, ownedBy, additionalProperties); } @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class PersonalAccessTokenRelationships {\n"); + sb.append(" leakInformation: ").append(toIndentedString(leakInformation)).append("\n"); sb.append(" ownedBy: ").append(toIndentedString(ownedBy)).append("\n"); sb.append(" additionalProperties: ") .append(toIndentedString(additionalProperties)) 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 index 4cb1aeaa1dc..fc89a75b3e1 100644 --- a/src/main/java/com/datadog/api/client/v2/model/PersonalAccessTokenResponse.java +++ b/src/main/java/com/datadog/api/client/v2/model/PersonalAccessTokenResponse.java @@ -12,12 +12,17 @@ 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 retrieving an access token. */ -@JsonPropertyOrder({PersonalAccessTokenResponse.JSON_PROPERTY_DATA}) +@JsonPropertyOrder({ + PersonalAccessTokenResponse.JSON_PROPERTY_DATA, + PersonalAccessTokenResponse.JSON_PROPERTY_INCLUDED +}) @jakarta.annotation.Generated( value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") public class PersonalAccessTokenResponse { @@ -25,6 +30,9 @@ public class PersonalAccessTokenResponse { public static final String JSON_PROPERTY_DATA = "data"; private PersonalAccessToken data; + public static final String JSON_PROPERTY_INCLUDED = "included"; + private List included = null; + public PersonalAccessTokenResponse data(PersonalAccessToken data) { this.data = data; this.unparsed |= data.unparsed; @@ -50,6 +58,46 @@ public void setData(PersonalAccessToken data) { } } + public PersonalAccessTokenResponse included(List included) { + this.included = included; + if (included != null) { + for (AccessTokenResponseIncludedItem item : included) { + this.unparsed |= item.unparsed; + } + } + return this; + } + + public PersonalAccessTokenResponse addIncludedItem(AccessTokenResponseIncludedItem includedItem) { + if (this.included == null) { + this.included = new ArrayList<>(); + } + this.included.add(includedItem); + this.unparsed |= includedItem.unparsed; + return this; + } + + /** + * Array of objects related to the access tokens. + * + * @return included + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_INCLUDED) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getIncluded() { + return included; + } + + public void setIncluded(List included) { + this.included = included; + if (included != null) { + for (AccessTokenResponseIncludedItem item : included) { + this.unparsed |= item.unparsed; + } + } + } + /** * A container for additional, undeclared properties. This is a holder for any undeclared * properties as specified with the 'additionalProperties' keyword in the OAS document. @@ -107,13 +155,14 @@ public boolean equals(Object o) { } PersonalAccessTokenResponse personalAccessTokenResponse = (PersonalAccessTokenResponse) o; return Objects.equals(this.data, personalAccessTokenResponse.data) + && Objects.equals(this.included, personalAccessTokenResponse.included) && Objects.equals( this.additionalProperties, personalAccessTokenResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(data, additionalProperties); + return Objects.hash(data, included, additionalProperties); } @Override @@ -121,6 +170,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class PersonalAccessTokenResponse {\n"); sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append(" included: ").append(toIndentedString(included)).append("\n"); sb.append(" additionalProperties: ") .append(toIndentedString(additionalProperties)) .append("\n"); diff --git a/src/main/java/com/datadog/api/client/v2/model/PersonalAccessTokensIncludeQueryParameterItem.java b/src/main/java/com/datadog/api/client/v2/model/PersonalAccessTokensIncludeQueryParameterItem.java new file mode 100644 index 00000000000..09795b2a930 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/PersonalAccessTokensIncludeQueryParameterItem.java @@ -0,0 +1,63 @@ +/* + * 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; + +/** Relationship object that should be included in the response. */ +@JsonSerialize( + using = + PersonalAccessTokensIncludeQueryParameterItem + .PersonalAccessTokensIncludeQueryParameterItemSerializer.class) +public class PersonalAccessTokensIncludeQueryParameterItem extends ModelEnum { + + private static final Set allowedValues = + new HashSet(Arrays.asList("leak_information")); + + public static final PersonalAccessTokensIncludeQueryParameterItem LEAK_INFORMATION = + new PersonalAccessTokensIncludeQueryParameterItem("leak_information"); + + PersonalAccessTokensIncludeQueryParameterItem(String value) { + super(value, allowedValues); + } + + public static class PersonalAccessTokensIncludeQueryParameterItemSerializer + extends StdSerializer { + public PersonalAccessTokensIncludeQueryParameterItemSerializer( + Class t) { + super(t); + } + + public PersonalAccessTokensIncludeQueryParameterItemSerializer() { + this(null); + } + + @Override + public void serialize( + PersonalAccessTokensIncludeQueryParameterItem value, + JsonGenerator jgen, + SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.value); + } + } + + @JsonCreator + public static PersonalAccessTokensIncludeQueryParameterItem fromValue(String value) { + return new PersonalAccessTokensIncludeQueryParameterItem(value); + } +} 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 index 939308b7523..8d5cb6dc5d8 100644 --- a/src/main/java/com/datadog/api/client/v2/model/PersonalAccessTokensSort.java +++ b/src/main/java/com/datadog/api/client/v2/model/PersonalAccessTokensSort.java @@ -32,7 +32,9 @@ public class PersonalAccessTokensSort extends ModelEnum { "expires_at", "-expires_at", "last_used_at", - "-last_used_at")); + "-last_used_at", + "leaked", + "-leaked")); public static final PersonalAccessTokensSort NAME_ASCENDING = new PersonalAccessTokensSort("name"); @@ -50,6 +52,10 @@ public class PersonalAccessTokensSort extends ModelEnum { new PersonalAccessTokensSort("last_used_at"); public static final PersonalAccessTokensSort LAST_USED_AT_DESCENDING = new PersonalAccessTokensSort("-last_used_at"); + public static final PersonalAccessTokensSort LEAKED_ASCENDING = + new PersonalAccessTokensSort("leaked"); + public static final PersonalAccessTokensSort LEAKED_DESCENDING = + new PersonalAccessTokensSort("-leaked"); PersonalAccessTokensSort(String value) { super(value, allowedValues); diff --git a/src/main/java/com/datadog/api/client/v2/model/RelationshipToLeakedKey.java b/src/main/java/com/datadog/api/client/v2/model/RelationshipToLeakedKey.java new file mode 100644 index 00000000000..45afca73868 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/RelationshipToLeakedKey.java @@ -0,0 +1,156 @@ +/* + * 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; + +/** + * Relationship to the leak the access token was found in. data is null when the access + * token has not been detected as leaked. + */ +@JsonPropertyOrder({RelationshipToLeakedKey.JSON_PROPERTY_DATA}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class RelationshipToLeakedKey { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_DATA = "data"; + private RelationshipToLeakedKeyData data; + + public RelationshipToLeakedKey() {} + + @JsonCreator + public RelationshipToLeakedKey( + @JsonProperty(required = true, value = JSON_PROPERTY_DATA) RelationshipToLeakedKeyData data) { + this.data = data; + if (data != null) { + this.unparsed |= data.unparsed; + } + } + + public RelationshipToLeakedKey data(RelationshipToLeakedKeyData data) { + this.data = data; + if (data != null) { + this.unparsed |= data.unparsed; + } + return this; + } + + /** + * Relationship to the leak the access token was found in. + * + * @return data + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_DATA) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public RelationshipToLeakedKeyData getData() { + return data; + } + + public void setData(RelationshipToLeakedKeyData data) { + this.data = data; + if (data != null) { + this.unparsed |= data.unparsed; + } + } + + /** + * 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 RelationshipToLeakedKey + */ + @JsonAnySetter + public RelationshipToLeakedKey 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 RelationshipToLeakedKey object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + RelationshipToLeakedKey relationshipToLeakedKey = (RelationshipToLeakedKey) o; + return Objects.equals(this.data, relationshipToLeakedKey.data) + && Objects.equals(this.additionalProperties, relationshipToLeakedKey.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(data, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class RelationshipToLeakedKey {\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/RelationshipToLeakedKeyData.java b/src/main/java/com/datadog/api/client/v2/model/RelationshipToLeakedKeyData.java new file mode 100644 index 00000000000..b17495ebd17 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/RelationshipToLeakedKeyData.java @@ -0,0 +1,179 @@ +/* + * 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; + +/** Relationship to the leak the access token was found in. */ +@JsonPropertyOrder({ + RelationshipToLeakedKeyData.JSON_PROPERTY_ID, + RelationshipToLeakedKeyData.JSON_PROPERTY_TYPE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class RelationshipToLeakedKeyData { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_ID = "id"; + private String id; + + public static final String JSON_PROPERTY_TYPE = "type"; + private LeakedKeyType type = LeakedKeyType.LEAKED_KEYS; + + public RelationshipToLeakedKeyData() {} + + @JsonCreator + public RelationshipToLeakedKeyData( + @JsonProperty(required = true, value = JSON_PROPERTY_ID) String id, + @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) LeakedKeyType type) { + this.id = id; + this.type = type; + this.unparsed |= !type.isValid(); + } + + public RelationshipToLeakedKeyData id(String id) { + this.id = id; + return this; + } + + /** + * A unique identifier that represents the leak. + * + * @return id + */ + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public RelationshipToLeakedKeyData type(LeakedKeyType type) { + this.type = type; + this.unparsed |= !type.isValid(); + return this; + } + + /** + * The definition of LeakedKeyType object. + * + * @return type + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public LeakedKeyType getType() { + return type; + } + + public void setType(LeakedKeyType 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 RelationshipToLeakedKeyData + */ + @JsonAnySetter + public RelationshipToLeakedKeyData 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 RelationshipToLeakedKeyData object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + RelationshipToLeakedKeyData relationshipToLeakedKeyData = (RelationshipToLeakedKeyData) o; + return Objects.equals(this.id, relationshipToLeakedKeyData.id) + && Objects.equals(this.type, relationshipToLeakedKeyData.type) + && Objects.equals( + this.additionalProperties, relationshipToLeakedKeyData.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(id, type, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class RelationshipToLeakedKeyData {\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/ServiceAccessTokenRelationships.java b/src/main/java/com/datadog/api/client/v2/model/ServiceAccessTokenRelationships.java index 25dfad6b607..eb8c3eff756 100644 --- a/src/main/java/com/datadog/api/client/v2/model/ServiceAccessTokenRelationships.java +++ b/src/main/java/com/datadog/api/client/v2/model/ServiceAccessTokenRelationships.java @@ -17,14 +17,46 @@ import java.util.Objects; /** Resources related to the access token. */ -@JsonPropertyOrder({ServiceAccessTokenRelationships.JSON_PROPERTY_OWNED_BY}) +@JsonPropertyOrder({ + ServiceAccessTokenRelationships.JSON_PROPERTY_LEAK_INFORMATION, + ServiceAccessTokenRelationships.JSON_PROPERTY_OWNED_BY +}) @jakarta.annotation.Generated( value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") public class ServiceAccessTokenRelationships { @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_LEAK_INFORMATION = "leak_information"; + private RelationshipToLeakedKey leakInformation; + public static final String JSON_PROPERTY_OWNED_BY = "owned_by"; private RelationshipToServiceAccount ownedBy; + public ServiceAccessTokenRelationships leakInformation(RelationshipToLeakedKey leakInformation) { + this.leakInformation = leakInformation; + this.unparsed |= leakInformation.unparsed; + return this; + } + + /** + * Relationship to the leak the access token was found in. data is null when the + * access token has not been detected as leaked. + * + * @return leakInformation + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_LEAK_INFORMATION) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public RelationshipToLeakedKey getLeakInformation() { + return leakInformation; + } + + public void setLeakInformation(RelationshipToLeakedKey leakInformation) { + this.leakInformation = leakInformation; + if (leakInformation != null) { + this.unparsed |= leakInformation.unparsed; + } + } + public ServiceAccessTokenRelationships ownedBy(RelationshipToServiceAccount ownedBy) { this.ownedBy = ownedBy; this.unparsed |= ownedBy.unparsed; @@ -107,20 +139,22 @@ public boolean equals(Object o) { } ServiceAccessTokenRelationships serviceAccessTokenRelationships = (ServiceAccessTokenRelationships) o; - return Objects.equals(this.ownedBy, serviceAccessTokenRelationships.ownedBy) + return Objects.equals(this.leakInformation, serviceAccessTokenRelationships.leakInformation) + && Objects.equals(this.ownedBy, serviceAccessTokenRelationships.ownedBy) && Objects.equals( this.additionalProperties, serviceAccessTokenRelationships.additionalProperties); } @Override public int hashCode() { - return Objects.hash(ownedBy, additionalProperties); + return Objects.hash(leakInformation, ownedBy, additionalProperties); } @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class ServiceAccessTokenRelationships {\n"); + sb.append(" leakInformation: ").append(toIndentedString(leakInformation)).append("\n"); sb.append(" ownedBy: ").append(toIndentedString(ownedBy)).append("\n"); sb.append(" additionalProperties: ") .append(toIndentedString(additionalProperties)) diff --git a/src/main/java/com/datadog/api/client/v2/model/ServiceAccessTokenResponse.java b/src/main/java/com/datadog/api/client/v2/model/ServiceAccessTokenResponse.java index e3e3814a0dc..6b749d73f61 100644 --- a/src/main/java/com/datadog/api/client/v2/model/ServiceAccessTokenResponse.java +++ b/src/main/java/com/datadog/api/client/v2/model/ServiceAccessTokenResponse.java @@ -12,12 +12,17 @@ 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 retrieving an access token. */ -@JsonPropertyOrder({ServiceAccessTokenResponse.JSON_PROPERTY_DATA}) +@JsonPropertyOrder({ + ServiceAccessTokenResponse.JSON_PROPERTY_DATA, + ServiceAccessTokenResponse.JSON_PROPERTY_INCLUDED +}) @jakarta.annotation.Generated( value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") public class ServiceAccessTokenResponse { @@ -25,6 +30,9 @@ public class ServiceAccessTokenResponse { public static final String JSON_PROPERTY_DATA = "data"; private ServiceAccessToken data; + public static final String JSON_PROPERTY_INCLUDED = "included"; + private List included = null; + public ServiceAccessTokenResponse data(ServiceAccessToken data) { this.data = data; this.unparsed |= data.unparsed; @@ -50,6 +58,46 @@ public void setData(ServiceAccessToken data) { } } + public ServiceAccessTokenResponse included(List included) { + this.included = included; + if (included != null) { + for (AccessTokenResponseIncludedItem item : included) { + this.unparsed |= item.unparsed; + } + } + return this; + } + + public ServiceAccessTokenResponse addIncludedItem(AccessTokenResponseIncludedItem includedItem) { + if (this.included == null) { + this.included = new ArrayList<>(); + } + this.included.add(includedItem); + this.unparsed |= includedItem.unparsed; + return this; + } + + /** + * Array of objects related to the access tokens. + * + * @return included + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_INCLUDED) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getIncluded() { + return included; + } + + public void setIncluded(List included) { + this.included = included; + if (included != null) { + for (AccessTokenResponseIncludedItem item : included) { + this.unparsed |= item.unparsed; + } + } + } + /** * A container for additional, undeclared properties. This is a holder for any undeclared * properties as specified with the 'additionalProperties' keyword in the OAS document. @@ -107,13 +155,14 @@ public boolean equals(Object o) { } ServiceAccessTokenResponse serviceAccessTokenResponse = (ServiceAccessTokenResponse) o; return Objects.equals(this.data, serviceAccessTokenResponse.data) + && Objects.equals(this.included, serviceAccessTokenResponse.included) && Objects.equals( this.additionalProperties, serviceAccessTokenResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(data, additionalProperties); + return Objects.hash(data, included, additionalProperties); } @Override @@ -121,6 +170,7 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class ServiceAccessTokenResponse {\n"); sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append(" included: ").append(toIndentedString(included)).append("\n"); sb.append(" additionalProperties: ") .append(toIndentedString(additionalProperties)) .append("\n"); diff --git a/src/main/java/com/datadog/api/client/v2/model/UpdatedPersonalAccessToken.java b/src/main/java/com/datadog/api/client/v2/model/UpdatedPersonalAccessToken.java new file mode 100644 index 00000000000..3c9039b3d8f --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/UpdatedPersonalAccessToken.java @@ -0,0 +1,242 @@ +/* + * 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; + +/** Datadog access token returned by the update endpoint. */ +@JsonPropertyOrder({ + UpdatedPersonalAccessToken.JSON_PROPERTY_ATTRIBUTES, + UpdatedPersonalAccessToken.JSON_PROPERTY_ID, + UpdatedPersonalAccessToken.JSON_PROPERTY_RELATIONSHIPS, + UpdatedPersonalAccessToken.JSON_PROPERTY_TYPE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class UpdatedPersonalAccessToken { + @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 String id; + + public static final String JSON_PROPERTY_RELATIONSHIPS = "relationships"; + private UpdatedPersonalAccessTokenRelationships relationships; + + public static final String JSON_PROPERTY_TYPE = "type"; + private PersonalAccessTokensType type = PersonalAccessTokensType.PERSONAL_ACCESS_TOKENS; + + public UpdatedPersonalAccessToken() {} + + @JsonCreator + public UpdatedPersonalAccessToken( + @JsonProperty(required = true, value = JSON_PROPERTY_ID) String id, + @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) PersonalAccessTokensType type) { + this.id = id; + this.type = type; + this.unparsed |= !type.isValid(); + } + + public UpdatedPersonalAccessToken attributes(PersonalAccessTokenAttributes attributes) { + this.attributes = attributes; + this.unparsed |= attributes.unparsed; + return this; + } + + /** + * Attributes of an access token. + * + * @return attributes + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_ATTRIBUTES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public PersonalAccessTokenAttributes getAttributes() { + return attributes; + } + + public void setAttributes(PersonalAccessTokenAttributes attributes) { + this.attributes = attributes; + if (attributes != null) { + this.unparsed |= attributes.unparsed; + } + } + + public UpdatedPersonalAccessToken id(String id) { + this.id = id; + return this; + } + + /** + * ID of the access token. + * + * @return id + */ + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public UpdatedPersonalAccessToken relationships( + UpdatedPersonalAccessTokenRelationships relationships) { + this.relationships = relationships; + this.unparsed |= relationships.unparsed; + return this; + } + + /** + * Resources related to the access token. + * + * @return relationships + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_RELATIONSHIPS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public UpdatedPersonalAccessTokenRelationships getRelationships() { + return relationships; + } + + public void setRelationships(UpdatedPersonalAccessTokenRelationships relationships) { + this.relationships = relationships; + if (relationships != null) { + this.unparsed |= relationships.unparsed; + } + } + + public UpdatedPersonalAccessToken type(PersonalAccessTokensType 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 PersonalAccessTokensType getType() { + return type; + } + + public void setType(PersonalAccessTokensType 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 UpdatedPersonalAccessToken + */ + @JsonAnySetter + public UpdatedPersonalAccessToken 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 UpdatedPersonalAccessToken object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UpdatedPersonalAccessToken updatedPersonalAccessToken = (UpdatedPersonalAccessToken) o; + return Objects.equals(this.attributes, updatedPersonalAccessToken.attributes) + && Objects.equals(this.id, updatedPersonalAccessToken.id) + && Objects.equals(this.relationships, updatedPersonalAccessToken.relationships) + && Objects.equals(this.type, updatedPersonalAccessToken.type) + && Objects.equals( + this.additionalProperties, updatedPersonalAccessToken.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(attributes, id, relationships, type, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class UpdatedPersonalAccessToken {\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/UpdatedPersonalAccessTokenRelationships.java b/src/main/java/com/datadog/api/client/v2/model/UpdatedPersonalAccessTokenRelationships.java new file mode 100644 index 00000000000..0721304b184 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/UpdatedPersonalAccessTokenRelationships.java @@ -0,0 +1,142 @@ +/* + * 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 access token. */ +@JsonPropertyOrder({UpdatedPersonalAccessTokenRelationships.JSON_PROPERTY_OWNED_BY}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class UpdatedPersonalAccessTokenRelationships { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_OWNED_BY = "owned_by"; + private RelationshipToUser ownedBy; + + public UpdatedPersonalAccessTokenRelationships 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; + if (ownedBy != null) { + this.unparsed |= ownedBy.unparsed; + } + } + + /** + * 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 UpdatedPersonalAccessTokenRelationships + */ + @JsonAnySetter + public UpdatedPersonalAccessTokenRelationships 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 UpdatedPersonalAccessTokenRelationships object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UpdatedPersonalAccessTokenRelationships updatedPersonalAccessTokenRelationships = + (UpdatedPersonalAccessTokenRelationships) o; + return Objects.equals(this.ownedBy, updatedPersonalAccessTokenRelationships.ownedBy) + && Objects.equals( + this.additionalProperties, + updatedPersonalAccessTokenRelationships.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(ownedBy, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class UpdatedPersonalAccessTokenRelationships {\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/UpdatedPersonalAccessTokenResponse.java b/src/main/java/com/datadog/api/client/v2/model/UpdatedPersonalAccessTokenResponse.java new file mode 100644 index 00000000000..0846a67e922 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/UpdatedPersonalAccessTokenResponse.java @@ -0,0 +1,150 @@ +/* + * 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; + +/** Response for updating an access token. */ +@JsonPropertyOrder({UpdatedPersonalAccessTokenResponse.JSON_PROPERTY_DATA}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class UpdatedPersonalAccessTokenResponse { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_DATA = "data"; + private UpdatedPersonalAccessToken data; + + public UpdatedPersonalAccessTokenResponse() {} + + @JsonCreator + public UpdatedPersonalAccessTokenResponse( + @JsonProperty(required = true, value = JSON_PROPERTY_DATA) UpdatedPersonalAccessToken data) { + this.data = data; + this.unparsed |= data.unparsed; + } + + public UpdatedPersonalAccessTokenResponse data(UpdatedPersonalAccessToken data) { + this.data = data; + this.unparsed |= data.unparsed; + return this; + } + + /** + * Datadog access token returned by the update endpoint. + * + * @return data + */ + @JsonProperty(JSON_PROPERTY_DATA) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public UpdatedPersonalAccessToken getData() { + return data; + } + + public void setData(UpdatedPersonalAccessToken data) { + this.data = data; + if (data != null) { + this.unparsed |= data.unparsed; + } + } + + /** + * 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 UpdatedPersonalAccessTokenResponse + */ + @JsonAnySetter + public UpdatedPersonalAccessTokenResponse 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 UpdatedPersonalAccessTokenResponse object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UpdatedPersonalAccessTokenResponse updatedPersonalAccessTokenResponse = + (UpdatedPersonalAccessTokenResponse) o; + return Objects.equals(this.data, updatedPersonalAccessTokenResponse.data) + && Objects.equals( + this.additionalProperties, updatedPersonalAccessTokenResponse.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(data, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class UpdatedPersonalAccessTokenResponse {\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/UpdatedServiceAccessToken.java b/src/main/java/com/datadog/api/client/v2/model/UpdatedServiceAccessToken.java new file mode 100644 index 00000000000..1e3d1ca294e --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/UpdatedServiceAccessToken.java @@ -0,0 +1,242 @@ +/* + * 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; + +/** Datadog access token returned by the update endpoint. */ +@JsonPropertyOrder({ + UpdatedServiceAccessToken.JSON_PROPERTY_ATTRIBUTES, + UpdatedServiceAccessToken.JSON_PROPERTY_ID, + UpdatedServiceAccessToken.JSON_PROPERTY_RELATIONSHIPS, + UpdatedServiceAccessToken.JSON_PROPERTY_TYPE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class UpdatedServiceAccessToken { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_ATTRIBUTES = "attributes"; + private ServiceAccessTokenAttributes attributes; + + public static final String JSON_PROPERTY_ID = "id"; + private String id; + + public static final String JSON_PROPERTY_RELATIONSHIPS = "relationships"; + private UpdatedServiceAccessTokenRelationships relationships; + + public static final String JSON_PROPERTY_TYPE = "type"; + private ServiceAccessTokensType type = ServiceAccessTokensType.SERVICE_ACCESS_TOKENS; + + public UpdatedServiceAccessToken() {} + + @JsonCreator + public UpdatedServiceAccessToken( + @JsonProperty(required = true, value = JSON_PROPERTY_ID) String id, + @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) ServiceAccessTokensType type) { + this.id = id; + this.type = type; + this.unparsed |= !type.isValid(); + } + + public UpdatedServiceAccessToken attributes(ServiceAccessTokenAttributes attributes) { + this.attributes = attributes; + this.unparsed |= attributes.unparsed; + return this; + } + + /** + * Attributes of an access token. + * + * @return attributes + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_ATTRIBUTES) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public ServiceAccessTokenAttributes getAttributes() { + return attributes; + } + + public void setAttributes(ServiceAccessTokenAttributes attributes) { + this.attributes = attributes; + if (attributes != null) { + this.unparsed |= attributes.unparsed; + } + } + + public UpdatedServiceAccessToken id(String id) { + this.id = id; + return this; + } + + /** + * ID of the access token. + * + * @return id + */ + @JsonProperty(JSON_PROPERTY_ID) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public UpdatedServiceAccessToken relationships( + UpdatedServiceAccessTokenRelationships relationships) { + this.relationships = relationships; + this.unparsed |= relationships.unparsed; + return this; + } + + /** + * Resources related to the access token. + * + * @return relationships + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_RELATIONSHIPS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public UpdatedServiceAccessTokenRelationships getRelationships() { + return relationships; + } + + public void setRelationships(UpdatedServiceAccessTokenRelationships relationships) { + this.relationships = relationships; + if (relationships != null) { + this.unparsed |= relationships.unparsed; + } + } + + public UpdatedServiceAccessToken type(ServiceAccessTokensType type) { + this.type = type; + this.unparsed |= !type.isValid(); + return this; + } + + /** + * Service access tokens resource type. + * + * @return type + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public ServiceAccessTokensType getType() { + return type; + } + + public void setType(ServiceAccessTokensType 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 UpdatedServiceAccessToken + */ + @JsonAnySetter + public UpdatedServiceAccessToken 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 UpdatedServiceAccessToken object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UpdatedServiceAccessToken updatedServiceAccessToken = (UpdatedServiceAccessToken) o; + return Objects.equals(this.attributes, updatedServiceAccessToken.attributes) + && Objects.equals(this.id, updatedServiceAccessToken.id) + && Objects.equals(this.relationships, updatedServiceAccessToken.relationships) + && Objects.equals(this.type, updatedServiceAccessToken.type) + && Objects.equals( + this.additionalProperties, updatedServiceAccessToken.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(attributes, id, relationships, type, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class UpdatedServiceAccessToken {\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/UpdatedServiceAccessTokenRelationships.java b/src/main/java/com/datadog/api/client/v2/model/UpdatedServiceAccessTokenRelationships.java new file mode 100644 index 00000000000..85473453d36 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/UpdatedServiceAccessTokenRelationships.java @@ -0,0 +1,141 @@ +/* + * 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 access token. */ +@JsonPropertyOrder({UpdatedServiceAccessTokenRelationships.JSON_PROPERTY_OWNED_BY}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class UpdatedServiceAccessTokenRelationships { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_OWNED_BY = "owned_by"; + private RelationshipToServiceAccount ownedBy; + + public UpdatedServiceAccessTokenRelationships ownedBy(RelationshipToServiceAccount ownedBy) { + this.ownedBy = ownedBy; + this.unparsed |= ownedBy.unparsed; + return this; + } + + /** + * Relationship to service account. + * + * @return ownedBy + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_OWNED_BY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public RelationshipToServiceAccount getOwnedBy() { + return ownedBy; + } + + public void setOwnedBy(RelationshipToServiceAccount ownedBy) { + this.ownedBy = ownedBy; + if (ownedBy != null) { + this.unparsed |= ownedBy.unparsed; + } + } + + /** + * 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 UpdatedServiceAccessTokenRelationships + */ + @JsonAnySetter + public UpdatedServiceAccessTokenRelationships 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 UpdatedServiceAccessTokenRelationships object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UpdatedServiceAccessTokenRelationships updatedServiceAccessTokenRelationships = + (UpdatedServiceAccessTokenRelationships) o; + return Objects.equals(this.ownedBy, updatedServiceAccessTokenRelationships.ownedBy) + && Objects.equals( + this.additionalProperties, updatedServiceAccessTokenRelationships.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(ownedBy, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class UpdatedServiceAccessTokenRelationships {\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/UpdatedServiceAccessTokenResponse.java b/src/main/java/com/datadog/api/client/v2/model/UpdatedServiceAccessTokenResponse.java new file mode 100644 index 00000000000..3d9274de03c --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/UpdatedServiceAccessTokenResponse.java @@ -0,0 +1,150 @@ +/* + * 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; + +/** Response for updating an access token. */ +@JsonPropertyOrder({UpdatedServiceAccessTokenResponse.JSON_PROPERTY_DATA}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class UpdatedServiceAccessTokenResponse { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_DATA = "data"; + private UpdatedServiceAccessToken data; + + public UpdatedServiceAccessTokenResponse() {} + + @JsonCreator + public UpdatedServiceAccessTokenResponse( + @JsonProperty(required = true, value = JSON_PROPERTY_DATA) UpdatedServiceAccessToken data) { + this.data = data; + this.unparsed |= data.unparsed; + } + + public UpdatedServiceAccessTokenResponse data(UpdatedServiceAccessToken data) { + this.data = data; + this.unparsed |= data.unparsed; + return this; + } + + /** + * Datadog access token returned by the update endpoint. + * + * @return data + */ + @JsonProperty(JSON_PROPERTY_DATA) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public UpdatedServiceAccessToken getData() { + return data; + } + + public void setData(UpdatedServiceAccessToken data) { + this.data = data; + if (data != null) { + this.unparsed |= data.unparsed; + } + } + + /** + * 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 UpdatedServiceAccessTokenResponse + */ + @JsonAnySetter + public UpdatedServiceAccessTokenResponse 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 UpdatedServiceAccessTokenResponse object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UpdatedServiceAccessTokenResponse updatedServiceAccessTokenResponse = + (UpdatedServiceAccessTokenResponse) o; + return Objects.equals(this.data, updatedServiceAccessTokenResponse.data) + && Objects.equals( + this.additionalProperties, updatedServiceAccessTokenResponse.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(data, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class UpdatedServiceAccessTokenResponse {\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/test/resources/generated-test/test-server b/src/test/resources/generated-test/test-server index ff395f697d5..417fcc086cf 100755 --- a/src/test/resources/generated-test/test-server +++ b/src/test/resources/generated-test/test-server @@ -10,15 +10,12 @@ from __future__ import annotations import argparse import base64 -import ctypes import json import os import re import tempfile import threading import uuid -import zlib -from ctypes.util import find_library from datetime import datetime, timezone from http import HTTPStatus from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer @@ -47,18 +44,6 @@ SAFE_BROWSER_HEADERS = { "content-security-policy": "default-src 'none'; sandbox", "x-content-type-options": "nosniff", } -ZSTD_CONTENTSIZE_UNKNOWN = (1 << 64) - 1 -ZSTD_CONTENTSIZE_ERROR = (1 << 64) - 2 -ZSTD_MAGIC = b"\x28\xb5\x2f\xfd" -ZSTD_SINGLE_SEGMENT_FLAG = 0x20 -ZSTD_DESCRIPTOR_LOW_BITS_MASK = 0x3F -ZSTD_MIN_RAW_FRAME_SIZE = 6 -ZSTD_FCS_TWO_BYTE_OFFSET = 0x100 -UINT8_MAX = (1 << 8) - 1 -UINT16_WITH_OFFSET_MAX = (1 << 16) - 1 + ZSTD_FCS_TWO_BYTE_OFFSET -UINT32_MAX = (1 << 32) - 1 -ZSTD_RAW_BLOCK_SIZE = 128 * 1024 -MAX_DECOMPRESSED_BODY_SIZE = 256 * 1024 * 1024 class RecordingDatabase: @@ -67,11 +52,9 @@ class RecordingDatabase: self.lock = threading.RLock() self.shards: dict[tuple[str, str], dict[str, Any]] = {} self.shard_paths: dict[tuple[str, str], Path] = {} - self.request_plans: dict[tuple[str, str, str], dict[str, Any]] = {} self.sessions: dict[str, dict[str, Any]] = {} self.fallback_consumed: set[tuple[str, str, str, int]] = set() self._load() - self._load_request_plans() def _load(self) -> None: manifest_path = self.root / "manifest.json" @@ -87,17 +70,6 @@ class RecordingDatabase: self.shards[key] = shard self.shard_paths[key] = path - def _load_request_plans(self) -> None: - root = self.root.parent / "test-runner-data" - manifest_path = root / "manifest.json" - if not manifest_path.exists(): - return - manifest = _read_json(manifest_path) - for item in manifest.get("scenarios", []): - plan = _read_json(root / item["file"]) - key = (item["version"], item["feature"], item["scenario"]) - self.request_plans[key] = plan.get("request", {}) - def start(self, version: str, feature: str, scenario: str, mode: str) -> dict[str, Any]: with self.lock: key = (version, feature) @@ -119,14 +91,13 @@ class RecordingDatabase: "key": key, "scenario": scenario, "recording": recording, - "request_plan": self.request_plans.get((version, feature, scenario)), "cursor": 0, "captures": [], "frozen_at": frozen_at, } return {"session": session_id, "frozen_at": frozen_at} - def replay(self, session_id: str | None, actual: dict[str, Any]) -> tuple[dict[str, Any], str | None]: + def replay(self, session_id: str | None, actual: dict[str, Any]) -> dict[str, Any]: with self.lock: if session_id: session = self.sessions.get(session_id) @@ -138,32 +109,20 @@ class RecordingDatabase: if cursor >= len(interactions): raise LookupError(f"Recording has no interaction #{cursor + 1}") expected = interactions[cursor] - request_plan = session["request_plan"] - if not _requests_match(expected["request"], actual, request_plan): + if not _requests_match(expected["request"], actual): raise RequestMismatchError(expected["request"], actual, cursor) session["cursor"] += 1 - compression = ( - request_plan.get("compression") - if request_plan and _request_matches_plan(expected["request"], request_plan) - else expected["request"].get("compression") - ) - return expected["response"], compression + return expected["response"] for (version, feature), shard in sorted(self.shards.items()): for recording in shard["recordings"]: for index, interaction in enumerate(recording["interactions"]): consumed_key = (version, feature, recording["scenario"], index) - request_plan = self.request_plans.get((version, feature, recording["scenario"])) if consumed_key not in self.fallback_consumed and _requests_match( - interaction["request"], actual, request_plan + interaction["request"], actual ): self.fallback_consumed.add(consumed_key) - compression = ( - request_plan.get("compression") - if request_plan and _request_matches_plan(interaction["request"], request_plan) - else interaction["request"].get("compression") - ) - return interaction["response"], compression + return interaction["response"] raise LookupError("No unconsumed interaction matches this request") def next_request(self, session_id: str) -> dict[str, Any]: @@ -339,21 +298,14 @@ class TestRequestHandler(BaseHTTPRequestHandler): def _handle_api_request(self) -> None: body = self._read_body() - actual = _normalise_request( - self.command, - self.path, - self.headers.get("content-type", ""), - self.headers.get("content-encoding", ""), - body, - ) + actual = _normalise_request(self.command, self.path, self.headers.get("content-type", ""), body) session_id = self.headers.get(SESSION_HEADER) if self.server.mode == "replay": - response, compression = self.server.database.replay(session_id, actual) + response = self.server.database.replay(session_id, actual) else: response = self._forward(body) self.server.database.capture(session_id, actual, response) - compression = None - self._send_recorded_response(response, compression=compression) + self._send_recorded_response(response) def _forward(self, body: bytes) -> dict[str, Any]: if not self.server.upstream: @@ -389,37 +341,17 @@ class TestRequestHandler(BaseHTTPRequestHandler): length = int(self.headers.get("content-length", "0")) return self.rfile.read(length) if length else b"" - def _send_recorded_response(self, response: dict[str, Any], *, compression: str | None = None) -> None: + def _send_recorded_response(self, response: dict[str, Any]) -> None: body_data = response.get("body", {}) if body_data.get("encoding") == "base64": body = base64.b64decode(body_data.get("value", "")) else: body = body_data.get("value", "").encode("utf-8") status = response["status"] - response_headers = response.get("headers", {}) - recorded_encoding = next( - (str(value) for key, value in response_headers.items() if key.lower() == "content-encoding"), - "", - ) - recorded_compression = recorded_encoding.strip().casefold() - if compression and _status_allows_message_content(status): - if recorded_compression: - decoded = _decompress_body(body, recorded_compression) - if decoded is None: - raise ValueError(f"Unsupported or invalid recorded response compression: {recorded_encoding}") - body = decoded - body = _compress_body(body, compression) self.send_response(status, response.get("reason")) - for key, value in response_headers.items(): - if ( - key.lower() - not in HOP_BY_HOP_HEADERS | {"content-encoding", "content-length"} | SAFE_BROWSER_HEADERS.keys() - ): + for key, value in response.get("headers", {}).items(): + if key.lower() not in HOP_BY_HOP_HEADERS | {"content-length"} | SAFE_BROWSER_HEADERS.keys(): self.send_header(key, value) - if compression and _status_allows_message_content(status): - self.send_header("content-encoding", compression) - elif recorded_encoding and _status_allows_message_content(status): - self.send_header("content-encoding", recorded_encoding) for key, value in SAFE_BROWSER_HEADERS.items(): self.send_header(key, value) if _status_allows_message_content(status): @@ -440,50 +372,21 @@ class TestRequestHandler(BaseHTTPRequestHandler): self.wfile.write(body) -def _normalise_request( - method: str, - raw_path: str, - content_type: str, - content_encoding: str, - body: bytes, -) -> dict[str, Any]: +def _normalise_request(method: str, raw_path: str, content_type: str, body: bytes) -> dict[str, Any]: parsed = urlsplit(raw_path) - compression = content_encoding.strip().casefold() - normalised_body = _normalise_body(body, content_type, compression) - request = { + normalised_body = _normalise_body(body, content_type) + return { "method": method.upper(), "path": _normalise_path(parsed.path), "query": sorted([list(pair) for pair in parse_qsl(parsed.query, keep_blank_values=True)]), "content_type": _normalise_content_type(content_type, normalised_body), "body": normalised_body, } - if compression: - request["compression"] = compression - return request -def _normalise_body(body: bytes, content_type: str, compression: str = "") -> dict[str, Any]: +def _normalise_body(body: bytes, content_type: str) -> dict[str, Any]: if not body: - if compression in {"gzip", "deflate", "zstd1"}: - return {"type": "invalid-compression", "value": ""} return {"type": "empty", "value": None} - if compression == "zstd1": - decompressed = _decompress_zstd(body) - if decompressed is None: - return { - "type": "invalid-compression", - "value": base64.b64encode(body).decode("ascii"), - } - body = decompressed - elif compression in {"gzip", "deflate"}: - wbits = zlib.MAX_WBITS | 16 if compression == "gzip" else zlib.MAX_WBITS - decompressed = _decompress_zlib(body, wbits=wbits) - if decompressed is None: - return { - "type": "invalid-compression", - "value": base64.b64encode(body).decode("ascii"), - } - body = decompressed media_type = _media_type(content_type) text = body.decode("utf-8", errors="surrogateescape") if media_type.endswith("json"): @@ -498,224 +401,6 @@ def _normalise_body(body: bytes, content_type: str, compression: str = "") -> di return {"type": "text", "value": text} -def _decompress_zlib( - body: bytes, - *, - wbits: int, - max_size: int = MAX_DECOMPRESSED_BODY_SIZE, -) -> bytes | None: - """Decompress exactly one complete zlib stream with bounded output.""" - decompressor = zlib.decompressobj(wbits) - output = bytearray() - pending = body - try: - while pending: - remaining = max_size - len(output) + 1 - chunk = decompressor.decompress(pending, remaining) - output.extend(chunk) - if len(output) > max_size: - return None - unconsumed = decompressor.unconsumed_tail - if not unconsumed: - break - if len(unconsumed) == len(pending) and not chunk: - return None - pending = unconsumed - except zlib.error: - return None - if not decompressor.eof or decompressor.unused_data or decompressor.unconsumed_tail: - return None - return bytes(output) - - -def _compress_body(body: bytes, compression: str) -> bytes: - if compression == "gzip": - compressor = zlib.compressobj(wbits=zlib.MAX_WBITS | 16) - return compressor.compress(body) + compressor.flush() - if compression == "deflate": - return zlib.compress(body) - if compression == "zstd1": - return _compress_zstd(body) - raise ValueError(f"Unsupported response compression: {compression}") - - -def _decompress_body(body: bytes, compression: str) -> bytes | None: - if compression == "gzip": - return _decompress_zlib(body, wbits=zlib.MAX_WBITS | 16) - if compression == "deflate": - return _decompress_zlib(body, wbits=zlib.MAX_WBITS) - if compression == "zstd1": - return _decompress_zstd(body) - return None - - -def _compress_zstd(body: bytes) -> bytes: - """Compress one Zstandard frame with the platform libzstd.""" - library = _load_zstd() - if library is None: - return _compress_zstd_raw_frame(body) - try: - library.ZSTD_isError.argtypes = [ctypes.c_size_t] - library.ZSTD_isError.restype = ctypes.c_uint - library.ZSTD_compressBound.argtypes = [ctypes.c_size_t] - library.ZSTD_compressBound.restype = ctypes.c_size_t - library.ZSTD_compress.argtypes = [ - ctypes.c_void_p, - ctypes.c_size_t, - ctypes.c_void_p, - ctypes.c_size_t, - ctypes.c_int, - ] - library.ZSTD_compress.restype = ctypes.c_size_t - - source = ctypes.create_string_buffer(body) - capacity = library.ZSTD_compressBound(len(body)) - destination = ctypes.create_string_buffer(max(1, capacity)) - compressed_size = library.ZSTD_compress(destination, capacity, source, len(body), 3) - if library.ZSTD_isError(compressed_size): - return _compress_zstd_raw_frame(body) - return destination.raw[:compressed_size] - except (AttributeError, OSError, OverflowError, TypeError): - return _compress_zstd_raw_frame(body) - - -def _compress_zstd_raw_frame(body: bytes) -> bytes: - """Create a valid Zstandard frame made only of dependency-free raw blocks.""" - size = len(body) - if size <= UINT8_MAX: - descriptor = 0x20 - content_size = size.to_bytes(1, "little") - elif size <= UINT16_WITH_OFFSET_MAX: - descriptor = 0x60 - content_size = (size - ZSTD_FCS_TWO_BYTE_OFFSET).to_bytes(2, "little") - elif size <= UINT32_MAX: - descriptor = 0xA0 - content_size = size.to_bytes(4, "little") - else: - descriptor = 0xE0 - content_size = size.to_bytes(8, "little") - - frame = bytearray(ZSTD_MAGIC) - frame.append(descriptor) - frame.extend(content_size) - offset = 0 - while offset < size: - chunk = body[offset : offset + ZSTD_RAW_BLOCK_SIZE] - offset += len(chunk) - header = (len(chunk) << 3) | int(offset == size) - frame.extend(header.to_bytes(3, "little")) - frame.extend(chunk) - if not body: - frame.extend(b"\x01\x00\x00") - return bytes(frame) - - -def _load_zstd() -> Any | None: - candidates = ( - find_library("zstd"), - "libzstd.so.1", - "libzstd.dylib", - "/opt/homebrew/lib/libzstd.dylib", - "/usr/local/lib/libzstd.dylib", - "libzstd.dll", - "zstd.dll", - ) - for candidate in dict.fromkeys(item for item in candidates if item): - try: - return ctypes.CDLL(candidate) - except OSError: - continue - return None - - -def _decompress_zstd(body: bytes) -> bytes | None: - """Decompress one complete Zstandard frame with the platform libzstd.""" - library = _load_zstd() - if library is None: - return _decompress_zstd_raw_frame(body) - - try: - library.ZSTD_isError.argtypes = [ctypes.c_size_t] - library.ZSTD_isError.restype = ctypes.c_uint - library.ZSTD_findFrameCompressedSize.argtypes = [ctypes.c_void_p, ctypes.c_size_t] - library.ZSTD_findFrameCompressedSize.restype = ctypes.c_size_t - library.ZSTD_getFrameContentSize.argtypes = [ctypes.c_void_p, ctypes.c_size_t] - library.ZSTD_getFrameContentSize.restype = ctypes.c_ulonglong - library.ZSTD_decompressBound.argtypes = [ctypes.c_void_p, ctypes.c_size_t] - library.ZSTD_decompressBound.restype = ctypes.c_ulonglong - library.ZSTD_decompress.argtypes = [ctypes.c_void_p, ctypes.c_size_t, ctypes.c_void_p, ctypes.c_size_t] - library.ZSTD_decompress.restype = ctypes.c_size_t - - source = ctypes.create_string_buffer(body) - source_pointer = ctypes.cast(source, ctypes.c_void_p) - compressed_size = library.ZSTD_findFrameCompressedSize(source_pointer, len(body)) - if library.ZSTD_isError(compressed_size) or compressed_size != len(body): - return None - - capacity = library.ZSTD_getFrameContentSize(source_pointer, len(body)) - if capacity == ZSTD_CONTENTSIZE_ERROR: - return None - if capacity == ZSTD_CONTENTSIZE_UNKNOWN: - capacity = library.ZSTD_decompressBound(source_pointer, len(body)) - if capacity > MAX_DECOMPRESSED_BODY_SIZE: - return None - - destination = ctypes.create_string_buffer(max(1, capacity)) - decompressed_size = library.ZSTD_decompress(destination, capacity, source_pointer, len(body)) - if library.ZSTD_isError(decompressed_size) or decompressed_size > capacity: - return None - return destination.raw[:decompressed_size] - except (AttributeError, OSError, OverflowError, TypeError): - return None - - -def _decompress_zstd_raw_frame(body: bytes) -> bytes | None: - """Decode the raw-block Zstandard frames emitted by the dependency-free fallback.""" - if len(body) < ZSTD_MIN_RAW_FRAME_SIZE or body[:4] != ZSTD_MAGIC: - return None - descriptor = body[4] - if descriptor & ZSTD_DESCRIPTOR_LOW_BITS_MASK != ZSTD_SINGLE_SEGMENT_FLAG: - return None - size_flag = descriptor >> 6 - size_bytes = (1, 2, 4, 8)[size_flag] - cursor = 5 - if len(body) < cursor + size_bytes: - return None - expected_size = int.from_bytes(body[cursor : cursor + size_bytes], "little") - if size_flag == 1: - expected_size += ZSTD_FCS_TWO_BYTE_OFFSET - if expected_size > MAX_DECOMPRESSED_BODY_SIZE: - return None - cursor += size_bytes - output = bytearray() - last_block = False - while not last_block: - if len(body) < cursor + 3: - return None - header = int.from_bytes(body[cursor : cursor + 3], "little") - cursor += 3 - last_block = bool(header & 1) - block_type = (header >> 1) & 0x3 - block_size = header >> 3 - if block_type == 0: - if len(body) < cursor + block_size: - return None - output.extend(body[cursor : cursor + block_size]) - cursor += block_size - elif block_type == 1: - if cursor >= len(body): - return None - output.extend(body[cursor : cursor + 1] * block_size) - cursor += 1 - else: - return None - if len(output) > MAX_DECOMPRESSED_BODY_SIZE: - return None - if cursor != len(body) or len(output) != expected_size: - return None - return bytes(output) - - def _normalise_json(value: Any) -> Any: if isinstance(value, dict): return {key: _normalise_json(item) for key, item in value.items()} @@ -730,33 +415,13 @@ def _normalise_content_type(content_type: str, body: dict[str, Any]) -> str: return "" if body["type"] == "empty" else _media_type(content_type) -def _requests_match( - expected: dict[str, Any], - actual: dict[str, Any], - request_plan: dict[str, Any] | None = None, -) -> bool: +def _requests_match(expected: dict[str, Any], actual: dict[str, Any]) -> bool: comparable_fields = ("method", "path", "query", "content_type") if any(expected[field] != actual[field] for field in comparable_fields): return False - expected_compression = expected.get("compression") - if request_plan and _request_matches_plan(expected, request_plan): - expected_compression = request_plan.get("compression", expected_compression) - if expected_compression is not None and actual.get("compression", "") != expected_compression: - return False return _bodies_match(expected["body"], actual["body"]) -def _request_matches_plan(request: dict[str, Any], plan: dict[str, Any]) -> bool: - if request["method"] != plan.get("method"): - return False - path = plan.get("path") - if not path: - return False - parts = re.split(r"(\{[^/{}]+\})", path) - pattern = "".join(r"[^/]+" if part.startswith("{") else re.escape(part) for part in parts) - return re.fullmatch(pattern, request["path"]) is not None - - def _bodies_match(expected: dict[str, Any], actual: dict[str, Any]) -> bool: if expected == actual: return True