diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 25e0ce11c24..ed0c820c526 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -5321,9 +5321,70 @@ components: type: string x-enum-varnames: - ACCOUNT_FILTERS + ActionConnectionAWSSecretsManager: + description: >- + AWS Secrets Manager settings shared by the credential references on a `DATACENTER` connection. These settings are required whenever a field uses an AWS Secrets Manager reference. + nullable: true + properties: + connection_id: + description: >- + ID of the AWS connection used to retrieve secrets. This connection must be in the same Datadog organization. + example: 00000000-0000-0000-0000-000000000001 + type: string + region: + description: AWS region containing the referenced secrets. + example: us-east-1 + minLength: 1 + type: string + type: + $ref: "#/components/schemas/ActionConnectionAWSSecretsManagerType" + required: + - type + - connection_id + - region + type: object + ActionConnectionAWSSecretsManagerReference: + description: >- + Reference to a string value in AWS Secrets Manager. The connection must also specify `external_secrets_manager` settings. AWS Secrets Manager references are supported for token-based credentials and HTTP authentication tokens on `DATACENTER` connections. + properties: + key: + description: >- + Top-level JSON key to extract from the secret string. Omit this field to use the entire secret string. + example: private_key + type: string + secret_id: + description: Name or ARN of the AWS Secrets Manager secret. + example: example/gcp/service-account + minLength: 1 + type: string + type: + $ref: "#/components/schemas/ActionConnectionAWSSecretsManagerType" + version_id: + description: >- + ID of the secret version to retrieve. Cannot be used together with `version_stage`. If both are omitted, the current version is used. + type: string + version_stage: + description: >- + Staging label of the secret version to retrieve. Cannot be used together with `version_id`. If both are omitted, the current version is used. + example: AWSCURRENT + type: string + required: + - type + - secret_id + type: object + ActionConnectionAWSSecretsManagerType: + description: AWS Secrets Manager secret backend. + enum: + - aws_secrets_manager + example: aws_secrets_manager + type: string + x-enum-varnames: + - AWS_SECRETS_MANAGER ActionConnectionAttributes: description: The definition of `ActionConnectionAttributes` object. properties: + external_secrets_manager: + $ref: "#/components/schemas/ActionConnectionAWSSecretsManager" integration: $ref: "#/components/schemas/ActionConnectionIntegration" name: @@ -5349,6 +5410,8 @@ components: ActionConnectionAttributesUpdate: description: The definition of `ActionConnectionAttributesUpdate` object. properties: + external_secrets_manager: + $ref: "#/components/schemas/ActionConnectionAWSSecretsManager" integration: $ref: "#/components/schemas/ActionConnectionIntegrationUpdate" name: @@ -5456,6 +5519,9 @@ components: - $ref: "#/components/schemas/SplitIntegrationUpdate" - $ref: "#/components/schemas/StatsigIntegrationUpdate" - $ref: "#/components/schemas/VirusTotalIntegrationUpdate" + ActionConnectionLiteralValue: + description: A literal string value for a connection credential. + type: string ActionQuery: description: An action query. This query type is used to trigger an action, such as sending a HTTP request. properties: @@ -8524,15 +8590,19 @@ components: description: The definition of the `AnthropicAPIKey` object. properties: api_token: - description: The `AnthropicAPIKey` `api_token`. - example: "" - type: string + $ref: "#/components/schemas/AnthropicAPIKeyApiToken" type: $ref: "#/components/schemas/AnthropicAPIKeyType" required: - type - api_token type: object + AnthropicAPIKeyApiToken: + description: The `AnthropicAPIKey` `api_token`. + example: "" + oneOf: + - $ref: "#/components/schemas/ActionConnectionLiteralValue" + - $ref: "#/components/schemas/ActionConnectionAWSSecretsManagerReference" AnthropicAPIKeyType: description: The definition of the `AnthropicAPIKey` object. enum: @@ -8545,13 +8615,17 @@ components: description: The definition of the `AnthropicAPIKey` object. properties: api_token: - description: The `AnthropicAPIKeyUpdate` `api_token`. - type: string + $ref: "#/components/schemas/AnthropicAPIKeyUpdateApiToken" type: $ref: "#/components/schemas/AnthropicAPIKeyType" required: - type type: object + AnthropicAPIKeyUpdateApiToken: + description: The `AnthropicAPIKeyUpdate` `api_token`. + oneOf: + - $ref: "#/components/schemas/ActionConnectionLiteralValue" + - $ref: "#/components/schemas/ActionConnectionAWSSecretsManagerReference" AnthropicCredentials: description: The definition of the `AnthropicCredentials` object. oneOf: @@ -11939,15 +12013,19 @@ components: description: The definition of the `AsanaAccessToken` object. properties: access_token: - description: The `AsanaAccessToken` `access_token`. - example: "" - type: string + $ref: "#/components/schemas/AsanaAccessTokenAccessToken" type: $ref: "#/components/schemas/AsanaAccessTokenType" required: - type - access_token type: object + AsanaAccessTokenAccessToken: + description: The `AsanaAccessToken` `access_token`. + example: "" + oneOf: + - $ref: "#/components/schemas/ActionConnectionLiteralValue" + - $ref: "#/components/schemas/ActionConnectionAWSSecretsManagerReference" AsanaAccessTokenType: description: The definition of the `AsanaAccessToken` object. enum: @@ -11960,13 +12038,17 @@ components: description: The definition of the `AsanaAccessToken` object. properties: access_token: - description: The `AsanaAccessTokenUpdate` `access_token`. - type: string + $ref: "#/components/schemas/AsanaAccessTokenUpdateAccessToken" type: $ref: "#/components/schemas/AsanaAccessTokenType" required: - type type: object + AsanaAccessTokenUpdateAccessToken: + description: The `AsanaAccessTokenUpdate` `access_token`. + oneOf: + - $ref: "#/components/schemas/ActionConnectionLiteralValue" + - $ref: "#/components/schemas/ActionConnectionAWSSecretsManagerReference" AsanaCredentials: description: The definition of the `AsanaCredentials` object. oneOf: @@ -19786,15 +19868,19 @@ components: description: The definition of the `CircleCIAPIKey` object. properties: api_token: - description: The `CircleCIAPIKey` `api_token`. - example: "" - type: string + $ref: "#/components/schemas/CircleCIAPIKeyApiToken" type: $ref: "#/components/schemas/CircleCIAPIKeyType" required: - type - api_token type: object + CircleCIAPIKeyApiToken: + description: The `CircleCIAPIKey` `api_token`. + example: "" + oneOf: + - $ref: "#/components/schemas/ActionConnectionLiteralValue" + - $ref: "#/components/schemas/ActionConnectionAWSSecretsManagerReference" CircleCIAPIKeyType: description: The definition of the `CircleCIAPIKey` object. enum: @@ -19807,13 +19893,17 @@ components: description: The definition of the `CircleCIAPIKey` object. properties: api_token: - description: The `CircleCIAPIKeyUpdate` `api_token`. - type: string + $ref: "#/components/schemas/CircleCIAPIKeyUpdateApiToken" type: $ref: "#/components/schemas/CircleCIAPIKeyType" required: - type type: object + CircleCIAPIKeyUpdateApiToken: + description: The `CircleCIAPIKeyUpdate` `api_token`. + oneOf: + - $ref: "#/components/schemas/ActionConnectionLiteralValue" + - $ref: "#/components/schemas/ActionConnectionAWSSecretsManagerReference" CircleCICredentials: description: The definition of the `CircleCICredentials` object. oneOf: @@ -19855,15 +19945,19 @@ components: description: The definition of the `ClickupAPIKey` object. properties: api_token: - description: The `ClickupAPIKey` `api_token`. - example: "" - type: string + $ref: "#/components/schemas/ClickupAPIKeyApiToken" type: $ref: "#/components/schemas/ClickupAPIKeyType" required: - type - api_token type: object + ClickupAPIKeyApiToken: + description: The `ClickupAPIKey` `api_token`. + example: "" + oneOf: + - $ref: "#/components/schemas/ActionConnectionLiteralValue" + - $ref: "#/components/schemas/ActionConnectionAWSSecretsManagerReference" ClickupAPIKeyType: description: The definition of the `ClickupAPIKey` object. enum: @@ -19876,13 +19970,17 @@ components: description: The definition of the `ClickupAPIKey` object. properties: api_token: - description: The `ClickupAPIKeyUpdate` `api_token`. - type: string + $ref: "#/components/schemas/ClickupAPIKeyUpdateApiToken" type: $ref: "#/components/schemas/ClickupAPIKeyType" required: - type type: object + ClickupAPIKeyUpdateApiToken: + description: The `ClickupAPIKeyUpdate` `api_token`. + oneOf: + - $ref: "#/components/schemas/ActionConnectionLiteralValue" + - $ref: "#/components/schemas/ActionConnectionAWSSecretsManagerReference" ClickupCredentials: description: The definition of the `ClickupCredentials` object. oneOf: @@ -21212,15 +21310,19 @@ components: description: The definition of the `CloudflareAPIToken` object. properties: api_token: - description: The `CloudflareAPIToken` `api_token`. - example: "" - type: string + $ref: "#/components/schemas/CloudflareAPITokenApiToken" type: $ref: "#/components/schemas/CloudflareAPITokenType" required: - type - api_token type: object + CloudflareAPITokenApiToken: + description: The `CloudflareAPIToken` `api_token`. + example: "" + oneOf: + - $ref: "#/components/schemas/ActionConnectionLiteralValue" + - $ref: "#/components/schemas/ActionConnectionAWSSecretsManagerReference" CloudflareAPITokenType: description: The definition of the `CloudflareAPIToken` object. enum: @@ -21233,13 +21335,17 @@ components: description: The definition of the `CloudflareAPIToken` object. properties: api_token: - description: The `CloudflareAPITokenUpdate` `api_token`. - type: string + $ref: "#/components/schemas/CloudflareAPITokenUpdateApiToken" type: $ref: "#/components/schemas/CloudflareAPITokenType" required: - type type: object + CloudflareAPITokenUpdateApiToken: + description: The `CloudflareAPITokenUpdate` `api_token`. + oneOf: + - $ref: "#/components/schemas/ActionConnectionLiteralValue" + - $ref: "#/components/schemas/ActionConnectionAWSSecretsManagerReference" CloudflareAccountCreateRequest: description: Payload schema when adding a Cloudflare account. properties: @@ -21421,13 +21527,9 @@ components: description: The definition of the `CloudflareGlobalAPIToken` object. properties: auth_email: - description: The `CloudflareGlobalAPIToken` `auth_email`. - example: "" - type: string + $ref: "#/components/schemas/CloudflareGlobalAPITokenAuthEmail" global_api_key: - description: The `CloudflareGlobalAPIToken` `global_api_key`. - example: "" - type: string + $ref: "#/components/schemas/CloudflareGlobalAPITokenGlobalApiKey" type: $ref: "#/components/schemas/CloudflareGlobalAPITokenType" required: @@ -21435,6 +21537,18 @@ components: - auth_email - global_api_key type: object + CloudflareGlobalAPITokenAuthEmail: + description: The `CloudflareGlobalAPIToken` `auth_email`. + example: "" + oneOf: + - $ref: "#/components/schemas/ActionConnectionLiteralValue" + - $ref: "#/components/schemas/ActionConnectionAWSSecretsManagerReference" + CloudflareGlobalAPITokenGlobalApiKey: + description: The `CloudflareGlobalAPIToken` `global_api_key`. + example: "" + oneOf: + - $ref: "#/components/schemas/ActionConnectionLiteralValue" + - $ref: "#/components/schemas/ActionConnectionAWSSecretsManagerReference" CloudflareGlobalAPITokenType: description: The definition of the `CloudflareGlobalAPIToken` object. enum: @@ -21447,16 +21561,24 @@ components: description: The definition of the `CloudflareGlobalAPIToken` object. properties: auth_email: - description: The `CloudflareGlobalAPITokenUpdate` `auth_email`. - type: string + $ref: "#/components/schemas/CloudflareGlobalAPITokenUpdateAuthEmail" global_api_key: - description: The `CloudflareGlobalAPITokenUpdate` `global_api_key`. - type: string + $ref: "#/components/schemas/CloudflareGlobalAPITokenUpdateGlobalApiKey" type: $ref: "#/components/schemas/CloudflareGlobalAPITokenType" required: - type type: object + CloudflareGlobalAPITokenUpdateAuthEmail: + description: The `CloudflareGlobalAPITokenUpdate` `auth_email`. + oneOf: + - $ref: "#/components/schemas/ActionConnectionLiteralValue" + - $ref: "#/components/schemas/ActionConnectionAWSSecretsManagerReference" + CloudflareGlobalAPITokenUpdateGlobalApiKey: + description: The `CloudflareGlobalAPITokenUpdate` `global_api_key`. + oneOf: + - $ref: "#/components/schemas/ActionConnectionLiteralValue" + - $ref: "#/components/schemas/ActionConnectionAWSSecretsManagerReference" CloudflareIntegration: description: The definition of the `CloudflareIntegration` object. properties: @@ -22664,17 +22786,11 @@ components: description: The definition of the `ConfigCatSDKKey` object. properties: api_password: - description: The `ConfigCatSDKKey` `api_password`. - example: "" - type: string + $ref: "#/components/schemas/ConfigCatSDKKeyApiPassword" api_username: - description: The `ConfigCatSDKKey` `api_username`. - example: "" - type: string + $ref: "#/components/schemas/ConfigCatSDKKeyApiUsername" sdk_key: - description: The `ConfigCatSDKKey` `sdk_key`. - example: "" - type: string + $ref: "#/components/schemas/ConfigCatSDKKeySdkKey" type: $ref: "#/components/schemas/ConfigCatSDKKeyType" required: @@ -22683,6 +22799,24 @@ components: - api_username - api_password type: object + ConfigCatSDKKeyApiPassword: + description: The `ConfigCatSDKKey` `api_password`. + example: "" + oneOf: + - $ref: "#/components/schemas/ActionConnectionLiteralValue" + - $ref: "#/components/schemas/ActionConnectionAWSSecretsManagerReference" + ConfigCatSDKKeyApiUsername: + description: The `ConfigCatSDKKey` `api_username`. + example: "" + oneOf: + - $ref: "#/components/schemas/ActionConnectionLiteralValue" + - $ref: "#/components/schemas/ActionConnectionAWSSecretsManagerReference" + ConfigCatSDKKeySdkKey: + description: The `ConfigCatSDKKey` `sdk_key`. + example: "" + oneOf: + - $ref: "#/components/schemas/ActionConnectionLiteralValue" + - $ref: "#/components/schemas/ActionConnectionAWSSecretsManagerReference" ConfigCatSDKKeyType: description: The definition of the `ConfigCatSDKKey` object. enum: @@ -22695,19 +22829,31 @@ components: description: The definition of the `ConfigCatSDKKey` object. properties: api_password: - description: The `ConfigCatSDKKeyUpdate` `api_password`. - type: string + $ref: "#/components/schemas/ConfigCatSDKKeyUpdateApiPassword" api_username: - description: The `ConfigCatSDKKeyUpdate` `api_username`. - type: string + $ref: "#/components/schemas/ConfigCatSDKKeyUpdateApiUsername" sdk_key: - description: The `ConfigCatSDKKeyUpdate` `sdk_key`. - type: string + $ref: "#/components/schemas/ConfigCatSDKKeyUpdateSdkKey" type: $ref: "#/components/schemas/ConfigCatSDKKeyType" required: - type type: object + ConfigCatSDKKeyUpdateApiPassword: + description: The `ConfigCatSDKKeyUpdate` `api_password`. + oneOf: + - $ref: "#/components/schemas/ActionConnectionLiteralValue" + - $ref: "#/components/schemas/ActionConnectionAWSSecretsManagerReference" + ConfigCatSDKKeyUpdateApiUsername: + description: The `ConfigCatSDKKeyUpdate` `api_username`. + oneOf: + - $ref: "#/components/schemas/ActionConnectionLiteralValue" + - $ref: "#/components/schemas/ActionConnectionAWSSecretsManagerReference" + ConfigCatSDKKeyUpdateSdkKey: + description: The `ConfigCatSDKKeyUpdate` `sdk_key`. + oneOf: + - $ref: "#/components/schemas/ActionConnectionLiteralValue" + - $ref: "#/components/schemas/ActionConnectionAWSSecretsManagerReference" ConfiguredSchedule: description: "Full resource representation of a configured schedule target with position (previous, current, or next)." properties: @@ -34249,20 +34395,13 @@ components: description: The definition of the `DatadogAPIKey` object. properties: api_key: - description: The `DatadogAPIKey` `api_key`. - example: "" - type: string + $ref: "#/components/schemas/DatadogAPIKeyApiKey" app_key: - description: The `DatadogAPIKey` `app_key`. - example: "" - type: string + $ref: "#/components/schemas/DatadogAPIKeyAppKey" datacenter: - description: The `DatadogAPIKey` `datacenter`. - example: "" - type: string + $ref: "#/components/schemas/DatadogAPIKeyDatacenter" subdomain: - description: Custom subdomain used for Datadog URLs generated with this Connection. For example, if this org uses `https://acme.datadoghq.com` to access Datadog, set this field to `acme`. If this field is omitted, generated URLs will use the default site URL for its datacenter (see [https://docs.datadoghq.com/getting_started/site](https://docs.datadoghq.com/getting_started/site)). - type: string + $ref: "#/components/schemas/DatadogAPIKeySubdomain" type: $ref: "#/components/schemas/DatadogAPIKeyType" required: @@ -34271,6 +34410,29 @@ components: - api_key - app_key type: object + DatadogAPIKeyApiKey: + description: The `DatadogAPIKey` `api_key`. + example: "" + oneOf: + - $ref: "#/components/schemas/ActionConnectionLiteralValue" + - $ref: "#/components/schemas/ActionConnectionAWSSecretsManagerReference" + DatadogAPIKeyAppKey: + description: The `DatadogAPIKey` `app_key`. + example: "" + oneOf: + - $ref: "#/components/schemas/ActionConnectionLiteralValue" + - $ref: "#/components/schemas/ActionConnectionAWSSecretsManagerReference" + DatadogAPIKeyDatacenter: + description: The `DatadogAPIKey` `datacenter`. + example: "" + oneOf: + - $ref: "#/components/schemas/ActionConnectionLiteralValue" + - $ref: "#/components/schemas/ActionConnectionAWSSecretsManagerReference" + DatadogAPIKeySubdomain: + description: Custom subdomain used for Datadog URLs generated with this Connection. For example, if this org uses `https://acme.datadoghq.com` to access Datadog, set this field to `acme`. If this field is omitted, generated URLs will use the default site URL for its datacenter (see [https://docs.datadoghq.com/getting_started/site](https://docs.datadoghq.com/getting_started/site)). + oneOf: + - $ref: "#/components/schemas/ActionConnectionLiteralValue" + - $ref: "#/components/schemas/ActionConnectionAWSSecretsManagerReference" DatadogAPIKeyType: description: The definition of the `DatadogAPIKey` object. enum: @@ -34283,22 +34445,33 @@ components: description: The definition of the `DatadogAPIKey` object. properties: api_key: - description: The `DatadogAPIKeyUpdate` `api_key`. - type: string + $ref: "#/components/schemas/DatadogAPIKeyUpdateApiKey" app_key: - description: The `DatadogAPIKeyUpdate` `app_key`. - type: string + $ref: "#/components/schemas/DatadogAPIKeyUpdateAppKey" datacenter: - description: The `DatadogAPIKeyUpdate` `datacenter`. - type: string + $ref: "#/components/schemas/DatadogAPIKeyUpdateDatacenter" subdomain: - description: Custom subdomain used for Datadog URLs generated with this Connection. For example, if this org uses `https://acme.datadoghq.com` to access Datadog, set this field to `acme`. If this field is omitted, generated URLs will use the default site URL for its datacenter (see [https://docs.datadoghq.com/getting_started/site](https://docs.datadoghq.com/getting_started/site)). - type: string + $ref: "#/components/schemas/DatadogAPIKeySubdomain" type: $ref: "#/components/schemas/DatadogAPIKeyType" required: - type type: object + DatadogAPIKeyUpdateApiKey: + description: The `DatadogAPIKeyUpdate` `api_key`. + oneOf: + - $ref: "#/components/schemas/ActionConnectionLiteralValue" + - $ref: "#/components/schemas/ActionConnectionAWSSecretsManagerReference" + DatadogAPIKeyUpdateAppKey: + description: The `DatadogAPIKeyUpdate` `app_key`. + oneOf: + - $ref: "#/components/schemas/ActionConnectionLiteralValue" + - $ref: "#/components/schemas/ActionConnectionAWSSecretsManagerReference" + DatadogAPIKeyUpdateDatacenter: + description: The `DatadogAPIKeyUpdate` `datacenter`. + oneOf: + - $ref: "#/components/schemas/ActionConnectionLiteralValue" + - $ref: "#/components/schemas/ActionConnectionAWSSecretsManagerReference" DatadogCredentials: description: The definition of the `DatadogCredentials` object. oneOf: @@ -50995,15 +51168,19 @@ components: description: The definition of the `FastlyAPIKey` object. properties: api_key: - description: The `FastlyAPIKey` `api_key`. - example: "" - type: string + $ref: "#/components/schemas/FastlyAPIKeyApiKey" type: $ref: "#/components/schemas/FastlyAPIKeyType" required: - type - api_key type: object + FastlyAPIKeyApiKey: + description: The `FastlyAPIKey` `api_key`. + example: "" + oneOf: + - $ref: "#/components/schemas/ActionConnectionLiteralValue" + - $ref: "#/components/schemas/ActionConnectionAWSSecretsManagerReference" FastlyAPIKeyType: description: The definition of the `FastlyAPIKey` object. enum: @@ -51016,13 +51193,17 @@ components: description: The definition of the `FastlyAPIKey` object. properties: api_key: - description: The `FastlyAPIKeyUpdate` `api_key`. - type: string + $ref: "#/components/schemas/FastlyAPIKeyUpdateApiKey" type: $ref: "#/components/schemas/FastlyAPIKeyType" required: - type type: object + FastlyAPIKeyUpdateApiKey: + description: The `FastlyAPIKeyUpdate` `api_key`. + oneOf: + - $ref: "#/components/schemas/ActionConnectionLiteralValue" + - $ref: "#/components/schemas/ActionConnectionAWSSecretsManagerReference" FastlyAccounResponseAttributes: description: Attributes object of a Fastly account. properties: @@ -55340,13 +55521,9 @@ components: description: The definition of the `FreshserviceAPIKey` object. properties: api_key: - description: The `FreshserviceAPIKey` `api_key`. - example: "" - type: string + $ref: "#/components/schemas/FreshserviceAPIKeyApiKey" domain: - description: The `FreshserviceAPIKey` `domain`. - example: "" - type: string + $ref: "#/components/schemas/FreshserviceAPIKeyDomain" type: $ref: "#/components/schemas/FreshserviceAPIKeyType" required: @@ -55354,6 +55531,18 @@ components: - domain - api_key type: object + FreshserviceAPIKeyApiKey: + description: The `FreshserviceAPIKey` `api_key`. + example: "" + oneOf: + - $ref: "#/components/schemas/ActionConnectionLiteralValue" + - $ref: "#/components/schemas/ActionConnectionAWSSecretsManagerReference" + FreshserviceAPIKeyDomain: + description: The `FreshserviceAPIKey` `domain`. + example: "" + oneOf: + - $ref: "#/components/schemas/ActionConnectionLiteralValue" + - $ref: "#/components/schemas/ActionConnectionAWSSecretsManagerReference" FreshserviceAPIKeyType: description: The definition of the `FreshserviceAPIKey` object. enum: @@ -55366,16 +55555,24 @@ components: description: The definition of the `FreshserviceAPIKey` object. properties: api_key: - description: The `FreshserviceAPIKeyUpdate` `api_key`. - type: string + $ref: "#/components/schemas/FreshserviceAPIKeyUpdateApiKey" domain: - description: The `FreshserviceAPIKeyUpdate` `domain`. - type: string + $ref: "#/components/schemas/FreshserviceAPIKeyUpdateDomain" type: $ref: "#/components/schemas/FreshserviceAPIKeyType" required: - type type: object + FreshserviceAPIKeyUpdateApiKey: + description: The `FreshserviceAPIKeyUpdate` `api_key`. + oneOf: + - $ref: "#/components/schemas/ActionConnectionLiteralValue" + - $ref: "#/components/schemas/ActionConnectionAWSSecretsManagerReference" + FreshserviceAPIKeyUpdateDomain: + description: The `FreshserviceAPIKeyUpdate` `domain`. + oneOf: + - $ref: "#/components/schemas/ActionConnectionLiteralValue" + - $ref: "#/components/schemas/ActionConnectionAWSSecretsManagerReference" FreshserviceCredentials: description: The definition of the `FreshserviceCredentials` object. oneOf: @@ -55967,13 +56164,9 @@ components: description: The definition of the `GCPServiceAccount` object. properties: private_key: - description: The `GCPServiceAccount` `private_key`. - example: "" - type: string + $ref: "#/components/schemas/GCPServiceAccountPrivateKey" service_account_email: - description: The `GCPServiceAccount` `service_account_email`. - example: "" - type: string + $ref: "#/components/schemas/GCPServiceAccountServiceAccountEmail" type: $ref: "#/components/schemas/GCPServiceAccountCredentialType" required: @@ -55999,6 +56192,18 @@ components: type: string type: array type: object + GCPServiceAccountPrivateKey: + description: The `GCPServiceAccount` `private_key`. + example: "" + oneOf: + - $ref: "#/components/schemas/ActionConnectionLiteralValue" + - $ref: "#/components/schemas/ActionConnectionAWSSecretsManagerReference" + GCPServiceAccountServiceAccountEmail: + description: The `GCPServiceAccount` `service_account_email`. + example: "" + oneOf: + - $ref: "#/components/schemas/ActionConnectionLiteralValue" + - $ref: "#/components/schemas/ActionConnectionAWSSecretsManagerReference" GCPServiceAccountType: default: gcp_service_account description: The type of account. @@ -56012,16 +56217,24 @@ components: description: The definition of the `GCPServiceAccount` object. properties: private_key: - description: The `GCPServiceAccountUpdate` `private_key`. - type: string + $ref: "#/components/schemas/GCPServiceAccountUpdatePrivateKey" service_account_email: - description: The `GCPServiceAccountUpdate` `service_account_email`. - type: string + $ref: "#/components/schemas/GCPServiceAccountUpdateServiceAccountEmail" type: $ref: "#/components/schemas/GCPServiceAccountCredentialType" required: - type type: object + GCPServiceAccountUpdatePrivateKey: + description: The `GCPServiceAccountUpdate` `private_key`. + oneOf: + - $ref: "#/components/schemas/ActionConnectionLiteralValue" + - $ref: "#/components/schemas/ActionConnectionAWSSecretsManagerReference" + GCPServiceAccountUpdateServiceAccountEmail: + description: The `GCPServiceAccountUpdate` `service_account_email`. + oneOf: + - $ref: "#/components/schemas/ActionConnectionLiteralValue" + - $ref: "#/components/schemas/ActionConnectionAWSSecretsManagerReference" GCPUsageCostConfig: description: Google Cloud Usage Cost config. properties: @@ -56453,15 +56666,19 @@ components: description: The definition of the `GeminiAPIKey` object. properties: api_key: - description: The `GeminiAPIKey` `api_key`. - example: "" - type: string + $ref: "#/components/schemas/GeminiAPIKeyApiKey" type: $ref: "#/components/schemas/GeminiAPIKeyType" required: - type - api_key type: object + GeminiAPIKeyApiKey: + description: The `GeminiAPIKey` `api_key`. + example: "" + oneOf: + - $ref: "#/components/schemas/ActionConnectionLiteralValue" + - $ref: "#/components/schemas/ActionConnectionAWSSecretsManagerReference" GeminiAPIKeyType: description: The definition of the `GeminiAPIKey` object. enum: @@ -56474,13 +56691,17 @@ components: description: The definition of the `GeminiAPIKey` object. properties: api_key: - description: The `GeminiAPIKeyUpdate` `api_key`. - type: string + $ref: "#/components/schemas/GeminiAPIKeyUpdateApiKey" type: $ref: "#/components/schemas/GeminiAPIKeyType" required: - type type: object + GeminiAPIKeyUpdateApiKey: + description: The `GeminiAPIKeyUpdate` `api_key`. + oneOf: + - $ref: "#/components/schemas/ActionConnectionLiteralValue" + - $ref: "#/components/schemas/ActionConnectionAWSSecretsManagerReference" GeminiCredentials: description: The definition of the `GeminiCredentials` object. oneOf: @@ -57916,15 +58137,19 @@ components: description: The definition of the `GitlabAPIKey` object. properties: api_token: - description: The `GitlabAPIKey` `api_token`. - example: "" - type: string + $ref: "#/components/schemas/GitlabAPIKeyApiToken" type: $ref: "#/components/schemas/GitlabAPIKeyType" required: - type - api_token type: object + GitlabAPIKeyApiToken: + description: The `GitlabAPIKey` `api_token`. + example: "" + oneOf: + - $ref: "#/components/schemas/ActionConnectionLiteralValue" + - $ref: "#/components/schemas/ActionConnectionAWSSecretsManagerReference" GitlabAPIKeyType: description: The definition of the `GitlabAPIKey` object. enum: @@ -57937,13 +58162,17 @@ components: description: The definition of the `GitlabAPIKey` object. properties: api_token: - description: The `GitlabAPIKeyUpdate` `api_token`. - type: string + $ref: "#/components/schemas/GitlabAPIKeyUpdateApiToken" type: $ref: "#/components/schemas/GitlabAPIKeyType" required: - type type: object + GitlabAPIKeyUpdateApiToken: + description: The `GitlabAPIKeyUpdate` `api_token`. + oneOf: + - $ref: "#/components/schemas/ActionConnectionLiteralValue" + - $ref: "#/components/schemas/ActionConnectionAWSSecretsManagerReference" GitlabCredentials: description: The definition of the `GitlabCredentials` object. oneOf: @@ -59724,15 +59953,19 @@ components: description: The definition of the `GreyNoiseAPIKey` object. properties: api_key: - description: The `GreyNoiseAPIKey` `api_key`. - example: "" - type: string + $ref: "#/components/schemas/GreyNoiseAPIKeyApiKey" type: $ref: "#/components/schemas/GreyNoiseAPIKeyType" required: - type - api_key type: object + GreyNoiseAPIKeyApiKey: + description: The `GreyNoiseAPIKey` `api_key`. + example: "" + oneOf: + - $ref: "#/components/schemas/ActionConnectionLiteralValue" + - $ref: "#/components/schemas/ActionConnectionAWSSecretsManagerReference" GreyNoiseAPIKeyType: description: The definition of the `GreyNoiseAPIKey` object. enum: @@ -59745,13 +59978,17 @@ components: description: The definition of the `GreyNoiseAPIKey` object. properties: api_key: - description: The `GreyNoiseAPIKeyUpdate` `api_key`. - type: string + $ref: "#/components/schemas/GreyNoiseAPIKeyUpdateApiKey" type: $ref: "#/components/schemas/GreyNoiseAPIKeyType" required: - type type: object + GreyNoiseAPIKeyUpdateApiKey: + description: The `GreyNoiseAPIKeyUpdate` `api_key`. + oneOf: + - $ref: "#/components/schemas/ActionConnectionLiteralValue" + - $ref: "#/components/schemas/ActionConnectionAWSSecretsManagerReference" GreyNoiseCredentials: description: The definition of the `GreyNoiseCredentials` object. oneOf: @@ -60080,9 +60317,7 @@ components: type: $ref: "#/components/schemas/TokenType" value: - description: The `HTTPToken` `value`. - example: Some Token Value - type: string + $ref: "#/components/schemas/HTTPTokenValue" required: - name - value @@ -60098,6 +60333,13 @@ components: items: $ref: "#/components/schemas/HTTPHeader" type: array + http_tokens: + description: >- + HTTP authentication tokens returned by the API. Use `tokens` when creating or updating tokens. + items: + $ref: "#/components/schemas/HTTPTokenResponse" + readOnly: true + type: array tokens: description: The `HTTPTokenAuth` `tokens`. items: @@ -60146,6 +60388,25 @@ components: required: - type type: object + HTTPTokenResponse: + description: An HTTP authentication token returned by the API. Its type is implicitly `SECRET`. + properties: + name: + description: Name of the HTTP authentication token. + example: MyToken + type: string + value: + $ref: "#/components/schemas/HTTPTokenResponseValue" + required: + - name + - value + type: object + HTTPTokenResponseValue: + description: The `HTTPTokenResponse` `value`. + example: Some Token Value + oneOf: + - $ref: "#/components/schemas/ActionConnectionLiteralValue" + - $ref: "#/components/schemas/ActionConnectionAWSSecretsManagerReference" HTTPTokenUpdate: description: The definition of `HTTPTokenUpdate` object. properties: @@ -60160,14 +60421,18 @@ components: type: $ref: "#/components/schemas/TokenType" value: - description: The `HTTPToken` `value`. - example: Some Token Value - type: string + $ref: "#/components/schemas/HTTPTokenValue" required: - name - type - value type: object + HTTPTokenValue: + description: The `HTTPToken` `value`. + example: Some Token Value + oneOf: + - $ref: "#/components/schemas/ActionConnectionLiteralValue" + - $ref: "#/components/schemas/ActionConnectionAWSSecretsManagerReference" HamrOrgConnectionAttributesRequest: description: Attributes for a HAMR organization connection request. properties: @@ -77033,15 +77298,19 @@ components: description: The definition of the `LaunchDarklyAPIKey` object. properties: api_token: - description: The `LaunchDarklyAPIKey` `api_token`. - example: "" - type: string + $ref: "#/components/schemas/LaunchDarklyAPIKeyApiToken" type: $ref: "#/components/schemas/LaunchDarklyAPIKeyType" required: - type - api_token type: object + LaunchDarklyAPIKeyApiToken: + description: The `LaunchDarklyAPIKey` `api_token`. + example: "" + oneOf: + - $ref: "#/components/schemas/ActionConnectionLiteralValue" + - $ref: "#/components/schemas/ActionConnectionAWSSecretsManagerReference" LaunchDarklyAPIKeyType: description: The definition of the `LaunchDarklyAPIKey` object. enum: @@ -77054,13 +77323,17 @@ components: description: The definition of the `LaunchDarklyAPIKey` object. properties: api_token: - description: The `LaunchDarklyAPIKeyUpdate` `api_token`. - type: string + $ref: "#/components/schemas/LaunchDarklyAPIKeyUpdateApiToken" type: $ref: "#/components/schemas/LaunchDarklyAPIKeyType" required: - type type: object + LaunchDarklyAPIKeyUpdateApiToken: + description: The `LaunchDarklyAPIKeyUpdate` `api_token`. + oneOf: + - $ref: "#/components/schemas/ActionConnectionLiteralValue" + - $ref: "#/components/schemas/ActionConnectionAWSSecretsManagerReference" LaunchDarklyCredentials: description: The definition of the `LaunchDarklyCredentials` object. oneOf: @@ -84979,15 +85252,19 @@ components: description: The definition of the `NotionAPIKey` object. properties: api_token: - description: The `NotionAPIKey` `api_token`. - example: "" - type: string + $ref: "#/components/schemas/NotionAPIKeyApiToken" type: $ref: "#/components/schemas/NotionAPIKeyType" required: - type - api_token type: object + NotionAPIKeyApiToken: + description: The `NotionAPIKey` `api_token`. + example: "" + oneOf: + - $ref: "#/components/schemas/ActionConnectionLiteralValue" + - $ref: "#/components/schemas/ActionConnectionAWSSecretsManagerReference" NotionAPIKeyType: description: The definition of the `NotionAPIKey` object. enum: @@ -85000,13 +85277,17 @@ components: description: The definition of the `NotionAPIKey` object. properties: api_token: - description: The `NotionAPIKeyUpdate` `api_token`. - type: string + $ref: "#/components/schemas/NotionAPIKeyUpdateApiToken" type: $ref: "#/components/schemas/NotionAPIKeyType" required: - type type: object + NotionAPIKeyUpdateApiToken: + description: The `NotionAPIKeyUpdate` `api_token`. + oneOf: + - $ref: "#/components/schemas/ActionConnectionLiteralValue" + - $ref: "#/components/schemas/ActionConnectionAWSSecretsManagerReference" NotionCredentials: description: The definition of the `NotionCredentials` object. oneOf: @@ -92766,13 +93047,9 @@ components: description: The definition of the `OktaAPIToken` object. properties: api_token: - description: The `OktaAPIToken` `api_token`. - example: "" - type: string + $ref: "#/components/schemas/OktaAPITokenApiToken" domain: - description: The `OktaAPIToken` `domain`. - example: "" - type: string + $ref: "#/components/schemas/OktaAPITokenDomain" type: $ref: "#/components/schemas/OktaAPITokenType" required: @@ -92780,6 +93057,18 @@ components: - domain - api_token type: object + OktaAPITokenApiToken: + description: The `OktaAPIToken` `api_token`. + example: "" + oneOf: + - $ref: "#/components/schemas/ActionConnectionLiteralValue" + - $ref: "#/components/schemas/ActionConnectionAWSSecretsManagerReference" + OktaAPITokenDomain: + description: The `OktaAPIToken` `domain`. + example: "" + oneOf: + - $ref: "#/components/schemas/ActionConnectionLiteralValue" + - $ref: "#/components/schemas/ActionConnectionAWSSecretsManagerReference" OktaAPITokenType: description: The definition of the `OktaAPIToken` object. enum: @@ -92792,16 +93081,24 @@ components: description: The definition of the `OktaAPIToken` object. properties: api_token: - description: The `OktaAPITokenUpdate` `api_token`. - type: string + $ref: "#/components/schemas/OktaAPITokenUpdateApiToken" domain: - description: The `OktaAPITokenUpdate` `domain`. - type: string + $ref: "#/components/schemas/OktaAPITokenUpdateDomain" type: $ref: "#/components/schemas/OktaAPITokenType" required: - type type: object + OktaAPITokenUpdateApiToken: + description: The `OktaAPITokenUpdate` `api_token`. + oneOf: + - $ref: "#/components/schemas/ActionConnectionLiteralValue" + - $ref: "#/components/schemas/ActionConnectionAWSSecretsManagerReference" + OktaAPITokenUpdateDomain: + description: The `OktaAPITokenUpdate` `domain`. + oneOf: + - $ref: "#/components/schemas/ActionConnectionLiteralValue" + - $ref: "#/components/schemas/ActionConnectionAWSSecretsManagerReference" OktaAccount: description: Schema for an Okta account. properties: @@ -93823,15 +94120,19 @@ components: description: The definition of the `OpenAIAPIKey` object. properties: api_token: - description: The `OpenAIAPIKey` `api_token`. - example: "" - type: string + $ref: "#/components/schemas/OpenAIAPIKeyApiToken" type: $ref: "#/components/schemas/OpenAIAPIKeyType" required: - type - api_token type: object + OpenAIAPIKeyApiToken: + description: The `OpenAIAPIKey` `api_token`. + example: "" + oneOf: + - $ref: "#/components/schemas/ActionConnectionLiteralValue" + - $ref: "#/components/schemas/ActionConnectionAWSSecretsManagerReference" OpenAIAPIKeyType: description: The definition of the `OpenAIAPIKey` object. enum: @@ -93844,13 +94145,17 @@ components: description: The definition of the `OpenAIAPIKey` object. properties: api_token: - description: The `OpenAIAPIKeyUpdate` `api_token`. - type: string + $ref: "#/components/schemas/OpenAIAPIKeyUpdateApiToken" type: $ref: "#/components/schemas/OpenAIAPIKeyType" required: - type type: object + OpenAIAPIKeyUpdateApiToken: + description: The `OpenAIAPIKeyUpdate` `api_token`. + oneOf: + - $ref: "#/components/schemas/ActionConnectionLiteralValue" + - $ref: "#/components/schemas/ActionConnectionAWSSecretsManagerReference" OpenAICredentials: description: The definition of the `OpenAICredentials` object. oneOf: @@ -123450,25 +123755,31 @@ components: description: The definition of the `ServiceNowBasicAuth` object. properties: instance: - description: The `ServiceNowBasicAuth` `instance`. - example: "" - type: string + $ref: "#/components/schemas/ServiceNowBasicAuthInstance" password: - description: The `ServiceNowBasicAuth` `password`. - example: "" - type: string + $ref: "#/components/schemas/ServiceNowBasicAuthPassword" type: $ref: "#/components/schemas/ServiceNowBasicAuthType" username: - description: The `ServiceNowBasicAuth` `username`. - example: "" - type: string + $ref: "#/components/schemas/ServiceNowBasicAuthUsername" required: - type - instance - username - password type: object + ServiceNowBasicAuthInstance: + description: The `ServiceNowBasicAuth` `instance`. + example: "" + oneOf: + - $ref: "#/components/schemas/ActionConnectionLiteralValue" + - $ref: "#/components/schemas/ActionConnectionAWSSecretsManagerReference" + ServiceNowBasicAuthPassword: + description: The `ServiceNowBasicAuth` `password`. + example: "" + oneOf: + - $ref: "#/components/schemas/ActionConnectionLiteralValue" + - $ref: "#/components/schemas/ActionConnectionAWSSecretsManagerReference" ServiceNowBasicAuthType: description: The definition of the `ServiceNowBasicAuth` object. enum: @@ -123481,19 +123792,37 @@ components: description: The definition of the `ServiceNowBasicAuth` object. properties: instance: - description: The `ServiceNowBasicAuthUpdate` `instance`. - type: string + $ref: "#/components/schemas/ServiceNowBasicAuthUpdateInstance" password: - description: The `ServiceNowBasicAuthUpdate` `password`. - type: string + $ref: "#/components/schemas/ServiceNowBasicAuthUpdatePassword" type: $ref: "#/components/schemas/ServiceNowBasicAuthType" username: - description: The `ServiceNowBasicAuthUpdate` `username`. - type: string + $ref: "#/components/schemas/ServiceNowBasicAuthUpdateUsername" required: - type type: object + ServiceNowBasicAuthUpdateInstance: + description: The `ServiceNowBasicAuthUpdate` `instance`. + oneOf: + - $ref: "#/components/schemas/ActionConnectionLiteralValue" + - $ref: "#/components/schemas/ActionConnectionAWSSecretsManagerReference" + ServiceNowBasicAuthUpdatePassword: + description: The `ServiceNowBasicAuthUpdate` `password`. + oneOf: + - $ref: "#/components/schemas/ActionConnectionLiteralValue" + - $ref: "#/components/schemas/ActionConnectionAWSSecretsManagerReference" + ServiceNowBasicAuthUpdateUsername: + description: The `ServiceNowBasicAuthUpdate` `username`. + oneOf: + - $ref: "#/components/schemas/ActionConnectionLiteralValue" + - $ref: "#/components/schemas/ActionConnectionAWSSecretsManagerReference" + ServiceNowBasicAuthUsername: + description: The `ServiceNowBasicAuth` `username`. + example: "" + oneOf: + - $ref: "#/components/schemas/ActionConnectionLiteralValue" + - $ref: "#/components/schemas/ActionConnectionAWSSecretsManagerReference" ServiceNowBusinessServiceAttributes: description: Attributes of a ServiceNow business service properties: @@ -127680,15 +128009,19 @@ components: description: The definition of the `SplitAPIKey` object. properties: api_key: - description: The `SplitAPIKey` `api_key`. - example: "" - type: string + $ref: "#/components/schemas/SplitAPIKeyApiKey" type: $ref: "#/components/schemas/SplitAPIKeyType" required: - type - api_key type: object + SplitAPIKeyApiKey: + description: The `SplitAPIKey` `api_key`. + example: "" + oneOf: + - $ref: "#/components/schemas/ActionConnectionLiteralValue" + - $ref: "#/components/schemas/ActionConnectionAWSSecretsManagerReference" SplitAPIKeyType: description: The definition of the `SplitAPIKey` object. enum: @@ -127701,13 +128034,17 @@ components: description: The definition of the `SplitAPIKey` object. properties: api_key: - description: The `SplitAPIKeyUpdate` `api_key`. - type: string + $ref: "#/components/schemas/SplitAPIKeyUpdateApiKey" type: $ref: "#/components/schemas/SplitAPIKeyType" required: - type type: object + SplitAPIKeyUpdateApiKey: + description: The `SplitAPIKeyUpdate` `api_key`. + oneOf: + - $ref: "#/components/schemas/ActionConnectionLiteralValue" + - $ref: "#/components/schemas/ActionConnectionAWSSecretsManagerReference" SplitCredentials: description: The definition of the `SplitCredentials` object. oneOf: @@ -127802,15 +128139,19 @@ components: description: The definition of the `StatsigAPIKey` object. properties: api_key: - description: The `StatsigAPIKey` `api_key`. - example: "" - type: string + $ref: "#/components/schemas/StatsigAPIKeyApiKey" type: $ref: "#/components/schemas/StatsigAPIKeyType" required: - type - api_key type: object + StatsigAPIKeyApiKey: + description: The `StatsigAPIKey` `api_key`. + example: "" + oneOf: + - $ref: "#/components/schemas/ActionConnectionLiteralValue" + - $ref: "#/components/schemas/ActionConnectionAWSSecretsManagerReference" StatsigAPIKeyType: description: The definition of the `StatsigAPIKey` object. enum: @@ -127823,13 +128164,17 @@ components: description: The definition of the `StatsigAPIKey` object. properties: api_key: - description: The `StatsigAPIKeyUpdate` `api_key`. - type: string + $ref: "#/components/schemas/StatsigAPIKeyUpdateApiKey" type: $ref: "#/components/schemas/StatsigAPIKeyType" required: - type type: object + StatsigAPIKeyUpdateApiKey: + description: The `StatsigAPIKeyUpdate` `api_key`. + oneOf: + - $ref: "#/components/schemas/ActionConnectionLiteralValue" + - $ref: "#/components/schemas/ActionConnectionAWSSecretsManagerReference" StatsigCredentials: description: The definition of the `StatsigCredentials` object. oneOf: @@ -144268,15 +144613,19 @@ components: description: The definition of the `VirusTotalAPIKey` object. properties: api_key: - description: The `VirusTotalAPIKey` `api_key`. - example: "" - type: string + $ref: "#/components/schemas/VirusTotalAPIKeyApiKey" type: $ref: "#/components/schemas/VirusTotalAPIKeyType" required: - type - api_key type: object + VirusTotalAPIKeyApiKey: + description: The `VirusTotalAPIKey` `api_key`. + example: "" + oneOf: + - $ref: "#/components/schemas/ActionConnectionLiteralValue" + - $ref: "#/components/schemas/ActionConnectionAWSSecretsManagerReference" VirusTotalAPIKeyType: description: The definition of the `VirusTotalAPIKey` object. enum: @@ -144289,13 +144638,17 @@ components: description: The definition of the `VirusTotalAPIKey` object. properties: api_key: - description: The `VirusTotalAPIKeyUpdate` `api_key`. - type: string + $ref: "#/components/schemas/VirusTotalAPIKeyUpdateApiKey" type: $ref: "#/components/schemas/VirusTotalAPIKeyType" required: - type type: object + VirusTotalAPIKeyUpdateApiKey: + description: The `VirusTotalAPIKeyUpdate` `api_key`. + oneOf: + - $ref: "#/components/schemas/ActionConnectionLiteralValue" + - $ref: "#/components/schemas/ActionConnectionAWSSecretsManagerReference" VirusTotalCredentials: description: The definition of the `VirusTotalCredentials` object. oneOf: diff --git a/examples/v2/action-connection/CreateActionConnection_4171110267.java b/examples/v2/action-connection/CreateActionConnection_4171110267.java new file mode 100644 index 00000000000..d476293224e --- /dev/null +++ b/examples/v2/action-connection/CreateActionConnection_4171110267.java @@ -0,0 +1,85 @@ +// Create a GCP Action Connection with AWS Secrets Manager references + +import com.datadog.api.client.ApiClient; +import com.datadog.api.client.ApiException; +import com.datadog.api.client.v2.api.ActionConnectionApi; +import com.datadog.api.client.v2.model.ActionConnectionAWSSecretsManager; +import com.datadog.api.client.v2.model.ActionConnectionAWSSecretsManagerReference; +import com.datadog.api.client.v2.model.ActionConnectionAWSSecretsManagerType; +import com.datadog.api.client.v2.model.ActionConnectionAttributes; +import com.datadog.api.client.v2.model.ActionConnectionData; +import com.datadog.api.client.v2.model.ActionConnectionDataType; +import com.datadog.api.client.v2.model.ActionConnectionIntegration; +import com.datadog.api.client.v2.model.CreateActionConnectionRequest; +import com.datadog.api.client.v2.model.CreateActionConnectionResponse; +import com.datadog.api.client.v2.model.GCPCredentials; +import com.datadog.api.client.v2.model.GCPIntegration; +import com.datadog.api.client.v2.model.GCPIntegrationType; +import com.datadog.api.client.v2.model.GCPServiceAccount; +import com.datadog.api.client.v2.model.GCPServiceAccountCredentialType; +import com.datadog.api.client.v2.model.GCPServiceAccountPrivateKey; +import com.datadog.api.client.v2.model.GCPServiceAccountServiceAccountEmail; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + defaultClient.setAccessToken(System.getenv("DD_BEARER_TOKEN")); + ActionConnectionApi apiInstance = new ActionConnectionApi(defaultClient); + + // there is a valid "action_connection" in the system + String ACTION_CONNECTION_DATA_ID = System.getenv("ACTION_CONNECTION_DATA_ID"); + + CreateActionConnectionRequest body = + new CreateActionConnectionRequest() + .data( + new ActionConnectionData() + .type(ActionConnectionDataType.ACTION_CONNECTION) + .attributes( + new ActionConnectionAttributes() + .name("GCP Secrets Manager Connection exampleactionconnection") + .externalSecretsManager( + new ActionConnectionAWSSecretsManager() + .type(ActionConnectionAWSSecretsManagerType.AWS_SECRETS_MANAGER) + .connectionId(ACTION_CONNECTION_DATA_ID) + .region("us-east-1")) + .integration( + new ActionConnectionIntegration( + new GCPIntegration() + .type(GCPIntegrationType.GCP) + .credentials( + new GCPCredentials( + new GCPServiceAccount() + .type( + GCPServiceAccountCredentialType + .GCPSERVICEACCOUNT) + .privateKey( + new GCPServiceAccountPrivateKey( + new ActionConnectionAWSSecretsManagerReference() + .type( + ActionConnectionAWSSecretsManagerType + .AWS_SECRETS_MANAGER) + .secretId( + "example/gcp/service-account") + .key("private_key"))) + .serviceAccountEmail( + new GCPServiceAccountServiceAccountEmail( + new ActionConnectionAWSSecretsManagerReference() + .type( + ActionConnectionAWSSecretsManagerType + .AWS_SECRETS_MANAGER) + .secretId( + "example/gcp/service-account") + .key("client_email"))))))))); + + try { + CreateActionConnectionResponse result = apiInstance.createActionConnection(body); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling ActionConnectionApi#createActionConnection"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} diff --git a/examples/v2/action-connection/CreateActionConnection_4217378621.java b/examples/v2/action-connection/CreateActionConnection_4217378621.java new file mode 100644 index 00000000000..a94eba38008 --- /dev/null +++ b/examples/v2/action-connection/CreateActionConnection_4217378621.java @@ -0,0 +1,102 @@ +// Create an HTTP Action Connection with an AWS Secrets Manager token + +import com.datadog.api.client.ApiClient; +import com.datadog.api.client.ApiException; +import com.datadog.api.client.v2.api.ActionConnectionApi; +import com.datadog.api.client.v2.model.ActionConnectionAWSSecretsManager; +import com.datadog.api.client.v2.model.ActionConnectionAWSSecretsManagerReference; +import com.datadog.api.client.v2.model.ActionConnectionAWSSecretsManagerType; +import com.datadog.api.client.v2.model.ActionConnectionAttributes; +import com.datadog.api.client.v2.model.ActionConnectionData; +import com.datadog.api.client.v2.model.ActionConnectionDataType; +import com.datadog.api.client.v2.model.ActionConnectionIntegration; +import com.datadog.api.client.v2.model.CreateActionConnectionRequest; +import com.datadog.api.client.v2.model.CreateActionConnectionResponse; +import com.datadog.api.client.v2.model.HTTPBody; +import com.datadog.api.client.v2.model.HTTPCredentials; +import com.datadog.api.client.v2.model.HTTPHeader; +import com.datadog.api.client.v2.model.HTTPIntegration; +import com.datadog.api.client.v2.model.HTTPIntegrationType; +import com.datadog.api.client.v2.model.HTTPToken; +import com.datadog.api.client.v2.model.HTTPTokenAuth; +import com.datadog.api.client.v2.model.HTTPTokenAuthType; +import com.datadog.api.client.v2.model.HTTPTokenValue; +import com.datadog.api.client.v2.model.TokenType; +import com.datadog.api.client.v2.model.UrlParam; +import java.util.Collections; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + defaultClient.setAccessToken(System.getenv("DD_BEARER_TOKEN")); + ActionConnectionApi apiInstance = new ActionConnectionApi(defaultClient); + + // there is a valid "action_connection" in the system + String ACTION_CONNECTION_DATA_ID = System.getenv("ACTION_CONNECTION_DATA_ID"); + + CreateActionConnectionRequest body = + new CreateActionConnectionRequest() + .data( + new ActionConnectionData() + .type(ActionConnectionDataType.ACTION_CONNECTION) + .attributes( + new ActionConnectionAttributes() + .name("HTTP Secrets Manager Connection exampleactionconnection") + .externalSecretsManager( + new ActionConnectionAWSSecretsManager() + .type(ActionConnectionAWSSecretsManagerType.AWS_SECRETS_MANAGER) + .connectionId(ACTION_CONNECTION_DATA_ID) + .region("us-east-1")) + .integration( + new ActionConnectionIntegration( + new HTTPIntegration() + .type(HTTPIntegrationType.HTTP) + .baseUrl("https://example.com") + .credentials( + new HTTPCredentials( + new HTTPTokenAuth() + .type(HTTPTokenAuthType.HTTPTOKENAUTH) + .tokens( + Collections.singletonList( + new HTTPToken() + .name("token") + .type(TokenType.SECRET) + .value( + new HTTPTokenValue( + new ActionConnectionAWSSecretsManagerReference() + .type( + ActionConnectionAWSSecretsManagerType + .AWS_SECRETS_MANAGER) + .secretId( + "example/http") + .key("token"))))) + .headers( + Collections.singletonList( + new HTTPHeader() + .name("ApiKey") + .value("literal-value"))) + .urlParameters( + Collections.singletonList( + new UrlParam() + .name("apiKey") + .value("literal-value"))) + .body( + new HTTPBody() + .contentType("application/json") + .content( + """ +{"example":"literal"} +""")))))))); + + try { + CreateActionConnectionResponse result = apiInstance.createActionConnection(body); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling ActionConnectionApi#createActionConnection"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} diff --git a/examples/v2/action-connection/CreateActionConnection_4258732703.java b/examples/v2/action-connection/CreateActionConnection_4258732703.java new file mode 100644 index 00000000000..a5123f03c80 --- /dev/null +++ b/examples/v2/action-connection/CreateActionConnection_4258732703.java @@ -0,0 +1,72 @@ +// Create an Anthropic Action Connection with an AWS Secrets Manager API token + +import com.datadog.api.client.ApiClient; +import com.datadog.api.client.ApiException; +import com.datadog.api.client.v2.api.ActionConnectionApi; +import com.datadog.api.client.v2.model.ActionConnectionAWSSecretsManager; +import com.datadog.api.client.v2.model.ActionConnectionAWSSecretsManagerReference; +import com.datadog.api.client.v2.model.ActionConnectionAWSSecretsManagerType; +import com.datadog.api.client.v2.model.ActionConnectionAttributes; +import com.datadog.api.client.v2.model.ActionConnectionData; +import com.datadog.api.client.v2.model.ActionConnectionDataType; +import com.datadog.api.client.v2.model.ActionConnectionIntegration; +import com.datadog.api.client.v2.model.AnthropicAPIKey; +import com.datadog.api.client.v2.model.AnthropicAPIKeyApiToken; +import com.datadog.api.client.v2.model.AnthropicAPIKeyType; +import com.datadog.api.client.v2.model.AnthropicCredentials; +import com.datadog.api.client.v2.model.AnthropicIntegration; +import com.datadog.api.client.v2.model.AnthropicIntegrationType; +import com.datadog.api.client.v2.model.CreateActionConnectionRequest; +import com.datadog.api.client.v2.model.CreateActionConnectionResponse; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + defaultClient.setAccessToken(System.getenv("DD_BEARER_TOKEN")); + ActionConnectionApi apiInstance = new ActionConnectionApi(defaultClient); + + // there is a valid "action_connection" in the system + String ACTION_CONNECTION_DATA_ID = System.getenv("ACTION_CONNECTION_DATA_ID"); + + CreateActionConnectionRequest body = + new CreateActionConnectionRequest() + .data( + new ActionConnectionData() + .type(ActionConnectionDataType.ACTION_CONNECTION) + .attributes( + new ActionConnectionAttributes() + .name("Anthropic Secrets Manager Connection exampleactionconnection") + .externalSecretsManager( + new ActionConnectionAWSSecretsManager() + .type(ActionConnectionAWSSecretsManagerType.AWS_SECRETS_MANAGER) + .connectionId(ACTION_CONNECTION_DATA_ID) + .region("us-east-1")) + .integration( + new ActionConnectionIntegration( + new AnthropicIntegration() + .type(AnthropicIntegrationType.ANTHROPIC) + .credentials( + new AnthropicCredentials( + new AnthropicAPIKey() + .type(AnthropicAPIKeyType.ANTHROPICAPIKEY) + .apiToken( + new AnthropicAPIKeyApiToken( + new ActionConnectionAWSSecretsManagerReference() + .type( + ActionConnectionAWSSecretsManagerType + .AWS_SECRETS_MANAGER) + .secretId("example/anthropic") + .key("api_token"))))))))); + + try { + CreateActionConnectionResponse result = apiInstance.createActionConnection(body); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling ActionConnectionApi#createActionConnection"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} diff --git a/examples/v2/action-connection/GetActionConnection_721033322.java b/examples/v2/action-connection/GetActionConnection_721033322.java new file mode 100644 index 00000000000..079db87e1d5 --- /dev/null +++ b/examples/v2/action-connection/GetActionConnection_721033322.java @@ -0,0 +1,29 @@ +// Get a GCP Action Connection preserves AWS Secrets Manager references + +import com.datadog.api.client.ApiClient; +import com.datadog.api.client.ApiException; +import com.datadog.api.client.v2.api.ActionConnectionApi; +import com.datadog.api.client.v2.model.GetActionConnectionResponse; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + defaultClient.setAccessToken(System.getenv("DD_BEARER_TOKEN")); + ActionConnectionApi apiInstance = new ActionConnectionApi(defaultClient); + + // there is a valid "gcp_action_connection" in the system + String GCP_ACTION_CONNECTION_DATA_ID = System.getenv("GCP_ACTION_CONNECTION_DATA_ID"); + + try { + GetActionConnectionResponse result = + apiInstance.getActionConnection(GCP_ACTION_CONNECTION_DATA_ID); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling ActionConnectionApi#getActionConnection"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} diff --git a/examples/v2/action-connection/UpdateActionConnection_426384263.java b/examples/v2/action-connection/UpdateActionConnection_426384263.java new file mode 100644 index 00000000000..5b43b1c5679 --- /dev/null +++ b/examples/v2/action-connection/UpdateActionConnection_426384263.java @@ -0,0 +1,89 @@ +// Update a GCP Action Connection with a versioned AWS Secrets Manager reference + +import com.datadog.api.client.ApiClient; +import com.datadog.api.client.ApiException; +import com.datadog.api.client.v2.api.ActionConnectionApi; +import com.datadog.api.client.v2.model.ActionConnectionAWSSecretsManager; +import com.datadog.api.client.v2.model.ActionConnectionAWSSecretsManagerReference; +import com.datadog.api.client.v2.model.ActionConnectionAWSSecretsManagerType; +import com.datadog.api.client.v2.model.ActionConnectionAttributesUpdate; +import com.datadog.api.client.v2.model.ActionConnectionDataType; +import com.datadog.api.client.v2.model.ActionConnectionDataUpdate; +import com.datadog.api.client.v2.model.ActionConnectionIntegrationUpdate; +import com.datadog.api.client.v2.model.GCPCredentialsUpdate; +import com.datadog.api.client.v2.model.GCPIntegrationType; +import com.datadog.api.client.v2.model.GCPIntegrationUpdate; +import com.datadog.api.client.v2.model.GCPServiceAccountCredentialType; +import com.datadog.api.client.v2.model.GCPServiceAccountUpdate; +import com.datadog.api.client.v2.model.GCPServiceAccountUpdatePrivateKey; +import com.datadog.api.client.v2.model.GCPServiceAccountUpdateServiceAccountEmail; +import com.datadog.api.client.v2.model.UpdateActionConnectionRequest; +import com.datadog.api.client.v2.model.UpdateActionConnectionResponse; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + defaultClient.setAccessToken(System.getenv("DD_BEARER_TOKEN")); + ActionConnectionApi apiInstance = new ActionConnectionApi(defaultClient); + + // there is a valid "gcp_action_connection" in the system + String GCP_ACTION_CONNECTION_DATA_ID = System.getenv("GCP_ACTION_CONNECTION_DATA_ID"); + + // there is a valid "action_connection" in the system + String ACTION_CONNECTION_DATA_ID = System.getenv("ACTION_CONNECTION_DATA_ID"); + + UpdateActionConnectionRequest body = + new UpdateActionConnectionRequest() + .data( + new ActionConnectionDataUpdate() + .type(ActionConnectionDataType.ACTION_CONNECTION) + .attributes( + new ActionConnectionAttributesUpdate() + .externalSecretsManager( + new ActionConnectionAWSSecretsManager() + .type(ActionConnectionAWSSecretsManagerType.AWS_SECRETS_MANAGER) + .connectionId(ACTION_CONNECTION_DATA_ID) + .region("us-east-1")) + .integration( + new ActionConnectionIntegrationUpdate( + new GCPIntegrationUpdate() + .type(GCPIntegrationType.GCP) + .credentials( + new GCPCredentialsUpdate( + new GCPServiceAccountUpdate() + .type( + GCPServiceAccountCredentialType + .GCPSERVICEACCOUNT) + .privateKey( + new GCPServiceAccountUpdatePrivateKey( + new ActionConnectionAWSSecretsManagerReference() + .type( + ActionConnectionAWSSecretsManagerType + .AWS_SECRETS_MANAGER) + .secretId( + "example/gcp/service-account") + .key("private_key") + .versionStage("AWSCURRENT"))) + .serviceAccountEmail( + new GCPServiceAccountUpdateServiceAccountEmail( + new ActionConnectionAWSSecretsManagerReference() + .type( + ActionConnectionAWSSecretsManagerType + .AWS_SECRETS_MANAGER) + .secretId( + "example/gcp/service-account") + .key("client_email"))))))))); + + try { + UpdateActionConnectionResponse result = + apiInstance.updateActionConnection(GCP_ACTION_CONNECTION_DATA_ID, body); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling ActionConnectionApi#updateActionConnection"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/ActionConnectionAWSSecretsManager.java b/src/main/java/com/datadog/api/client/v2/model/ActionConnectionAWSSecretsManager.java new file mode 100644 index 00000000000..c001459dc42 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ActionConnectionAWSSecretsManager.java @@ -0,0 +1,213 @@ +/* + * 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; + +/** + * AWS Secrets Manager settings shared by the credential references on a DATACENTER + * connection. These settings are required whenever a field uses an AWS Secrets Manager reference. + */ +@JsonPropertyOrder({ + ActionConnectionAWSSecretsManager.JSON_PROPERTY_CONNECTION_ID, + ActionConnectionAWSSecretsManager.JSON_PROPERTY_REGION, + ActionConnectionAWSSecretsManager.JSON_PROPERTY_TYPE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class ActionConnectionAWSSecretsManager { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_CONNECTION_ID = "connection_id"; + private String connectionId; + + public static final String JSON_PROPERTY_REGION = "region"; + private String region; + + public static final String JSON_PROPERTY_TYPE = "type"; + private ActionConnectionAWSSecretsManagerType type; + + public ActionConnectionAWSSecretsManager() {} + + @JsonCreator + public ActionConnectionAWSSecretsManager( + @JsonProperty(required = true, value = JSON_PROPERTY_CONNECTION_ID) String connectionId, + @JsonProperty(required = true, value = JSON_PROPERTY_REGION) String region, + @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) + ActionConnectionAWSSecretsManagerType type) { + this.connectionId = connectionId; + this.region = region; + this.type = type; + this.unparsed |= !type.isValid(); + } + + public ActionConnectionAWSSecretsManager connectionId(String connectionId) { + this.connectionId = connectionId; + return this; + } + + /** + * ID of the AWS connection used to retrieve secrets. This connection must be in the same Datadog + * organization. + * + * @return connectionId + */ + @JsonProperty(JSON_PROPERTY_CONNECTION_ID) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getConnectionId() { + return connectionId; + } + + public void setConnectionId(String connectionId) { + this.connectionId = connectionId; + } + + public ActionConnectionAWSSecretsManager region(String region) { + this.region = region; + return this; + } + + /** + * AWS region containing the referenced secrets. + * + * @return region + */ + @JsonProperty(JSON_PROPERTY_REGION) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getRegion() { + return region; + } + + public void setRegion(String region) { + this.region = region; + } + + public ActionConnectionAWSSecretsManager type(ActionConnectionAWSSecretsManagerType type) { + this.type = type; + this.unparsed |= !type.isValid(); + return this; + } + + /** + * AWS Secrets Manager secret backend. + * + * @return type + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public ActionConnectionAWSSecretsManagerType getType() { + return type; + } + + public void setType(ActionConnectionAWSSecretsManagerType 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 ActionConnectionAWSSecretsManager + */ + @JsonAnySetter + public ActionConnectionAWSSecretsManager 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 ActionConnectionAWSSecretsManager object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ActionConnectionAWSSecretsManager actionConnectionAwsSecretsManager = + (ActionConnectionAWSSecretsManager) o; + return Objects.equals(this.connectionId, actionConnectionAwsSecretsManager.connectionId) + && Objects.equals(this.region, actionConnectionAwsSecretsManager.region) + && Objects.equals(this.type, actionConnectionAwsSecretsManager.type) + && Objects.equals( + this.additionalProperties, actionConnectionAwsSecretsManager.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(connectionId, region, type, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ActionConnectionAWSSecretsManager {\n"); + sb.append(" connectionId: ").append(toIndentedString(connectionId)).append("\n"); + sb.append(" region: ").append(toIndentedString(region)).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/ActionConnectionAWSSecretsManagerReference.java b/src/main/java/com/datadog/api/client/v2/model/ActionConnectionAWSSecretsManagerReference.java new file mode 100644 index 00000000000..ef156bd5e45 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ActionConnectionAWSSecretsManagerReference.java @@ -0,0 +1,273 @@ +/* + * 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; + +/** + * Reference to a string value in AWS Secrets Manager. The connection must also specify + * external_secrets_manager settings. AWS Secrets Manager references are supported for + * token-based credentials and HTTP authentication tokens on DATACENTER connections. + */ +@JsonPropertyOrder({ + ActionConnectionAWSSecretsManagerReference.JSON_PROPERTY_KEY, + ActionConnectionAWSSecretsManagerReference.JSON_PROPERTY_SECRET_ID, + ActionConnectionAWSSecretsManagerReference.JSON_PROPERTY_TYPE, + ActionConnectionAWSSecretsManagerReference.JSON_PROPERTY_VERSION_ID, + ActionConnectionAWSSecretsManagerReference.JSON_PROPERTY_VERSION_STAGE +}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class ActionConnectionAWSSecretsManagerReference { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_KEY = "key"; + private String key; + + public static final String JSON_PROPERTY_SECRET_ID = "secret_id"; + private String secretId; + + public static final String JSON_PROPERTY_TYPE = "type"; + private ActionConnectionAWSSecretsManagerType type; + + public static final String JSON_PROPERTY_VERSION_ID = "version_id"; + private String versionId; + + public static final String JSON_PROPERTY_VERSION_STAGE = "version_stage"; + private String versionStage; + + public ActionConnectionAWSSecretsManagerReference() {} + + @JsonCreator + public ActionConnectionAWSSecretsManagerReference( + @JsonProperty(required = true, value = JSON_PROPERTY_SECRET_ID) String secretId, + @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) + ActionConnectionAWSSecretsManagerType type) { + this.secretId = secretId; + this.type = type; + this.unparsed |= !type.isValid(); + } + + public ActionConnectionAWSSecretsManagerReference key(String key) { + this.key = key; + return this; + } + + /** + * Top-level JSON key to extract from the secret string. Omit this field to use the entire secret + * string. + * + * @return key + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_KEY) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public ActionConnectionAWSSecretsManagerReference secretId(String secretId) { + this.secretId = secretId; + return this; + } + + /** + * Name or ARN of the AWS Secrets Manager secret. + * + * @return secretId + */ + @JsonProperty(JSON_PROPERTY_SECRET_ID) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getSecretId() { + return secretId; + } + + public void setSecretId(String secretId) { + this.secretId = secretId; + } + + public ActionConnectionAWSSecretsManagerReference type( + ActionConnectionAWSSecretsManagerType type) { + this.type = type; + this.unparsed |= !type.isValid(); + return this; + } + + /** + * AWS Secrets Manager secret backend. + * + * @return type + */ + @JsonProperty(JSON_PROPERTY_TYPE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public ActionConnectionAWSSecretsManagerType getType() { + return type; + } + + public void setType(ActionConnectionAWSSecretsManagerType type) { + if (!type.isValid()) { + this.unparsed = true; + } + this.type = type; + } + + public ActionConnectionAWSSecretsManagerReference versionId(String versionId) { + this.versionId = versionId; + return this; + } + + /** + * ID of the secret version to retrieve. Cannot be used together with version_stage. + * If both are omitted, the current version is used. + * + * @return versionId + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_VERSION_ID) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getVersionId() { + return versionId; + } + + public void setVersionId(String versionId) { + this.versionId = versionId; + } + + public ActionConnectionAWSSecretsManagerReference versionStage(String versionStage) { + this.versionStage = versionStage; + return this; + } + + /** + * Staging label of the secret version to retrieve. Cannot be used together with version_id + * . If both are omitted, the current version is used. + * + * @return versionStage + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_VERSION_STAGE) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public String getVersionStage() { + return versionStage; + } + + public void setVersionStage(String versionStage) { + this.versionStage = versionStage; + } + + /** + * 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 ActionConnectionAWSSecretsManagerReference + */ + @JsonAnySetter + public ActionConnectionAWSSecretsManagerReference 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 ActionConnectionAWSSecretsManagerReference object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ActionConnectionAWSSecretsManagerReference actionConnectionAwsSecretsManagerReference = + (ActionConnectionAWSSecretsManagerReference) o; + return Objects.equals(this.key, actionConnectionAwsSecretsManagerReference.key) + && Objects.equals(this.secretId, actionConnectionAwsSecretsManagerReference.secretId) + && Objects.equals(this.type, actionConnectionAwsSecretsManagerReference.type) + && Objects.equals(this.versionId, actionConnectionAwsSecretsManagerReference.versionId) + && Objects.equals( + this.versionStage, actionConnectionAwsSecretsManagerReference.versionStage) + && Objects.equals( + this.additionalProperties, + actionConnectionAwsSecretsManagerReference.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(key, secretId, type, versionId, versionStage, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ActionConnectionAWSSecretsManagerReference {\n"); + sb.append(" key: ").append(toIndentedString(key)).append("\n"); + sb.append(" secretId: ").append(toIndentedString(secretId)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" versionId: ").append(toIndentedString(versionId)).append("\n"); + sb.append(" versionStage: ").append(toIndentedString(versionStage)).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/ActionConnectionAWSSecretsManagerType.java b/src/main/java/com/datadog/api/client/v2/model/ActionConnectionAWSSecretsManagerType.java new file mode 100644 index 00000000000..815656cf1e3 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ActionConnectionAWSSecretsManagerType.java @@ -0,0 +1,62 @@ +/* + * 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; + +/** AWS Secrets Manager secret backend. */ +@JsonSerialize( + using = + ActionConnectionAWSSecretsManagerType.ActionConnectionAWSSecretsManagerTypeSerializer.class) +public class ActionConnectionAWSSecretsManagerType extends ModelEnum { + + private static final Set allowedValues = + new HashSet(Arrays.asList("aws_secrets_manager")); + + public static final ActionConnectionAWSSecretsManagerType AWS_SECRETS_MANAGER = + new ActionConnectionAWSSecretsManagerType("aws_secrets_manager"); + + ActionConnectionAWSSecretsManagerType(String value) { + super(value, allowedValues); + } + + public static class ActionConnectionAWSSecretsManagerTypeSerializer + extends StdSerializer { + public ActionConnectionAWSSecretsManagerTypeSerializer( + Class t) { + super(t); + } + + public ActionConnectionAWSSecretsManagerTypeSerializer() { + this(null); + } + + @Override + public void serialize( + ActionConnectionAWSSecretsManagerType value, + JsonGenerator jgen, + SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.value); + } + } + + @JsonCreator + public static ActionConnectionAWSSecretsManagerType fromValue(String value) { + return new ActionConnectionAWSSecretsManagerType(value); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/ActionConnectionAttributes.java b/src/main/java/com/datadog/api/client/v2/model/ActionConnectionAttributes.java index b25b02e796b..e32a496136b 100644 --- a/src/main/java/com/datadog/api/client/v2/model/ActionConnectionAttributes.java +++ b/src/main/java/com/datadog/api/client/v2/model/ActionConnectionAttributes.java @@ -18,9 +18,11 @@ import java.util.List; import java.util.Map; import java.util.Objects; +import org.openapitools.jackson.nullable.JsonNullable; /** The definition of ActionConnectionAttributes object. */ @JsonPropertyOrder({ + ActionConnectionAttributes.JSON_PROPERTY_EXTERNAL_SECRETS_MANAGER, ActionConnectionAttributes.JSON_PROPERTY_INTEGRATION, ActionConnectionAttributes.JSON_PROPERTY_NAME, ActionConnectionAttributes.JSON_PROPERTY_TAGS @@ -29,6 +31,10 @@ value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") public class ActionConnectionAttributes { @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_EXTERNAL_SECRETS_MANAGER = "external_secrets_manager"; + private JsonNullable externalSecretsManager = + JsonNullable.undefined(); + public static final String JSON_PROPERTY_INTEGRATION = "integration"; private ActionConnectionIntegration integration; @@ -50,6 +56,42 @@ public ActionConnectionAttributes( this.name = name; } + public ActionConnectionAttributes externalSecretsManager( + ActionConnectionAWSSecretsManager externalSecretsManager) { + this.externalSecretsManager = + JsonNullable.of(externalSecretsManager); + return this; + } + + /** + * AWS Secrets Manager settings shared by the credential references on a DATACENTER + * connection. These settings are required whenever a field uses an AWS Secrets Manager reference. + * + * @return externalSecretsManager + */ + @jakarta.annotation.Nullable + @JsonIgnore + public ActionConnectionAWSSecretsManager getExternalSecretsManager() { + return externalSecretsManager.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_EXTERNAL_SECRETS_MANAGER) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public JsonNullable getExternalSecretsManager_JsonNullable() { + return externalSecretsManager; + } + + @JsonProperty(JSON_PROPERTY_EXTERNAL_SECRETS_MANAGER) + public void setExternalSecretsManager_JsonNullable( + JsonNullable externalSecretsManager) { + this.externalSecretsManager = externalSecretsManager; + } + + public void setExternalSecretsManager(ActionConnectionAWSSecretsManager externalSecretsManager) { + this.externalSecretsManager = + JsonNullable.of(externalSecretsManager); + } + public ActionConnectionAttributes integration(ActionConnectionIntegration integration) { this.integration = integration; this.unparsed |= integration.unparsed; @@ -180,7 +222,9 @@ public boolean equals(Object o) { return false; } ActionConnectionAttributes actionConnectionAttributes = (ActionConnectionAttributes) o; - return Objects.equals(this.integration, actionConnectionAttributes.integration) + return Objects.equals( + this.externalSecretsManager, actionConnectionAttributes.externalSecretsManager) + && Objects.equals(this.integration, actionConnectionAttributes.integration) && Objects.equals(this.name, actionConnectionAttributes.name) && Objects.equals(this.tags, actionConnectionAttributes.tags) && Objects.equals( @@ -189,13 +233,16 @@ public boolean equals(Object o) { @Override public int hashCode() { - return Objects.hash(integration, name, tags, additionalProperties); + return Objects.hash(externalSecretsManager, integration, name, tags, additionalProperties); } @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class ActionConnectionAttributes {\n"); + sb.append(" externalSecretsManager: ") + .append(toIndentedString(externalSecretsManager)) + .append("\n"); sb.append(" integration: ").append(toIndentedString(integration)).append("\n"); sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" tags: ").append(toIndentedString(tags)).append("\n"); diff --git a/src/main/java/com/datadog/api/client/v2/model/ActionConnectionAttributesUpdate.java b/src/main/java/com/datadog/api/client/v2/model/ActionConnectionAttributesUpdate.java index 98c02a77a66..0529b7727b0 100644 --- a/src/main/java/com/datadog/api/client/v2/model/ActionConnectionAttributesUpdate.java +++ b/src/main/java/com/datadog/api/client/v2/model/ActionConnectionAttributesUpdate.java @@ -17,9 +17,11 @@ import java.util.List; import java.util.Map; import java.util.Objects; +import org.openapitools.jackson.nullable.JsonNullable; /** The definition of ActionConnectionAttributesUpdate object. */ @JsonPropertyOrder({ + ActionConnectionAttributesUpdate.JSON_PROPERTY_EXTERNAL_SECRETS_MANAGER, ActionConnectionAttributesUpdate.JSON_PROPERTY_INTEGRATION, ActionConnectionAttributesUpdate.JSON_PROPERTY_NAME, ActionConnectionAttributesUpdate.JSON_PROPERTY_TAGS @@ -28,6 +30,10 @@ value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") public class ActionConnectionAttributesUpdate { @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_EXTERNAL_SECRETS_MANAGER = "external_secrets_manager"; + private JsonNullable externalSecretsManager = + JsonNullable.undefined(); + public static final String JSON_PROPERTY_INTEGRATION = "integration"; private ActionConnectionIntegrationUpdate integration; @@ -37,6 +43,42 @@ public class ActionConnectionAttributesUpdate { public static final String JSON_PROPERTY_TAGS = "tags"; private List tags = null; + public ActionConnectionAttributesUpdate externalSecretsManager( + ActionConnectionAWSSecretsManager externalSecretsManager) { + this.externalSecretsManager = + JsonNullable.of(externalSecretsManager); + return this; + } + + /** + * AWS Secrets Manager settings shared by the credential references on a DATACENTER + * connection. These settings are required whenever a field uses an AWS Secrets Manager reference. + * + * @return externalSecretsManager + */ + @jakarta.annotation.Nullable + @JsonIgnore + public ActionConnectionAWSSecretsManager getExternalSecretsManager() { + return externalSecretsManager.orElse(null); + } + + @JsonProperty(JSON_PROPERTY_EXTERNAL_SECRETS_MANAGER) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public JsonNullable getExternalSecretsManager_JsonNullable() { + return externalSecretsManager; + } + + @JsonProperty(JSON_PROPERTY_EXTERNAL_SECRETS_MANAGER) + public void setExternalSecretsManager_JsonNullable( + JsonNullable externalSecretsManager) { + this.externalSecretsManager = externalSecretsManager; + } + + public void setExternalSecretsManager(ActionConnectionAWSSecretsManager externalSecretsManager) { + this.externalSecretsManager = + JsonNullable.of(externalSecretsManager); + } + public ActionConnectionAttributesUpdate integration( ActionConnectionIntegrationUpdate integration) { this.integration = integration; @@ -171,7 +213,9 @@ public boolean equals(Object o) { } ActionConnectionAttributesUpdate actionConnectionAttributesUpdate = (ActionConnectionAttributesUpdate) o; - return Objects.equals(this.integration, actionConnectionAttributesUpdate.integration) + return Objects.equals( + this.externalSecretsManager, actionConnectionAttributesUpdate.externalSecretsManager) + && Objects.equals(this.integration, actionConnectionAttributesUpdate.integration) && Objects.equals(this.name, actionConnectionAttributesUpdate.name) && Objects.equals(this.tags, actionConnectionAttributesUpdate.tags) && Objects.equals( @@ -180,13 +224,16 @@ public boolean equals(Object o) { @Override public int hashCode() { - return Objects.hash(integration, name, tags, additionalProperties); + return Objects.hash(externalSecretsManager, integration, name, tags, additionalProperties); } @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class ActionConnectionAttributesUpdate {\n"); + sb.append(" externalSecretsManager: ") + .append(toIndentedString(externalSecretsManager)) + .append("\n"); sb.append(" integration: ").append(toIndentedString(integration)).append("\n"); sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" tags: ").append(toIndentedString(tags)).append("\n"); diff --git a/src/main/java/com/datadog/api/client/v2/model/AnthropicAPIKey.java b/src/main/java/com/datadog/api/client/v2/model/AnthropicAPIKey.java index 6bdc0af7e2e..eb184d2907f 100644 --- a/src/main/java/com/datadog/api/client/v2/model/AnthropicAPIKey.java +++ b/src/main/java/com/datadog/api/client/v2/model/AnthropicAPIKey.java @@ -24,7 +24,7 @@ public class AnthropicAPIKey { @JsonIgnore public boolean unparsed = false; public static final String JSON_PROPERTY_API_TOKEN = "api_token"; - private String apiToken; + private AnthropicAPIKeyApiToken apiToken; public static final String JSON_PROPERTY_TYPE = "type"; private AnthropicAPIKeyType type; @@ -33,15 +33,18 @@ public AnthropicAPIKey() {} @JsonCreator public AnthropicAPIKey( - @JsonProperty(required = true, value = JSON_PROPERTY_API_TOKEN) String apiToken, + @JsonProperty(required = true, value = JSON_PROPERTY_API_TOKEN) + AnthropicAPIKeyApiToken apiToken, @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) AnthropicAPIKeyType type) { this.apiToken = apiToken; + this.unparsed |= apiToken.unparsed; this.type = type; this.unparsed |= !type.isValid(); } - public AnthropicAPIKey apiToken(String apiToken) { + public AnthropicAPIKey apiToken(AnthropicAPIKeyApiToken apiToken) { this.apiToken = apiToken; + this.unparsed |= apiToken.unparsed; return this; } @@ -52,12 +55,15 @@ public AnthropicAPIKey apiToken(String apiToken) { */ @JsonProperty(JSON_PROPERTY_API_TOKEN) @JsonInclude(value = JsonInclude.Include.ALWAYS) - public String getApiToken() { + public AnthropicAPIKeyApiToken getApiToken() { return apiToken; } - public void setApiToken(String apiToken) { + public void setApiToken(AnthropicAPIKeyApiToken apiToken) { this.apiToken = apiToken; + if (apiToken != null) { + this.unparsed |= apiToken.unparsed; + } } public AnthropicAPIKey type(AnthropicAPIKeyType type) { diff --git a/src/main/java/com/datadog/api/client/v2/model/AnthropicAPIKeyApiToken.java b/src/main/java/com/datadog/api/client/v2/model/AnthropicAPIKeyApiToken.java new file mode 100644 index 00000000000..3c0357764ef --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/AnthropicAPIKeyApiToken.java @@ -0,0 +1,288 @@ +/* + * 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 = AnthropicAPIKeyApiToken.AnthropicAPIKeyApiTokenDeserializer.class) +@JsonSerialize(using = AnthropicAPIKeyApiToken.AnthropicAPIKeyApiTokenSerializer.class) +public class AnthropicAPIKeyApiToken extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(AnthropicAPIKeyApiToken.class.getName()); + + @JsonIgnore public boolean unparsed = false; + + public static class AnthropicAPIKeyApiTokenSerializer + extends StdSerializer { + public AnthropicAPIKeyApiTokenSerializer(Class t) { + super(t); + } + + public AnthropicAPIKeyApiTokenSerializer() { + this(null); + } + + @Override + public void serialize( + AnthropicAPIKeyApiToken value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class AnthropicAPIKeyApiTokenDeserializer + extends StdDeserializer { + public AnthropicAPIKeyApiTokenDeserializer() { + this(AnthropicAPIKeyApiToken.class); + } + + public AnthropicAPIKeyApiTokenDeserializer(Class vc) { + super(vc); + } + + @Override + public AnthropicAPIKeyApiToken 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 String + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (String.class.equals(Integer.class) + || String.class.equals(Long.class) + || String.class.equals(Float.class) + || String.class.equals(Double.class) + || String.class.equals(Boolean.class) + || String.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((String.class.equals(Integer.class) || String.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((String.class.equals(Float.class) || String.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (String.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (String.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(String.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. + deserialized = tmp; + match++; + + log.log(Level.FINER, "Input data matches schema 'String'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'String'", e); + } + + // deserialize ActionConnectionAWSSecretsManagerReference + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = + tree.traverse(jp.getCodec()) + .readValueAs(ActionConnectionAWSSecretsManagerReference.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 (!((ActionConnectionAWSSecretsManagerReference) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log( + Level.FINER, + "Input data matches schema 'ActionConnectionAWSSecretsManagerReference'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'ActionConnectionAWSSecretsManagerReference'", + e); + } + + AnthropicAPIKeyApiToken ret = new AnthropicAPIKeyApiToken(); + 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 AnthropicAPIKeyApiToken getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + throw new JsonMappingException(ctxt.getParser(), "AnthropicAPIKeyApiToken cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public AnthropicAPIKeyApiToken() { + super("oneOf", Boolean.FALSE); + } + + public AnthropicAPIKeyApiToken(String o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public AnthropicAPIKeyApiToken(ActionConnectionAWSSecretsManagerReference o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("String", new GenericType() {}); + schemas.put( + "ActionConnectionAWSSecretsManagerReference", + new GenericType() {}); + JSON.registerDescendants(AnthropicAPIKeyApiToken.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map getSchemas() { + return AnthropicAPIKeyApiToken.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: String, ActionConnectionAWSSecretsManagerReference + * + *

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(String.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + if (JSON.isInstanceOf( + ActionConnectionAWSSecretsManagerReference.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 String, ActionConnectionAWSSecretsManagerReference"); + } + + /** + * Get the actual instance, which can be the following: String, + * ActionConnectionAWSSecretsManagerReference + * + * @return The actual instance (String, ActionConnectionAWSSecretsManagerReference) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `String`. If the actual instance is not `String`, the + * ClassCastException will be thrown. + * + * @return The actual instance of `String` + * @throws ClassCastException if the instance is not `String` + */ + public String getString() throws ClassCastException { + return (String) super.getActualInstance(); + } + + /** + * Get the actual instance of `ActionConnectionAWSSecretsManagerReference`. If the actual instance + * is not `ActionConnectionAWSSecretsManagerReference`, the ClassCastException will be thrown. + * + * @return The actual instance of `ActionConnectionAWSSecretsManagerReference` + * @throws ClassCastException if the instance is not `ActionConnectionAWSSecretsManagerReference` + */ + public ActionConnectionAWSSecretsManagerReference getActionConnectionAWSSecretsManagerReference() + throws ClassCastException { + return (ActionConnectionAWSSecretsManagerReference) super.getActualInstance(); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/AnthropicAPIKeyUpdate.java b/src/main/java/com/datadog/api/client/v2/model/AnthropicAPIKeyUpdate.java index 5979c73c6b1..41f0aff0e77 100644 --- a/src/main/java/com/datadog/api/client/v2/model/AnthropicAPIKeyUpdate.java +++ b/src/main/java/com/datadog/api/client/v2/model/AnthropicAPIKeyUpdate.java @@ -27,7 +27,7 @@ public class AnthropicAPIKeyUpdate { @JsonIgnore public boolean unparsed = false; public static final String JSON_PROPERTY_API_TOKEN = "api_token"; - private String apiToken; + private AnthropicAPIKeyUpdateApiToken apiToken; public static final String JSON_PROPERTY_TYPE = "type"; private AnthropicAPIKeyType type; @@ -41,8 +41,9 @@ public AnthropicAPIKeyUpdate( this.unparsed |= !type.isValid(); } - public AnthropicAPIKeyUpdate apiToken(String apiToken) { + public AnthropicAPIKeyUpdate apiToken(AnthropicAPIKeyUpdateApiToken apiToken) { this.apiToken = apiToken; + this.unparsed |= apiToken.unparsed; return this; } @@ -54,12 +55,15 @@ public AnthropicAPIKeyUpdate apiToken(String apiToken) { @jakarta.annotation.Nullable @JsonProperty(JSON_PROPERTY_API_TOKEN) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public String getApiToken() { + public AnthropicAPIKeyUpdateApiToken getApiToken() { return apiToken; } - public void setApiToken(String apiToken) { + public void setApiToken(AnthropicAPIKeyUpdateApiToken apiToken) { this.apiToken = apiToken; + if (apiToken != null) { + this.unparsed |= apiToken.unparsed; + } } public AnthropicAPIKeyUpdate type(AnthropicAPIKeyType type) { diff --git a/src/main/java/com/datadog/api/client/v2/model/AnthropicAPIKeyUpdateApiToken.java b/src/main/java/com/datadog/api/client/v2/model/AnthropicAPIKeyUpdateApiToken.java new file mode 100644 index 00000000000..fffa825de49 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/AnthropicAPIKeyUpdateApiToken.java @@ -0,0 +1,291 @@ +/* + * 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 = AnthropicAPIKeyUpdateApiToken.AnthropicAPIKeyUpdateApiTokenDeserializer.class) +@JsonSerialize(using = AnthropicAPIKeyUpdateApiToken.AnthropicAPIKeyUpdateApiTokenSerializer.class) +public class AnthropicAPIKeyUpdateApiToken extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(AnthropicAPIKeyUpdateApiToken.class.getName()); + + @JsonIgnore public boolean unparsed = false; + + public static class AnthropicAPIKeyUpdateApiTokenSerializer + extends StdSerializer { + public AnthropicAPIKeyUpdateApiTokenSerializer(Class t) { + super(t); + } + + public AnthropicAPIKeyUpdateApiTokenSerializer() { + this(null); + } + + @Override + public void serialize( + AnthropicAPIKeyUpdateApiToken value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class AnthropicAPIKeyUpdateApiTokenDeserializer + extends StdDeserializer { + public AnthropicAPIKeyUpdateApiTokenDeserializer() { + this(AnthropicAPIKeyUpdateApiToken.class); + } + + public AnthropicAPIKeyUpdateApiTokenDeserializer(Class vc) { + super(vc); + } + + @Override + public AnthropicAPIKeyUpdateApiToken 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 String + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (String.class.equals(Integer.class) + || String.class.equals(Long.class) + || String.class.equals(Float.class) + || String.class.equals(Double.class) + || String.class.equals(Boolean.class) + || String.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((String.class.equals(Integer.class) || String.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((String.class.equals(Float.class) || String.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (String.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (String.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(String.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. + deserialized = tmp; + match++; + + log.log(Level.FINER, "Input data matches schema 'String'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'String'", e); + } + + // deserialize ActionConnectionAWSSecretsManagerReference + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = + tree.traverse(jp.getCodec()) + .readValueAs(ActionConnectionAWSSecretsManagerReference.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 (!((ActionConnectionAWSSecretsManagerReference) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log( + Level.FINER, + "Input data matches schema 'ActionConnectionAWSSecretsManagerReference'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'ActionConnectionAWSSecretsManagerReference'", + e); + } + + AnthropicAPIKeyUpdateApiToken ret = new AnthropicAPIKeyUpdateApiToken(); + 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 AnthropicAPIKeyUpdateApiToken getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + throw new JsonMappingException( + ctxt.getParser(), "AnthropicAPIKeyUpdateApiToken cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public AnthropicAPIKeyUpdateApiToken() { + super("oneOf", Boolean.FALSE); + } + + public AnthropicAPIKeyUpdateApiToken(String o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public AnthropicAPIKeyUpdateApiToken(ActionConnectionAWSSecretsManagerReference o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("String", new GenericType() {}); + schemas.put( + "ActionConnectionAWSSecretsManagerReference", + new GenericType() {}); + JSON.registerDescendants( + AnthropicAPIKeyUpdateApiToken.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map getSchemas() { + return AnthropicAPIKeyUpdateApiToken.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: String, ActionConnectionAWSSecretsManagerReference + * + *

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(String.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + if (JSON.isInstanceOf( + ActionConnectionAWSSecretsManagerReference.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 String, ActionConnectionAWSSecretsManagerReference"); + } + + /** + * Get the actual instance, which can be the following: String, + * ActionConnectionAWSSecretsManagerReference + * + * @return The actual instance (String, ActionConnectionAWSSecretsManagerReference) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `String`. If the actual instance is not `String`, the + * ClassCastException will be thrown. + * + * @return The actual instance of `String` + * @throws ClassCastException if the instance is not `String` + */ + public String getString() throws ClassCastException { + return (String) super.getActualInstance(); + } + + /** + * Get the actual instance of `ActionConnectionAWSSecretsManagerReference`. If the actual instance + * is not `ActionConnectionAWSSecretsManagerReference`, the ClassCastException will be thrown. + * + * @return The actual instance of `ActionConnectionAWSSecretsManagerReference` + * @throws ClassCastException if the instance is not `ActionConnectionAWSSecretsManagerReference` + */ + public ActionConnectionAWSSecretsManagerReference getActionConnectionAWSSecretsManagerReference() + throws ClassCastException { + return (ActionConnectionAWSSecretsManagerReference) super.getActualInstance(); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/AsanaAccessToken.java b/src/main/java/com/datadog/api/client/v2/model/AsanaAccessToken.java index 5c775d5ee60..9ba5fef45b4 100644 --- a/src/main/java/com/datadog/api/client/v2/model/AsanaAccessToken.java +++ b/src/main/java/com/datadog/api/client/v2/model/AsanaAccessToken.java @@ -27,7 +27,7 @@ public class AsanaAccessToken { @JsonIgnore public boolean unparsed = false; public static final String JSON_PROPERTY_ACCESS_TOKEN = "access_token"; - private String accessToken; + private AsanaAccessTokenAccessToken accessToken; public static final String JSON_PROPERTY_TYPE = "type"; private AsanaAccessTokenType type; @@ -36,15 +36,18 @@ public AsanaAccessToken() {} @JsonCreator public AsanaAccessToken( - @JsonProperty(required = true, value = JSON_PROPERTY_ACCESS_TOKEN) String accessToken, + @JsonProperty(required = true, value = JSON_PROPERTY_ACCESS_TOKEN) + AsanaAccessTokenAccessToken accessToken, @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) AsanaAccessTokenType type) { this.accessToken = accessToken; + this.unparsed |= accessToken.unparsed; this.type = type; this.unparsed |= !type.isValid(); } - public AsanaAccessToken accessToken(String accessToken) { + public AsanaAccessToken accessToken(AsanaAccessTokenAccessToken accessToken) { this.accessToken = accessToken; + this.unparsed |= accessToken.unparsed; return this; } @@ -55,12 +58,15 @@ public AsanaAccessToken accessToken(String accessToken) { */ @JsonProperty(JSON_PROPERTY_ACCESS_TOKEN) @JsonInclude(value = JsonInclude.Include.ALWAYS) - public String getAccessToken() { + public AsanaAccessTokenAccessToken getAccessToken() { return accessToken; } - public void setAccessToken(String accessToken) { + public void setAccessToken(AsanaAccessTokenAccessToken accessToken) { this.accessToken = accessToken; + if (accessToken != null) { + this.unparsed |= accessToken.unparsed; + } } public AsanaAccessToken type(AsanaAccessTokenType type) { diff --git a/src/main/java/com/datadog/api/client/v2/model/AsanaAccessTokenAccessToken.java b/src/main/java/com/datadog/api/client/v2/model/AsanaAccessTokenAccessToken.java new file mode 100644 index 00000000000..74c7f234265 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/AsanaAccessTokenAccessToken.java @@ -0,0 +1,290 @@ +/* + * 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 = AsanaAccessTokenAccessToken.AsanaAccessTokenAccessTokenDeserializer.class) +@JsonSerialize(using = AsanaAccessTokenAccessToken.AsanaAccessTokenAccessTokenSerializer.class) +public class AsanaAccessTokenAccessToken extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(AsanaAccessTokenAccessToken.class.getName()); + + @JsonIgnore public boolean unparsed = false; + + public static class AsanaAccessTokenAccessTokenSerializer + extends StdSerializer { + public AsanaAccessTokenAccessTokenSerializer(Class t) { + super(t); + } + + public AsanaAccessTokenAccessTokenSerializer() { + this(null); + } + + @Override + public void serialize( + AsanaAccessTokenAccessToken value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class AsanaAccessTokenAccessTokenDeserializer + extends StdDeserializer { + public AsanaAccessTokenAccessTokenDeserializer() { + this(AsanaAccessTokenAccessToken.class); + } + + public AsanaAccessTokenAccessTokenDeserializer(Class vc) { + super(vc); + } + + @Override + public AsanaAccessTokenAccessToken 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 String + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (String.class.equals(Integer.class) + || String.class.equals(Long.class) + || String.class.equals(Float.class) + || String.class.equals(Double.class) + || String.class.equals(Boolean.class) + || String.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((String.class.equals(Integer.class) || String.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((String.class.equals(Float.class) || String.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (String.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (String.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(String.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. + deserialized = tmp; + match++; + + log.log(Level.FINER, "Input data matches schema 'String'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'String'", e); + } + + // deserialize ActionConnectionAWSSecretsManagerReference + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = + tree.traverse(jp.getCodec()) + .readValueAs(ActionConnectionAWSSecretsManagerReference.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 (!((ActionConnectionAWSSecretsManagerReference) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log( + Level.FINER, + "Input data matches schema 'ActionConnectionAWSSecretsManagerReference'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'ActionConnectionAWSSecretsManagerReference'", + e); + } + + AsanaAccessTokenAccessToken ret = new AsanaAccessTokenAccessToken(); + 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 AsanaAccessTokenAccessToken getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + throw new JsonMappingException( + ctxt.getParser(), "AsanaAccessTokenAccessToken cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public AsanaAccessTokenAccessToken() { + super("oneOf", Boolean.FALSE); + } + + public AsanaAccessTokenAccessToken(String o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public AsanaAccessTokenAccessToken(ActionConnectionAWSSecretsManagerReference o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("String", new GenericType() {}); + schemas.put( + "ActionConnectionAWSSecretsManagerReference", + new GenericType() {}); + JSON.registerDescendants( + AsanaAccessTokenAccessToken.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map getSchemas() { + return AsanaAccessTokenAccessToken.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: String, ActionConnectionAWSSecretsManagerReference + * + *

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(String.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + if (JSON.isInstanceOf( + ActionConnectionAWSSecretsManagerReference.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 String, ActionConnectionAWSSecretsManagerReference"); + } + + /** + * Get the actual instance, which can be the following: String, + * ActionConnectionAWSSecretsManagerReference + * + * @return The actual instance (String, ActionConnectionAWSSecretsManagerReference) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `String`. If the actual instance is not `String`, the + * ClassCastException will be thrown. + * + * @return The actual instance of `String` + * @throws ClassCastException if the instance is not `String` + */ + public String getString() throws ClassCastException { + return (String) super.getActualInstance(); + } + + /** + * Get the actual instance of `ActionConnectionAWSSecretsManagerReference`. If the actual instance + * is not `ActionConnectionAWSSecretsManagerReference`, the ClassCastException will be thrown. + * + * @return The actual instance of `ActionConnectionAWSSecretsManagerReference` + * @throws ClassCastException if the instance is not `ActionConnectionAWSSecretsManagerReference` + */ + public ActionConnectionAWSSecretsManagerReference getActionConnectionAWSSecretsManagerReference() + throws ClassCastException { + return (ActionConnectionAWSSecretsManagerReference) super.getActualInstance(); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/AsanaAccessTokenUpdate.java b/src/main/java/com/datadog/api/client/v2/model/AsanaAccessTokenUpdate.java index 15509f9958e..ca84880c482 100644 --- a/src/main/java/com/datadog/api/client/v2/model/AsanaAccessTokenUpdate.java +++ b/src/main/java/com/datadog/api/client/v2/model/AsanaAccessTokenUpdate.java @@ -27,7 +27,7 @@ public class AsanaAccessTokenUpdate { @JsonIgnore public boolean unparsed = false; public static final String JSON_PROPERTY_ACCESS_TOKEN = "access_token"; - private String accessToken; + private AsanaAccessTokenUpdateAccessToken accessToken; public static final String JSON_PROPERTY_TYPE = "type"; private AsanaAccessTokenType type; @@ -41,8 +41,9 @@ public AsanaAccessTokenUpdate( this.unparsed |= !type.isValid(); } - public AsanaAccessTokenUpdate accessToken(String accessToken) { + public AsanaAccessTokenUpdate accessToken(AsanaAccessTokenUpdateAccessToken accessToken) { this.accessToken = accessToken; + this.unparsed |= accessToken.unparsed; return this; } @@ -54,12 +55,15 @@ public AsanaAccessTokenUpdate accessToken(String accessToken) { @jakarta.annotation.Nullable @JsonProperty(JSON_PROPERTY_ACCESS_TOKEN) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public String getAccessToken() { + public AsanaAccessTokenUpdateAccessToken getAccessToken() { return accessToken; } - public void setAccessToken(String accessToken) { + public void setAccessToken(AsanaAccessTokenUpdateAccessToken accessToken) { this.accessToken = accessToken; + if (accessToken != null) { + this.unparsed |= accessToken.unparsed; + } } public AsanaAccessTokenUpdate type(AsanaAccessTokenType type) { diff --git a/src/main/java/com/datadog/api/client/v2/model/AsanaAccessTokenUpdateAccessToken.java b/src/main/java/com/datadog/api/client/v2/model/AsanaAccessTokenUpdateAccessToken.java new file mode 100644 index 00000000000..3e1db611974 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/AsanaAccessTokenUpdateAccessToken.java @@ -0,0 +1,293 @@ +/* + * 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 = AsanaAccessTokenUpdateAccessToken.AsanaAccessTokenUpdateAccessTokenDeserializer.class) +@JsonSerialize( + using = AsanaAccessTokenUpdateAccessToken.AsanaAccessTokenUpdateAccessTokenSerializer.class) +public class AsanaAccessTokenUpdateAccessToken extends AbstractOpenApiSchema { + private static final Logger log = + Logger.getLogger(AsanaAccessTokenUpdateAccessToken.class.getName()); + + @JsonIgnore public boolean unparsed = false; + + public static class AsanaAccessTokenUpdateAccessTokenSerializer + extends StdSerializer { + public AsanaAccessTokenUpdateAccessTokenSerializer(Class t) { + super(t); + } + + public AsanaAccessTokenUpdateAccessTokenSerializer() { + this(null); + } + + @Override + public void serialize( + AsanaAccessTokenUpdateAccessToken value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class AsanaAccessTokenUpdateAccessTokenDeserializer + extends StdDeserializer { + public AsanaAccessTokenUpdateAccessTokenDeserializer() { + this(AsanaAccessTokenUpdateAccessToken.class); + } + + public AsanaAccessTokenUpdateAccessTokenDeserializer(Class vc) { + super(vc); + } + + @Override + public AsanaAccessTokenUpdateAccessToken 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 String + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (String.class.equals(Integer.class) + || String.class.equals(Long.class) + || String.class.equals(Float.class) + || String.class.equals(Double.class) + || String.class.equals(Boolean.class) + || String.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((String.class.equals(Integer.class) || String.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((String.class.equals(Float.class) || String.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (String.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (String.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(String.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. + deserialized = tmp; + match++; + + log.log(Level.FINER, "Input data matches schema 'String'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'String'", e); + } + + // deserialize ActionConnectionAWSSecretsManagerReference + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = + tree.traverse(jp.getCodec()) + .readValueAs(ActionConnectionAWSSecretsManagerReference.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 (!((ActionConnectionAWSSecretsManagerReference) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log( + Level.FINER, + "Input data matches schema 'ActionConnectionAWSSecretsManagerReference'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'ActionConnectionAWSSecretsManagerReference'", + e); + } + + AsanaAccessTokenUpdateAccessToken ret = new AsanaAccessTokenUpdateAccessToken(); + 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 AsanaAccessTokenUpdateAccessToken getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + throw new JsonMappingException( + ctxt.getParser(), "AsanaAccessTokenUpdateAccessToken cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public AsanaAccessTokenUpdateAccessToken() { + super("oneOf", Boolean.FALSE); + } + + public AsanaAccessTokenUpdateAccessToken(String o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public AsanaAccessTokenUpdateAccessToken(ActionConnectionAWSSecretsManagerReference o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("String", new GenericType() {}); + schemas.put( + "ActionConnectionAWSSecretsManagerReference", + new GenericType() {}); + JSON.registerDescendants( + AsanaAccessTokenUpdateAccessToken.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map getSchemas() { + return AsanaAccessTokenUpdateAccessToken.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: String, ActionConnectionAWSSecretsManagerReference + * + *

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(String.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + if (JSON.isInstanceOf( + ActionConnectionAWSSecretsManagerReference.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 String, ActionConnectionAWSSecretsManagerReference"); + } + + /** + * Get the actual instance, which can be the following: String, + * ActionConnectionAWSSecretsManagerReference + * + * @return The actual instance (String, ActionConnectionAWSSecretsManagerReference) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `String`. If the actual instance is not `String`, the + * ClassCastException will be thrown. + * + * @return The actual instance of `String` + * @throws ClassCastException if the instance is not `String` + */ + public String getString() throws ClassCastException { + return (String) super.getActualInstance(); + } + + /** + * Get the actual instance of `ActionConnectionAWSSecretsManagerReference`. If the actual instance + * is not `ActionConnectionAWSSecretsManagerReference`, the ClassCastException will be thrown. + * + * @return The actual instance of `ActionConnectionAWSSecretsManagerReference` + * @throws ClassCastException if the instance is not `ActionConnectionAWSSecretsManagerReference` + */ + public ActionConnectionAWSSecretsManagerReference getActionConnectionAWSSecretsManagerReference() + throws ClassCastException { + return (ActionConnectionAWSSecretsManagerReference) super.getActualInstance(); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/CircleCIAPIKey.java b/src/main/java/com/datadog/api/client/v2/model/CircleCIAPIKey.java index 95e15eb4bd3..8f477d1d8e2 100644 --- a/src/main/java/com/datadog/api/client/v2/model/CircleCIAPIKey.java +++ b/src/main/java/com/datadog/api/client/v2/model/CircleCIAPIKey.java @@ -24,7 +24,7 @@ public class CircleCIAPIKey { @JsonIgnore public boolean unparsed = false; public static final String JSON_PROPERTY_API_TOKEN = "api_token"; - private String apiToken; + private CircleCIAPIKeyApiToken apiToken; public static final String JSON_PROPERTY_TYPE = "type"; private CircleCIAPIKeyType type; @@ -33,15 +33,18 @@ public CircleCIAPIKey() {} @JsonCreator public CircleCIAPIKey( - @JsonProperty(required = true, value = JSON_PROPERTY_API_TOKEN) String apiToken, + @JsonProperty(required = true, value = JSON_PROPERTY_API_TOKEN) + CircleCIAPIKeyApiToken apiToken, @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) CircleCIAPIKeyType type) { this.apiToken = apiToken; + this.unparsed |= apiToken.unparsed; this.type = type; this.unparsed |= !type.isValid(); } - public CircleCIAPIKey apiToken(String apiToken) { + public CircleCIAPIKey apiToken(CircleCIAPIKeyApiToken apiToken) { this.apiToken = apiToken; + this.unparsed |= apiToken.unparsed; return this; } @@ -52,12 +55,15 @@ public CircleCIAPIKey apiToken(String apiToken) { */ @JsonProperty(JSON_PROPERTY_API_TOKEN) @JsonInclude(value = JsonInclude.Include.ALWAYS) - public String getApiToken() { + public CircleCIAPIKeyApiToken getApiToken() { return apiToken; } - public void setApiToken(String apiToken) { + public void setApiToken(CircleCIAPIKeyApiToken apiToken) { this.apiToken = apiToken; + if (apiToken != null) { + this.unparsed |= apiToken.unparsed; + } } public CircleCIAPIKey type(CircleCIAPIKeyType type) { diff --git a/src/main/java/com/datadog/api/client/v2/model/CircleCIAPIKeyApiToken.java b/src/main/java/com/datadog/api/client/v2/model/CircleCIAPIKeyApiToken.java new file mode 100644 index 00000000000..166b819c51f --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/CircleCIAPIKeyApiToken.java @@ -0,0 +1,288 @@ +/* + * 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 = CircleCIAPIKeyApiToken.CircleCIAPIKeyApiTokenDeserializer.class) +@JsonSerialize(using = CircleCIAPIKeyApiToken.CircleCIAPIKeyApiTokenSerializer.class) +public class CircleCIAPIKeyApiToken extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(CircleCIAPIKeyApiToken.class.getName()); + + @JsonIgnore public boolean unparsed = false; + + public static class CircleCIAPIKeyApiTokenSerializer + extends StdSerializer { + public CircleCIAPIKeyApiTokenSerializer(Class t) { + super(t); + } + + public CircleCIAPIKeyApiTokenSerializer() { + this(null); + } + + @Override + public void serialize( + CircleCIAPIKeyApiToken value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class CircleCIAPIKeyApiTokenDeserializer + extends StdDeserializer { + public CircleCIAPIKeyApiTokenDeserializer() { + this(CircleCIAPIKeyApiToken.class); + } + + public CircleCIAPIKeyApiTokenDeserializer(Class vc) { + super(vc); + } + + @Override + public CircleCIAPIKeyApiToken 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 String + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (String.class.equals(Integer.class) + || String.class.equals(Long.class) + || String.class.equals(Float.class) + || String.class.equals(Double.class) + || String.class.equals(Boolean.class) + || String.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((String.class.equals(Integer.class) || String.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((String.class.equals(Float.class) || String.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (String.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (String.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(String.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. + deserialized = tmp; + match++; + + log.log(Level.FINER, "Input data matches schema 'String'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'String'", e); + } + + // deserialize ActionConnectionAWSSecretsManagerReference + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = + tree.traverse(jp.getCodec()) + .readValueAs(ActionConnectionAWSSecretsManagerReference.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 (!((ActionConnectionAWSSecretsManagerReference) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log( + Level.FINER, + "Input data matches schema 'ActionConnectionAWSSecretsManagerReference'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'ActionConnectionAWSSecretsManagerReference'", + e); + } + + CircleCIAPIKeyApiToken ret = new CircleCIAPIKeyApiToken(); + 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 CircleCIAPIKeyApiToken getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + throw new JsonMappingException(ctxt.getParser(), "CircleCIAPIKeyApiToken cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public CircleCIAPIKeyApiToken() { + super("oneOf", Boolean.FALSE); + } + + public CircleCIAPIKeyApiToken(String o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public CircleCIAPIKeyApiToken(ActionConnectionAWSSecretsManagerReference o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("String", new GenericType() {}); + schemas.put( + "ActionConnectionAWSSecretsManagerReference", + new GenericType() {}); + JSON.registerDescendants(CircleCIAPIKeyApiToken.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map getSchemas() { + return CircleCIAPIKeyApiToken.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: String, ActionConnectionAWSSecretsManagerReference + * + *

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(String.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + if (JSON.isInstanceOf( + ActionConnectionAWSSecretsManagerReference.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 String, ActionConnectionAWSSecretsManagerReference"); + } + + /** + * Get the actual instance, which can be the following: String, + * ActionConnectionAWSSecretsManagerReference + * + * @return The actual instance (String, ActionConnectionAWSSecretsManagerReference) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `String`. If the actual instance is not `String`, the + * ClassCastException will be thrown. + * + * @return The actual instance of `String` + * @throws ClassCastException if the instance is not `String` + */ + public String getString() throws ClassCastException { + return (String) super.getActualInstance(); + } + + /** + * Get the actual instance of `ActionConnectionAWSSecretsManagerReference`. If the actual instance + * is not `ActionConnectionAWSSecretsManagerReference`, the ClassCastException will be thrown. + * + * @return The actual instance of `ActionConnectionAWSSecretsManagerReference` + * @throws ClassCastException if the instance is not `ActionConnectionAWSSecretsManagerReference` + */ + public ActionConnectionAWSSecretsManagerReference getActionConnectionAWSSecretsManagerReference() + throws ClassCastException { + return (ActionConnectionAWSSecretsManagerReference) super.getActualInstance(); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/CircleCIAPIKeyUpdate.java b/src/main/java/com/datadog/api/client/v2/model/CircleCIAPIKeyUpdate.java index 29b28fcffb1..5b8169bd08c 100644 --- a/src/main/java/com/datadog/api/client/v2/model/CircleCIAPIKeyUpdate.java +++ b/src/main/java/com/datadog/api/client/v2/model/CircleCIAPIKeyUpdate.java @@ -27,7 +27,7 @@ public class CircleCIAPIKeyUpdate { @JsonIgnore public boolean unparsed = false; public static final String JSON_PROPERTY_API_TOKEN = "api_token"; - private String apiToken; + private CircleCIAPIKeyUpdateApiToken apiToken; public static final String JSON_PROPERTY_TYPE = "type"; private CircleCIAPIKeyType type; @@ -41,8 +41,9 @@ public CircleCIAPIKeyUpdate( this.unparsed |= !type.isValid(); } - public CircleCIAPIKeyUpdate apiToken(String apiToken) { + public CircleCIAPIKeyUpdate apiToken(CircleCIAPIKeyUpdateApiToken apiToken) { this.apiToken = apiToken; + this.unparsed |= apiToken.unparsed; return this; } @@ -54,12 +55,15 @@ public CircleCIAPIKeyUpdate apiToken(String apiToken) { @jakarta.annotation.Nullable @JsonProperty(JSON_PROPERTY_API_TOKEN) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public String getApiToken() { + public CircleCIAPIKeyUpdateApiToken getApiToken() { return apiToken; } - public void setApiToken(String apiToken) { + public void setApiToken(CircleCIAPIKeyUpdateApiToken apiToken) { this.apiToken = apiToken; + if (apiToken != null) { + this.unparsed |= apiToken.unparsed; + } } public CircleCIAPIKeyUpdate type(CircleCIAPIKeyType type) { diff --git a/src/main/java/com/datadog/api/client/v2/model/CircleCIAPIKeyUpdateApiToken.java b/src/main/java/com/datadog/api/client/v2/model/CircleCIAPIKeyUpdateApiToken.java new file mode 100644 index 00000000000..2738384e289 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/CircleCIAPIKeyUpdateApiToken.java @@ -0,0 +1,291 @@ +/* + * 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 = CircleCIAPIKeyUpdateApiToken.CircleCIAPIKeyUpdateApiTokenDeserializer.class) +@JsonSerialize(using = CircleCIAPIKeyUpdateApiToken.CircleCIAPIKeyUpdateApiTokenSerializer.class) +public class CircleCIAPIKeyUpdateApiToken extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(CircleCIAPIKeyUpdateApiToken.class.getName()); + + @JsonIgnore public boolean unparsed = false; + + public static class CircleCIAPIKeyUpdateApiTokenSerializer + extends StdSerializer { + public CircleCIAPIKeyUpdateApiTokenSerializer(Class t) { + super(t); + } + + public CircleCIAPIKeyUpdateApiTokenSerializer() { + this(null); + } + + @Override + public void serialize( + CircleCIAPIKeyUpdateApiToken value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class CircleCIAPIKeyUpdateApiTokenDeserializer + extends StdDeserializer { + public CircleCIAPIKeyUpdateApiTokenDeserializer() { + this(CircleCIAPIKeyUpdateApiToken.class); + } + + public CircleCIAPIKeyUpdateApiTokenDeserializer(Class vc) { + super(vc); + } + + @Override + public CircleCIAPIKeyUpdateApiToken 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 String + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (String.class.equals(Integer.class) + || String.class.equals(Long.class) + || String.class.equals(Float.class) + || String.class.equals(Double.class) + || String.class.equals(Boolean.class) + || String.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((String.class.equals(Integer.class) || String.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((String.class.equals(Float.class) || String.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (String.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (String.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(String.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. + deserialized = tmp; + match++; + + log.log(Level.FINER, "Input data matches schema 'String'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'String'", e); + } + + // deserialize ActionConnectionAWSSecretsManagerReference + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = + tree.traverse(jp.getCodec()) + .readValueAs(ActionConnectionAWSSecretsManagerReference.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 (!((ActionConnectionAWSSecretsManagerReference) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log( + Level.FINER, + "Input data matches schema 'ActionConnectionAWSSecretsManagerReference'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'ActionConnectionAWSSecretsManagerReference'", + e); + } + + CircleCIAPIKeyUpdateApiToken ret = new CircleCIAPIKeyUpdateApiToken(); + 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 CircleCIAPIKeyUpdateApiToken getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + throw new JsonMappingException( + ctxt.getParser(), "CircleCIAPIKeyUpdateApiToken cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public CircleCIAPIKeyUpdateApiToken() { + super("oneOf", Boolean.FALSE); + } + + public CircleCIAPIKeyUpdateApiToken(String o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public CircleCIAPIKeyUpdateApiToken(ActionConnectionAWSSecretsManagerReference o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("String", new GenericType() {}); + schemas.put( + "ActionConnectionAWSSecretsManagerReference", + new GenericType() {}); + JSON.registerDescendants( + CircleCIAPIKeyUpdateApiToken.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map getSchemas() { + return CircleCIAPIKeyUpdateApiToken.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: String, ActionConnectionAWSSecretsManagerReference + * + *

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(String.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + if (JSON.isInstanceOf( + ActionConnectionAWSSecretsManagerReference.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 String, ActionConnectionAWSSecretsManagerReference"); + } + + /** + * Get the actual instance, which can be the following: String, + * ActionConnectionAWSSecretsManagerReference + * + * @return The actual instance (String, ActionConnectionAWSSecretsManagerReference) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `String`. If the actual instance is not `String`, the + * ClassCastException will be thrown. + * + * @return The actual instance of `String` + * @throws ClassCastException if the instance is not `String` + */ + public String getString() throws ClassCastException { + return (String) super.getActualInstance(); + } + + /** + * Get the actual instance of `ActionConnectionAWSSecretsManagerReference`. If the actual instance + * is not `ActionConnectionAWSSecretsManagerReference`, the ClassCastException will be thrown. + * + * @return The actual instance of `ActionConnectionAWSSecretsManagerReference` + * @throws ClassCastException if the instance is not `ActionConnectionAWSSecretsManagerReference` + */ + public ActionConnectionAWSSecretsManagerReference getActionConnectionAWSSecretsManagerReference() + throws ClassCastException { + return (ActionConnectionAWSSecretsManagerReference) super.getActualInstance(); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/ClickupAPIKey.java b/src/main/java/com/datadog/api/client/v2/model/ClickupAPIKey.java index 495c68dbb48..8f04a5e7e7f 100644 --- a/src/main/java/com/datadog/api/client/v2/model/ClickupAPIKey.java +++ b/src/main/java/com/datadog/api/client/v2/model/ClickupAPIKey.java @@ -24,7 +24,7 @@ public class ClickupAPIKey { @JsonIgnore public boolean unparsed = false; public static final String JSON_PROPERTY_API_TOKEN = "api_token"; - private String apiToken; + private ClickupAPIKeyApiToken apiToken; public static final String JSON_PROPERTY_TYPE = "type"; private ClickupAPIKeyType type; @@ -33,15 +33,18 @@ public ClickupAPIKey() {} @JsonCreator public ClickupAPIKey( - @JsonProperty(required = true, value = JSON_PROPERTY_API_TOKEN) String apiToken, + @JsonProperty(required = true, value = JSON_PROPERTY_API_TOKEN) + ClickupAPIKeyApiToken apiToken, @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) ClickupAPIKeyType type) { this.apiToken = apiToken; + this.unparsed |= apiToken.unparsed; this.type = type; this.unparsed |= !type.isValid(); } - public ClickupAPIKey apiToken(String apiToken) { + public ClickupAPIKey apiToken(ClickupAPIKeyApiToken apiToken) { this.apiToken = apiToken; + this.unparsed |= apiToken.unparsed; return this; } @@ -52,12 +55,15 @@ public ClickupAPIKey apiToken(String apiToken) { */ @JsonProperty(JSON_PROPERTY_API_TOKEN) @JsonInclude(value = JsonInclude.Include.ALWAYS) - public String getApiToken() { + public ClickupAPIKeyApiToken getApiToken() { return apiToken; } - public void setApiToken(String apiToken) { + public void setApiToken(ClickupAPIKeyApiToken apiToken) { this.apiToken = apiToken; + if (apiToken != null) { + this.unparsed |= apiToken.unparsed; + } } public ClickupAPIKey type(ClickupAPIKeyType type) { diff --git a/src/main/java/com/datadog/api/client/v2/model/ClickupAPIKeyApiToken.java b/src/main/java/com/datadog/api/client/v2/model/ClickupAPIKeyApiToken.java new file mode 100644 index 00000000000..a541ca1b094 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ClickupAPIKeyApiToken.java @@ -0,0 +1,287 @@ +/* + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.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 = ClickupAPIKeyApiToken.ClickupAPIKeyApiTokenDeserializer.class) +@JsonSerialize(using = ClickupAPIKeyApiToken.ClickupAPIKeyApiTokenSerializer.class) +public class ClickupAPIKeyApiToken extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(ClickupAPIKeyApiToken.class.getName()); + + @JsonIgnore public boolean unparsed = false; + + public static class ClickupAPIKeyApiTokenSerializer extends StdSerializer { + public ClickupAPIKeyApiTokenSerializer(Class t) { + super(t); + } + + public ClickupAPIKeyApiTokenSerializer() { + this(null); + } + + @Override + public void serialize( + ClickupAPIKeyApiToken value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class ClickupAPIKeyApiTokenDeserializer + extends StdDeserializer { + public ClickupAPIKeyApiTokenDeserializer() { + this(ClickupAPIKeyApiToken.class); + } + + public ClickupAPIKeyApiTokenDeserializer(Class vc) { + super(vc); + } + + @Override + public ClickupAPIKeyApiToken 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 String + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (String.class.equals(Integer.class) + || String.class.equals(Long.class) + || String.class.equals(Float.class) + || String.class.equals(Double.class) + || String.class.equals(Boolean.class) + || String.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((String.class.equals(Integer.class) || String.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((String.class.equals(Float.class) || String.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (String.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (String.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(String.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. + deserialized = tmp; + match++; + + log.log(Level.FINER, "Input data matches schema 'String'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'String'", e); + } + + // deserialize ActionConnectionAWSSecretsManagerReference + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = + tree.traverse(jp.getCodec()) + .readValueAs(ActionConnectionAWSSecretsManagerReference.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 (!((ActionConnectionAWSSecretsManagerReference) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log( + Level.FINER, + "Input data matches schema 'ActionConnectionAWSSecretsManagerReference'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'ActionConnectionAWSSecretsManagerReference'", + e); + } + + ClickupAPIKeyApiToken ret = new ClickupAPIKeyApiToken(); + 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 ClickupAPIKeyApiToken getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + throw new JsonMappingException(ctxt.getParser(), "ClickupAPIKeyApiToken cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public ClickupAPIKeyApiToken() { + super("oneOf", Boolean.FALSE); + } + + public ClickupAPIKeyApiToken(String o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public ClickupAPIKeyApiToken(ActionConnectionAWSSecretsManagerReference o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("String", new GenericType() {}); + schemas.put( + "ActionConnectionAWSSecretsManagerReference", + new GenericType() {}); + JSON.registerDescendants(ClickupAPIKeyApiToken.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map getSchemas() { + return ClickupAPIKeyApiToken.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: String, ActionConnectionAWSSecretsManagerReference + * + *

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(String.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + if (JSON.isInstanceOf( + ActionConnectionAWSSecretsManagerReference.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 String, ActionConnectionAWSSecretsManagerReference"); + } + + /** + * Get the actual instance, which can be the following: String, + * ActionConnectionAWSSecretsManagerReference + * + * @return The actual instance (String, ActionConnectionAWSSecretsManagerReference) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `String`. If the actual instance is not `String`, the + * ClassCastException will be thrown. + * + * @return The actual instance of `String` + * @throws ClassCastException if the instance is not `String` + */ + public String getString() throws ClassCastException { + return (String) super.getActualInstance(); + } + + /** + * Get the actual instance of `ActionConnectionAWSSecretsManagerReference`. If the actual instance + * is not `ActionConnectionAWSSecretsManagerReference`, the ClassCastException will be thrown. + * + * @return The actual instance of `ActionConnectionAWSSecretsManagerReference` + * @throws ClassCastException if the instance is not `ActionConnectionAWSSecretsManagerReference` + */ + public ActionConnectionAWSSecretsManagerReference getActionConnectionAWSSecretsManagerReference() + throws ClassCastException { + return (ActionConnectionAWSSecretsManagerReference) super.getActualInstance(); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/ClickupAPIKeyUpdate.java b/src/main/java/com/datadog/api/client/v2/model/ClickupAPIKeyUpdate.java index dc886471ea3..b74546c3d48 100644 --- a/src/main/java/com/datadog/api/client/v2/model/ClickupAPIKeyUpdate.java +++ b/src/main/java/com/datadog/api/client/v2/model/ClickupAPIKeyUpdate.java @@ -27,7 +27,7 @@ public class ClickupAPIKeyUpdate { @JsonIgnore public boolean unparsed = false; public static final String JSON_PROPERTY_API_TOKEN = "api_token"; - private String apiToken; + private ClickupAPIKeyUpdateApiToken apiToken; public static final String JSON_PROPERTY_TYPE = "type"; private ClickupAPIKeyType type; @@ -41,8 +41,9 @@ public ClickupAPIKeyUpdate( this.unparsed |= !type.isValid(); } - public ClickupAPIKeyUpdate apiToken(String apiToken) { + public ClickupAPIKeyUpdate apiToken(ClickupAPIKeyUpdateApiToken apiToken) { this.apiToken = apiToken; + this.unparsed |= apiToken.unparsed; return this; } @@ -54,12 +55,15 @@ public ClickupAPIKeyUpdate apiToken(String apiToken) { @jakarta.annotation.Nullable @JsonProperty(JSON_PROPERTY_API_TOKEN) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public String getApiToken() { + public ClickupAPIKeyUpdateApiToken getApiToken() { return apiToken; } - public void setApiToken(String apiToken) { + public void setApiToken(ClickupAPIKeyUpdateApiToken apiToken) { this.apiToken = apiToken; + if (apiToken != null) { + this.unparsed |= apiToken.unparsed; + } } public ClickupAPIKeyUpdate type(ClickupAPIKeyType type) { diff --git a/src/main/java/com/datadog/api/client/v2/model/ClickupAPIKeyUpdateApiToken.java b/src/main/java/com/datadog/api/client/v2/model/ClickupAPIKeyUpdateApiToken.java new file mode 100644 index 00000000000..e352608380d --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ClickupAPIKeyUpdateApiToken.java @@ -0,0 +1,290 @@ +/* + * 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 = ClickupAPIKeyUpdateApiToken.ClickupAPIKeyUpdateApiTokenDeserializer.class) +@JsonSerialize(using = ClickupAPIKeyUpdateApiToken.ClickupAPIKeyUpdateApiTokenSerializer.class) +public class ClickupAPIKeyUpdateApiToken extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(ClickupAPIKeyUpdateApiToken.class.getName()); + + @JsonIgnore public boolean unparsed = false; + + public static class ClickupAPIKeyUpdateApiTokenSerializer + extends StdSerializer { + public ClickupAPIKeyUpdateApiTokenSerializer(Class t) { + super(t); + } + + public ClickupAPIKeyUpdateApiTokenSerializer() { + this(null); + } + + @Override + public void serialize( + ClickupAPIKeyUpdateApiToken value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class ClickupAPIKeyUpdateApiTokenDeserializer + extends StdDeserializer { + public ClickupAPIKeyUpdateApiTokenDeserializer() { + this(ClickupAPIKeyUpdateApiToken.class); + } + + public ClickupAPIKeyUpdateApiTokenDeserializer(Class vc) { + super(vc); + } + + @Override + public ClickupAPIKeyUpdateApiToken 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 String + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (String.class.equals(Integer.class) + || String.class.equals(Long.class) + || String.class.equals(Float.class) + || String.class.equals(Double.class) + || String.class.equals(Boolean.class) + || String.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((String.class.equals(Integer.class) || String.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((String.class.equals(Float.class) || String.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (String.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (String.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(String.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. + deserialized = tmp; + match++; + + log.log(Level.FINER, "Input data matches schema 'String'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'String'", e); + } + + // deserialize ActionConnectionAWSSecretsManagerReference + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = + tree.traverse(jp.getCodec()) + .readValueAs(ActionConnectionAWSSecretsManagerReference.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 (!((ActionConnectionAWSSecretsManagerReference) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log( + Level.FINER, + "Input data matches schema 'ActionConnectionAWSSecretsManagerReference'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'ActionConnectionAWSSecretsManagerReference'", + e); + } + + ClickupAPIKeyUpdateApiToken ret = new ClickupAPIKeyUpdateApiToken(); + 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 ClickupAPIKeyUpdateApiToken getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + throw new JsonMappingException( + ctxt.getParser(), "ClickupAPIKeyUpdateApiToken cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public ClickupAPIKeyUpdateApiToken() { + super("oneOf", Boolean.FALSE); + } + + public ClickupAPIKeyUpdateApiToken(String o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public ClickupAPIKeyUpdateApiToken(ActionConnectionAWSSecretsManagerReference o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("String", new GenericType() {}); + schemas.put( + "ActionConnectionAWSSecretsManagerReference", + new GenericType() {}); + JSON.registerDescendants( + ClickupAPIKeyUpdateApiToken.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map getSchemas() { + return ClickupAPIKeyUpdateApiToken.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: String, ActionConnectionAWSSecretsManagerReference + * + *

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(String.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + if (JSON.isInstanceOf( + ActionConnectionAWSSecretsManagerReference.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 String, ActionConnectionAWSSecretsManagerReference"); + } + + /** + * Get the actual instance, which can be the following: String, + * ActionConnectionAWSSecretsManagerReference + * + * @return The actual instance (String, ActionConnectionAWSSecretsManagerReference) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `String`. If the actual instance is not `String`, the + * ClassCastException will be thrown. + * + * @return The actual instance of `String` + * @throws ClassCastException if the instance is not `String` + */ + public String getString() throws ClassCastException { + return (String) super.getActualInstance(); + } + + /** + * Get the actual instance of `ActionConnectionAWSSecretsManagerReference`. If the actual instance + * is not `ActionConnectionAWSSecretsManagerReference`, the ClassCastException will be thrown. + * + * @return The actual instance of `ActionConnectionAWSSecretsManagerReference` + * @throws ClassCastException if the instance is not `ActionConnectionAWSSecretsManagerReference` + */ + public ActionConnectionAWSSecretsManagerReference getActionConnectionAWSSecretsManagerReference() + throws ClassCastException { + return (ActionConnectionAWSSecretsManagerReference) super.getActualInstance(); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/CloudflareAPIToken.java b/src/main/java/com/datadog/api/client/v2/model/CloudflareAPIToken.java index 7a44638bf83..e0bc81f538c 100644 --- a/src/main/java/com/datadog/api/client/v2/model/CloudflareAPIToken.java +++ b/src/main/java/com/datadog/api/client/v2/model/CloudflareAPIToken.java @@ -27,7 +27,7 @@ public class CloudflareAPIToken { @JsonIgnore public boolean unparsed = false; public static final String JSON_PROPERTY_API_TOKEN = "api_token"; - private String apiToken; + private CloudflareAPITokenApiToken apiToken; public static final String JSON_PROPERTY_TYPE = "type"; private CloudflareAPITokenType type; @@ -36,15 +36,18 @@ public CloudflareAPIToken() {} @JsonCreator public CloudflareAPIToken( - @JsonProperty(required = true, value = JSON_PROPERTY_API_TOKEN) String apiToken, + @JsonProperty(required = true, value = JSON_PROPERTY_API_TOKEN) + CloudflareAPITokenApiToken apiToken, @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) CloudflareAPITokenType type) { this.apiToken = apiToken; + this.unparsed |= apiToken.unparsed; this.type = type; this.unparsed |= !type.isValid(); } - public CloudflareAPIToken apiToken(String apiToken) { + public CloudflareAPIToken apiToken(CloudflareAPITokenApiToken apiToken) { this.apiToken = apiToken; + this.unparsed |= apiToken.unparsed; return this; } @@ -55,12 +58,15 @@ public CloudflareAPIToken apiToken(String apiToken) { */ @JsonProperty(JSON_PROPERTY_API_TOKEN) @JsonInclude(value = JsonInclude.Include.ALWAYS) - public String getApiToken() { + public CloudflareAPITokenApiToken getApiToken() { return apiToken; } - public void setApiToken(String apiToken) { + public void setApiToken(CloudflareAPITokenApiToken apiToken) { this.apiToken = apiToken; + if (apiToken != null) { + this.unparsed |= apiToken.unparsed; + } } public CloudflareAPIToken type(CloudflareAPITokenType type) { diff --git a/src/main/java/com/datadog/api/client/v2/model/CloudflareAPITokenApiToken.java b/src/main/java/com/datadog/api/client/v2/model/CloudflareAPITokenApiToken.java new file mode 100644 index 00000000000..4999a610ab6 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/CloudflareAPITokenApiToken.java @@ -0,0 +1,289 @@ +/* + * 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 = CloudflareAPITokenApiToken.CloudflareAPITokenApiTokenDeserializer.class) +@JsonSerialize(using = CloudflareAPITokenApiToken.CloudflareAPITokenApiTokenSerializer.class) +public class CloudflareAPITokenApiToken extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(CloudflareAPITokenApiToken.class.getName()); + + @JsonIgnore public boolean unparsed = false; + + public static class CloudflareAPITokenApiTokenSerializer + extends StdSerializer { + public CloudflareAPITokenApiTokenSerializer(Class t) { + super(t); + } + + public CloudflareAPITokenApiTokenSerializer() { + this(null); + } + + @Override + public void serialize( + CloudflareAPITokenApiToken value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class CloudflareAPITokenApiTokenDeserializer + extends StdDeserializer { + public CloudflareAPITokenApiTokenDeserializer() { + this(CloudflareAPITokenApiToken.class); + } + + public CloudflareAPITokenApiTokenDeserializer(Class vc) { + super(vc); + } + + @Override + public CloudflareAPITokenApiToken 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 String + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (String.class.equals(Integer.class) + || String.class.equals(Long.class) + || String.class.equals(Float.class) + || String.class.equals(Double.class) + || String.class.equals(Boolean.class) + || String.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((String.class.equals(Integer.class) || String.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((String.class.equals(Float.class) || String.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (String.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (String.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(String.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. + deserialized = tmp; + match++; + + log.log(Level.FINER, "Input data matches schema 'String'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'String'", e); + } + + // deserialize ActionConnectionAWSSecretsManagerReference + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = + tree.traverse(jp.getCodec()) + .readValueAs(ActionConnectionAWSSecretsManagerReference.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 (!((ActionConnectionAWSSecretsManagerReference) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log( + Level.FINER, + "Input data matches schema 'ActionConnectionAWSSecretsManagerReference'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'ActionConnectionAWSSecretsManagerReference'", + e); + } + + CloudflareAPITokenApiToken ret = new CloudflareAPITokenApiToken(); + 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 CloudflareAPITokenApiToken getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + throw new JsonMappingException(ctxt.getParser(), "CloudflareAPITokenApiToken cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public CloudflareAPITokenApiToken() { + super("oneOf", Boolean.FALSE); + } + + public CloudflareAPITokenApiToken(String o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public CloudflareAPITokenApiToken(ActionConnectionAWSSecretsManagerReference o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("String", new GenericType() {}); + schemas.put( + "ActionConnectionAWSSecretsManagerReference", + new GenericType() {}); + JSON.registerDescendants( + CloudflareAPITokenApiToken.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map getSchemas() { + return CloudflareAPITokenApiToken.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: String, ActionConnectionAWSSecretsManagerReference + * + *

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(String.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + if (JSON.isInstanceOf( + ActionConnectionAWSSecretsManagerReference.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 String, ActionConnectionAWSSecretsManagerReference"); + } + + /** + * Get the actual instance, which can be the following: String, + * ActionConnectionAWSSecretsManagerReference + * + * @return The actual instance (String, ActionConnectionAWSSecretsManagerReference) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `String`. If the actual instance is not `String`, the + * ClassCastException will be thrown. + * + * @return The actual instance of `String` + * @throws ClassCastException if the instance is not `String` + */ + public String getString() throws ClassCastException { + return (String) super.getActualInstance(); + } + + /** + * Get the actual instance of `ActionConnectionAWSSecretsManagerReference`. If the actual instance + * is not `ActionConnectionAWSSecretsManagerReference`, the ClassCastException will be thrown. + * + * @return The actual instance of `ActionConnectionAWSSecretsManagerReference` + * @throws ClassCastException if the instance is not `ActionConnectionAWSSecretsManagerReference` + */ + public ActionConnectionAWSSecretsManagerReference getActionConnectionAWSSecretsManagerReference() + throws ClassCastException { + return (ActionConnectionAWSSecretsManagerReference) super.getActualInstance(); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/CloudflareAPITokenUpdate.java b/src/main/java/com/datadog/api/client/v2/model/CloudflareAPITokenUpdate.java index 8ec2d25498d..2f5f9e67880 100644 --- a/src/main/java/com/datadog/api/client/v2/model/CloudflareAPITokenUpdate.java +++ b/src/main/java/com/datadog/api/client/v2/model/CloudflareAPITokenUpdate.java @@ -27,7 +27,7 @@ public class CloudflareAPITokenUpdate { @JsonIgnore public boolean unparsed = false; public static final String JSON_PROPERTY_API_TOKEN = "api_token"; - private String apiToken; + private CloudflareAPITokenUpdateApiToken apiToken; public static final String JSON_PROPERTY_TYPE = "type"; private CloudflareAPITokenType type; @@ -41,8 +41,9 @@ public CloudflareAPITokenUpdate( this.unparsed |= !type.isValid(); } - public CloudflareAPITokenUpdate apiToken(String apiToken) { + public CloudflareAPITokenUpdate apiToken(CloudflareAPITokenUpdateApiToken apiToken) { this.apiToken = apiToken; + this.unparsed |= apiToken.unparsed; return this; } @@ -54,12 +55,15 @@ public CloudflareAPITokenUpdate apiToken(String apiToken) { @jakarta.annotation.Nullable @JsonProperty(JSON_PROPERTY_API_TOKEN) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public String getApiToken() { + public CloudflareAPITokenUpdateApiToken getApiToken() { return apiToken; } - public void setApiToken(String apiToken) { + public void setApiToken(CloudflareAPITokenUpdateApiToken apiToken) { this.apiToken = apiToken; + if (apiToken != null) { + this.unparsed |= apiToken.unparsed; + } } public CloudflareAPITokenUpdate type(CloudflareAPITokenType type) { diff --git a/src/main/java/com/datadog/api/client/v2/model/CloudflareAPITokenUpdateApiToken.java b/src/main/java/com/datadog/api/client/v2/model/CloudflareAPITokenUpdateApiToken.java new file mode 100644 index 00000000000..e22ffc8603f --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/CloudflareAPITokenUpdateApiToken.java @@ -0,0 +1,293 @@ +/* + * 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 = CloudflareAPITokenUpdateApiToken.CloudflareAPITokenUpdateApiTokenDeserializer.class) +@JsonSerialize( + using = CloudflareAPITokenUpdateApiToken.CloudflareAPITokenUpdateApiTokenSerializer.class) +public class CloudflareAPITokenUpdateApiToken extends AbstractOpenApiSchema { + private static final Logger log = + Logger.getLogger(CloudflareAPITokenUpdateApiToken.class.getName()); + + @JsonIgnore public boolean unparsed = false; + + public static class CloudflareAPITokenUpdateApiTokenSerializer + extends StdSerializer { + public CloudflareAPITokenUpdateApiTokenSerializer(Class t) { + super(t); + } + + public CloudflareAPITokenUpdateApiTokenSerializer() { + this(null); + } + + @Override + public void serialize( + CloudflareAPITokenUpdateApiToken value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class CloudflareAPITokenUpdateApiTokenDeserializer + extends StdDeserializer { + public CloudflareAPITokenUpdateApiTokenDeserializer() { + this(CloudflareAPITokenUpdateApiToken.class); + } + + public CloudflareAPITokenUpdateApiTokenDeserializer(Class vc) { + super(vc); + } + + @Override + public CloudflareAPITokenUpdateApiToken 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 String + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (String.class.equals(Integer.class) + || String.class.equals(Long.class) + || String.class.equals(Float.class) + || String.class.equals(Double.class) + || String.class.equals(Boolean.class) + || String.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((String.class.equals(Integer.class) || String.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((String.class.equals(Float.class) || String.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (String.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (String.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(String.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. + deserialized = tmp; + match++; + + log.log(Level.FINER, "Input data matches schema 'String'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'String'", e); + } + + // deserialize ActionConnectionAWSSecretsManagerReference + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = + tree.traverse(jp.getCodec()) + .readValueAs(ActionConnectionAWSSecretsManagerReference.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 (!((ActionConnectionAWSSecretsManagerReference) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log( + Level.FINER, + "Input data matches schema 'ActionConnectionAWSSecretsManagerReference'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'ActionConnectionAWSSecretsManagerReference'", + e); + } + + CloudflareAPITokenUpdateApiToken ret = new CloudflareAPITokenUpdateApiToken(); + 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 CloudflareAPITokenUpdateApiToken getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + throw new JsonMappingException( + ctxt.getParser(), "CloudflareAPITokenUpdateApiToken cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public CloudflareAPITokenUpdateApiToken() { + super("oneOf", Boolean.FALSE); + } + + public CloudflareAPITokenUpdateApiToken(String o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public CloudflareAPITokenUpdateApiToken(ActionConnectionAWSSecretsManagerReference o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("String", new GenericType() {}); + schemas.put( + "ActionConnectionAWSSecretsManagerReference", + new GenericType() {}); + JSON.registerDescendants( + CloudflareAPITokenUpdateApiToken.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map getSchemas() { + return CloudflareAPITokenUpdateApiToken.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: String, ActionConnectionAWSSecretsManagerReference + * + *

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(String.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + if (JSON.isInstanceOf( + ActionConnectionAWSSecretsManagerReference.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 String, ActionConnectionAWSSecretsManagerReference"); + } + + /** + * Get the actual instance, which can be the following: String, + * ActionConnectionAWSSecretsManagerReference + * + * @return The actual instance (String, ActionConnectionAWSSecretsManagerReference) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `String`. If the actual instance is not `String`, the + * ClassCastException will be thrown. + * + * @return The actual instance of `String` + * @throws ClassCastException if the instance is not `String` + */ + public String getString() throws ClassCastException { + return (String) super.getActualInstance(); + } + + /** + * Get the actual instance of `ActionConnectionAWSSecretsManagerReference`. If the actual instance + * is not `ActionConnectionAWSSecretsManagerReference`, the ClassCastException will be thrown. + * + * @return The actual instance of `ActionConnectionAWSSecretsManagerReference` + * @throws ClassCastException if the instance is not `ActionConnectionAWSSecretsManagerReference` + */ + public ActionConnectionAWSSecretsManagerReference getActionConnectionAWSSecretsManagerReference() + throws ClassCastException { + return (ActionConnectionAWSSecretsManagerReference) super.getActualInstance(); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/CloudflareGlobalAPIToken.java b/src/main/java/com/datadog/api/client/v2/model/CloudflareGlobalAPIToken.java index a1736b4042c..f5e5c003755 100644 --- a/src/main/java/com/datadog/api/client/v2/model/CloudflareGlobalAPIToken.java +++ b/src/main/java/com/datadog/api/client/v2/model/CloudflareGlobalAPIToken.java @@ -28,10 +28,10 @@ public class CloudflareGlobalAPIToken { @JsonIgnore public boolean unparsed = false; public static final String JSON_PROPERTY_AUTH_EMAIL = "auth_email"; - private String authEmail; + private CloudflareGlobalAPITokenAuthEmail authEmail; public static final String JSON_PROPERTY_GLOBAL_API_KEY = "global_api_key"; - private String globalApiKey; + private CloudflareGlobalAPITokenGlobalApiKey globalApiKey; public static final String JSON_PROPERTY_TYPE = "type"; private CloudflareGlobalAPITokenType type; @@ -40,18 +40,23 @@ public CloudflareGlobalAPIToken() {} @JsonCreator public CloudflareGlobalAPIToken( - @JsonProperty(required = true, value = JSON_PROPERTY_AUTH_EMAIL) String authEmail, - @JsonProperty(required = true, value = JSON_PROPERTY_GLOBAL_API_KEY) String globalApiKey, + @JsonProperty(required = true, value = JSON_PROPERTY_AUTH_EMAIL) + CloudflareGlobalAPITokenAuthEmail authEmail, + @JsonProperty(required = true, value = JSON_PROPERTY_GLOBAL_API_KEY) + CloudflareGlobalAPITokenGlobalApiKey globalApiKey, @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) CloudflareGlobalAPITokenType type) { this.authEmail = authEmail; + this.unparsed |= authEmail.unparsed; this.globalApiKey = globalApiKey; + this.unparsed |= globalApiKey.unparsed; this.type = type; this.unparsed |= !type.isValid(); } - public CloudflareGlobalAPIToken authEmail(String authEmail) { + public CloudflareGlobalAPIToken authEmail(CloudflareGlobalAPITokenAuthEmail authEmail) { this.authEmail = authEmail; + this.unparsed |= authEmail.unparsed; return this; } @@ -62,16 +67,20 @@ public CloudflareGlobalAPIToken authEmail(String authEmail) { */ @JsonProperty(JSON_PROPERTY_AUTH_EMAIL) @JsonInclude(value = JsonInclude.Include.ALWAYS) - public String getAuthEmail() { + public CloudflareGlobalAPITokenAuthEmail getAuthEmail() { return authEmail; } - public void setAuthEmail(String authEmail) { + public void setAuthEmail(CloudflareGlobalAPITokenAuthEmail authEmail) { this.authEmail = authEmail; + if (authEmail != null) { + this.unparsed |= authEmail.unparsed; + } } - public CloudflareGlobalAPIToken globalApiKey(String globalApiKey) { + public CloudflareGlobalAPIToken globalApiKey(CloudflareGlobalAPITokenGlobalApiKey globalApiKey) { this.globalApiKey = globalApiKey; + this.unparsed |= globalApiKey.unparsed; return this; } @@ -82,12 +91,15 @@ public CloudflareGlobalAPIToken globalApiKey(String globalApiKey) { */ @JsonProperty(JSON_PROPERTY_GLOBAL_API_KEY) @JsonInclude(value = JsonInclude.Include.ALWAYS) - public String getGlobalApiKey() { + public CloudflareGlobalAPITokenGlobalApiKey getGlobalApiKey() { return globalApiKey; } - public void setGlobalApiKey(String globalApiKey) { + public void setGlobalApiKey(CloudflareGlobalAPITokenGlobalApiKey globalApiKey) { this.globalApiKey = globalApiKey; + if (globalApiKey != null) { + this.unparsed |= globalApiKey.unparsed; + } } public CloudflareGlobalAPIToken type(CloudflareGlobalAPITokenType type) { diff --git a/src/main/java/com/datadog/api/client/v2/model/CloudflareGlobalAPITokenAuthEmail.java b/src/main/java/com/datadog/api/client/v2/model/CloudflareGlobalAPITokenAuthEmail.java new file mode 100644 index 00000000000..05c000d0ccc --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/CloudflareGlobalAPITokenAuthEmail.java @@ -0,0 +1,293 @@ +/* + * 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 = CloudflareGlobalAPITokenAuthEmail.CloudflareGlobalAPITokenAuthEmailDeserializer.class) +@JsonSerialize( + using = CloudflareGlobalAPITokenAuthEmail.CloudflareGlobalAPITokenAuthEmailSerializer.class) +public class CloudflareGlobalAPITokenAuthEmail extends AbstractOpenApiSchema { + private static final Logger log = + Logger.getLogger(CloudflareGlobalAPITokenAuthEmail.class.getName()); + + @JsonIgnore public boolean unparsed = false; + + public static class CloudflareGlobalAPITokenAuthEmailSerializer + extends StdSerializer { + public CloudflareGlobalAPITokenAuthEmailSerializer(Class t) { + super(t); + } + + public CloudflareGlobalAPITokenAuthEmailSerializer() { + this(null); + } + + @Override + public void serialize( + CloudflareGlobalAPITokenAuthEmail value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class CloudflareGlobalAPITokenAuthEmailDeserializer + extends StdDeserializer { + public CloudflareGlobalAPITokenAuthEmailDeserializer() { + this(CloudflareGlobalAPITokenAuthEmail.class); + } + + public CloudflareGlobalAPITokenAuthEmailDeserializer(Class vc) { + super(vc); + } + + @Override + public CloudflareGlobalAPITokenAuthEmail 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 String + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (String.class.equals(Integer.class) + || String.class.equals(Long.class) + || String.class.equals(Float.class) + || String.class.equals(Double.class) + || String.class.equals(Boolean.class) + || String.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((String.class.equals(Integer.class) || String.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((String.class.equals(Float.class) || String.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (String.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (String.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(String.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. + deserialized = tmp; + match++; + + log.log(Level.FINER, "Input data matches schema 'String'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'String'", e); + } + + // deserialize ActionConnectionAWSSecretsManagerReference + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = + tree.traverse(jp.getCodec()) + .readValueAs(ActionConnectionAWSSecretsManagerReference.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 (!((ActionConnectionAWSSecretsManagerReference) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log( + Level.FINER, + "Input data matches schema 'ActionConnectionAWSSecretsManagerReference'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'ActionConnectionAWSSecretsManagerReference'", + e); + } + + CloudflareGlobalAPITokenAuthEmail ret = new CloudflareGlobalAPITokenAuthEmail(); + 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 CloudflareGlobalAPITokenAuthEmail getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + throw new JsonMappingException( + ctxt.getParser(), "CloudflareGlobalAPITokenAuthEmail cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public CloudflareGlobalAPITokenAuthEmail() { + super("oneOf", Boolean.FALSE); + } + + public CloudflareGlobalAPITokenAuthEmail(String o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public CloudflareGlobalAPITokenAuthEmail(ActionConnectionAWSSecretsManagerReference o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("String", new GenericType() {}); + schemas.put( + "ActionConnectionAWSSecretsManagerReference", + new GenericType() {}); + JSON.registerDescendants( + CloudflareGlobalAPITokenAuthEmail.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map getSchemas() { + return CloudflareGlobalAPITokenAuthEmail.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: String, ActionConnectionAWSSecretsManagerReference + * + *

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(String.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + if (JSON.isInstanceOf( + ActionConnectionAWSSecretsManagerReference.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 String, ActionConnectionAWSSecretsManagerReference"); + } + + /** + * Get the actual instance, which can be the following: String, + * ActionConnectionAWSSecretsManagerReference + * + * @return The actual instance (String, ActionConnectionAWSSecretsManagerReference) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `String`. If the actual instance is not `String`, the + * ClassCastException will be thrown. + * + * @return The actual instance of `String` + * @throws ClassCastException if the instance is not `String` + */ + public String getString() throws ClassCastException { + return (String) super.getActualInstance(); + } + + /** + * Get the actual instance of `ActionConnectionAWSSecretsManagerReference`. If the actual instance + * is not `ActionConnectionAWSSecretsManagerReference`, the ClassCastException will be thrown. + * + * @return The actual instance of `ActionConnectionAWSSecretsManagerReference` + * @throws ClassCastException if the instance is not `ActionConnectionAWSSecretsManagerReference` + */ + public ActionConnectionAWSSecretsManagerReference getActionConnectionAWSSecretsManagerReference() + throws ClassCastException { + return (ActionConnectionAWSSecretsManagerReference) super.getActualInstance(); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/CloudflareGlobalAPITokenGlobalApiKey.java b/src/main/java/com/datadog/api/client/v2/model/CloudflareGlobalAPITokenGlobalApiKey.java new file mode 100644 index 00000000000..db3dac8a2d5 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/CloudflareGlobalAPITokenGlobalApiKey.java @@ -0,0 +1,296 @@ +/* + * 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 = + CloudflareGlobalAPITokenGlobalApiKey.CloudflareGlobalAPITokenGlobalApiKeyDeserializer.class) +@JsonSerialize( + using = + CloudflareGlobalAPITokenGlobalApiKey.CloudflareGlobalAPITokenGlobalApiKeySerializer.class) +public class CloudflareGlobalAPITokenGlobalApiKey extends AbstractOpenApiSchema { + private static final Logger log = + Logger.getLogger(CloudflareGlobalAPITokenGlobalApiKey.class.getName()); + + @JsonIgnore public boolean unparsed = false; + + public static class CloudflareGlobalAPITokenGlobalApiKeySerializer + extends StdSerializer { + public CloudflareGlobalAPITokenGlobalApiKeySerializer( + Class t) { + super(t); + } + + public CloudflareGlobalAPITokenGlobalApiKeySerializer() { + this(null); + } + + @Override + public void serialize( + CloudflareGlobalAPITokenGlobalApiKey value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class CloudflareGlobalAPITokenGlobalApiKeyDeserializer + extends StdDeserializer { + public CloudflareGlobalAPITokenGlobalApiKeyDeserializer() { + this(CloudflareGlobalAPITokenGlobalApiKey.class); + } + + public CloudflareGlobalAPITokenGlobalApiKeyDeserializer(Class vc) { + super(vc); + } + + @Override + public CloudflareGlobalAPITokenGlobalApiKey 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 String + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (String.class.equals(Integer.class) + || String.class.equals(Long.class) + || String.class.equals(Float.class) + || String.class.equals(Double.class) + || String.class.equals(Boolean.class) + || String.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((String.class.equals(Integer.class) || String.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((String.class.equals(Float.class) || String.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (String.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (String.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(String.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. + deserialized = tmp; + match++; + + log.log(Level.FINER, "Input data matches schema 'String'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'String'", e); + } + + // deserialize ActionConnectionAWSSecretsManagerReference + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = + tree.traverse(jp.getCodec()) + .readValueAs(ActionConnectionAWSSecretsManagerReference.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 (!((ActionConnectionAWSSecretsManagerReference) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log( + Level.FINER, + "Input data matches schema 'ActionConnectionAWSSecretsManagerReference'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'ActionConnectionAWSSecretsManagerReference'", + e); + } + + CloudflareGlobalAPITokenGlobalApiKey ret = new CloudflareGlobalAPITokenGlobalApiKey(); + 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 CloudflareGlobalAPITokenGlobalApiKey getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + throw new JsonMappingException( + ctxt.getParser(), "CloudflareGlobalAPITokenGlobalApiKey cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public CloudflareGlobalAPITokenGlobalApiKey() { + super("oneOf", Boolean.FALSE); + } + + public CloudflareGlobalAPITokenGlobalApiKey(String o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public CloudflareGlobalAPITokenGlobalApiKey(ActionConnectionAWSSecretsManagerReference o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("String", new GenericType() {}); + schemas.put( + "ActionConnectionAWSSecretsManagerReference", + new GenericType() {}); + JSON.registerDescendants( + CloudflareGlobalAPITokenGlobalApiKey.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map getSchemas() { + return CloudflareGlobalAPITokenGlobalApiKey.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: String, ActionConnectionAWSSecretsManagerReference + * + *

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(String.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + if (JSON.isInstanceOf( + ActionConnectionAWSSecretsManagerReference.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 String, ActionConnectionAWSSecretsManagerReference"); + } + + /** + * Get the actual instance, which can be the following: String, + * ActionConnectionAWSSecretsManagerReference + * + * @return The actual instance (String, ActionConnectionAWSSecretsManagerReference) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `String`. If the actual instance is not `String`, the + * ClassCastException will be thrown. + * + * @return The actual instance of `String` + * @throws ClassCastException if the instance is not `String` + */ + public String getString() throws ClassCastException { + return (String) super.getActualInstance(); + } + + /** + * Get the actual instance of `ActionConnectionAWSSecretsManagerReference`. If the actual instance + * is not `ActionConnectionAWSSecretsManagerReference`, the ClassCastException will be thrown. + * + * @return The actual instance of `ActionConnectionAWSSecretsManagerReference` + * @throws ClassCastException if the instance is not `ActionConnectionAWSSecretsManagerReference` + */ + public ActionConnectionAWSSecretsManagerReference getActionConnectionAWSSecretsManagerReference() + throws ClassCastException { + return (ActionConnectionAWSSecretsManagerReference) super.getActualInstance(); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/CloudflareGlobalAPITokenUpdate.java b/src/main/java/com/datadog/api/client/v2/model/CloudflareGlobalAPITokenUpdate.java index 41cab6763ab..49651d735a5 100644 --- a/src/main/java/com/datadog/api/client/v2/model/CloudflareGlobalAPITokenUpdate.java +++ b/src/main/java/com/datadog/api/client/v2/model/CloudflareGlobalAPITokenUpdate.java @@ -28,10 +28,10 @@ public class CloudflareGlobalAPITokenUpdate { @JsonIgnore public boolean unparsed = false; public static final String JSON_PROPERTY_AUTH_EMAIL = "auth_email"; - private String authEmail; + private CloudflareGlobalAPITokenUpdateAuthEmail authEmail; public static final String JSON_PROPERTY_GLOBAL_API_KEY = "global_api_key"; - private String globalApiKey; + private CloudflareGlobalAPITokenUpdateGlobalApiKey globalApiKey; public static final String JSON_PROPERTY_TYPE = "type"; private CloudflareGlobalAPITokenType type; @@ -46,8 +46,10 @@ public CloudflareGlobalAPITokenUpdate( this.unparsed |= !type.isValid(); } - public CloudflareGlobalAPITokenUpdate authEmail(String authEmail) { + public CloudflareGlobalAPITokenUpdate authEmail( + CloudflareGlobalAPITokenUpdateAuthEmail authEmail) { this.authEmail = authEmail; + this.unparsed |= authEmail.unparsed; return this; } @@ -59,16 +61,21 @@ public CloudflareGlobalAPITokenUpdate authEmail(String authEmail) { @jakarta.annotation.Nullable @JsonProperty(JSON_PROPERTY_AUTH_EMAIL) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public String getAuthEmail() { + public CloudflareGlobalAPITokenUpdateAuthEmail getAuthEmail() { return authEmail; } - public void setAuthEmail(String authEmail) { + public void setAuthEmail(CloudflareGlobalAPITokenUpdateAuthEmail authEmail) { this.authEmail = authEmail; + if (authEmail != null) { + this.unparsed |= authEmail.unparsed; + } } - public CloudflareGlobalAPITokenUpdate globalApiKey(String globalApiKey) { + public CloudflareGlobalAPITokenUpdate globalApiKey( + CloudflareGlobalAPITokenUpdateGlobalApiKey globalApiKey) { this.globalApiKey = globalApiKey; + this.unparsed |= globalApiKey.unparsed; return this; } @@ -80,12 +87,15 @@ public CloudflareGlobalAPITokenUpdate globalApiKey(String globalApiKey) { @jakarta.annotation.Nullable @JsonProperty(JSON_PROPERTY_GLOBAL_API_KEY) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public String getGlobalApiKey() { + public CloudflareGlobalAPITokenUpdateGlobalApiKey getGlobalApiKey() { return globalApiKey; } - public void setGlobalApiKey(String globalApiKey) { + public void setGlobalApiKey(CloudflareGlobalAPITokenUpdateGlobalApiKey globalApiKey) { this.globalApiKey = globalApiKey; + if (globalApiKey != null) { + this.unparsed |= globalApiKey.unparsed; + } } public CloudflareGlobalAPITokenUpdate type(CloudflareGlobalAPITokenType type) { diff --git a/src/main/java/com/datadog/api/client/v2/model/CloudflareGlobalAPITokenUpdateAuthEmail.java b/src/main/java/com/datadog/api/client/v2/model/CloudflareGlobalAPITokenUpdateAuthEmail.java new file mode 100644 index 00000000000..c3d69e4266b --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/CloudflareGlobalAPITokenUpdateAuthEmail.java @@ -0,0 +1,300 @@ +/* + * 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 = + CloudflareGlobalAPITokenUpdateAuthEmail.CloudflareGlobalAPITokenUpdateAuthEmailDeserializer + .class) +@JsonSerialize( + using = + CloudflareGlobalAPITokenUpdateAuthEmail.CloudflareGlobalAPITokenUpdateAuthEmailSerializer + .class) +public class CloudflareGlobalAPITokenUpdateAuthEmail extends AbstractOpenApiSchema { + private static final Logger log = + Logger.getLogger(CloudflareGlobalAPITokenUpdateAuthEmail.class.getName()); + + @JsonIgnore public boolean unparsed = false; + + public static class CloudflareGlobalAPITokenUpdateAuthEmailSerializer + extends StdSerializer { + public CloudflareGlobalAPITokenUpdateAuthEmailSerializer( + Class t) { + super(t); + } + + public CloudflareGlobalAPITokenUpdateAuthEmailSerializer() { + this(null); + } + + @Override + public void serialize( + CloudflareGlobalAPITokenUpdateAuthEmail value, + JsonGenerator jgen, + SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class CloudflareGlobalAPITokenUpdateAuthEmailDeserializer + extends StdDeserializer { + public CloudflareGlobalAPITokenUpdateAuthEmailDeserializer() { + this(CloudflareGlobalAPITokenUpdateAuthEmail.class); + } + + public CloudflareGlobalAPITokenUpdateAuthEmailDeserializer(Class vc) { + super(vc); + } + + @Override + public CloudflareGlobalAPITokenUpdateAuthEmail 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 String + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (String.class.equals(Integer.class) + || String.class.equals(Long.class) + || String.class.equals(Float.class) + || String.class.equals(Double.class) + || String.class.equals(Boolean.class) + || String.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((String.class.equals(Integer.class) || String.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((String.class.equals(Float.class) || String.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (String.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (String.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(String.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. + deserialized = tmp; + match++; + + log.log(Level.FINER, "Input data matches schema 'String'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'String'", e); + } + + // deserialize ActionConnectionAWSSecretsManagerReference + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = + tree.traverse(jp.getCodec()) + .readValueAs(ActionConnectionAWSSecretsManagerReference.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 (!((ActionConnectionAWSSecretsManagerReference) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log( + Level.FINER, + "Input data matches schema 'ActionConnectionAWSSecretsManagerReference'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'ActionConnectionAWSSecretsManagerReference'", + e); + } + + CloudflareGlobalAPITokenUpdateAuthEmail ret = new CloudflareGlobalAPITokenUpdateAuthEmail(); + 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 CloudflareGlobalAPITokenUpdateAuthEmail getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + throw new JsonMappingException( + ctxt.getParser(), "CloudflareGlobalAPITokenUpdateAuthEmail cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public CloudflareGlobalAPITokenUpdateAuthEmail() { + super("oneOf", Boolean.FALSE); + } + + public CloudflareGlobalAPITokenUpdateAuthEmail(String o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public CloudflareGlobalAPITokenUpdateAuthEmail(ActionConnectionAWSSecretsManagerReference o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("String", new GenericType() {}); + schemas.put( + "ActionConnectionAWSSecretsManagerReference", + new GenericType() {}); + JSON.registerDescendants( + CloudflareGlobalAPITokenUpdateAuthEmail.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map getSchemas() { + return CloudflareGlobalAPITokenUpdateAuthEmail.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: String, ActionConnectionAWSSecretsManagerReference + * + *

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(String.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + if (JSON.isInstanceOf( + ActionConnectionAWSSecretsManagerReference.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 String, ActionConnectionAWSSecretsManagerReference"); + } + + /** + * Get the actual instance, which can be the following: String, + * ActionConnectionAWSSecretsManagerReference + * + * @return The actual instance (String, ActionConnectionAWSSecretsManagerReference) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `String`. If the actual instance is not `String`, the + * ClassCastException will be thrown. + * + * @return The actual instance of `String` + * @throws ClassCastException if the instance is not `String` + */ + public String getString() throws ClassCastException { + return (String) super.getActualInstance(); + } + + /** + * Get the actual instance of `ActionConnectionAWSSecretsManagerReference`. If the actual instance + * is not `ActionConnectionAWSSecretsManagerReference`, the ClassCastException will be thrown. + * + * @return The actual instance of `ActionConnectionAWSSecretsManagerReference` + * @throws ClassCastException if the instance is not `ActionConnectionAWSSecretsManagerReference` + */ + public ActionConnectionAWSSecretsManagerReference getActionConnectionAWSSecretsManagerReference() + throws ClassCastException { + return (ActionConnectionAWSSecretsManagerReference) super.getActualInstance(); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/CloudflareGlobalAPITokenUpdateGlobalApiKey.java b/src/main/java/com/datadog/api/client/v2/model/CloudflareGlobalAPITokenUpdateGlobalApiKey.java new file mode 100644 index 00000000000..610f2ba057b --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/CloudflareGlobalAPITokenUpdateGlobalApiKey.java @@ -0,0 +1,301 @@ +/* + * 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 = + CloudflareGlobalAPITokenUpdateGlobalApiKey + .CloudflareGlobalAPITokenUpdateGlobalApiKeyDeserializer.class) +@JsonSerialize( + using = + CloudflareGlobalAPITokenUpdateGlobalApiKey + .CloudflareGlobalAPITokenUpdateGlobalApiKeySerializer.class) +public class CloudflareGlobalAPITokenUpdateGlobalApiKey extends AbstractOpenApiSchema { + private static final Logger log = + Logger.getLogger(CloudflareGlobalAPITokenUpdateGlobalApiKey.class.getName()); + + @JsonIgnore public boolean unparsed = false; + + public static class CloudflareGlobalAPITokenUpdateGlobalApiKeySerializer + extends StdSerializer { + public CloudflareGlobalAPITokenUpdateGlobalApiKeySerializer( + Class t) { + super(t); + } + + public CloudflareGlobalAPITokenUpdateGlobalApiKeySerializer() { + this(null); + } + + @Override + public void serialize( + CloudflareGlobalAPITokenUpdateGlobalApiKey value, + JsonGenerator jgen, + SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class CloudflareGlobalAPITokenUpdateGlobalApiKeyDeserializer + extends StdDeserializer { + public CloudflareGlobalAPITokenUpdateGlobalApiKeyDeserializer() { + this(CloudflareGlobalAPITokenUpdateGlobalApiKey.class); + } + + public CloudflareGlobalAPITokenUpdateGlobalApiKeyDeserializer(Class vc) { + super(vc); + } + + @Override + public CloudflareGlobalAPITokenUpdateGlobalApiKey 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 String + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (String.class.equals(Integer.class) + || String.class.equals(Long.class) + || String.class.equals(Float.class) + || String.class.equals(Double.class) + || String.class.equals(Boolean.class) + || String.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((String.class.equals(Integer.class) || String.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((String.class.equals(Float.class) || String.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (String.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (String.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(String.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. + deserialized = tmp; + match++; + + log.log(Level.FINER, "Input data matches schema 'String'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'String'", e); + } + + // deserialize ActionConnectionAWSSecretsManagerReference + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = + tree.traverse(jp.getCodec()) + .readValueAs(ActionConnectionAWSSecretsManagerReference.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 (!((ActionConnectionAWSSecretsManagerReference) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log( + Level.FINER, + "Input data matches schema 'ActionConnectionAWSSecretsManagerReference'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'ActionConnectionAWSSecretsManagerReference'", + e); + } + + CloudflareGlobalAPITokenUpdateGlobalApiKey ret = + new CloudflareGlobalAPITokenUpdateGlobalApiKey(); + 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 CloudflareGlobalAPITokenUpdateGlobalApiKey getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + throw new JsonMappingException( + ctxt.getParser(), "CloudflareGlobalAPITokenUpdateGlobalApiKey cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public CloudflareGlobalAPITokenUpdateGlobalApiKey() { + super("oneOf", Boolean.FALSE); + } + + public CloudflareGlobalAPITokenUpdateGlobalApiKey(String o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public CloudflareGlobalAPITokenUpdateGlobalApiKey(ActionConnectionAWSSecretsManagerReference o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("String", new GenericType() {}); + schemas.put( + "ActionConnectionAWSSecretsManagerReference", + new GenericType() {}); + JSON.registerDescendants( + CloudflareGlobalAPITokenUpdateGlobalApiKey.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map getSchemas() { + return CloudflareGlobalAPITokenUpdateGlobalApiKey.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: String, ActionConnectionAWSSecretsManagerReference + * + *

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(String.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + if (JSON.isInstanceOf( + ActionConnectionAWSSecretsManagerReference.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 String, ActionConnectionAWSSecretsManagerReference"); + } + + /** + * Get the actual instance, which can be the following: String, + * ActionConnectionAWSSecretsManagerReference + * + * @return The actual instance (String, ActionConnectionAWSSecretsManagerReference) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `String`. If the actual instance is not `String`, the + * ClassCastException will be thrown. + * + * @return The actual instance of `String` + * @throws ClassCastException if the instance is not `String` + */ + public String getString() throws ClassCastException { + return (String) super.getActualInstance(); + } + + /** + * Get the actual instance of `ActionConnectionAWSSecretsManagerReference`. If the actual instance + * is not `ActionConnectionAWSSecretsManagerReference`, the ClassCastException will be thrown. + * + * @return The actual instance of `ActionConnectionAWSSecretsManagerReference` + * @throws ClassCastException if the instance is not `ActionConnectionAWSSecretsManagerReference` + */ + public ActionConnectionAWSSecretsManagerReference getActionConnectionAWSSecretsManagerReference() + throws ClassCastException { + return (ActionConnectionAWSSecretsManagerReference) super.getActualInstance(); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/ConfigCatSDKKey.java b/src/main/java/com/datadog/api/client/v2/model/ConfigCatSDKKey.java index f7fb71ca5ae..ba26bcb77f9 100644 --- a/src/main/java/com/datadog/api/client/v2/model/ConfigCatSDKKey.java +++ b/src/main/java/com/datadog/api/client/v2/model/ConfigCatSDKKey.java @@ -29,13 +29,13 @@ public class ConfigCatSDKKey { @JsonIgnore public boolean unparsed = false; public static final String JSON_PROPERTY_API_PASSWORD = "api_password"; - private String apiPassword; + private ConfigCatSDKKeyApiPassword apiPassword; public static final String JSON_PROPERTY_API_USERNAME = "api_username"; - private String apiUsername; + private ConfigCatSDKKeyApiUsername apiUsername; public static final String JSON_PROPERTY_SDK_KEY = "sdk_key"; - private String sdkKey; + private ConfigCatSDKKeySdkKey sdkKey; public static final String JSON_PROPERTY_TYPE = "type"; private ConfigCatSDKKeyType type; @@ -44,19 +44,25 @@ public ConfigCatSDKKey() {} @JsonCreator public ConfigCatSDKKey( - @JsonProperty(required = true, value = JSON_PROPERTY_API_PASSWORD) String apiPassword, - @JsonProperty(required = true, value = JSON_PROPERTY_API_USERNAME) String apiUsername, - @JsonProperty(required = true, value = JSON_PROPERTY_SDK_KEY) String sdkKey, + @JsonProperty(required = true, value = JSON_PROPERTY_API_PASSWORD) + ConfigCatSDKKeyApiPassword apiPassword, + @JsonProperty(required = true, value = JSON_PROPERTY_API_USERNAME) + ConfigCatSDKKeyApiUsername apiUsername, + @JsonProperty(required = true, value = JSON_PROPERTY_SDK_KEY) ConfigCatSDKKeySdkKey sdkKey, @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) ConfigCatSDKKeyType type) { this.apiPassword = apiPassword; + this.unparsed |= apiPassword.unparsed; this.apiUsername = apiUsername; + this.unparsed |= apiUsername.unparsed; this.sdkKey = sdkKey; + this.unparsed |= sdkKey.unparsed; this.type = type; this.unparsed |= !type.isValid(); } - public ConfigCatSDKKey apiPassword(String apiPassword) { + public ConfigCatSDKKey apiPassword(ConfigCatSDKKeyApiPassword apiPassword) { this.apiPassword = apiPassword; + this.unparsed |= apiPassword.unparsed; return this; } @@ -67,16 +73,20 @@ public ConfigCatSDKKey apiPassword(String apiPassword) { */ @JsonProperty(JSON_PROPERTY_API_PASSWORD) @JsonInclude(value = JsonInclude.Include.ALWAYS) - public String getApiPassword() { + public ConfigCatSDKKeyApiPassword getApiPassword() { return apiPassword; } - public void setApiPassword(String apiPassword) { + public void setApiPassword(ConfigCatSDKKeyApiPassword apiPassword) { this.apiPassword = apiPassword; + if (apiPassword != null) { + this.unparsed |= apiPassword.unparsed; + } } - public ConfigCatSDKKey apiUsername(String apiUsername) { + public ConfigCatSDKKey apiUsername(ConfigCatSDKKeyApiUsername apiUsername) { this.apiUsername = apiUsername; + this.unparsed |= apiUsername.unparsed; return this; } @@ -87,16 +97,20 @@ public ConfigCatSDKKey apiUsername(String apiUsername) { */ @JsonProperty(JSON_PROPERTY_API_USERNAME) @JsonInclude(value = JsonInclude.Include.ALWAYS) - public String getApiUsername() { + public ConfigCatSDKKeyApiUsername getApiUsername() { return apiUsername; } - public void setApiUsername(String apiUsername) { + public void setApiUsername(ConfigCatSDKKeyApiUsername apiUsername) { this.apiUsername = apiUsername; + if (apiUsername != null) { + this.unparsed |= apiUsername.unparsed; + } } - public ConfigCatSDKKey sdkKey(String sdkKey) { + public ConfigCatSDKKey sdkKey(ConfigCatSDKKeySdkKey sdkKey) { this.sdkKey = sdkKey; + this.unparsed |= sdkKey.unparsed; return this; } @@ -107,12 +121,15 @@ public ConfigCatSDKKey sdkKey(String sdkKey) { */ @JsonProperty(JSON_PROPERTY_SDK_KEY) @JsonInclude(value = JsonInclude.Include.ALWAYS) - public String getSdkKey() { + public ConfigCatSDKKeySdkKey getSdkKey() { return sdkKey; } - public void setSdkKey(String sdkKey) { + public void setSdkKey(ConfigCatSDKKeySdkKey sdkKey) { this.sdkKey = sdkKey; + if (sdkKey != null) { + this.unparsed |= sdkKey.unparsed; + } } public ConfigCatSDKKey type(ConfigCatSDKKeyType type) { diff --git a/src/main/java/com/datadog/api/client/v2/model/ConfigCatSDKKeyApiPassword.java b/src/main/java/com/datadog/api/client/v2/model/ConfigCatSDKKeyApiPassword.java new file mode 100644 index 00000000000..1cd79c53728 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ConfigCatSDKKeyApiPassword.java @@ -0,0 +1,289 @@ +/* + * 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 = ConfigCatSDKKeyApiPassword.ConfigCatSDKKeyApiPasswordDeserializer.class) +@JsonSerialize(using = ConfigCatSDKKeyApiPassword.ConfigCatSDKKeyApiPasswordSerializer.class) +public class ConfigCatSDKKeyApiPassword extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(ConfigCatSDKKeyApiPassword.class.getName()); + + @JsonIgnore public boolean unparsed = false; + + public static class ConfigCatSDKKeyApiPasswordSerializer + extends StdSerializer { + public ConfigCatSDKKeyApiPasswordSerializer(Class t) { + super(t); + } + + public ConfigCatSDKKeyApiPasswordSerializer() { + this(null); + } + + @Override + public void serialize( + ConfigCatSDKKeyApiPassword value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class ConfigCatSDKKeyApiPasswordDeserializer + extends StdDeserializer { + public ConfigCatSDKKeyApiPasswordDeserializer() { + this(ConfigCatSDKKeyApiPassword.class); + } + + public ConfigCatSDKKeyApiPasswordDeserializer(Class vc) { + super(vc); + } + + @Override + public ConfigCatSDKKeyApiPassword 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 String + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (String.class.equals(Integer.class) + || String.class.equals(Long.class) + || String.class.equals(Float.class) + || String.class.equals(Double.class) + || String.class.equals(Boolean.class) + || String.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((String.class.equals(Integer.class) || String.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((String.class.equals(Float.class) || String.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (String.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (String.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(String.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. + deserialized = tmp; + match++; + + log.log(Level.FINER, "Input data matches schema 'String'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'String'", e); + } + + // deserialize ActionConnectionAWSSecretsManagerReference + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = + tree.traverse(jp.getCodec()) + .readValueAs(ActionConnectionAWSSecretsManagerReference.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 (!((ActionConnectionAWSSecretsManagerReference) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log( + Level.FINER, + "Input data matches schema 'ActionConnectionAWSSecretsManagerReference'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'ActionConnectionAWSSecretsManagerReference'", + e); + } + + ConfigCatSDKKeyApiPassword ret = new ConfigCatSDKKeyApiPassword(); + 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 ConfigCatSDKKeyApiPassword getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + throw new JsonMappingException(ctxt.getParser(), "ConfigCatSDKKeyApiPassword cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public ConfigCatSDKKeyApiPassword() { + super("oneOf", Boolean.FALSE); + } + + public ConfigCatSDKKeyApiPassword(String o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public ConfigCatSDKKeyApiPassword(ActionConnectionAWSSecretsManagerReference o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("String", new GenericType() {}); + schemas.put( + "ActionConnectionAWSSecretsManagerReference", + new GenericType() {}); + JSON.registerDescendants( + ConfigCatSDKKeyApiPassword.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map getSchemas() { + return ConfigCatSDKKeyApiPassword.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: String, ActionConnectionAWSSecretsManagerReference + * + *

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(String.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + if (JSON.isInstanceOf( + ActionConnectionAWSSecretsManagerReference.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 String, ActionConnectionAWSSecretsManagerReference"); + } + + /** + * Get the actual instance, which can be the following: String, + * ActionConnectionAWSSecretsManagerReference + * + * @return The actual instance (String, ActionConnectionAWSSecretsManagerReference) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `String`. If the actual instance is not `String`, the + * ClassCastException will be thrown. + * + * @return The actual instance of `String` + * @throws ClassCastException if the instance is not `String` + */ + public String getString() throws ClassCastException { + return (String) super.getActualInstance(); + } + + /** + * Get the actual instance of `ActionConnectionAWSSecretsManagerReference`. If the actual instance + * is not `ActionConnectionAWSSecretsManagerReference`, the ClassCastException will be thrown. + * + * @return The actual instance of `ActionConnectionAWSSecretsManagerReference` + * @throws ClassCastException if the instance is not `ActionConnectionAWSSecretsManagerReference` + */ + public ActionConnectionAWSSecretsManagerReference getActionConnectionAWSSecretsManagerReference() + throws ClassCastException { + return (ActionConnectionAWSSecretsManagerReference) super.getActualInstance(); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/ConfigCatSDKKeyApiUsername.java b/src/main/java/com/datadog/api/client/v2/model/ConfigCatSDKKeyApiUsername.java new file mode 100644 index 00000000000..945ff220094 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ConfigCatSDKKeyApiUsername.java @@ -0,0 +1,289 @@ +/* + * 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 = ConfigCatSDKKeyApiUsername.ConfigCatSDKKeyApiUsernameDeserializer.class) +@JsonSerialize(using = ConfigCatSDKKeyApiUsername.ConfigCatSDKKeyApiUsernameSerializer.class) +public class ConfigCatSDKKeyApiUsername extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(ConfigCatSDKKeyApiUsername.class.getName()); + + @JsonIgnore public boolean unparsed = false; + + public static class ConfigCatSDKKeyApiUsernameSerializer + extends StdSerializer { + public ConfigCatSDKKeyApiUsernameSerializer(Class t) { + super(t); + } + + public ConfigCatSDKKeyApiUsernameSerializer() { + this(null); + } + + @Override + public void serialize( + ConfigCatSDKKeyApiUsername value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class ConfigCatSDKKeyApiUsernameDeserializer + extends StdDeserializer { + public ConfigCatSDKKeyApiUsernameDeserializer() { + this(ConfigCatSDKKeyApiUsername.class); + } + + public ConfigCatSDKKeyApiUsernameDeserializer(Class vc) { + super(vc); + } + + @Override + public ConfigCatSDKKeyApiUsername 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 String + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (String.class.equals(Integer.class) + || String.class.equals(Long.class) + || String.class.equals(Float.class) + || String.class.equals(Double.class) + || String.class.equals(Boolean.class) + || String.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((String.class.equals(Integer.class) || String.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((String.class.equals(Float.class) || String.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (String.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (String.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(String.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. + deserialized = tmp; + match++; + + log.log(Level.FINER, "Input data matches schema 'String'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'String'", e); + } + + // deserialize ActionConnectionAWSSecretsManagerReference + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = + tree.traverse(jp.getCodec()) + .readValueAs(ActionConnectionAWSSecretsManagerReference.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 (!((ActionConnectionAWSSecretsManagerReference) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log( + Level.FINER, + "Input data matches schema 'ActionConnectionAWSSecretsManagerReference'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'ActionConnectionAWSSecretsManagerReference'", + e); + } + + ConfigCatSDKKeyApiUsername ret = new ConfigCatSDKKeyApiUsername(); + 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 ConfigCatSDKKeyApiUsername getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + throw new JsonMappingException(ctxt.getParser(), "ConfigCatSDKKeyApiUsername cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public ConfigCatSDKKeyApiUsername() { + super("oneOf", Boolean.FALSE); + } + + public ConfigCatSDKKeyApiUsername(String o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public ConfigCatSDKKeyApiUsername(ActionConnectionAWSSecretsManagerReference o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("String", new GenericType() {}); + schemas.put( + "ActionConnectionAWSSecretsManagerReference", + new GenericType() {}); + JSON.registerDescendants( + ConfigCatSDKKeyApiUsername.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map getSchemas() { + return ConfigCatSDKKeyApiUsername.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: String, ActionConnectionAWSSecretsManagerReference + * + *

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(String.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + if (JSON.isInstanceOf( + ActionConnectionAWSSecretsManagerReference.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 String, ActionConnectionAWSSecretsManagerReference"); + } + + /** + * Get the actual instance, which can be the following: String, + * ActionConnectionAWSSecretsManagerReference + * + * @return The actual instance (String, ActionConnectionAWSSecretsManagerReference) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `String`. If the actual instance is not `String`, the + * ClassCastException will be thrown. + * + * @return The actual instance of `String` + * @throws ClassCastException if the instance is not `String` + */ + public String getString() throws ClassCastException { + return (String) super.getActualInstance(); + } + + /** + * Get the actual instance of `ActionConnectionAWSSecretsManagerReference`. If the actual instance + * is not `ActionConnectionAWSSecretsManagerReference`, the ClassCastException will be thrown. + * + * @return The actual instance of `ActionConnectionAWSSecretsManagerReference` + * @throws ClassCastException if the instance is not `ActionConnectionAWSSecretsManagerReference` + */ + public ActionConnectionAWSSecretsManagerReference getActionConnectionAWSSecretsManagerReference() + throws ClassCastException { + return (ActionConnectionAWSSecretsManagerReference) super.getActualInstance(); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/ConfigCatSDKKeySdkKey.java b/src/main/java/com/datadog/api/client/v2/model/ConfigCatSDKKeySdkKey.java new file mode 100644 index 00000000000..30f4461f078 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ConfigCatSDKKeySdkKey.java @@ -0,0 +1,287 @@ +/* + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.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 = ConfigCatSDKKeySdkKey.ConfigCatSDKKeySdkKeyDeserializer.class) +@JsonSerialize(using = ConfigCatSDKKeySdkKey.ConfigCatSDKKeySdkKeySerializer.class) +public class ConfigCatSDKKeySdkKey extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(ConfigCatSDKKeySdkKey.class.getName()); + + @JsonIgnore public boolean unparsed = false; + + public static class ConfigCatSDKKeySdkKeySerializer extends StdSerializer { + public ConfigCatSDKKeySdkKeySerializer(Class t) { + super(t); + } + + public ConfigCatSDKKeySdkKeySerializer() { + this(null); + } + + @Override + public void serialize( + ConfigCatSDKKeySdkKey value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class ConfigCatSDKKeySdkKeyDeserializer + extends StdDeserializer { + public ConfigCatSDKKeySdkKeyDeserializer() { + this(ConfigCatSDKKeySdkKey.class); + } + + public ConfigCatSDKKeySdkKeyDeserializer(Class vc) { + super(vc); + } + + @Override + public ConfigCatSDKKeySdkKey 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 String + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (String.class.equals(Integer.class) + || String.class.equals(Long.class) + || String.class.equals(Float.class) + || String.class.equals(Double.class) + || String.class.equals(Boolean.class) + || String.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((String.class.equals(Integer.class) || String.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((String.class.equals(Float.class) || String.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (String.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (String.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(String.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. + deserialized = tmp; + match++; + + log.log(Level.FINER, "Input data matches schema 'String'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'String'", e); + } + + // deserialize ActionConnectionAWSSecretsManagerReference + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = + tree.traverse(jp.getCodec()) + .readValueAs(ActionConnectionAWSSecretsManagerReference.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 (!((ActionConnectionAWSSecretsManagerReference) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log( + Level.FINER, + "Input data matches schema 'ActionConnectionAWSSecretsManagerReference'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'ActionConnectionAWSSecretsManagerReference'", + e); + } + + ConfigCatSDKKeySdkKey ret = new ConfigCatSDKKeySdkKey(); + 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 ConfigCatSDKKeySdkKey getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + throw new JsonMappingException(ctxt.getParser(), "ConfigCatSDKKeySdkKey cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public ConfigCatSDKKeySdkKey() { + super("oneOf", Boolean.FALSE); + } + + public ConfigCatSDKKeySdkKey(String o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public ConfigCatSDKKeySdkKey(ActionConnectionAWSSecretsManagerReference o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("String", new GenericType() {}); + schemas.put( + "ActionConnectionAWSSecretsManagerReference", + new GenericType() {}); + JSON.registerDescendants(ConfigCatSDKKeySdkKey.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map getSchemas() { + return ConfigCatSDKKeySdkKey.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: String, ActionConnectionAWSSecretsManagerReference + * + *

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(String.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + if (JSON.isInstanceOf( + ActionConnectionAWSSecretsManagerReference.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 String, ActionConnectionAWSSecretsManagerReference"); + } + + /** + * Get the actual instance, which can be the following: String, + * ActionConnectionAWSSecretsManagerReference + * + * @return The actual instance (String, ActionConnectionAWSSecretsManagerReference) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `String`. If the actual instance is not `String`, the + * ClassCastException will be thrown. + * + * @return The actual instance of `String` + * @throws ClassCastException if the instance is not `String` + */ + public String getString() throws ClassCastException { + return (String) super.getActualInstance(); + } + + /** + * Get the actual instance of `ActionConnectionAWSSecretsManagerReference`. If the actual instance + * is not `ActionConnectionAWSSecretsManagerReference`, the ClassCastException will be thrown. + * + * @return The actual instance of `ActionConnectionAWSSecretsManagerReference` + * @throws ClassCastException if the instance is not `ActionConnectionAWSSecretsManagerReference` + */ + public ActionConnectionAWSSecretsManagerReference getActionConnectionAWSSecretsManagerReference() + throws ClassCastException { + return (ActionConnectionAWSSecretsManagerReference) super.getActualInstance(); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/ConfigCatSDKKeyUpdate.java b/src/main/java/com/datadog/api/client/v2/model/ConfigCatSDKKeyUpdate.java index 547b7282484..5d6359a8a2c 100644 --- a/src/main/java/com/datadog/api/client/v2/model/ConfigCatSDKKeyUpdate.java +++ b/src/main/java/com/datadog/api/client/v2/model/ConfigCatSDKKeyUpdate.java @@ -29,13 +29,13 @@ public class ConfigCatSDKKeyUpdate { @JsonIgnore public boolean unparsed = false; public static final String JSON_PROPERTY_API_PASSWORD = "api_password"; - private String apiPassword; + private ConfigCatSDKKeyUpdateApiPassword apiPassword; public static final String JSON_PROPERTY_API_USERNAME = "api_username"; - private String apiUsername; + private ConfigCatSDKKeyUpdateApiUsername apiUsername; public static final String JSON_PROPERTY_SDK_KEY = "sdk_key"; - private String sdkKey; + private ConfigCatSDKKeyUpdateSdkKey sdkKey; public static final String JSON_PROPERTY_TYPE = "type"; private ConfigCatSDKKeyType type; @@ -49,8 +49,9 @@ public ConfigCatSDKKeyUpdate( this.unparsed |= !type.isValid(); } - public ConfigCatSDKKeyUpdate apiPassword(String apiPassword) { + public ConfigCatSDKKeyUpdate apiPassword(ConfigCatSDKKeyUpdateApiPassword apiPassword) { this.apiPassword = apiPassword; + this.unparsed |= apiPassword.unparsed; return this; } @@ -62,16 +63,20 @@ public ConfigCatSDKKeyUpdate apiPassword(String apiPassword) { @jakarta.annotation.Nullable @JsonProperty(JSON_PROPERTY_API_PASSWORD) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public String getApiPassword() { + public ConfigCatSDKKeyUpdateApiPassword getApiPassword() { return apiPassword; } - public void setApiPassword(String apiPassword) { + public void setApiPassword(ConfigCatSDKKeyUpdateApiPassword apiPassword) { this.apiPassword = apiPassword; + if (apiPassword != null) { + this.unparsed |= apiPassword.unparsed; + } } - public ConfigCatSDKKeyUpdate apiUsername(String apiUsername) { + public ConfigCatSDKKeyUpdate apiUsername(ConfigCatSDKKeyUpdateApiUsername apiUsername) { this.apiUsername = apiUsername; + this.unparsed |= apiUsername.unparsed; return this; } @@ -83,16 +88,20 @@ public ConfigCatSDKKeyUpdate apiUsername(String apiUsername) { @jakarta.annotation.Nullable @JsonProperty(JSON_PROPERTY_API_USERNAME) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public String getApiUsername() { + public ConfigCatSDKKeyUpdateApiUsername getApiUsername() { return apiUsername; } - public void setApiUsername(String apiUsername) { + public void setApiUsername(ConfigCatSDKKeyUpdateApiUsername apiUsername) { this.apiUsername = apiUsername; + if (apiUsername != null) { + this.unparsed |= apiUsername.unparsed; + } } - public ConfigCatSDKKeyUpdate sdkKey(String sdkKey) { + public ConfigCatSDKKeyUpdate sdkKey(ConfigCatSDKKeyUpdateSdkKey sdkKey) { this.sdkKey = sdkKey; + this.unparsed |= sdkKey.unparsed; return this; } @@ -104,12 +113,15 @@ public ConfigCatSDKKeyUpdate sdkKey(String sdkKey) { @jakarta.annotation.Nullable @JsonProperty(JSON_PROPERTY_SDK_KEY) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public String getSdkKey() { + public ConfigCatSDKKeyUpdateSdkKey getSdkKey() { return sdkKey; } - public void setSdkKey(String sdkKey) { + public void setSdkKey(ConfigCatSDKKeyUpdateSdkKey sdkKey) { this.sdkKey = sdkKey; + if (sdkKey != null) { + this.unparsed |= sdkKey.unparsed; + } } public ConfigCatSDKKeyUpdate type(ConfigCatSDKKeyType type) { diff --git a/src/main/java/com/datadog/api/client/v2/model/ConfigCatSDKKeyUpdateApiPassword.java b/src/main/java/com/datadog/api/client/v2/model/ConfigCatSDKKeyUpdateApiPassword.java new file mode 100644 index 00000000000..f42fc4b188b --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ConfigCatSDKKeyUpdateApiPassword.java @@ -0,0 +1,293 @@ +/* + * 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 = ConfigCatSDKKeyUpdateApiPassword.ConfigCatSDKKeyUpdateApiPasswordDeserializer.class) +@JsonSerialize( + using = ConfigCatSDKKeyUpdateApiPassword.ConfigCatSDKKeyUpdateApiPasswordSerializer.class) +public class ConfigCatSDKKeyUpdateApiPassword extends AbstractOpenApiSchema { + private static final Logger log = + Logger.getLogger(ConfigCatSDKKeyUpdateApiPassword.class.getName()); + + @JsonIgnore public boolean unparsed = false; + + public static class ConfigCatSDKKeyUpdateApiPasswordSerializer + extends StdSerializer { + public ConfigCatSDKKeyUpdateApiPasswordSerializer(Class t) { + super(t); + } + + public ConfigCatSDKKeyUpdateApiPasswordSerializer() { + this(null); + } + + @Override + public void serialize( + ConfigCatSDKKeyUpdateApiPassword value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class ConfigCatSDKKeyUpdateApiPasswordDeserializer + extends StdDeserializer { + public ConfigCatSDKKeyUpdateApiPasswordDeserializer() { + this(ConfigCatSDKKeyUpdateApiPassword.class); + } + + public ConfigCatSDKKeyUpdateApiPasswordDeserializer(Class vc) { + super(vc); + } + + @Override + public ConfigCatSDKKeyUpdateApiPassword 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 String + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (String.class.equals(Integer.class) + || String.class.equals(Long.class) + || String.class.equals(Float.class) + || String.class.equals(Double.class) + || String.class.equals(Boolean.class) + || String.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((String.class.equals(Integer.class) || String.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((String.class.equals(Float.class) || String.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (String.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (String.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(String.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. + deserialized = tmp; + match++; + + log.log(Level.FINER, "Input data matches schema 'String'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'String'", e); + } + + // deserialize ActionConnectionAWSSecretsManagerReference + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = + tree.traverse(jp.getCodec()) + .readValueAs(ActionConnectionAWSSecretsManagerReference.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 (!((ActionConnectionAWSSecretsManagerReference) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log( + Level.FINER, + "Input data matches schema 'ActionConnectionAWSSecretsManagerReference'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'ActionConnectionAWSSecretsManagerReference'", + e); + } + + ConfigCatSDKKeyUpdateApiPassword ret = new ConfigCatSDKKeyUpdateApiPassword(); + 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 ConfigCatSDKKeyUpdateApiPassword getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + throw new JsonMappingException( + ctxt.getParser(), "ConfigCatSDKKeyUpdateApiPassword cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public ConfigCatSDKKeyUpdateApiPassword() { + super("oneOf", Boolean.FALSE); + } + + public ConfigCatSDKKeyUpdateApiPassword(String o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public ConfigCatSDKKeyUpdateApiPassword(ActionConnectionAWSSecretsManagerReference o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("String", new GenericType() {}); + schemas.put( + "ActionConnectionAWSSecretsManagerReference", + new GenericType() {}); + JSON.registerDescendants( + ConfigCatSDKKeyUpdateApiPassword.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map getSchemas() { + return ConfigCatSDKKeyUpdateApiPassword.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: String, ActionConnectionAWSSecretsManagerReference + * + *

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(String.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + if (JSON.isInstanceOf( + ActionConnectionAWSSecretsManagerReference.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 String, ActionConnectionAWSSecretsManagerReference"); + } + + /** + * Get the actual instance, which can be the following: String, + * ActionConnectionAWSSecretsManagerReference + * + * @return The actual instance (String, ActionConnectionAWSSecretsManagerReference) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `String`. If the actual instance is not `String`, the + * ClassCastException will be thrown. + * + * @return The actual instance of `String` + * @throws ClassCastException if the instance is not `String` + */ + public String getString() throws ClassCastException { + return (String) super.getActualInstance(); + } + + /** + * Get the actual instance of `ActionConnectionAWSSecretsManagerReference`. If the actual instance + * is not `ActionConnectionAWSSecretsManagerReference`, the ClassCastException will be thrown. + * + * @return The actual instance of `ActionConnectionAWSSecretsManagerReference` + * @throws ClassCastException if the instance is not `ActionConnectionAWSSecretsManagerReference` + */ + public ActionConnectionAWSSecretsManagerReference getActionConnectionAWSSecretsManagerReference() + throws ClassCastException { + return (ActionConnectionAWSSecretsManagerReference) super.getActualInstance(); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/ConfigCatSDKKeyUpdateApiUsername.java b/src/main/java/com/datadog/api/client/v2/model/ConfigCatSDKKeyUpdateApiUsername.java new file mode 100644 index 00000000000..491ab4079b5 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ConfigCatSDKKeyUpdateApiUsername.java @@ -0,0 +1,293 @@ +/* + * 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 = ConfigCatSDKKeyUpdateApiUsername.ConfigCatSDKKeyUpdateApiUsernameDeserializer.class) +@JsonSerialize( + using = ConfigCatSDKKeyUpdateApiUsername.ConfigCatSDKKeyUpdateApiUsernameSerializer.class) +public class ConfigCatSDKKeyUpdateApiUsername extends AbstractOpenApiSchema { + private static final Logger log = + Logger.getLogger(ConfigCatSDKKeyUpdateApiUsername.class.getName()); + + @JsonIgnore public boolean unparsed = false; + + public static class ConfigCatSDKKeyUpdateApiUsernameSerializer + extends StdSerializer { + public ConfigCatSDKKeyUpdateApiUsernameSerializer(Class t) { + super(t); + } + + public ConfigCatSDKKeyUpdateApiUsernameSerializer() { + this(null); + } + + @Override + public void serialize( + ConfigCatSDKKeyUpdateApiUsername value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class ConfigCatSDKKeyUpdateApiUsernameDeserializer + extends StdDeserializer { + public ConfigCatSDKKeyUpdateApiUsernameDeserializer() { + this(ConfigCatSDKKeyUpdateApiUsername.class); + } + + public ConfigCatSDKKeyUpdateApiUsernameDeserializer(Class vc) { + super(vc); + } + + @Override + public ConfigCatSDKKeyUpdateApiUsername 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 String + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (String.class.equals(Integer.class) + || String.class.equals(Long.class) + || String.class.equals(Float.class) + || String.class.equals(Double.class) + || String.class.equals(Boolean.class) + || String.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((String.class.equals(Integer.class) || String.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((String.class.equals(Float.class) || String.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (String.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (String.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(String.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. + deserialized = tmp; + match++; + + log.log(Level.FINER, "Input data matches schema 'String'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'String'", e); + } + + // deserialize ActionConnectionAWSSecretsManagerReference + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = + tree.traverse(jp.getCodec()) + .readValueAs(ActionConnectionAWSSecretsManagerReference.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 (!((ActionConnectionAWSSecretsManagerReference) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log( + Level.FINER, + "Input data matches schema 'ActionConnectionAWSSecretsManagerReference'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'ActionConnectionAWSSecretsManagerReference'", + e); + } + + ConfigCatSDKKeyUpdateApiUsername ret = new ConfigCatSDKKeyUpdateApiUsername(); + 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 ConfigCatSDKKeyUpdateApiUsername getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + throw new JsonMappingException( + ctxt.getParser(), "ConfigCatSDKKeyUpdateApiUsername cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public ConfigCatSDKKeyUpdateApiUsername() { + super("oneOf", Boolean.FALSE); + } + + public ConfigCatSDKKeyUpdateApiUsername(String o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public ConfigCatSDKKeyUpdateApiUsername(ActionConnectionAWSSecretsManagerReference o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("String", new GenericType() {}); + schemas.put( + "ActionConnectionAWSSecretsManagerReference", + new GenericType() {}); + JSON.registerDescendants( + ConfigCatSDKKeyUpdateApiUsername.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map getSchemas() { + return ConfigCatSDKKeyUpdateApiUsername.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: String, ActionConnectionAWSSecretsManagerReference + * + *

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(String.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + if (JSON.isInstanceOf( + ActionConnectionAWSSecretsManagerReference.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 String, ActionConnectionAWSSecretsManagerReference"); + } + + /** + * Get the actual instance, which can be the following: String, + * ActionConnectionAWSSecretsManagerReference + * + * @return The actual instance (String, ActionConnectionAWSSecretsManagerReference) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `String`. If the actual instance is not `String`, the + * ClassCastException will be thrown. + * + * @return The actual instance of `String` + * @throws ClassCastException if the instance is not `String` + */ + public String getString() throws ClassCastException { + return (String) super.getActualInstance(); + } + + /** + * Get the actual instance of `ActionConnectionAWSSecretsManagerReference`. If the actual instance + * is not `ActionConnectionAWSSecretsManagerReference`, the ClassCastException will be thrown. + * + * @return The actual instance of `ActionConnectionAWSSecretsManagerReference` + * @throws ClassCastException if the instance is not `ActionConnectionAWSSecretsManagerReference` + */ + public ActionConnectionAWSSecretsManagerReference getActionConnectionAWSSecretsManagerReference() + throws ClassCastException { + return (ActionConnectionAWSSecretsManagerReference) super.getActualInstance(); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/ConfigCatSDKKeyUpdateSdkKey.java b/src/main/java/com/datadog/api/client/v2/model/ConfigCatSDKKeyUpdateSdkKey.java new file mode 100644 index 00000000000..16bdda08ff4 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ConfigCatSDKKeyUpdateSdkKey.java @@ -0,0 +1,290 @@ +/* + * 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 = ConfigCatSDKKeyUpdateSdkKey.ConfigCatSDKKeyUpdateSdkKeyDeserializer.class) +@JsonSerialize(using = ConfigCatSDKKeyUpdateSdkKey.ConfigCatSDKKeyUpdateSdkKeySerializer.class) +public class ConfigCatSDKKeyUpdateSdkKey extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(ConfigCatSDKKeyUpdateSdkKey.class.getName()); + + @JsonIgnore public boolean unparsed = false; + + public static class ConfigCatSDKKeyUpdateSdkKeySerializer + extends StdSerializer { + public ConfigCatSDKKeyUpdateSdkKeySerializer(Class t) { + super(t); + } + + public ConfigCatSDKKeyUpdateSdkKeySerializer() { + this(null); + } + + @Override + public void serialize( + ConfigCatSDKKeyUpdateSdkKey value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class ConfigCatSDKKeyUpdateSdkKeyDeserializer + extends StdDeserializer { + public ConfigCatSDKKeyUpdateSdkKeyDeserializer() { + this(ConfigCatSDKKeyUpdateSdkKey.class); + } + + public ConfigCatSDKKeyUpdateSdkKeyDeserializer(Class vc) { + super(vc); + } + + @Override + public ConfigCatSDKKeyUpdateSdkKey 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 String + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (String.class.equals(Integer.class) + || String.class.equals(Long.class) + || String.class.equals(Float.class) + || String.class.equals(Double.class) + || String.class.equals(Boolean.class) + || String.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((String.class.equals(Integer.class) || String.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((String.class.equals(Float.class) || String.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (String.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (String.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(String.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. + deserialized = tmp; + match++; + + log.log(Level.FINER, "Input data matches schema 'String'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'String'", e); + } + + // deserialize ActionConnectionAWSSecretsManagerReference + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = + tree.traverse(jp.getCodec()) + .readValueAs(ActionConnectionAWSSecretsManagerReference.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 (!((ActionConnectionAWSSecretsManagerReference) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log( + Level.FINER, + "Input data matches schema 'ActionConnectionAWSSecretsManagerReference'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'ActionConnectionAWSSecretsManagerReference'", + e); + } + + ConfigCatSDKKeyUpdateSdkKey ret = new ConfigCatSDKKeyUpdateSdkKey(); + 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 ConfigCatSDKKeyUpdateSdkKey getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + throw new JsonMappingException( + ctxt.getParser(), "ConfigCatSDKKeyUpdateSdkKey cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public ConfigCatSDKKeyUpdateSdkKey() { + super("oneOf", Boolean.FALSE); + } + + public ConfigCatSDKKeyUpdateSdkKey(String o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public ConfigCatSDKKeyUpdateSdkKey(ActionConnectionAWSSecretsManagerReference o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("String", new GenericType() {}); + schemas.put( + "ActionConnectionAWSSecretsManagerReference", + new GenericType() {}); + JSON.registerDescendants( + ConfigCatSDKKeyUpdateSdkKey.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map getSchemas() { + return ConfigCatSDKKeyUpdateSdkKey.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: String, ActionConnectionAWSSecretsManagerReference + * + *

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(String.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + if (JSON.isInstanceOf( + ActionConnectionAWSSecretsManagerReference.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 String, ActionConnectionAWSSecretsManagerReference"); + } + + /** + * Get the actual instance, which can be the following: String, + * ActionConnectionAWSSecretsManagerReference + * + * @return The actual instance (String, ActionConnectionAWSSecretsManagerReference) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `String`. If the actual instance is not `String`, the + * ClassCastException will be thrown. + * + * @return The actual instance of `String` + * @throws ClassCastException if the instance is not `String` + */ + public String getString() throws ClassCastException { + return (String) super.getActualInstance(); + } + + /** + * Get the actual instance of `ActionConnectionAWSSecretsManagerReference`. If the actual instance + * is not `ActionConnectionAWSSecretsManagerReference`, the ClassCastException will be thrown. + * + * @return The actual instance of `ActionConnectionAWSSecretsManagerReference` + * @throws ClassCastException if the instance is not `ActionConnectionAWSSecretsManagerReference` + */ + public ActionConnectionAWSSecretsManagerReference getActionConnectionAWSSecretsManagerReference() + throws ClassCastException { + return (ActionConnectionAWSSecretsManagerReference) super.getActualInstance(); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/DatadogAPIKey.java b/src/main/java/com/datadog/api/client/v2/model/DatadogAPIKey.java index 1b4058da461..6ade902cee9 100644 --- a/src/main/java/com/datadog/api/client/v2/model/DatadogAPIKey.java +++ b/src/main/java/com/datadog/api/client/v2/model/DatadogAPIKey.java @@ -30,16 +30,16 @@ public class DatadogAPIKey { @JsonIgnore public boolean unparsed = false; public static final String JSON_PROPERTY_API_KEY = "api_key"; - private String apiKey; + private DatadogAPIKeyApiKey apiKey; public static final String JSON_PROPERTY_APP_KEY = "app_key"; - private String appKey; + private DatadogAPIKeyAppKey appKey; public static final String JSON_PROPERTY_DATACENTER = "datacenter"; - private String datacenter; + private DatadogAPIKeyDatacenter datacenter; public static final String JSON_PROPERTY_SUBDOMAIN = "subdomain"; - private String subdomain; + private DatadogAPIKeySubdomain subdomain; public static final String JSON_PROPERTY_TYPE = "type"; private DatadogAPIKeyType type; @@ -48,19 +48,24 @@ public DatadogAPIKey() {} @JsonCreator public DatadogAPIKey( - @JsonProperty(required = true, value = JSON_PROPERTY_API_KEY) String apiKey, - @JsonProperty(required = true, value = JSON_PROPERTY_APP_KEY) String appKey, - @JsonProperty(required = true, value = JSON_PROPERTY_DATACENTER) String datacenter, + @JsonProperty(required = true, value = JSON_PROPERTY_API_KEY) DatadogAPIKeyApiKey apiKey, + @JsonProperty(required = true, value = JSON_PROPERTY_APP_KEY) DatadogAPIKeyAppKey appKey, + @JsonProperty(required = true, value = JSON_PROPERTY_DATACENTER) + DatadogAPIKeyDatacenter datacenter, @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) DatadogAPIKeyType type) { this.apiKey = apiKey; + this.unparsed |= apiKey.unparsed; this.appKey = appKey; + this.unparsed |= appKey.unparsed; this.datacenter = datacenter; + this.unparsed |= datacenter.unparsed; this.type = type; this.unparsed |= !type.isValid(); } - public DatadogAPIKey apiKey(String apiKey) { + public DatadogAPIKey apiKey(DatadogAPIKeyApiKey apiKey) { this.apiKey = apiKey; + this.unparsed |= apiKey.unparsed; return this; } @@ -71,16 +76,20 @@ public DatadogAPIKey apiKey(String apiKey) { */ @JsonProperty(JSON_PROPERTY_API_KEY) @JsonInclude(value = JsonInclude.Include.ALWAYS) - public String getApiKey() { + public DatadogAPIKeyApiKey getApiKey() { return apiKey; } - public void setApiKey(String apiKey) { + public void setApiKey(DatadogAPIKeyApiKey apiKey) { this.apiKey = apiKey; + if (apiKey != null) { + this.unparsed |= apiKey.unparsed; + } } - public DatadogAPIKey appKey(String appKey) { + public DatadogAPIKey appKey(DatadogAPIKeyAppKey appKey) { this.appKey = appKey; + this.unparsed |= appKey.unparsed; return this; } @@ -91,16 +100,20 @@ public DatadogAPIKey appKey(String appKey) { */ @JsonProperty(JSON_PROPERTY_APP_KEY) @JsonInclude(value = JsonInclude.Include.ALWAYS) - public String getAppKey() { + public DatadogAPIKeyAppKey getAppKey() { return appKey; } - public void setAppKey(String appKey) { + public void setAppKey(DatadogAPIKeyAppKey appKey) { this.appKey = appKey; + if (appKey != null) { + this.unparsed |= appKey.unparsed; + } } - public DatadogAPIKey datacenter(String datacenter) { + public DatadogAPIKey datacenter(DatadogAPIKeyDatacenter datacenter) { this.datacenter = datacenter; + this.unparsed |= datacenter.unparsed; return this; } @@ -111,16 +124,20 @@ public DatadogAPIKey datacenter(String datacenter) { */ @JsonProperty(JSON_PROPERTY_DATACENTER) @JsonInclude(value = JsonInclude.Include.ALWAYS) - public String getDatacenter() { + public DatadogAPIKeyDatacenter getDatacenter() { return datacenter; } - public void setDatacenter(String datacenter) { + public void setDatacenter(DatadogAPIKeyDatacenter datacenter) { this.datacenter = datacenter; + if (datacenter != null) { + this.unparsed |= datacenter.unparsed; + } } - public DatadogAPIKey subdomain(String subdomain) { + public DatadogAPIKey subdomain(DatadogAPIKeySubdomain subdomain) { this.subdomain = subdomain; + this.unparsed |= subdomain.unparsed; return this; } @@ -136,12 +153,15 @@ public DatadogAPIKey subdomain(String subdomain) { @jakarta.annotation.Nullable @JsonProperty(JSON_PROPERTY_SUBDOMAIN) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public String getSubdomain() { + public DatadogAPIKeySubdomain getSubdomain() { return subdomain; } - public void setSubdomain(String subdomain) { + public void setSubdomain(DatadogAPIKeySubdomain subdomain) { this.subdomain = subdomain; + if (subdomain != null) { + this.unparsed |= subdomain.unparsed; + } } public DatadogAPIKey type(DatadogAPIKeyType type) { diff --git a/src/main/java/com/datadog/api/client/v2/model/DatadogAPIKeyApiKey.java b/src/main/java/com/datadog/api/client/v2/model/DatadogAPIKeyApiKey.java new file mode 100644 index 00000000000..d12bbff23de --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/DatadogAPIKeyApiKey.java @@ -0,0 +1,286 @@ +/* + * 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 = DatadogAPIKeyApiKey.DatadogAPIKeyApiKeyDeserializer.class) +@JsonSerialize(using = DatadogAPIKeyApiKey.DatadogAPIKeyApiKeySerializer.class) +public class DatadogAPIKeyApiKey extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(DatadogAPIKeyApiKey.class.getName()); + + @JsonIgnore public boolean unparsed = false; + + public static class DatadogAPIKeyApiKeySerializer extends StdSerializer { + public DatadogAPIKeyApiKeySerializer(Class t) { + super(t); + } + + public DatadogAPIKeyApiKeySerializer() { + this(null); + } + + @Override + public void serialize( + DatadogAPIKeyApiKey value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class DatadogAPIKeyApiKeyDeserializer extends StdDeserializer { + public DatadogAPIKeyApiKeyDeserializer() { + this(DatadogAPIKeyApiKey.class); + } + + public DatadogAPIKeyApiKeyDeserializer(Class vc) { + super(vc); + } + + @Override + public DatadogAPIKeyApiKey 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 String + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (String.class.equals(Integer.class) + || String.class.equals(Long.class) + || String.class.equals(Float.class) + || String.class.equals(Double.class) + || String.class.equals(Boolean.class) + || String.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((String.class.equals(Integer.class) || String.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((String.class.equals(Float.class) || String.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (String.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (String.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(String.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. + deserialized = tmp; + match++; + + log.log(Level.FINER, "Input data matches schema 'String'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'String'", e); + } + + // deserialize ActionConnectionAWSSecretsManagerReference + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = + tree.traverse(jp.getCodec()) + .readValueAs(ActionConnectionAWSSecretsManagerReference.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 (!((ActionConnectionAWSSecretsManagerReference) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log( + Level.FINER, + "Input data matches schema 'ActionConnectionAWSSecretsManagerReference'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'ActionConnectionAWSSecretsManagerReference'", + e); + } + + DatadogAPIKeyApiKey ret = new DatadogAPIKeyApiKey(); + 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 DatadogAPIKeyApiKey getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + throw new JsonMappingException(ctxt.getParser(), "DatadogAPIKeyApiKey cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public DatadogAPIKeyApiKey() { + super("oneOf", Boolean.FALSE); + } + + public DatadogAPIKeyApiKey(String o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public DatadogAPIKeyApiKey(ActionConnectionAWSSecretsManagerReference o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("String", new GenericType() {}); + schemas.put( + "ActionConnectionAWSSecretsManagerReference", + new GenericType() {}); + JSON.registerDescendants(DatadogAPIKeyApiKey.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map getSchemas() { + return DatadogAPIKeyApiKey.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: String, ActionConnectionAWSSecretsManagerReference + * + *

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(String.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + if (JSON.isInstanceOf( + ActionConnectionAWSSecretsManagerReference.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 String, ActionConnectionAWSSecretsManagerReference"); + } + + /** + * Get the actual instance, which can be the following: String, + * ActionConnectionAWSSecretsManagerReference + * + * @return The actual instance (String, ActionConnectionAWSSecretsManagerReference) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `String`. If the actual instance is not `String`, the + * ClassCastException will be thrown. + * + * @return The actual instance of `String` + * @throws ClassCastException if the instance is not `String` + */ + public String getString() throws ClassCastException { + return (String) super.getActualInstance(); + } + + /** + * Get the actual instance of `ActionConnectionAWSSecretsManagerReference`. If the actual instance + * is not `ActionConnectionAWSSecretsManagerReference`, the ClassCastException will be thrown. + * + * @return The actual instance of `ActionConnectionAWSSecretsManagerReference` + * @throws ClassCastException if the instance is not `ActionConnectionAWSSecretsManagerReference` + */ + public ActionConnectionAWSSecretsManagerReference getActionConnectionAWSSecretsManagerReference() + throws ClassCastException { + return (ActionConnectionAWSSecretsManagerReference) super.getActualInstance(); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/DatadogAPIKeyAppKey.java b/src/main/java/com/datadog/api/client/v2/model/DatadogAPIKeyAppKey.java new file mode 100644 index 00000000000..45564321d83 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/DatadogAPIKeyAppKey.java @@ -0,0 +1,286 @@ +/* + * 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 = DatadogAPIKeyAppKey.DatadogAPIKeyAppKeyDeserializer.class) +@JsonSerialize(using = DatadogAPIKeyAppKey.DatadogAPIKeyAppKeySerializer.class) +public class DatadogAPIKeyAppKey extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(DatadogAPIKeyAppKey.class.getName()); + + @JsonIgnore public boolean unparsed = false; + + public static class DatadogAPIKeyAppKeySerializer extends StdSerializer { + public DatadogAPIKeyAppKeySerializer(Class t) { + super(t); + } + + public DatadogAPIKeyAppKeySerializer() { + this(null); + } + + @Override + public void serialize( + DatadogAPIKeyAppKey value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class DatadogAPIKeyAppKeyDeserializer extends StdDeserializer { + public DatadogAPIKeyAppKeyDeserializer() { + this(DatadogAPIKeyAppKey.class); + } + + public DatadogAPIKeyAppKeyDeserializer(Class vc) { + super(vc); + } + + @Override + public DatadogAPIKeyAppKey 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 String + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (String.class.equals(Integer.class) + || String.class.equals(Long.class) + || String.class.equals(Float.class) + || String.class.equals(Double.class) + || String.class.equals(Boolean.class) + || String.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((String.class.equals(Integer.class) || String.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((String.class.equals(Float.class) || String.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (String.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (String.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(String.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. + deserialized = tmp; + match++; + + log.log(Level.FINER, "Input data matches schema 'String'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'String'", e); + } + + // deserialize ActionConnectionAWSSecretsManagerReference + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = + tree.traverse(jp.getCodec()) + .readValueAs(ActionConnectionAWSSecretsManagerReference.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 (!((ActionConnectionAWSSecretsManagerReference) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log( + Level.FINER, + "Input data matches schema 'ActionConnectionAWSSecretsManagerReference'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'ActionConnectionAWSSecretsManagerReference'", + e); + } + + DatadogAPIKeyAppKey ret = new DatadogAPIKeyAppKey(); + 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 DatadogAPIKeyAppKey getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + throw new JsonMappingException(ctxt.getParser(), "DatadogAPIKeyAppKey cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public DatadogAPIKeyAppKey() { + super("oneOf", Boolean.FALSE); + } + + public DatadogAPIKeyAppKey(String o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public DatadogAPIKeyAppKey(ActionConnectionAWSSecretsManagerReference o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("String", new GenericType() {}); + schemas.put( + "ActionConnectionAWSSecretsManagerReference", + new GenericType() {}); + JSON.registerDescendants(DatadogAPIKeyAppKey.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map getSchemas() { + return DatadogAPIKeyAppKey.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: String, ActionConnectionAWSSecretsManagerReference + * + *

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(String.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + if (JSON.isInstanceOf( + ActionConnectionAWSSecretsManagerReference.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 String, ActionConnectionAWSSecretsManagerReference"); + } + + /** + * Get the actual instance, which can be the following: String, + * ActionConnectionAWSSecretsManagerReference + * + * @return The actual instance (String, ActionConnectionAWSSecretsManagerReference) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `String`. If the actual instance is not `String`, the + * ClassCastException will be thrown. + * + * @return The actual instance of `String` + * @throws ClassCastException if the instance is not `String` + */ + public String getString() throws ClassCastException { + return (String) super.getActualInstance(); + } + + /** + * Get the actual instance of `ActionConnectionAWSSecretsManagerReference`. If the actual instance + * is not `ActionConnectionAWSSecretsManagerReference`, the ClassCastException will be thrown. + * + * @return The actual instance of `ActionConnectionAWSSecretsManagerReference` + * @throws ClassCastException if the instance is not `ActionConnectionAWSSecretsManagerReference` + */ + public ActionConnectionAWSSecretsManagerReference getActionConnectionAWSSecretsManagerReference() + throws ClassCastException { + return (ActionConnectionAWSSecretsManagerReference) super.getActualInstance(); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/DatadogAPIKeyDatacenter.java b/src/main/java/com/datadog/api/client/v2/model/DatadogAPIKeyDatacenter.java new file mode 100644 index 00000000000..91623d73889 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/DatadogAPIKeyDatacenter.java @@ -0,0 +1,288 @@ +/* + * 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 = DatadogAPIKeyDatacenter.DatadogAPIKeyDatacenterDeserializer.class) +@JsonSerialize(using = DatadogAPIKeyDatacenter.DatadogAPIKeyDatacenterSerializer.class) +public class DatadogAPIKeyDatacenter extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(DatadogAPIKeyDatacenter.class.getName()); + + @JsonIgnore public boolean unparsed = false; + + public static class DatadogAPIKeyDatacenterSerializer + extends StdSerializer { + public DatadogAPIKeyDatacenterSerializer(Class t) { + super(t); + } + + public DatadogAPIKeyDatacenterSerializer() { + this(null); + } + + @Override + public void serialize( + DatadogAPIKeyDatacenter value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class DatadogAPIKeyDatacenterDeserializer + extends StdDeserializer { + public DatadogAPIKeyDatacenterDeserializer() { + this(DatadogAPIKeyDatacenter.class); + } + + public DatadogAPIKeyDatacenterDeserializer(Class vc) { + super(vc); + } + + @Override + public DatadogAPIKeyDatacenter 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 String + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (String.class.equals(Integer.class) + || String.class.equals(Long.class) + || String.class.equals(Float.class) + || String.class.equals(Double.class) + || String.class.equals(Boolean.class) + || String.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((String.class.equals(Integer.class) || String.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((String.class.equals(Float.class) || String.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (String.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (String.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(String.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. + deserialized = tmp; + match++; + + log.log(Level.FINER, "Input data matches schema 'String'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'String'", e); + } + + // deserialize ActionConnectionAWSSecretsManagerReference + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = + tree.traverse(jp.getCodec()) + .readValueAs(ActionConnectionAWSSecretsManagerReference.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 (!((ActionConnectionAWSSecretsManagerReference) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log( + Level.FINER, + "Input data matches schema 'ActionConnectionAWSSecretsManagerReference'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'ActionConnectionAWSSecretsManagerReference'", + e); + } + + DatadogAPIKeyDatacenter ret = new DatadogAPIKeyDatacenter(); + 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 DatadogAPIKeyDatacenter getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + throw new JsonMappingException(ctxt.getParser(), "DatadogAPIKeyDatacenter cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public DatadogAPIKeyDatacenter() { + super("oneOf", Boolean.FALSE); + } + + public DatadogAPIKeyDatacenter(String o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public DatadogAPIKeyDatacenter(ActionConnectionAWSSecretsManagerReference o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("String", new GenericType() {}); + schemas.put( + "ActionConnectionAWSSecretsManagerReference", + new GenericType() {}); + JSON.registerDescendants(DatadogAPIKeyDatacenter.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map getSchemas() { + return DatadogAPIKeyDatacenter.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: String, ActionConnectionAWSSecretsManagerReference + * + *

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(String.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + if (JSON.isInstanceOf( + ActionConnectionAWSSecretsManagerReference.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 String, ActionConnectionAWSSecretsManagerReference"); + } + + /** + * Get the actual instance, which can be the following: String, + * ActionConnectionAWSSecretsManagerReference + * + * @return The actual instance (String, ActionConnectionAWSSecretsManagerReference) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `String`. If the actual instance is not `String`, the + * ClassCastException will be thrown. + * + * @return The actual instance of `String` + * @throws ClassCastException if the instance is not `String` + */ + public String getString() throws ClassCastException { + return (String) super.getActualInstance(); + } + + /** + * Get the actual instance of `ActionConnectionAWSSecretsManagerReference`. If the actual instance + * is not `ActionConnectionAWSSecretsManagerReference`, the ClassCastException will be thrown. + * + * @return The actual instance of `ActionConnectionAWSSecretsManagerReference` + * @throws ClassCastException if the instance is not `ActionConnectionAWSSecretsManagerReference` + */ + public ActionConnectionAWSSecretsManagerReference getActionConnectionAWSSecretsManagerReference() + throws ClassCastException { + return (ActionConnectionAWSSecretsManagerReference) super.getActualInstance(); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/DatadogAPIKeySubdomain.java b/src/main/java/com/datadog/api/client/v2/model/DatadogAPIKeySubdomain.java new file mode 100644 index 00000000000..a8c57a6629e --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/DatadogAPIKeySubdomain.java @@ -0,0 +1,288 @@ +/* + * 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 = DatadogAPIKeySubdomain.DatadogAPIKeySubdomainDeserializer.class) +@JsonSerialize(using = DatadogAPIKeySubdomain.DatadogAPIKeySubdomainSerializer.class) +public class DatadogAPIKeySubdomain extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(DatadogAPIKeySubdomain.class.getName()); + + @JsonIgnore public boolean unparsed = false; + + public static class DatadogAPIKeySubdomainSerializer + extends StdSerializer { + public DatadogAPIKeySubdomainSerializer(Class t) { + super(t); + } + + public DatadogAPIKeySubdomainSerializer() { + this(null); + } + + @Override + public void serialize( + DatadogAPIKeySubdomain value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class DatadogAPIKeySubdomainDeserializer + extends StdDeserializer { + public DatadogAPIKeySubdomainDeserializer() { + this(DatadogAPIKeySubdomain.class); + } + + public DatadogAPIKeySubdomainDeserializer(Class vc) { + super(vc); + } + + @Override + public DatadogAPIKeySubdomain 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 String + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (String.class.equals(Integer.class) + || String.class.equals(Long.class) + || String.class.equals(Float.class) + || String.class.equals(Double.class) + || String.class.equals(Boolean.class) + || String.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((String.class.equals(Integer.class) || String.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((String.class.equals(Float.class) || String.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (String.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (String.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(String.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. + deserialized = tmp; + match++; + + log.log(Level.FINER, "Input data matches schema 'String'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'String'", e); + } + + // deserialize ActionConnectionAWSSecretsManagerReference + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = + tree.traverse(jp.getCodec()) + .readValueAs(ActionConnectionAWSSecretsManagerReference.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 (!((ActionConnectionAWSSecretsManagerReference) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log( + Level.FINER, + "Input data matches schema 'ActionConnectionAWSSecretsManagerReference'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'ActionConnectionAWSSecretsManagerReference'", + e); + } + + DatadogAPIKeySubdomain ret = new DatadogAPIKeySubdomain(); + 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 DatadogAPIKeySubdomain getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + throw new JsonMappingException(ctxt.getParser(), "DatadogAPIKeySubdomain cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public DatadogAPIKeySubdomain() { + super("oneOf", Boolean.FALSE); + } + + public DatadogAPIKeySubdomain(String o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public DatadogAPIKeySubdomain(ActionConnectionAWSSecretsManagerReference o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("String", new GenericType() {}); + schemas.put( + "ActionConnectionAWSSecretsManagerReference", + new GenericType() {}); + JSON.registerDescendants(DatadogAPIKeySubdomain.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map getSchemas() { + return DatadogAPIKeySubdomain.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: String, ActionConnectionAWSSecretsManagerReference + * + *

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(String.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + if (JSON.isInstanceOf( + ActionConnectionAWSSecretsManagerReference.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 String, ActionConnectionAWSSecretsManagerReference"); + } + + /** + * Get the actual instance, which can be the following: String, + * ActionConnectionAWSSecretsManagerReference + * + * @return The actual instance (String, ActionConnectionAWSSecretsManagerReference) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `String`. If the actual instance is not `String`, the + * ClassCastException will be thrown. + * + * @return The actual instance of `String` + * @throws ClassCastException if the instance is not `String` + */ + public String getString() throws ClassCastException { + return (String) super.getActualInstance(); + } + + /** + * Get the actual instance of `ActionConnectionAWSSecretsManagerReference`. If the actual instance + * is not `ActionConnectionAWSSecretsManagerReference`, the ClassCastException will be thrown. + * + * @return The actual instance of `ActionConnectionAWSSecretsManagerReference` + * @throws ClassCastException if the instance is not `ActionConnectionAWSSecretsManagerReference` + */ + public ActionConnectionAWSSecretsManagerReference getActionConnectionAWSSecretsManagerReference() + throws ClassCastException { + return (ActionConnectionAWSSecretsManagerReference) super.getActualInstance(); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/DatadogAPIKeyUpdate.java b/src/main/java/com/datadog/api/client/v2/model/DatadogAPIKeyUpdate.java index 8a0ebe58f3d..1d2501ead36 100644 --- a/src/main/java/com/datadog/api/client/v2/model/DatadogAPIKeyUpdate.java +++ b/src/main/java/com/datadog/api/client/v2/model/DatadogAPIKeyUpdate.java @@ -30,16 +30,16 @@ public class DatadogAPIKeyUpdate { @JsonIgnore public boolean unparsed = false; public static final String JSON_PROPERTY_API_KEY = "api_key"; - private String apiKey; + private DatadogAPIKeyUpdateApiKey apiKey; public static final String JSON_PROPERTY_APP_KEY = "app_key"; - private String appKey; + private DatadogAPIKeyUpdateAppKey appKey; public static final String JSON_PROPERTY_DATACENTER = "datacenter"; - private String datacenter; + private DatadogAPIKeyUpdateDatacenter datacenter; public static final String JSON_PROPERTY_SUBDOMAIN = "subdomain"; - private String subdomain; + private DatadogAPIKeySubdomain subdomain; public static final String JSON_PROPERTY_TYPE = "type"; private DatadogAPIKeyType type; @@ -53,8 +53,9 @@ public DatadogAPIKeyUpdate( this.unparsed |= !type.isValid(); } - public DatadogAPIKeyUpdate apiKey(String apiKey) { + public DatadogAPIKeyUpdate apiKey(DatadogAPIKeyUpdateApiKey apiKey) { this.apiKey = apiKey; + this.unparsed |= apiKey.unparsed; return this; } @@ -66,16 +67,20 @@ public DatadogAPIKeyUpdate apiKey(String apiKey) { @jakarta.annotation.Nullable @JsonProperty(JSON_PROPERTY_API_KEY) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public String getApiKey() { + public DatadogAPIKeyUpdateApiKey getApiKey() { return apiKey; } - public void setApiKey(String apiKey) { + public void setApiKey(DatadogAPIKeyUpdateApiKey apiKey) { this.apiKey = apiKey; + if (apiKey != null) { + this.unparsed |= apiKey.unparsed; + } } - public DatadogAPIKeyUpdate appKey(String appKey) { + public DatadogAPIKeyUpdate appKey(DatadogAPIKeyUpdateAppKey appKey) { this.appKey = appKey; + this.unparsed |= appKey.unparsed; return this; } @@ -87,16 +92,20 @@ public DatadogAPIKeyUpdate appKey(String appKey) { @jakarta.annotation.Nullable @JsonProperty(JSON_PROPERTY_APP_KEY) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public String getAppKey() { + public DatadogAPIKeyUpdateAppKey getAppKey() { return appKey; } - public void setAppKey(String appKey) { + public void setAppKey(DatadogAPIKeyUpdateAppKey appKey) { this.appKey = appKey; + if (appKey != null) { + this.unparsed |= appKey.unparsed; + } } - public DatadogAPIKeyUpdate datacenter(String datacenter) { + public DatadogAPIKeyUpdate datacenter(DatadogAPIKeyUpdateDatacenter datacenter) { this.datacenter = datacenter; + this.unparsed |= datacenter.unparsed; return this; } @@ -108,16 +117,20 @@ public DatadogAPIKeyUpdate datacenter(String datacenter) { @jakarta.annotation.Nullable @JsonProperty(JSON_PROPERTY_DATACENTER) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public String getDatacenter() { + public DatadogAPIKeyUpdateDatacenter getDatacenter() { return datacenter; } - public void setDatacenter(String datacenter) { + public void setDatacenter(DatadogAPIKeyUpdateDatacenter datacenter) { this.datacenter = datacenter; + if (datacenter != null) { + this.unparsed |= datacenter.unparsed; + } } - public DatadogAPIKeyUpdate subdomain(String subdomain) { + public DatadogAPIKeyUpdate subdomain(DatadogAPIKeySubdomain subdomain) { this.subdomain = subdomain; + this.unparsed |= subdomain.unparsed; return this; } @@ -133,12 +146,15 @@ public DatadogAPIKeyUpdate subdomain(String subdomain) { @jakarta.annotation.Nullable @JsonProperty(JSON_PROPERTY_SUBDOMAIN) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public String getSubdomain() { + public DatadogAPIKeySubdomain getSubdomain() { return subdomain; } - public void setSubdomain(String subdomain) { + public void setSubdomain(DatadogAPIKeySubdomain subdomain) { this.subdomain = subdomain; + if (subdomain != null) { + this.unparsed |= subdomain.unparsed; + } } public DatadogAPIKeyUpdate type(DatadogAPIKeyType type) { diff --git a/src/main/java/com/datadog/api/client/v2/model/DatadogAPIKeyUpdateApiKey.java b/src/main/java/com/datadog/api/client/v2/model/DatadogAPIKeyUpdateApiKey.java new file mode 100644 index 00000000000..22e7638e09b --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/DatadogAPIKeyUpdateApiKey.java @@ -0,0 +1,288 @@ +/* + * 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 = DatadogAPIKeyUpdateApiKey.DatadogAPIKeyUpdateApiKeyDeserializer.class) +@JsonSerialize(using = DatadogAPIKeyUpdateApiKey.DatadogAPIKeyUpdateApiKeySerializer.class) +public class DatadogAPIKeyUpdateApiKey extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(DatadogAPIKeyUpdateApiKey.class.getName()); + + @JsonIgnore public boolean unparsed = false; + + public static class DatadogAPIKeyUpdateApiKeySerializer + extends StdSerializer { + public DatadogAPIKeyUpdateApiKeySerializer(Class t) { + super(t); + } + + public DatadogAPIKeyUpdateApiKeySerializer() { + this(null); + } + + @Override + public void serialize( + DatadogAPIKeyUpdateApiKey value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class DatadogAPIKeyUpdateApiKeyDeserializer + extends StdDeserializer { + public DatadogAPIKeyUpdateApiKeyDeserializer() { + this(DatadogAPIKeyUpdateApiKey.class); + } + + public DatadogAPIKeyUpdateApiKeyDeserializer(Class vc) { + super(vc); + } + + @Override + public DatadogAPIKeyUpdateApiKey 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 String + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (String.class.equals(Integer.class) + || String.class.equals(Long.class) + || String.class.equals(Float.class) + || String.class.equals(Double.class) + || String.class.equals(Boolean.class) + || String.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((String.class.equals(Integer.class) || String.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((String.class.equals(Float.class) || String.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (String.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (String.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(String.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. + deserialized = tmp; + match++; + + log.log(Level.FINER, "Input data matches schema 'String'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'String'", e); + } + + // deserialize ActionConnectionAWSSecretsManagerReference + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = + tree.traverse(jp.getCodec()) + .readValueAs(ActionConnectionAWSSecretsManagerReference.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 (!((ActionConnectionAWSSecretsManagerReference) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log( + Level.FINER, + "Input data matches schema 'ActionConnectionAWSSecretsManagerReference'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'ActionConnectionAWSSecretsManagerReference'", + e); + } + + DatadogAPIKeyUpdateApiKey ret = new DatadogAPIKeyUpdateApiKey(); + 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 DatadogAPIKeyUpdateApiKey getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + throw new JsonMappingException(ctxt.getParser(), "DatadogAPIKeyUpdateApiKey cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public DatadogAPIKeyUpdateApiKey() { + super("oneOf", Boolean.FALSE); + } + + public DatadogAPIKeyUpdateApiKey(String o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public DatadogAPIKeyUpdateApiKey(ActionConnectionAWSSecretsManagerReference o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("String", new GenericType() {}); + schemas.put( + "ActionConnectionAWSSecretsManagerReference", + new GenericType() {}); + JSON.registerDescendants(DatadogAPIKeyUpdateApiKey.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map getSchemas() { + return DatadogAPIKeyUpdateApiKey.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: String, ActionConnectionAWSSecretsManagerReference + * + *

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(String.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + if (JSON.isInstanceOf( + ActionConnectionAWSSecretsManagerReference.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 String, ActionConnectionAWSSecretsManagerReference"); + } + + /** + * Get the actual instance, which can be the following: String, + * ActionConnectionAWSSecretsManagerReference + * + * @return The actual instance (String, ActionConnectionAWSSecretsManagerReference) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `String`. If the actual instance is not `String`, the + * ClassCastException will be thrown. + * + * @return The actual instance of `String` + * @throws ClassCastException if the instance is not `String` + */ + public String getString() throws ClassCastException { + return (String) super.getActualInstance(); + } + + /** + * Get the actual instance of `ActionConnectionAWSSecretsManagerReference`. If the actual instance + * is not `ActionConnectionAWSSecretsManagerReference`, the ClassCastException will be thrown. + * + * @return The actual instance of `ActionConnectionAWSSecretsManagerReference` + * @throws ClassCastException if the instance is not `ActionConnectionAWSSecretsManagerReference` + */ + public ActionConnectionAWSSecretsManagerReference getActionConnectionAWSSecretsManagerReference() + throws ClassCastException { + return (ActionConnectionAWSSecretsManagerReference) super.getActualInstance(); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/DatadogAPIKeyUpdateAppKey.java b/src/main/java/com/datadog/api/client/v2/model/DatadogAPIKeyUpdateAppKey.java new file mode 100644 index 00000000000..fddbb8d457b --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/DatadogAPIKeyUpdateAppKey.java @@ -0,0 +1,288 @@ +/* + * 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 = DatadogAPIKeyUpdateAppKey.DatadogAPIKeyUpdateAppKeyDeserializer.class) +@JsonSerialize(using = DatadogAPIKeyUpdateAppKey.DatadogAPIKeyUpdateAppKeySerializer.class) +public class DatadogAPIKeyUpdateAppKey extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(DatadogAPIKeyUpdateAppKey.class.getName()); + + @JsonIgnore public boolean unparsed = false; + + public static class DatadogAPIKeyUpdateAppKeySerializer + extends StdSerializer { + public DatadogAPIKeyUpdateAppKeySerializer(Class t) { + super(t); + } + + public DatadogAPIKeyUpdateAppKeySerializer() { + this(null); + } + + @Override + public void serialize( + DatadogAPIKeyUpdateAppKey value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class DatadogAPIKeyUpdateAppKeyDeserializer + extends StdDeserializer { + public DatadogAPIKeyUpdateAppKeyDeserializer() { + this(DatadogAPIKeyUpdateAppKey.class); + } + + public DatadogAPIKeyUpdateAppKeyDeserializer(Class vc) { + super(vc); + } + + @Override + public DatadogAPIKeyUpdateAppKey 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 String + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (String.class.equals(Integer.class) + || String.class.equals(Long.class) + || String.class.equals(Float.class) + || String.class.equals(Double.class) + || String.class.equals(Boolean.class) + || String.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((String.class.equals(Integer.class) || String.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((String.class.equals(Float.class) || String.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (String.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (String.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(String.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. + deserialized = tmp; + match++; + + log.log(Level.FINER, "Input data matches schema 'String'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'String'", e); + } + + // deserialize ActionConnectionAWSSecretsManagerReference + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = + tree.traverse(jp.getCodec()) + .readValueAs(ActionConnectionAWSSecretsManagerReference.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 (!((ActionConnectionAWSSecretsManagerReference) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log( + Level.FINER, + "Input data matches schema 'ActionConnectionAWSSecretsManagerReference'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'ActionConnectionAWSSecretsManagerReference'", + e); + } + + DatadogAPIKeyUpdateAppKey ret = new DatadogAPIKeyUpdateAppKey(); + 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 DatadogAPIKeyUpdateAppKey getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + throw new JsonMappingException(ctxt.getParser(), "DatadogAPIKeyUpdateAppKey cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public DatadogAPIKeyUpdateAppKey() { + super("oneOf", Boolean.FALSE); + } + + public DatadogAPIKeyUpdateAppKey(String o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public DatadogAPIKeyUpdateAppKey(ActionConnectionAWSSecretsManagerReference o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("String", new GenericType() {}); + schemas.put( + "ActionConnectionAWSSecretsManagerReference", + new GenericType() {}); + JSON.registerDescendants(DatadogAPIKeyUpdateAppKey.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map getSchemas() { + return DatadogAPIKeyUpdateAppKey.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: String, ActionConnectionAWSSecretsManagerReference + * + *

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(String.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + if (JSON.isInstanceOf( + ActionConnectionAWSSecretsManagerReference.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 String, ActionConnectionAWSSecretsManagerReference"); + } + + /** + * Get the actual instance, which can be the following: String, + * ActionConnectionAWSSecretsManagerReference + * + * @return The actual instance (String, ActionConnectionAWSSecretsManagerReference) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `String`. If the actual instance is not `String`, the + * ClassCastException will be thrown. + * + * @return The actual instance of `String` + * @throws ClassCastException if the instance is not `String` + */ + public String getString() throws ClassCastException { + return (String) super.getActualInstance(); + } + + /** + * Get the actual instance of `ActionConnectionAWSSecretsManagerReference`. If the actual instance + * is not `ActionConnectionAWSSecretsManagerReference`, the ClassCastException will be thrown. + * + * @return The actual instance of `ActionConnectionAWSSecretsManagerReference` + * @throws ClassCastException if the instance is not `ActionConnectionAWSSecretsManagerReference` + */ + public ActionConnectionAWSSecretsManagerReference getActionConnectionAWSSecretsManagerReference() + throws ClassCastException { + return (ActionConnectionAWSSecretsManagerReference) super.getActualInstance(); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/DatadogAPIKeyUpdateDatacenter.java b/src/main/java/com/datadog/api/client/v2/model/DatadogAPIKeyUpdateDatacenter.java new file mode 100644 index 00000000000..424bbe1aa05 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/DatadogAPIKeyUpdateDatacenter.java @@ -0,0 +1,291 @@ +/* + * 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 = DatadogAPIKeyUpdateDatacenter.DatadogAPIKeyUpdateDatacenterDeserializer.class) +@JsonSerialize(using = DatadogAPIKeyUpdateDatacenter.DatadogAPIKeyUpdateDatacenterSerializer.class) +public class DatadogAPIKeyUpdateDatacenter extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(DatadogAPIKeyUpdateDatacenter.class.getName()); + + @JsonIgnore public boolean unparsed = false; + + public static class DatadogAPIKeyUpdateDatacenterSerializer + extends StdSerializer { + public DatadogAPIKeyUpdateDatacenterSerializer(Class t) { + super(t); + } + + public DatadogAPIKeyUpdateDatacenterSerializer() { + this(null); + } + + @Override + public void serialize( + DatadogAPIKeyUpdateDatacenter value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class DatadogAPIKeyUpdateDatacenterDeserializer + extends StdDeserializer { + public DatadogAPIKeyUpdateDatacenterDeserializer() { + this(DatadogAPIKeyUpdateDatacenter.class); + } + + public DatadogAPIKeyUpdateDatacenterDeserializer(Class vc) { + super(vc); + } + + @Override + public DatadogAPIKeyUpdateDatacenter 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 String + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (String.class.equals(Integer.class) + || String.class.equals(Long.class) + || String.class.equals(Float.class) + || String.class.equals(Double.class) + || String.class.equals(Boolean.class) + || String.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((String.class.equals(Integer.class) || String.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((String.class.equals(Float.class) || String.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (String.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (String.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(String.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. + deserialized = tmp; + match++; + + log.log(Level.FINER, "Input data matches schema 'String'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'String'", e); + } + + // deserialize ActionConnectionAWSSecretsManagerReference + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = + tree.traverse(jp.getCodec()) + .readValueAs(ActionConnectionAWSSecretsManagerReference.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 (!((ActionConnectionAWSSecretsManagerReference) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log( + Level.FINER, + "Input data matches schema 'ActionConnectionAWSSecretsManagerReference'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'ActionConnectionAWSSecretsManagerReference'", + e); + } + + DatadogAPIKeyUpdateDatacenter ret = new DatadogAPIKeyUpdateDatacenter(); + 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 DatadogAPIKeyUpdateDatacenter getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + throw new JsonMappingException( + ctxt.getParser(), "DatadogAPIKeyUpdateDatacenter cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public DatadogAPIKeyUpdateDatacenter() { + super("oneOf", Boolean.FALSE); + } + + public DatadogAPIKeyUpdateDatacenter(String o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public DatadogAPIKeyUpdateDatacenter(ActionConnectionAWSSecretsManagerReference o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("String", new GenericType() {}); + schemas.put( + "ActionConnectionAWSSecretsManagerReference", + new GenericType() {}); + JSON.registerDescendants( + DatadogAPIKeyUpdateDatacenter.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map getSchemas() { + return DatadogAPIKeyUpdateDatacenter.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: String, ActionConnectionAWSSecretsManagerReference + * + *

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(String.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + if (JSON.isInstanceOf( + ActionConnectionAWSSecretsManagerReference.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 String, ActionConnectionAWSSecretsManagerReference"); + } + + /** + * Get the actual instance, which can be the following: String, + * ActionConnectionAWSSecretsManagerReference + * + * @return The actual instance (String, ActionConnectionAWSSecretsManagerReference) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `String`. If the actual instance is not `String`, the + * ClassCastException will be thrown. + * + * @return The actual instance of `String` + * @throws ClassCastException if the instance is not `String` + */ + public String getString() throws ClassCastException { + return (String) super.getActualInstance(); + } + + /** + * Get the actual instance of `ActionConnectionAWSSecretsManagerReference`. If the actual instance + * is not `ActionConnectionAWSSecretsManagerReference`, the ClassCastException will be thrown. + * + * @return The actual instance of `ActionConnectionAWSSecretsManagerReference` + * @throws ClassCastException if the instance is not `ActionConnectionAWSSecretsManagerReference` + */ + public ActionConnectionAWSSecretsManagerReference getActionConnectionAWSSecretsManagerReference() + throws ClassCastException { + return (ActionConnectionAWSSecretsManagerReference) super.getActualInstance(); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/FastlyAPIKey.java b/src/main/java/com/datadog/api/client/v2/model/FastlyAPIKey.java index 568441ec38c..5c3f372d026 100644 --- a/src/main/java/com/datadog/api/client/v2/model/FastlyAPIKey.java +++ b/src/main/java/com/datadog/api/client/v2/model/FastlyAPIKey.java @@ -24,7 +24,7 @@ public class FastlyAPIKey { @JsonIgnore public boolean unparsed = false; public static final String JSON_PROPERTY_API_KEY = "api_key"; - private String apiKey; + private FastlyAPIKeyApiKey apiKey; public static final String JSON_PROPERTY_TYPE = "type"; private FastlyAPIKeyType type; @@ -33,15 +33,17 @@ public FastlyAPIKey() {} @JsonCreator public FastlyAPIKey( - @JsonProperty(required = true, value = JSON_PROPERTY_API_KEY) String apiKey, + @JsonProperty(required = true, value = JSON_PROPERTY_API_KEY) FastlyAPIKeyApiKey apiKey, @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) FastlyAPIKeyType type) { this.apiKey = apiKey; + this.unparsed |= apiKey.unparsed; this.type = type; this.unparsed |= !type.isValid(); } - public FastlyAPIKey apiKey(String apiKey) { + public FastlyAPIKey apiKey(FastlyAPIKeyApiKey apiKey) { this.apiKey = apiKey; + this.unparsed |= apiKey.unparsed; return this; } @@ -52,12 +54,15 @@ public FastlyAPIKey apiKey(String apiKey) { */ @JsonProperty(JSON_PROPERTY_API_KEY) @JsonInclude(value = JsonInclude.Include.ALWAYS) - public String getApiKey() { + public FastlyAPIKeyApiKey getApiKey() { return apiKey; } - public void setApiKey(String apiKey) { + public void setApiKey(FastlyAPIKeyApiKey apiKey) { this.apiKey = apiKey; + if (apiKey != null) { + this.unparsed |= apiKey.unparsed; + } } public FastlyAPIKey type(FastlyAPIKeyType type) { diff --git a/src/main/java/com/datadog/api/client/v2/model/FastlyAPIKeyApiKey.java b/src/main/java/com/datadog/api/client/v2/model/FastlyAPIKeyApiKey.java new file mode 100644 index 00000000000..20f9616078b --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/FastlyAPIKeyApiKey.java @@ -0,0 +1,285 @@ +/* + * 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 = FastlyAPIKeyApiKey.FastlyAPIKeyApiKeyDeserializer.class) +@JsonSerialize(using = FastlyAPIKeyApiKey.FastlyAPIKeyApiKeySerializer.class) +public class FastlyAPIKeyApiKey extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(FastlyAPIKeyApiKey.class.getName()); + + @JsonIgnore public boolean unparsed = false; + + public static class FastlyAPIKeyApiKeySerializer extends StdSerializer { + public FastlyAPIKeyApiKeySerializer(Class t) { + super(t); + } + + public FastlyAPIKeyApiKeySerializer() { + this(null); + } + + @Override + public void serialize(FastlyAPIKeyApiKey value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class FastlyAPIKeyApiKeyDeserializer extends StdDeserializer { + public FastlyAPIKeyApiKeyDeserializer() { + this(FastlyAPIKeyApiKey.class); + } + + public FastlyAPIKeyApiKeyDeserializer(Class vc) { + super(vc); + } + + @Override + public FastlyAPIKeyApiKey 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 String + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (String.class.equals(Integer.class) + || String.class.equals(Long.class) + || String.class.equals(Float.class) + || String.class.equals(Double.class) + || String.class.equals(Boolean.class) + || String.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((String.class.equals(Integer.class) || String.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((String.class.equals(Float.class) || String.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (String.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (String.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(String.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. + deserialized = tmp; + match++; + + log.log(Level.FINER, "Input data matches schema 'String'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'String'", e); + } + + // deserialize ActionConnectionAWSSecretsManagerReference + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = + tree.traverse(jp.getCodec()) + .readValueAs(ActionConnectionAWSSecretsManagerReference.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 (!((ActionConnectionAWSSecretsManagerReference) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log( + Level.FINER, + "Input data matches schema 'ActionConnectionAWSSecretsManagerReference'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'ActionConnectionAWSSecretsManagerReference'", + e); + } + + FastlyAPIKeyApiKey ret = new FastlyAPIKeyApiKey(); + 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 FastlyAPIKeyApiKey getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + throw new JsonMappingException(ctxt.getParser(), "FastlyAPIKeyApiKey cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public FastlyAPIKeyApiKey() { + super("oneOf", Boolean.FALSE); + } + + public FastlyAPIKeyApiKey(String o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public FastlyAPIKeyApiKey(ActionConnectionAWSSecretsManagerReference o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("String", new GenericType() {}); + schemas.put( + "ActionConnectionAWSSecretsManagerReference", + new GenericType() {}); + JSON.registerDescendants(FastlyAPIKeyApiKey.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map getSchemas() { + return FastlyAPIKeyApiKey.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: String, ActionConnectionAWSSecretsManagerReference + * + *

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(String.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + if (JSON.isInstanceOf( + ActionConnectionAWSSecretsManagerReference.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 String, ActionConnectionAWSSecretsManagerReference"); + } + + /** + * Get the actual instance, which can be the following: String, + * ActionConnectionAWSSecretsManagerReference + * + * @return The actual instance (String, ActionConnectionAWSSecretsManagerReference) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `String`. If the actual instance is not `String`, the + * ClassCastException will be thrown. + * + * @return The actual instance of `String` + * @throws ClassCastException if the instance is not `String` + */ + public String getString() throws ClassCastException { + return (String) super.getActualInstance(); + } + + /** + * Get the actual instance of `ActionConnectionAWSSecretsManagerReference`. If the actual instance + * is not `ActionConnectionAWSSecretsManagerReference`, the ClassCastException will be thrown. + * + * @return The actual instance of `ActionConnectionAWSSecretsManagerReference` + * @throws ClassCastException if the instance is not `ActionConnectionAWSSecretsManagerReference` + */ + public ActionConnectionAWSSecretsManagerReference getActionConnectionAWSSecretsManagerReference() + throws ClassCastException { + return (ActionConnectionAWSSecretsManagerReference) super.getActualInstance(); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/FastlyAPIKeyUpdate.java b/src/main/java/com/datadog/api/client/v2/model/FastlyAPIKeyUpdate.java index 0965c431e06..234b1da7739 100644 --- a/src/main/java/com/datadog/api/client/v2/model/FastlyAPIKeyUpdate.java +++ b/src/main/java/com/datadog/api/client/v2/model/FastlyAPIKeyUpdate.java @@ -27,7 +27,7 @@ public class FastlyAPIKeyUpdate { @JsonIgnore public boolean unparsed = false; public static final String JSON_PROPERTY_API_KEY = "api_key"; - private String apiKey; + private FastlyAPIKeyUpdateApiKey apiKey; public static final String JSON_PROPERTY_TYPE = "type"; private FastlyAPIKeyType type; @@ -41,8 +41,9 @@ public FastlyAPIKeyUpdate( this.unparsed |= !type.isValid(); } - public FastlyAPIKeyUpdate apiKey(String apiKey) { + public FastlyAPIKeyUpdate apiKey(FastlyAPIKeyUpdateApiKey apiKey) { this.apiKey = apiKey; + this.unparsed |= apiKey.unparsed; return this; } @@ -54,12 +55,15 @@ public FastlyAPIKeyUpdate apiKey(String apiKey) { @jakarta.annotation.Nullable @JsonProperty(JSON_PROPERTY_API_KEY) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public String getApiKey() { + public FastlyAPIKeyUpdateApiKey getApiKey() { return apiKey; } - public void setApiKey(String apiKey) { + public void setApiKey(FastlyAPIKeyUpdateApiKey apiKey) { this.apiKey = apiKey; + if (apiKey != null) { + this.unparsed |= apiKey.unparsed; + } } public FastlyAPIKeyUpdate type(FastlyAPIKeyType type) { diff --git a/src/main/java/com/datadog/api/client/v2/model/FastlyAPIKeyUpdateApiKey.java b/src/main/java/com/datadog/api/client/v2/model/FastlyAPIKeyUpdateApiKey.java new file mode 100644 index 00000000000..0d35e7a0473 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/FastlyAPIKeyUpdateApiKey.java @@ -0,0 +1,288 @@ +/* + * 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 = FastlyAPIKeyUpdateApiKey.FastlyAPIKeyUpdateApiKeyDeserializer.class) +@JsonSerialize(using = FastlyAPIKeyUpdateApiKey.FastlyAPIKeyUpdateApiKeySerializer.class) +public class FastlyAPIKeyUpdateApiKey extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(FastlyAPIKeyUpdateApiKey.class.getName()); + + @JsonIgnore public boolean unparsed = false; + + public static class FastlyAPIKeyUpdateApiKeySerializer + extends StdSerializer { + public FastlyAPIKeyUpdateApiKeySerializer(Class t) { + super(t); + } + + public FastlyAPIKeyUpdateApiKeySerializer() { + this(null); + } + + @Override + public void serialize( + FastlyAPIKeyUpdateApiKey value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class FastlyAPIKeyUpdateApiKeyDeserializer + extends StdDeserializer { + public FastlyAPIKeyUpdateApiKeyDeserializer() { + this(FastlyAPIKeyUpdateApiKey.class); + } + + public FastlyAPIKeyUpdateApiKeyDeserializer(Class vc) { + super(vc); + } + + @Override + public FastlyAPIKeyUpdateApiKey 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 String + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (String.class.equals(Integer.class) + || String.class.equals(Long.class) + || String.class.equals(Float.class) + || String.class.equals(Double.class) + || String.class.equals(Boolean.class) + || String.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((String.class.equals(Integer.class) || String.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((String.class.equals(Float.class) || String.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (String.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (String.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(String.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. + deserialized = tmp; + match++; + + log.log(Level.FINER, "Input data matches schema 'String'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'String'", e); + } + + // deserialize ActionConnectionAWSSecretsManagerReference + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = + tree.traverse(jp.getCodec()) + .readValueAs(ActionConnectionAWSSecretsManagerReference.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 (!((ActionConnectionAWSSecretsManagerReference) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log( + Level.FINER, + "Input data matches schema 'ActionConnectionAWSSecretsManagerReference'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'ActionConnectionAWSSecretsManagerReference'", + e); + } + + FastlyAPIKeyUpdateApiKey ret = new FastlyAPIKeyUpdateApiKey(); + 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 FastlyAPIKeyUpdateApiKey getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + throw new JsonMappingException(ctxt.getParser(), "FastlyAPIKeyUpdateApiKey cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public FastlyAPIKeyUpdateApiKey() { + super("oneOf", Boolean.FALSE); + } + + public FastlyAPIKeyUpdateApiKey(String o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public FastlyAPIKeyUpdateApiKey(ActionConnectionAWSSecretsManagerReference o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("String", new GenericType() {}); + schemas.put( + "ActionConnectionAWSSecretsManagerReference", + new GenericType() {}); + JSON.registerDescendants(FastlyAPIKeyUpdateApiKey.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map getSchemas() { + return FastlyAPIKeyUpdateApiKey.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: String, ActionConnectionAWSSecretsManagerReference + * + *

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(String.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + if (JSON.isInstanceOf( + ActionConnectionAWSSecretsManagerReference.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 String, ActionConnectionAWSSecretsManagerReference"); + } + + /** + * Get the actual instance, which can be the following: String, + * ActionConnectionAWSSecretsManagerReference + * + * @return The actual instance (String, ActionConnectionAWSSecretsManagerReference) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `String`. If the actual instance is not `String`, the + * ClassCastException will be thrown. + * + * @return The actual instance of `String` + * @throws ClassCastException if the instance is not `String` + */ + public String getString() throws ClassCastException { + return (String) super.getActualInstance(); + } + + /** + * Get the actual instance of `ActionConnectionAWSSecretsManagerReference`. If the actual instance + * is not `ActionConnectionAWSSecretsManagerReference`, the ClassCastException will be thrown. + * + * @return The actual instance of `ActionConnectionAWSSecretsManagerReference` + * @throws ClassCastException if the instance is not `ActionConnectionAWSSecretsManagerReference` + */ + public ActionConnectionAWSSecretsManagerReference getActionConnectionAWSSecretsManagerReference() + throws ClassCastException { + return (ActionConnectionAWSSecretsManagerReference) super.getActualInstance(); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/FreshserviceAPIKey.java b/src/main/java/com/datadog/api/client/v2/model/FreshserviceAPIKey.java index 214e88989ff..bbe30d13f0a 100644 --- a/src/main/java/com/datadog/api/client/v2/model/FreshserviceAPIKey.java +++ b/src/main/java/com/datadog/api/client/v2/model/FreshserviceAPIKey.java @@ -28,10 +28,10 @@ public class FreshserviceAPIKey { @JsonIgnore public boolean unparsed = false; public static final String JSON_PROPERTY_API_KEY = "api_key"; - private String apiKey; + private FreshserviceAPIKeyApiKey apiKey; public static final String JSON_PROPERTY_DOMAIN = "domain"; - private String domain; + private FreshserviceAPIKeyDomain domain; public static final String JSON_PROPERTY_TYPE = "type"; private FreshserviceAPIKeyType type; @@ -40,17 +40,20 @@ public FreshserviceAPIKey() {} @JsonCreator public FreshserviceAPIKey( - @JsonProperty(required = true, value = JSON_PROPERTY_API_KEY) String apiKey, - @JsonProperty(required = true, value = JSON_PROPERTY_DOMAIN) String domain, + @JsonProperty(required = true, value = JSON_PROPERTY_API_KEY) FreshserviceAPIKeyApiKey apiKey, + @JsonProperty(required = true, value = JSON_PROPERTY_DOMAIN) FreshserviceAPIKeyDomain domain, @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) FreshserviceAPIKeyType type) { this.apiKey = apiKey; + this.unparsed |= apiKey.unparsed; this.domain = domain; + this.unparsed |= domain.unparsed; this.type = type; this.unparsed |= !type.isValid(); } - public FreshserviceAPIKey apiKey(String apiKey) { + public FreshserviceAPIKey apiKey(FreshserviceAPIKeyApiKey apiKey) { this.apiKey = apiKey; + this.unparsed |= apiKey.unparsed; return this; } @@ -61,16 +64,20 @@ public FreshserviceAPIKey apiKey(String apiKey) { */ @JsonProperty(JSON_PROPERTY_API_KEY) @JsonInclude(value = JsonInclude.Include.ALWAYS) - public String getApiKey() { + public FreshserviceAPIKeyApiKey getApiKey() { return apiKey; } - public void setApiKey(String apiKey) { + public void setApiKey(FreshserviceAPIKeyApiKey apiKey) { this.apiKey = apiKey; + if (apiKey != null) { + this.unparsed |= apiKey.unparsed; + } } - public FreshserviceAPIKey domain(String domain) { + public FreshserviceAPIKey domain(FreshserviceAPIKeyDomain domain) { this.domain = domain; + this.unparsed |= domain.unparsed; return this; } @@ -81,12 +88,15 @@ public FreshserviceAPIKey domain(String domain) { */ @JsonProperty(JSON_PROPERTY_DOMAIN) @JsonInclude(value = JsonInclude.Include.ALWAYS) - public String getDomain() { + public FreshserviceAPIKeyDomain getDomain() { return domain; } - public void setDomain(String domain) { + public void setDomain(FreshserviceAPIKeyDomain domain) { this.domain = domain; + if (domain != null) { + this.unparsed |= domain.unparsed; + } } public FreshserviceAPIKey type(FreshserviceAPIKeyType type) { diff --git a/src/main/java/com/datadog/api/client/v2/model/FreshserviceAPIKeyApiKey.java b/src/main/java/com/datadog/api/client/v2/model/FreshserviceAPIKeyApiKey.java new file mode 100644 index 00000000000..a077bbc974d --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/FreshserviceAPIKeyApiKey.java @@ -0,0 +1,288 @@ +/* + * 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 = FreshserviceAPIKeyApiKey.FreshserviceAPIKeyApiKeyDeserializer.class) +@JsonSerialize(using = FreshserviceAPIKeyApiKey.FreshserviceAPIKeyApiKeySerializer.class) +public class FreshserviceAPIKeyApiKey extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(FreshserviceAPIKeyApiKey.class.getName()); + + @JsonIgnore public boolean unparsed = false; + + public static class FreshserviceAPIKeyApiKeySerializer + extends StdSerializer { + public FreshserviceAPIKeyApiKeySerializer(Class t) { + super(t); + } + + public FreshserviceAPIKeyApiKeySerializer() { + this(null); + } + + @Override + public void serialize( + FreshserviceAPIKeyApiKey value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class FreshserviceAPIKeyApiKeyDeserializer + extends StdDeserializer { + public FreshserviceAPIKeyApiKeyDeserializer() { + this(FreshserviceAPIKeyApiKey.class); + } + + public FreshserviceAPIKeyApiKeyDeserializer(Class vc) { + super(vc); + } + + @Override + public FreshserviceAPIKeyApiKey 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 String + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (String.class.equals(Integer.class) + || String.class.equals(Long.class) + || String.class.equals(Float.class) + || String.class.equals(Double.class) + || String.class.equals(Boolean.class) + || String.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((String.class.equals(Integer.class) || String.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((String.class.equals(Float.class) || String.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (String.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (String.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(String.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. + deserialized = tmp; + match++; + + log.log(Level.FINER, "Input data matches schema 'String'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'String'", e); + } + + // deserialize ActionConnectionAWSSecretsManagerReference + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = + tree.traverse(jp.getCodec()) + .readValueAs(ActionConnectionAWSSecretsManagerReference.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 (!((ActionConnectionAWSSecretsManagerReference) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log( + Level.FINER, + "Input data matches schema 'ActionConnectionAWSSecretsManagerReference'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'ActionConnectionAWSSecretsManagerReference'", + e); + } + + FreshserviceAPIKeyApiKey ret = new FreshserviceAPIKeyApiKey(); + 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 FreshserviceAPIKeyApiKey getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + throw new JsonMappingException(ctxt.getParser(), "FreshserviceAPIKeyApiKey cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public FreshserviceAPIKeyApiKey() { + super("oneOf", Boolean.FALSE); + } + + public FreshserviceAPIKeyApiKey(String o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public FreshserviceAPIKeyApiKey(ActionConnectionAWSSecretsManagerReference o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("String", new GenericType() {}); + schemas.put( + "ActionConnectionAWSSecretsManagerReference", + new GenericType() {}); + JSON.registerDescendants(FreshserviceAPIKeyApiKey.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map getSchemas() { + return FreshserviceAPIKeyApiKey.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: String, ActionConnectionAWSSecretsManagerReference + * + *

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(String.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + if (JSON.isInstanceOf( + ActionConnectionAWSSecretsManagerReference.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 String, ActionConnectionAWSSecretsManagerReference"); + } + + /** + * Get the actual instance, which can be the following: String, + * ActionConnectionAWSSecretsManagerReference + * + * @return The actual instance (String, ActionConnectionAWSSecretsManagerReference) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `String`. If the actual instance is not `String`, the + * ClassCastException will be thrown. + * + * @return The actual instance of `String` + * @throws ClassCastException if the instance is not `String` + */ + public String getString() throws ClassCastException { + return (String) super.getActualInstance(); + } + + /** + * Get the actual instance of `ActionConnectionAWSSecretsManagerReference`. If the actual instance + * is not `ActionConnectionAWSSecretsManagerReference`, the ClassCastException will be thrown. + * + * @return The actual instance of `ActionConnectionAWSSecretsManagerReference` + * @throws ClassCastException if the instance is not `ActionConnectionAWSSecretsManagerReference` + */ + public ActionConnectionAWSSecretsManagerReference getActionConnectionAWSSecretsManagerReference() + throws ClassCastException { + return (ActionConnectionAWSSecretsManagerReference) super.getActualInstance(); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/FreshserviceAPIKeyDomain.java b/src/main/java/com/datadog/api/client/v2/model/FreshserviceAPIKeyDomain.java new file mode 100644 index 00000000000..7ab414cd1c6 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/FreshserviceAPIKeyDomain.java @@ -0,0 +1,288 @@ +/* + * 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 = FreshserviceAPIKeyDomain.FreshserviceAPIKeyDomainDeserializer.class) +@JsonSerialize(using = FreshserviceAPIKeyDomain.FreshserviceAPIKeyDomainSerializer.class) +public class FreshserviceAPIKeyDomain extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(FreshserviceAPIKeyDomain.class.getName()); + + @JsonIgnore public boolean unparsed = false; + + public static class FreshserviceAPIKeyDomainSerializer + extends StdSerializer { + public FreshserviceAPIKeyDomainSerializer(Class t) { + super(t); + } + + public FreshserviceAPIKeyDomainSerializer() { + this(null); + } + + @Override + public void serialize( + FreshserviceAPIKeyDomain value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class FreshserviceAPIKeyDomainDeserializer + extends StdDeserializer { + public FreshserviceAPIKeyDomainDeserializer() { + this(FreshserviceAPIKeyDomain.class); + } + + public FreshserviceAPIKeyDomainDeserializer(Class vc) { + super(vc); + } + + @Override + public FreshserviceAPIKeyDomain 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 String + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (String.class.equals(Integer.class) + || String.class.equals(Long.class) + || String.class.equals(Float.class) + || String.class.equals(Double.class) + || String.class.equals(Boolean.class) + || String.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((String.class.equals(Integer.class) || String.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((String.class.equals(Float.class) || String.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (String.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (String.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(String.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. + deserialized = tmp; + match++; + + log.log(Level.FINER, "Input data matches schema 'String'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'String'", e); + } + + // deserialize ActionConnectionAWSSecretsManagerReference + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = + tree.traverse(jp.getCodec()) + .readValueAs(ActionConnectionAWSSecretsManagerReference.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 (!((ActionConnectionAWSSecretsManagerReference) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log( + Level.FINER, + "Input data matches schema 'ActionConnectionAWSSecretsManagerReference'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'ActionConnectionAWSSecretsManagerReference'", + e); + } + + FreshserviceAPIKeyDomain ret = new FreshserviceAPIKeyDomain(); + 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 FreshserviceAPIKeyDomain getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + throw new JsonMappingException(ctxt.getParser(), "FreshserviceAPIKeyDomain cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public FreshserviceAPIKeyDomain() { + super("oneOf", Boolean.FALSE); + } + + public FreshserviceAPIKeyDomain(String o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public FreshserviceAPIKeyDomain(ActionConnectionAWSSecretsManagerReference o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("String", new GenericType() {}); + schemas.put( + "ActionConnectionAWSSecretsManagerReference", + new GenericType() {}); + JSON.registerDescendants(FreshserviceAPIKeyDomain.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map getSchemas() { + return FreshserviceAPIKeyDomain.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: String, ActionConnectionAWSSecretsManagerReference + * + *

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(String.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + if (JSON.isInstanceOf( + ActionConnectionAWSSecretsManagerReference.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 String, ActionConnectionAWSSecretsManagerReference"); + } + + /** + * Get the actual instance, which can be the following: String, + * ActionConnectionAWSSecretsManagerReference + * + * @return The actual instance (String, ActionConnectionAWSSecretsManagerReference) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `String`. If the actual instance is not `String`, the + * ClassCastException will be thrown. + * + * @return The actual instance of `String` + * @throws ClassCastException if the instance is not `String` + */ + public String getString() throws ClassCastException { + return (String) super.getActualInstance(); + } + + /** + * Get the actual instance of `ActionConnectionAWSSecretsManagerReference`. If the actual instance + * is not `ActionConnectionAWSSecretsManagerReference`, the ClassCastException will be thrown. + * + * @return The actual instance of `ActionConnectionAWSSecretsManagerReference` + * @throws ClassCastException if the instance is not `ActionConnectionAWSSecretsManagerReference` + */ + public ActionConnectionAWSSecretsManagerReference getActionConnectionAWSSecretsManagerReference() + throws ClassCastException { + return (ActionConnectionAWSSecretsManagerReference) super.getActualInstance(); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/FreshserviceAPIKeyUpdate.java b/src/main/java/com/datadog/api/client/v2/model/FreshserviceAPIKeyUpdate.java index 04eef1e1cba..cf541060438 100644 --- a/src/main/java/com/datadog/api/client/v2/model/FreshserviceAPIKeyUpdate.java +++ b/src/main/java/com/datadog/api/client/v2/model/FreshserviceAPIKeyUpdate.java @@ -28,10 +28,10 @@ public class FreshserviceAPIKeyUpdate { @JsonIgnore public boolean unparsed = false; public static final String JSON_PROPERTY_API_KEY = "api_key"; - private String apiKey; + private FreshserviceAPIKeyUpdateApiKey apiKey; public static final String JSON_PROPERTY_DOMAIN = "domain"; - private String domain; + private FreshserviceAPIKeyUpdateDomain domain; public static final String JSON_PROPERTY_TYPE = "type"; private FreshserviceAPIKeyType type; @@ -45,8 +45,9 @@ public FreshserviceAPIKeyUpdate( this.unparsed |= !type.isValid(); } - public FreshserviceAPIKeyUpdate apiKey(String apiKey) { + public FreshserviceAPIKeyUpdate apiKey(FreshserviceAPIKeyUpdateApiKey apiKey) { this.apiKey = apiKey; + this.unparsed |= apiKey.unparsed; return this; } @@ -58,16 +59,20 @@ public FreshserviceAPIKeyUpdate apiKey(String apiKey) { @jakarta.annotation.Nullable @JsonProperty(JSON_PROPERTY_API_KEY) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public String getApiKey() { + public FreshserviceAPIKeyUpdateApiKey getApiKey() { return apiKey; } - public void setApiKey(String apiKey) { + public void setApiKey(FreshserviceAPIKeyUpdateApiKey apiKey) { this.apiKey = apiKey; + if (apiKey != null) { + this.unparsed |= apiKey.unparsed; + } } - public FreshserviceAPIKeyUpdate domain(String domain) { + public FreshserviceAPIKeyUpdate domain(FreshserviceAPIKeyUpdateDomain domain) { this.domain = domain; + this.unparsed |= domain.unparsed; return this; } @@ -79,12 +84,15 @@ public FreshserviceAPIKeyUpdate domain(String domain) { @jakarta.annotation.Nullable @JsonProperty(JSON_PROPERTY_DOMAIN) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public String getDomain() { + public FreshserviceAPIKeyUpdateDomain getDomain() { return domain; } - public void setDomain(String domain) { + public void setDomain(FreshserviceAPIKeyUpdateDomain domain) { this.domain = domain; + if (domain != null) { + this.unparsed |= domain.unparsed; + } } public FreshserviceAPIKeyUpdate type(FreshserviceAPIKeyType type) { diff --git a/src/main/java/com/datadog/api/client/v2/model/FreshserviceAPIKeyUpdateApiKey.java b/src/main/java/com/datadog/api/client/v2/model/FreshserviceAPIKeyUpdateApiKey.java new file mode 100644 index 00000000000..525dbb0147a --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/FreshserviceAPIKeyUpdateApiKey.java @@ -0,0 +1,293 @@ +/* + * 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 = FreshserviceAPIKeyUpdateApiKey.FreshserviceAPIKeyUpdateApiKeyDeserializer.class) +@JsonSerialize( + using = FreshserviceAPIKeyUpdateApiKey.FreshserviceAPIKeyUpdateApiKeySerializer.class) +public class FreshserviceAPIKeyUpdateApiKey extends AbstractOpenApiSchema { + private static final Logger log = + Logger.getLogger(FreshserviceAPIKeyUpdateApiKey.class.getName()); + + @JsonIgnore public boolean unparsed = false; + + public static class FreshserviceAPIKeyUpdateApiKeySerializer + extends StdSerializer { + public FreshserviceAPIKeyUpdateApiKeySerializer(Class t) { + super(t); + } + + public FreshserviceAPIKeyUpdateApiKeySerializer() { + this(null); + } + + @Override + public void serialize( + FreshserviceAPIKeyUpdateApiKey value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class FreshserviceAPIKeyUpdateApiKeyDeserializer + extends StdDeserializer { + public FreshserviceAPIKeyUpdateApiKeyDeserializer() { + this(FreshserviceAPIKeyUpdateApiKey.class); + } + + public FreshserviceAPIKeyUpdateApiKeyDeserializer(Class vc) { + super(vc); + } + + @Override + public FreshserviceAPIKeyUpdateApiKey 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 String + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (String.class.equals(Integer.class) + || String.class.equals(Long.class) + || String.class.equals(Float.class) + || String.class.equals(Double.class) + || String.class.equals(Boolean.class) + || String.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((String.class.equals(Integer.class) || String.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((String.class.equals(Float.class) || String.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (String.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (String.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(String.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. + deserialized = tmp; + match++; + + log.log(Level.FINER, "Input data matches schema 'String'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'String'", e); + } + + // deserialize ActionConnectionAWSSecretsManagerReference + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = + tree.traverse(jp.getCodec()) + .readValueAs(ActionConnectionAWSSecretsManagerReference.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 (!((ActionConnectionAWSSecretsManagerReference) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log( + Level.FINER, + "Input data matches schema 'ActionConnectionAWSSecretsManagerReference'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'ActionConnectionAWSSecretsManagerReference'", + e); + } + + FreshserviceAPIKeyUpdateApiKey ret = new FreshserviceAPIKeyUpdateApiKey(); + 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 FreshserviceAPIKeyUpdateApiKey getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + throw new JsonMappingException( + ctxt.getParser(), "FreshserviceAPIKeyUpdateApiKey cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public FreshserviceAPIKeyUpdateApiKey() { + super("oneOf", Boolean.FALSE); + } + + public FreshserviceAPIKeyUpdateApiKey(String o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public FreshserviceAPIKeyUpdateApiKey(ActionConnectionAWSSecretsManagerReference o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("String", new GenericType() {}); + schemas.put( + "ActionConnectionAWSSecretsManagerReference", + new GenericType() {}); + JSON.registerDescendants( + FreshserviceAPIKeyUpdateApiKey.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map getSchemas() { + return FreshserviceAPIKeyUpdateApiKey.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: String, ActionConnectionAWSSecretsManagerReference + * + *

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(String.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + if (JSON.isInstanceOf( + ActionConnectionAWSSecretsManagerReference.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 String, ActionConnectionAWSSecretsManagerReference"); + } + + /** + * Get the actual instance, which can be the following: String, + * ActionConnectionAWSSecretsManagerReference + * + * @return The actual instance (String, ActionConnectionAWSSecretsManagerReference) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `String`. If the actual instance is not `String`, the + * ClassCastException will be thrown. + * + * @return The actual instance of `String` + * @throws ClassCastException if the instance is not `String` + */ + public String getString() throws ClassCastException { + return (String) super.getActualInstance(); + } + + /** + * Get the actual instance of `ActionConnectionAWSSecretsManagerReference`. If the actual instance + * is not `ActionConnectionAWSSecretsManagerReference`, the ClassCastException will be thrown. + * + * @return The actual instance of `ActionConnectionAWSSecretsManagerReference` + * @throws ClassCastException if the instance is not `ActionConnectionAWSSecretsManagerReference` + */ + public ActionConnectionAWSSecretsManagerReference getActionConnectionAWSSecretsManagerReference() + throws ClassCastException { + return (ActionConnectionAWSSecretsManagerReference) super.getActualInstance(); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/FreshserviceAPIKeyUpdateDomain.java b/src/main/java/com/datadog/api/client/v2/model/FreshserviceAPIKeyUpdateDomain.java new file mode 100644 index 00000000000..e3fa03f3249 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/FreshserviceAPIKeyUpdateDomain.java @@ -0,0 +1,293 @@ +/* + * 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 = FreshserviceAPIKeyUpdateDomain.FreshserviceAPIKeyUpdateDomainDeserializer.class) +@JsonSerialize( + using = FreshserviceAPIKeyUpdateDomain.FreshserviceAPIKeyUpdateDomainSerializer.class) +public class FreshserviceAPIKeyUpdateDomain extends AbstractOpenApiSchema { + private static final Logger log = + Logger.getLogger(FreshserviceAPIKeyUpdateDomain.class.getName()); + + @JsonIgnore public boolean unparsed = false; + + public static class FreshserviceAPIKeyUpdateDomainSerializer + extends StdSerializer { + public FreshserviceAPIKeyUpdateDomainSerializer(Class t) { + super(t); + } + + public FreshserviceAPIKeyUpdateDomainSerializer() { + this(null); + } + + @Override + public void serialize( + FreshserviceAPIKeyUpdateDomain value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class FreshserviceAPIKeyUpdateDomainDeserializer + extends StdDeserializer { + public FreshserviceAPIKeyUpdateDomainDeserializer() { + this(FreshserviceAPIKeyUpdateDomain.class); + } + + public FreshserviceAPIKeyUpdateDomainDeserializer(Class vc) { + super(vc); + } + + @Override + public FreshserviceAPIKeyUpdateDomain 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 String + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (String.class.equals(Integer.class) + || String.class.equals(Long.class) + || String.class.equals(Float.class) + || String.class.equals(Double.class) + || String.class.equals(Boolean.class) + || String.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((String.class.equals(Integer.class) || String.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((String.class.equals(Float.class) || String.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (String.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (String.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(String.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. + deserialized = tmp; + match++; + + log.log(Level.FINER, "Input data matches schema 'String'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'String'", e); + } + + // deserialize ActionConnectionAWSSecretsManagerReference + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = + tree.traverse(jp.getCodec()) + .readValueAs(ActionConnectionAWSSecretsManagerReference.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 (!((ActionConnectionAWSSecretsManagerReference) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log( + Level.FINER, + "Input data matches schema 'ActionConnectionAWSSecretsManagerReference'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'ActionConnectionAWSSecretsManagerReference'", + e); + } + + FreshserviceAPIKeyUpdateDomain ret = new FreshserviceAPIKeyUpdateDomain(); + 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 FreshserviceAPIKeyUpdateDomain getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + throw new JsonMappingException( + ctxt.getParser(), "FreshserviceAPIKeyUpdateDomain cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public FreshserviceAPIKeyUpdateDomain() { + super("oneOf", Boolean.FALSE); + } + + public FreshserviceAPIKeyUpdateDomain(String o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public FreshserviceAPIKeyUpdateDomain(ActionConnectionAWSSecretsManagerReference o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("String", new GenericType() {}); + schemas.put( + "ActionConnectionAWSSecretsManagerReference", + new GenericType() {}); + JSON.registerDescendants( + FreshserviceAPIKeyUpdateDomain.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map getSchemas() { + return FreshserviceAPIKeyUpdateDomain.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: String, ActionConnectionAWSSecretsManagerReference + * + *

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(String.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + if (JSON.isInstanceOf( + ActionConnectionAWSSecretsManagerReference.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 String, ActionConnectionAWSSecretsManagerReference"); + } + + /** + * Get the actual instance, which can be the following: String, + * ActionConnectionAWSSecretsManagerReference + * + * @return The actual instance (String, ActionConnectionAWSSecretsManagerReference) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `String`. If the actual instance is not `String`, the + * ClassCastException will be thrown. + * + * @return The actual instance of `String` + * @throws ClassCastException if the instance is not `String` + */ + public String getString() throws ClassCastException { + return (String) super.getActualInstance(); + } + + /** + * Get the actual instance of `ActionConnectionAWSSecretsManagerReference`. If the actual instance + * is not `ActionConnectionAWSSecretsManagerReference`, the ClassCastException will be thrown. + * + * @return The actual instance of `ActionConnectionAWSSecretsManagerReference` + * @throws ClassCastException if the instance is not `ActionConnectionAWSSecretsManagerReference` + */ + public ActionConnectionAWSSecretsManagerReference getActionConnectionAWSSecretsManagerReference() + throws ClassCastException { + return (ActionConnectionAWSSecretsManagerReference) super.getActualInstance(); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/GCPServiceAccount.java b/src/main/java/com/datadog/api/client/v2/model/GCPServiceAccount.java index 4a71bc0680d..9920072af8e 100644 --- a/src/main/java/com/datadog/api/client/v2/model/GCPServiceAccount.java +++ b/src/main/java/com/datadog/api/client/v2/model/GCPServiceAccount.java @@ -28,10 +28,10 @@ public class GCPServiceAccount { @JsonIgnore public boolean unparsed = false; public static final String JSON_PROPERTY_PRIVATE_KEY = "private_key"; - private String privateKey; + private GCPServiceAccountPrivateKey privateKey; public static final String JSON_PROPERTY_SERVICE_ACCOUNT_EMAIL = "service_account_email"; - private String serviceAccountEmail; + private GCPServiceAccountServiceAccountEmail serviceAccountEmail; public static final String JSON_PROPERTY_TYPE = "type"; private GCPServiceAccountCredentialType type; @@ -40,19 +40,23 @@ public GCPServiceAccount() {} @JsonCreator public GCPServiceAccount( - @JsonProperty(required = true, value = JSON_PROPERTY_PRIVATE_KEY) String privateKey, + @JsonProperty(required = true, value = JSON_PROPERTY_PRIVATE_KEY) + GCPServiceAccountPrivateKey privateKey, @JsonProperty(required = true, value = JSON_PROPERTY_SERVICE_ACCOUNT_EMAIL) - String serviceAccountEmail, + GCPServiceAccountServiceAccountEmail serviceAccountEmail, @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) GCPServiceAccountCredentialType type) { this.privateKey = privateKey; + this.unparsed |= privateKey.unparsed; this.serviceAccountEmail = serviceAccountEmail; + this.unparsed |= serviceAccountEmail.unparsed; this.type = type; this.unparsed |= !type.isValid(); } - public GCPServiceAccount privateKey(String privateKey) { + public GCPServiceAccount privateKey(GCPServiceAccountPrivateKey privateKey) { this.privateKey = privateKey; + this.unparsed |= privateKey.unparsed; return this; } @@ -63,16 +67,21 @@ public GCPServiceAccount privateKey(String privateKey) { */ @JsonProperty(JSON_PROPERTY_PRIVATE_KEY) @JsonInclude(value = JsonInclude.Include.ALWAYS) - public String getPrivateKey() { + public GCPServiceAccountPrivateKey getPrivateKey() { return privateKey; } - public void setPrivateKey(String privateKey) { + public void setPrivateKey(GCPServiceAccountPrivateKey privateKey) { this.privateKey = privateKey; + if (privateKey != null) { + this.unparsed |= privateKey.unparsed; + } } - public GCPServiceAccount serviceAccountEmail(String serviceAccountEmail) { + public GCPServiceAccount serviceAccountEmail( + GCPServiceAccountServiceAccountEmail serviceAccountEmail) { this.serviceAccountEmail = serviceAccountEmail; + this.unparsed |= serviceAccountEmail.unparsed; return this; } @@ -83,12 +92,15 @@ public GCPServiceAccount serviceAccountEmail(String serviceAccountEmail) { */ @JsonProperty(JSON_PROPERTY_SERVICE_ACCOUNT_EMAIL) @JsonInclude(value = JsonInclude.Include.ALWAYS) - public String getServiceAccountEmail() { + public GCPServiceAccountServiceAccountEmail getServiceAccountEmail() { return serviceAccountEmail; } - public void setServiceAccountEmail(String serviceAccountEmail) { + public void setServiceAccountEmail(GCPServiceAccountServiceAccountEmail serviceAccountEmail) { this.serviceAccountEmail = serviceAccountEmail; + if (serviceAccountEmail != null) { + this.unparsed |= serviceAccountEmail.unparsed; + } } public GCPServiceAccount type(GCPServiceAccountCredentialType type) { diff --git a/src/main/java/com/datadog/api/client/v2/model/GCPServiceAccountPrivateKey.java b/src/main/java/com/datadog/api/client/v2/model/GCPServiceAccountPrivateKey.java new file mode 100644 index 00000000000..824d3d465d1 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/GCPServiceAccountPrivateKey.java @@ -0,0 +1,290 @@ +/* + * 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 = GCPServiceAccountPrivateKey.GCPServiceAccountPrivateKeyDeserializer.class) +@JsonSerialize(using = GCPServiceAccountPrivateKey.GCPServiceAccountPrivateKeySerializer.class) +public class GCPServiceAccountPrivateKey extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(GCPServiceAccountPrivateKey.class.getName()); + + @JsonIgnore public boolean unparsed = false; + + public static class GCPServiceAccountPrivateKeySerializer + extends StdSerializer { + public GCPServiceAccountPrivateKeySerializer(Class t) { + super(t); + } + + public GCPServiceAccountPrivateKeySerializer() { + this(null); + } + + @Override + public void serialize( + GCPServiceAccountPrivateKey value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class GCPServiceAccountPrivateKeyDeserializer + extends StdDeserializer { + public GCPServiceAccountPrivateKeyDeserializer() { + this(GCPServiceAccountPrivateKey.class); + } + + public GCPServiceAccountPrivateKeyDeserializer(Class vc) { + super(vc); + } + + @Override + public GCPServiceAccountPrivateKey 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 String + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (String.class.equals(Integer.class) + || String.class.equals(Long.class) + || String.class.equals(Float.class) + || String.class.equals(Double.class) + || String.class.equals(Boolean.class) + || String.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((String.class.equals(Integer.class) || String.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((String.class.equals(Float.class) || String.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (String.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (String.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(String.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. + deserialized = tmp; + match++; + + log.log(Level.FINER, "Input data matches schema 'String'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'String'", e); + } + + // deserialize ActionConnectionAWSSecretsManagerReference + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = + tree.traverse(jp.getCodec()) + .readValueAs(ActionConnectionAWSSecretsManagerReference.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 (!((ActionConnectionAWSSecretsManagerReference) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log( + Level.FINER, + "Input data matches schema 'ActionConnectionAWSSecretsManagerReference'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'ActionConnectionAWSSecretsManagerReference'", + e); + } + + GCPServiceAccountPrivateKey ret = new GCPServiceAccountPrivateKey(); + 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 GCPServiceAccountPrivateKey getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + throw new JsonMappingException( + ctxt.getParser(), "GCPServiceAccountPrivateKey cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public GCPServiceAccountPrivateKey() { + super("oneOf", Boolean.FALSE); + } + + public GCPServiceAccountPrivateKey(String o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public GCPServiceAccountPrivateKey(ActionConnectionAWSSecretsManagerReference o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("String", new GenericType() {}); + schemas.put( + "ActionConnectionAWSSecretsManagerReference", + new GenericType() {}); + JSON.registerDescendants( + GCPServiceAccountPrivateKey.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map getSchemas() { + return GCPServiceAccountPrivateKey.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: String, ActionConnectionAWSSecretsManagerReference + * + *

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(String.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + if (JSON.isInstanceOf( + ActionConnectionAWSSecretsManagerReference.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 String, ActionConnectionAWSSecretsManagerReference"); + } + + /** + * Get the actual instance, which can be the following: String, + * ActionConnectionAWSSecretsManagerReference + * + * @return The actual instance (String, ActionConnectionAWSSecretsManagerReference) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `String`. If the actual instance is not `String`, the + * ClassCastException will be thrown. + * + * @return The actual instance of `String` + * @throws ClassCastException if the instance is not `String` + */ + public String getString() throws ClassCastException { + return (String) super.getActualInstance(); + } + + /** + * Get the actual instance of `ActionConnectionAWSSecretsManagerReference`. If the actual instance + * is not `ActionConnectionAWSSecretsManagerReference`, the ClassCastException will be thrown. + * + * @return The actual instance of `ActionConnectionAWSSecretsManagerReference` + * @throws ClassCastException if the instance is not `ActionConnectionAWSSecretsManagerReference` + */ + public ActionConnectionAWSSecretsManagerReference getActionConnectionAWSSecretsManagerReference() + throws ClassCastException { + return (ActionConnectionAWSSecretsManagerReference) super.getActualInstance(); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/GCPServiceAccountServiceAccountEmail.java b/src/main/java/com/datadog/api/client/v2/model/GCPServiceAccountServiceAccountEmail.java new file mode 100644 index 00000000000..44bd3fa8486 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/GCPServiceAccountServiceAccountEmail.java @@ -0,0 +1,296 @@ +/* + * 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 = + GCPServiceAccountServiceAccountEmail.GCPServiceAccountServiceAccountEmailDeserializer.class) +@JsonSerialize( + using = + GCPServiceAccountServiceAccountEmail.GCPServiceAccountServiceAccountEmailSerializer.class) +public class GCPServiceAccountServiceAccountEmail extends AbstractOpenApiSchema { + private static final Logger log = + Logger.getLogger(GCPServiceAccountServiceAccountEmail.class.getName()); + + @JsonIgnore public boolean unparsed = false; + + public static class GCPServiceAccountServiceAccountEmailSerializer + extends StdSerializer { + public GCPServiceAccountServiceAccountEmailSerializer( + Class t) { + super(t); + } + + public GCPServiceAccountServiceAccountEmailSerializer() { + this(null); + } + + @Override + public void serialize( + GCPServiceAccountServiceAccountEmail value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class GCPServiceAccountServiceAccountEmailDeserializer + extends StdDeserializer { + public GCPServiceAccountServiceAccountEmailDeserializer() { + this(GCPServiceAccountServiceAccountEmail.class); + } + + public GCPServiceAccountServiceAccountEmailDeserializer(Class vc) { + super(vc); + } + + @Override + public GCPServiceAccountServiceAccountEmail 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 String + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (String.class.equals(Integer.class) + || String.class.equals(Long.class) + || String.class.equals(Float.class) + || String.class.equals(Double.class) + || String.class.equals(Boolean.class) + || String.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((String.class.equals(Integer.class) || String.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((String.class.equals(Float.class) || String.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (String.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (String.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(String.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. + deserialized = tmp; + match++; + + log.log(Level.FINER, "Input data matches schema 'String'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'String'", e); + } + + // deserialize ActionConnectionAWSSecretsManagerReference + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = + tree.traverse(jp.getCodec()) + .readValueAs(ActionConnectionAWSSecretsManagerReference.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 (!((ActionConnectionAWSSecretsManagerReference) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log( + Level.FINER, + "Input data matches schema 'ActionConnectionAWSSecretsManagerReference'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'ActionConnectionAWSSecretsManagerReference'", + e); + } + + GCPServiceAccountServiceAccountEmail ret = new GCPServiceAccountServiceAccountEmail(); + 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 GCPServiceAccountServiceAccountEmail getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + throw new JsonMappingException( + ctxt.getParser(), "GCPServiceAccountServiceAccountEmail cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public GCPServiceAccountServiceAccountEmail() { + super("oneOf", Boolean.FALSE); + } + + public GCPServiceAccountServiceAccountEmail(String o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public GCPServiceAccountServiceAccountEmail(ActionConnectionAWSSecretsManagerReference o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("String", new GenericType() {}); + schemas.put( + "ActionConnectionAWSSecretsManagerReference", + new GenericType() {}); + JSON.registerDescendants( + GCPServiceAccountServiceAccountEmail.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map getSchemas() { + return GCPServiceAccountServiceAccountEmail.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: String, ActionConnectionAWSSecretsManagerReference + * + *

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(String.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + if (JSON.isInstanceOf( + ActionConnectionAWSSecretsManagerReference.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 String, ActionConnectionAWSSecretsManagerReference"); + } + + /** + * Get the actual instance, which can be the following: String, + * ActionConnectionAWSSecretsManagerReference + * + * @return The actual instance (String, ActionConnectionAWSSecretsManagerReference) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `String`. If the actual instance is not `String`, the + * ClassCastException will be thrown. + * + * @return The actual instance of `String` + * @throws ClassCastException if the instance is not `String` + */ + public String getString() throws ClassCastException { + return (String) super.getActualInstance(); + } + + /** + * Get the actual instance of `ActionConnectionAWSSecretsManagerReference`. If the actual instance + * is not `ActionConnectionAWSSecretsManagerReference`, the ClassCastException will be thrown. + * + * @return The actual instance of `ActionConnectionAWSSecretsManagerReference` + * @throws ClassCastException if the instance is not `ActionConnectionAWSSecretsManagerReference` + */ + public ActionConnectionAWSSecretsManagerReference getActionConnectionAWSSecretsManagerReference() + throws ClassCastException { + return (ActionConnectionAWSSecretsManagerReference) super.getActualInstance(); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/GCPServiceAccountUpdate.java b/src/main/java/com/datadog/api/client/v2/model/GCPServiceAccountUpdate.java index a2c4c4553e9..18904336cfa 100644 --- a/src/main/java/com/datadog/api/client/v2/model/GCPServiceAccountUpdate.java +++ b/src/main/java/com/datadog/api/client/v2/model/GCPServiceAccountUpdate.java @@ -28,10 +28,10 @@ public class GCPServiceAccountUpdate { @JsonIgnore public boolean unparsed = false; public static final String JSON_PROPERTY_PRIVATE_KEY = "private_key"; - private String privateKey; + private GCPServiceAccountUpdatePrivateKey privateKey; public static final String JSON_PROPERTY_SERVICE_ACCOUNT_EMAIL = "service_account_email"; - private String serviceAccountEmail; + private GCPServiceAccountUpdateServiceAccountEmail serviceAccountEmail; public static final String JSON_PROPERTY_TYPE = "type"; private GCPServiceAccountCredentialType type; @@ -46,8 +46,9 @@ public GCPServiceAccountUpdate( this.unparsed |= !type.isValid(); } - public GCPServiceAccountUpdate privateKey(String privateKey) { + public GCPServiceAccountUpdate privateKey(GCPServiceAccountUpdatePrivateKey privateKey) { this.privateKey = privateKey; + this.unparsed |= privateKey.unparsed; return this; } @@ -59,16 +60,21 @@ public GCPServiceAccountUpdate privateKey(String privateKey) { @jakarta.annotation.Nullable @JsonProperty(JSON_PROPERTY_PRIVATE_KEY) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public String getPrivateKey() { + public GCPServiceAccountUpdatePrivateKey getPrivateKey() { return privateKey; } - public void setPrivateKey(String privateKey) { + public void setPrivateKey(GCPServiceAccountUpdatePrivateKey privateKey) { this.privateKey = privateKey; + if (privateKey != null) { + this.unparsed |= privateKey.unparsed; + } } - public GCPServiceAccountUpdate serviceAccountEmail(String serviceAccountEmail) { + public GCPServiceAccountUpdate serviceAccountEmail( + GCPServiceAccountUpdateServiceAccountEmail serviceAccountEmail) { this.serviceAccountEmail = serviceAccountEmail; + this.unparsed |= serviceAccountEmail.unparsed; return this; } @@ -80,12 +86,16 @@ public GCPServiceAccountUpdate serviceAccountEmail(String serviceAccountEmail) { @jakarta.annotation.Nullable @JsonProperty(JSON_PROPERTY_SERVICE_ACCOUNT_EMAIL) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public String getServiceAccountEmail() { + public GCPServiceAccountUpdateServiceAccountEmail getServiceAccountEmail() { return serviceAccountEmail; } - public void setServiceAccountEmail(String serviceAccountEmail) { + public void setServiceAccountEmail( + GCPServiceAccountUpdateServiceAccountEmail serviceAccountEmail) { this.serviceAccountEmail = serviceAccountEmail; + if (serviceAccountEmail != null) { + this.unparsed |= serviceAccountEmail.unparsed; + } } public GCPServiceAccountUpdate type(GCPServiceAccountCredentialType type) { diff --git a/src/main/java/com/datadog/api/client/v2/model/GCPServiceAccountUpdatePrivateKey.java b/src/main/java/com/datadog/api/client/v2/model/GCPServiceAccountUpdatePrivateKey.java new file mode 100644 index 00000000000..93270d570b2 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/GCPServiceAccountUpdatePrivateKey.java @@ -0,0 +1,293 @@ +/* + * 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 = GCPServiceAccountUpdatePrivateKey.GCPServiceAccountUpdatePrivateKeyDeserializer.class) +@JsonSerialize( + using = GCPServiceAccountUpdatePrivateKey.GCPServiceAccountUpdatePrivateKeySerializer.class) +public class GCPServiceAccountUpdatePrivateKey extends AbstractOpenApiSchema { + private static final Logger log = + Logger.getLogger(GCPServiceAccountUpdatePrivateKey.class.getName()); + + @JsonIgnore public boolean unparsed = false; + + public static class GCPServiceAccountUpdatePrivateKeySerializer + extends StdSerializer { + public GCPServiceAccountUpdatePrivateKeySerializer(Class t) { + super(t); + } + + public GCPServiceAccountUpdatePrivateKeySerializer() { + this(null); + } + + @Override + public void serialize( + GCPServiceAccountUpdatePrivateKey value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class GCPServiceAccountUpdatePrivateKeyDeserializer + extends StdDeserializer { + public GCPServiceAccountUpdatePrivateKeyDeserializer() { + this(GCPServiceAccountUpdatePrivateKey.class); + } + + public GCPServiceAccountUpdatePrivateKeyDeserializer(Class vc) { + super(vc); + } + + @Override + public GCPServiceAccountUpdatePrivateKey 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 String + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (String.class.equals(Integer.class) + || String.class.equals(Long.class) + || String.class.equals(Float.class) + || String.class.equals(Double.class) + || String.class.equals(Boolean.class) + || String.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((String.class.equals(Integer.class) || String.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((String.class.equals(Float.class) || String.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (String.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (String.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(String.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. + deserialized = tmp; + match++; + + log.log(Level.FINER, "Input data matches schema 'String'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'String'", e); + } + + // deserialize ActionConnectionAWSSecretsManagerReference + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = + tree.traverse(jp.getCodec()) + .readValueAs(ActionConnectionAWSSecretsManagerReference.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 (!((ActionConnectionAWSSecretsManagerReference) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log( + Level.FINER, + "Input data matches schema 'ActionConnectionAWSSecretsManagerReference'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'ActionConnectionAWSSecretsManagerReference'", + e); + } + + GCPServiceAccountUpdatePrivateKey ret = new GCPServiceAccountUpdatePrivateKey(); + 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 GCPServiceAccountUpdatePrivateKey getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + throw new JsonMappingException( + ctxt.getParser(), "GCPServiceAccountUpdatePrivateKey cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public GCPServiceAccountUpdatePrivateKey() { + super("oneOf", Boolean.FALSE); + } + + public GCPServiceAccountUpdatePrivateKey(String o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public GCPServiceAccountUpdatePrivateKey(ActionConnectionAWSSecretsManagerReference o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("String", new GenericType() {}); + schemas.put( + "ActionConnectionAWSSecretsManagerReference", + new GenericType() {}); + JSON.registerDescendants( + GCPServiceAccountUpdatePrivateKey.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map getSchemas() { + return GCPServiceAccountUpdatePrivateKey.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: String, ActionConnectionAWSSecretsManagerReference + * + *

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(String.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + if (JSON.isInstanceOf( + ActionConnectionAWSSecretsManagerReference.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 String, ActionConnectionAWSSecretsManagerReference"); + } + + /** + * Get the actual instance, which can be the following: String, + * ActionConnectionAWSSecretsManagerReference + * + * @return The actual instance (String, ActionConnectionAWSSecretsManagerReference) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `String`. If the actual instance is not `String`, the + * ClassCastException will be thrown. + * + * @return The actual instance of `String` + * @throws ClassCastException if the instance is not `String` + */ + public String getString() throws ClassCastException { + return (String) super.getActualInstance(); + } + + /** + * Get the actual instance of `ActionConnectionAWSSecretsManagerReference`. If the actual instance + * is not `ActionConnectionAWSSecretsManagerReference`, the ClassCastException will be thrown. + * + * @return The actual instance of `ActionConnectionAWSSecretsManagerReference` + * @throws ClassCastException if the instance is not `ActionConnectionAWSSecretsManagerReference` + */ + public ActionConnectionAWSSecretsManagerReference getActionConnectionAWSSecretsManagerReference() + throws ClassCastException { + return (ActionConnectionAWSSecretsManagerReference) super.getActualInstance(); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/GCPServiceAccountUpdateServiceAccountEmail.java b/src/main/java/com/datadog/api/client/v2/model/GCPServiceAccountUpdateServiceAccountEmail.java new file mode 100644 index 00000000000..2ebf4de689b --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/GCPServiceAccountUpdateServiceAccountEmail.java @@ -0,0 +1,301 @@ +/* + * 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 = + GCPServiceAccountUpdateServiceAccountEmail + .GCPServiceAccountUpdateServiceAccountEmailDeserializer.class) +@JsonSerialize( + using = + GCPServiceAccountUpdateServiceAccountEmail + .GCPServiceAccountUpdateServiceAccountEmailSerializer.class) +public class GCPServiceAccountUpdateServiceAccountEmail extends AbstractOpenApiSchema { + private static final Logger log = + Logger.getLogger(GCPServiceAccountUpdateServiceAccountEmail.class.getName()); + + @JsonIgnore public boolean unparsed = false; + + public static class GCPServiceAccountUpdateServiceAccountEmailSerializer + extends StdSerializer { + public GCPServiceAccountUpdateServiceAccountEmailSerializer( + Class t) { + super(t); + } + + public GCPServiceAccountUpdateServiceAccountEmailSerializer() { + this(null); + } + + @Override + public void serialize( + GCPServiceAccountUpdateServiceAccountEmail value, + JsonGenerator jgen, + SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class GCPServiceAccountUpdateServiceAccountEmailDeserializer + extends StdDeserializer { + public GCPServiceAccountUpdateServiceAccountEmailDeserializer() { + this(GCPServiceAccountUpdateServiceAccountEmail.class); + } + + public GCPServiceAccountUpdateServiceAccountEmailDeserializer(Class vc) { + super(vc); + } + + @Override + public GCPServiceAccountUpdateServiceAccountEmail 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 String + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (String.class.equals(Integer.class) + || String.class.equals(Long.class) + || String.class.equals(Float.class) + || String.class.equals(Double.class) + || String.class.equals(Boolean.class) + || String.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((String.class.equals(Integer.class) || String.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((String.class.equals(Float.class) || String.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (String.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (String.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(String.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. + deserialized = tmp; + match++; + + log.log(Level.FINER, "Input data matches schema 'String'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'String'", e); + } + + // deserialize ActionConnectionAWSSecretsManagerReference + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = + tree.traverse(jp.getCodec()) + .readValueAs(ActionConnectionAWSSecretsManagerReference.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 (!((ActionConnectionAWSSecretsManagerReference) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log( + Level.FINER, + "Input data matches schema 'ActionConnectionAWSSecretsManagerReference'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'ActionConnectionAWSSecretsManagerReference'", + e); + } + + GCPServiceAccountUpdateServiceAccountEmail ret = + new GCPServiceAccountUpdateServiceAccountEmail(); + 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 GCPServiceAccountUpdateServiceAccountEmail getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + throw new JsonMappingException( + ctxt.getParser(), "GCPServiceAccountUpdateServiceAccountEmail cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public GCPServiceAccountUpdateServiceAccountEmail() { + super("oneOf", Boolean.FALSE); + } + + public GCPServiceAccountUpdateServiceAccountEmail(String o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public GCPServiceAccountUpdateServiceAccountEmail(ActionConnectionAWSSecretsManagerReference o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("String", new GenericType() {}); + schemas.put( + "ActionConnectionAWSSecretsManagerReference", + new GenericType() {}); + JSON.registerDescendants( + GCPServiceAccountUpdateServiceAccountEmail.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map getSchemas() { + return GCPServiceAccountUpdateServiceAccountEmail.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: String, ActionConnectionAWSSecretsManagerReference + * + *

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(String.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + if (JSON.isInstanceOf( + ActionConnectionAWSSecretsManagerReference.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 String, ActionConnectionAWSSecretsManagerReference"); + } + + /** + * Get the actual instance, which can be the following: String, + * ActionConnectionAWSSecretsManagerReference + * + * @return The actual instance (String, ActionConnectionAWSSecretsManagerReference) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `String`. If the actual instance is not `String`, the + * ClassCastException will be thrown. + * + * @return The actual instance of `String` + * @throws ClassCastException if the instance is not `String` + */ + public String getString() throws ClassCastException { + return (String) super.getActualInstance(); + } + + /** + * Get the actual instance of `ActionConnectionAWSSecretsManagerReference`. If the actual instance + * is not `ActionConnectionAWSSecretsManagerReference`, the ClassCastException will be thrown. + * + * @return The actual instance of `ActionConnectionAWSSecretsManagerReference` + * @throws ClassCastException if the instance is not `ActionConnectionAWSSecretsManagerReference` + */ + public ActionConnectionAWSSecretsManagerReference getActionConnectionAWSSecretsManagerReference() + throws ClassCastException { + return (ActionConnectionAWSSecretsManagerReference) super.getActualInstance(); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/GeminiAPIKey.java b/src/main/java/com/datadog/api/client/v2/model/GeminiAPIKey.java index 53fbce40862..6895545b83c 100644 --- a/src/main/java/com/datadog/api/client/v2/model/GeminiAPIKey.java +++ b/src/main/java/com/datadog/api/client/v2/model/GeminiAPIKey.java @@ -24,7 +24,7 @@ public class GeminiAPIKey { @JsonIgnore public boolean unparsed = false; public static final String JSON_PROPERTY_API_KEY = "api_key"; - private String apiKey; + private GeminiAPIKeyApiKey apiKey; public static final String JSON_PROPERTY_TYPE = "type"; private GeminiAPIKeyType type; @@ -33,15 +33,17 @@ public GeminiAPIKey() {} @JsonCreator public GeminiAPIKey( - @JsonProperty(required = true, value = JSON_PROPERTY_API_KEY) String apiKey, + @JsonProperty(required = true, value = JSON_PROPERTY_API_KEY) GeminiAPIKeyApiKey apiKey, @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) GeminiAPIKeyType type) { this.apiKey = apiKey; + this.unparsed |= apiKey.unparsed; this.type = type; this.unparsed |= !type.isValid(); } - public GeminiAPIKey apiKey(String apiKey) { + public GeminiAPIKey apiKey(GeminiAPIKeyApiKey apiKey) { this.apiKey = apiKey; + this.unparsed |= apiKey.unparsed; return this; } @@ -52,12 +54,15 @@ public GeminiAPIKey apiKey(String apiKey) { */ @JsonProperty(JSON_PROPERTY_API_KEY) @JsonInclude(value = JsonInclude.Include.ALWAYS) - public String getApiKey() { + public GeminiAPIKeyApiKey getApiKey() { return apiKey; } - public void setApiKey(String apiKey) { + public void setApiKey(GeminiAPIKeyApiKey apiKey) { this.apiKey = apiKey; + if (apiKey != null) { + this.unparsed |= apiKey.unparsed; + } } public GeminiAPIKey type(GeminiAPIKeyType type) { diff --git a/src/main/java/com/datadog/api/client/v2/model/GeminiAPIKeyApiKey.java b/src/main/java/com/datadog/api/client/v2/model/GeminiAPIKeyApiKey.java new file mode 100644 index 00000000000..6c08a02da6e --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/GeminiAPIKeyApiKey.java @@ -0,0 +1,285 @@ +/* + * 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 = GeminiAPIKeyApiKey.GeminiAPIKeyApiKeyDeserializer.class) +@JsonSerialize(using = GeminiAPIKeyApiKey.GeminiAPIKeyApiKeySerializer.class) +public class GeminiAPIKeyApiKey extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(GeminiAPIKeyApiKey.class.getName()); + + @JsonIgnore public boolean unparsed = false; + + public static class GeminiAPIKeyApiKeySerializer extends StdSerializer { + public GeminiAPIKeyApiKeySerializer(Class t) { + super(t); + } + + public GeminiAPIKeyApiKeySerializer() { + this(null); + } + + @Override + public void serialize(GeminiAPIKeyApiKey value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class GeminiAPIKeyApiKeyDeserializer extends StdDeserializer { + public GeminiAPIKeyApiKeyDeserializer() { + this(GeminiAPIKeyApiKey.class); + } + + public GeminiAPIKeyApiKeyDeserializer(Class vc) { + super(vc); + } + + @Override + public GeminiAPIKeyApiKey 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 String + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (String.class.equals(Integer.class) + || String.class.equals(Long.class) + || String.class.equals(Float.class) + || String.class.equals(Double.class) + || String.class.equals(Boolean.class) + || String.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((String.class.equals(Integer.class) || String.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((String.class.equals(Float.class) || String.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (String.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (String.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(String.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. + deserialized = tmp; + match++; + + log.log(Level.FINER, "Input data matches schema 'String'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'String'", e); + } + + // deserialize ActionConnectionAWSSecretsManagerReference + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = + tree.traverse(jp.getCodec()) + .readValueAs(ActionConnectionAWSSecretsManagerReference.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 (!((ActionConnectionAWSSecretsManagerReference) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log( + Level.FINER, + "Input data matches schema 'ActionConnectionAWSSecretsManagerReference'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'ActionConnectionAWSSecretsManagerReference'", + e); + } + + GeminiAPIKeyApiKey ret = new GeminiAPIKeyApiKey(); + 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 GeminiAPIKeyApiKey getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + throw new JsonMappingException(ctxt.getParser(), "GeminiAPIKeyApiKey cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public GeminiAPIKeyApiKey() { + super("oneOf", Boolean.FALSE); + } + + public GeminiAPIKeyApiKey(String o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public GeminiAPIKeyApiKey(ActionConnectionAWSSecretsManagerReference o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("String", new GenericType() {}); + schemas.put( + "ActionConnectionAWSSecretsManagerReference", + new GenericType() {}); + JSON.registerDescendants(GeminiAPIKeyApiKey.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map getSchemas() { + return GeminiAPIKeyApiKey.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: String, ActionConnectionAWSSecretsManagerReference + * + *

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(String.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + if (JSON.isInstanceOf( + ActionConnectionAWSSecretsManagerReference.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 String, ActionConnectionAWSSecretsManagerReference"); + } + + /** + * Get the actual instance, which can be the following: String, + * ActionConnectionAWSSecretsManagerReference + * + * @return The actual instance (String, ActionConnectionAWSSecretsManagerReference) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `String`. If the actual instance is not `String`, the + * ClassCastException will be thrown. + * + * @return The actual instance of `String` + * @throws ClassCastException if the instance is not `String` + */ + public String getString() throws ClassCastException { + return (String) super.getActualInstance(); + } + + /** + * Get the actual instance of `ActionConnectionAWSSecretsManagerReference`. If the actual instance + * is not `ActionConnectionAWSSecretsManagerReference`, the ClassCastException will be thrown. + * + * @return The actual instance of `ActionConnectionAWSSecretsManagerReference` + * @throws ClassCastException if the instance is not `ActionConnectionAWSSecretsManagerReference` + */ + public ActionConnectionAWSSecretsManagerReference getActionConnectionAWSSecretsManagerReference() + throws ClassCastException { + return (ActionConnectionAWSSecretsManagerReference) super.getActualInstance(); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/GeminiAPIKeyUpdate.java b/src/main/java/com/datadog/api/client/v2/model/GeminiAPIKeyUpdate.java index f5e519da532..e20a9f13271 100644 --- a/src/main/java/com/datadog/api/client/v2/model/GeminiAPIKeyUpdate.java +++ b/src/main/java/com/datadog/api/client/v2/model/GeminiAPIKeyUpdate.java @@ -27,7 +27,7 @@ public class GeminiAPIKeyUpdate { @JsonIgnore public boolean unparsed = false; public static final String JSON_PROPERTY_API_KEY = "api_key"; - private String apiKey; + private GeminiAPIKeyUpdateApiKey apiKey; public static final String JSON_PROPERTY_TYPE = "type"; private GeminiAPIKeyType type; @@ -41,8 +41,9 @@ public GeminiAPIKeyUpdate( this.unparsed |= !type.isValid(); } - public GeminiAPIKeyUpdate apiKey(String apiKey) { + public GeminiAPIKeyUpdate apiKey(GeminiAPIKeyUpdateApiKey apiKey) { this.apiKey = apiKey; + this.unparsed |= apiKey.unparsed; return this; } @@ -54,12 +55,15 @@ public GeminiAPIKeyUpdate apiKey(String apiKey) { @jakarta.annotation.Nullable @JsonProperty(JSON_PROPERTY_API_KEY) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public String getApiKey() { + public GeminiAPIKeyUpdateApiKey getApiKey() { return apiKey; } - public void setApiKey(String apiKey) { + public void setApiKey(GeminiAPIKeyUpdateApiKey apiKey) { this.apiKey = apiKey; + if (apiKey != null) { + this.unparsed |= apiKey.unparsed; + } } public GeminiAPIKeyUpdate type(GeminiAPIKeyType type) { diff --git a/src/main/java/com/datadog/api/client/v2/model/GeminiAPIKeyUpdateApiKey.java b/src/main/java/com/datadog/api/client/v2/model/GeminiAPIKeyUpdateApiKey.java new file mode 100644 index 00000000000..3dcff5cb957 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/GeminiAPIKeyUpdateApiKey.java @@ -0,0 +1,288 @@ +/* + * 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 = GeminiAPIKeyUpdateApiKey.GeminiAPIKeyUpdateApiKeyDeserializer.class) +@JsonSerialize(using = GeminiAPIKeyUpdateApiKey.GeminiAPIKeyUpdateApiKeySerializer.class) +public class GeminiAPIKeyUpdateApiKey extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(GeminiAPIKeyUpdateApiKey.class.getName()); + + @JsonIgnore public boolean unparsed = false; + + public static class GeminiAPIKeyUpdateApiKeySerializer + extends StdSerializer { + public GeminiAPIKeyUpdateApiKeySerializer(Class t) { + super(t); + } + + public GeminiAPIKeyUpdateApiKeySerializer() { + this(null); + } + + @Override + public void serialize( + GeminiAPIKeyUpdateApiKey value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class GeminiAPIKeyUpdateApiKeyDeserializer + extends StdDeserializer { + public GeminiAPIKeyUpdateApiKeyDeserializer() { + this(GeminiAPIKeyUpdateApiKey.class); + } + + public GeminiAPIKeyUpdateApiKeyDeserializer(Class vc) { + super(vc); + } + + @Override + public GeminiAPIKeyUpdateApiKey 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 String + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (String.class.equals(Integer.class) + || String.class.equals(Long.class) + || String.class.equals(Float.class) + || String.class.equals(Double.class) + || String.class.equals(Boolean.class) + || String.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((String.class.equals(Integer.class) || String.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((String.class.equals(Float.class) || String.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (String.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (String.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(String.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. + deserialized = tmp; + match++; + + log.log(Level.FINER, "Input data matches schema 'String'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'String'", e); + } + + // deserialize ActionConnectionAWSSecretsManagerReference + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = + tree.traverse(jp.getCodec()) + .readValueAs(ActionConnectionAWSSecretsManagerReference.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 (!((ActionConnectionAWSSecretsManagerReference) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log( + Level.FINER, + "Input data matches schema 'ActionConnectionAWSSecretsManagerReference'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'ActionConnectionAWSSecretsManagerReference'", + e); + } + + GeminiAPIKeyUpdateApiKey ret = new GeminiAPIKeyUpdateApiKey(); + 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 GeminiAPIKeyUpdateApiKey getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + throw new JsonMappingException(ctxt.getParser(), "GeminiAPIKeyUpdateApiKey cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public GeminiAPIKeyUpdateApiKey() { + super("oneOf", Boolean.FALSE); + } + + public GeminiAPIKeyUpdateApiKey(String o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public GeminiAPIKeyUpdateApiKey(ActionConnectionAWSSecretsManagerReference o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("String", new GenericType() {}); + schemas.put( + "ActionConnectionAWSSecretsManagerReference", + new GenericType() {}); + JSON.registerDescendants(GeminiAPIKeyUpdateApiKey.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map getSchemas() { + return GeminiAPIKeyUpdateApiKey.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: String, ActionConnectionAWSSecretsManagerReference + * + *

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(String.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + if (JSON.isInstanceOf( + ActionConnectionAWSSecretsManagerReference.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 String, ActionConnectionAWSSecretsManagerReference"); + } + + /** + * Get the actual instance, which can be the following: String, + * ActionConnectionAWSSecretsManagerReference + * + * @return The actual instance (String, ActionConnectionAWSSecretsManagerReference) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `String`. If the actual instance is not `String`, the + * ClassCastException will be thrown. + * + * @return The actual instance of `String` + * @throws ClassCastException if the instance is not `String` + */ + public String getString() throws ClassCastException { + return (String) super.getActualInstance(); + } + + /** + * Get the actual instance of `ActionConnectionAWSSecretsManagerReference`. If the actual instance + * is not `ActionConnectionAWSSecretsManagerReference`, the ClassCastException will be thrown. + * + * @return The actual instance of `ActionConnectionAWSSecretsManagerReference` + * @throws ClassCastException if the instance is not `ActionConnectionAWSSecretsManagerReference` + */ + public ActionConnectionAWSSecretsManagerReference getActionConnectionAWSSecretsManagerReference() + throws ClassCastException { + return (ActionConnectionAWSSecretsManagerReference) super.getActualInstance(); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/GitlabAPIKey.java b/src/main/java/com/datadog/api/client/v2/model/GitlabAPIKey.java index 23039379ed7..95e517b5a07 100644 --- a/src/main/java/com/datadog/api/client/v2/model/GitlabAPIKey.java +++ b/src/main/java/com/datadog/api/client/v2/model/GitlabAPIKey.java @@ -24,7 +24,7 @@ public class GitlabAPIKey { @JsonIgnore public boolean unparsed = false; public static final String JSON_PROPERTY_API_TOKEN = "api_token"; - private String apiToken; + private GitlabAPIKeyApiToken apiToken; public static final String JSON_PROPERTY_TYPE = "type"; private GitlabAPIKeyType type; @@ -33,15 +33,17 @@ public GitlabAPIKey() {} @JsonCreator public GitlabAPIKey( - @JsonProperty(required = true, value = JSON_PROPERTY_API_TOKEN) String apiToken, + @JsonProperty(required = true, value = JSON_PROPERTY_API_TOKEN) GitlabAPIKeyApiToken apiToken, @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) GitlabAPIKeyType type) { this.apiToken = apiToken; + this.unparsed |= apiToken.unparsed; this.type = type; this.unparsed |= !type.isValid(); } - public GitlabAPIKey apiToken(String apiToken) { + public GitlabAPIKey apiToken(GitlabAPIKeyApiToken apiToken) { this.apiToken = apiToken; + this.unparsed |= apiToken.unparsed; return this; } @@ -52,12 +54,15 @@ public GitlabAPIKey apiToken(String apiToken) { */ @JsonProperty(JSON_PROPERTY_API_TOKEN) @JsonInclude(value = JsonInclude.Include.ALWAYS) - public String getApiToken() { + public GitlabAPIKeyApiToken getApiToken() { return apiToken; } - public void setApiToken(String apiToken) { + public void setApiToken(GitlabAPIKeyApiToken apiToken) { this.apiToken = apiToken; + if (apiToken != null) { + this.unparsed |= apiToken.unparsed; + } } public GitlabAPIKey type(GitlabAPIKeyType type) { diff --git a/src/main/java/com/datadog/api/client/v2/model/GitlabAPIKeyApiToken.java b/src/main/java/com/datadog/api/client/v2/model/GitlabAPIKeyApiToken.java new file mode 100644 index 00000000000..82565754aba --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/GitlabAPIKeyApiToken.java @@ -0,0 +1,287 @@ +/* + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.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 = GitlabAPIKeyApiToken.GitlabAPIKeyApiTokenDeserializer.class) +@JsonSerialize(using = GitlabAPIKeyApiToken.GitlabAPIKeyApiTokenSerializer.class) +public class GitlabAPIKeyApiToken extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(GitlabAPIKeyApiToken.class.getName()); + + @JsonIgnore public boolean unparsed = false; + + public static class GitlabAPIKeyApiTokenSerializer extends StdSerializer { + public GitlabAPIKeyApiTokenSerializer(Class t) { + super(t); + } + + public GitlabAPIKeyApiTokenSerializer() { + this(null); + } + + @Override + public void serialize( + GitlabAPIKeyApiToken value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class GitlabAPIKeyApiTokenDeserializer + extends StdDeserializer { + public GitlabAPIKeyApiTokenDeserializer() { + this(GitlabAPIKeyApiToken.class); + } + + public GitlabAPIKeyApiTokenDeserializer(Class vc) { + super(vc); + } + + @Override + public GitlabAPIKeyApiToken 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 String + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (String.class.equals(Integer.class) + || String.class.equals(Long.class) + || String.class.equals(Float.class) + || String.class.equals(Double.class) + || String.class.equals(Boolean.class) + || String.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((String.class.equals(Integer.class) || String.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((String.class.equals(Float.class) || String.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (String.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (String.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(String.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. + deserialized = tmp; + match++; + + log.log(Level.FINER, "Input data matches schema 'String'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'String'", e); + } + + // deserialize ActionConnectionAWSSecretsManagerReference + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = + tree.traverse(jp.getCodec()) + .readValueAs(ActionConnectionAWSSecretsManagerReference.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 (!((ActionConnectionAWSSecretsManagerReference) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log( + Level.FINER, + "Input data matches schema 'ActionConnectionAWSSecretsManagerReference'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'ActionConnectionAWSSecretsManagerReference'", + e); + } + + GitlabAPIKeyApiToken ret = new GitlabAPIKeyApiToken(); + 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 GitlabAPIKeyApiToken getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + throw new JsonMappingException(ctxt.getParser(), "GitlabAPIKeyApiToken cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public GitlabAPIKeyApiToken() { + super("oneOf", Boolean.FALSE); + } + + public GitlabAPIKeyApiToken(String o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public GitlabAPIKeyApiToken(ActionConnectionAWSSecretsManagerReference o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("String", new GenericType() {}); + schemas.put( + "ActionConnectionAWSSecretsManagerReference", + new GenericType() {}); + JSON.registerDescendants(GitlabAPIKeyApiToken.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map getSchemas() { + return GitlabAPIKeyApiToken.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: String, ActionConnectionAWSSecretsManagerReference + * + *

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(String.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + if (JSON.isInstanceOf( + ActionConnectionAWSSecretsManagerReference.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 String, ActionConnectionAWSSecretsManagerReference"); + } + + /** + * Get the actual instance, which can be the following: String, + * ActionConnectionAWSSecretsManagerReference + * + * @return The actual instance (String, ActionConnectionAWSSecretsManagerReference) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `String`. If the actual instance is not `String`, the + * ClassCastException will be thrown. + * + * @return The actual instance of `String` + * @throws ClassCastException if the instance is not `String` + */ + public String getString() throws ClassCastException { + return (String) super.getActualInstance(); + } + + /** + * Get the actual instance of `ActionConnectionAWSSecretsManagerReference`. If the actual instance + * is not `ActionConnectionAWSSecretsManagerReference`, the ClassCastException will be thrown. + * + * @return The actual instance of `ActionConnectionAWSSecretsManagerReference` + * @throws ClassCastException if the instance is not `ActionConnectionAWSSecretsManagerReference` + */ + public ActionConnectionAWSSecretsManagerReference getActionConnectionAWSSecretsManagerReference() + throws ClassCastException { + return (ActionConnectionAWSSecretsManagerReference) super.getActualInstance(); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/GitlabAPIKeyUpdate.java b/src/main/java/com/datadog/api/client/v2/model/GitlabAPIKeyUpdate.java index fa3e6ed05e7..6454d243e60 100644 --- a/src/main/java/com/datadog/api/client/v2/model/GitlabAPIKeyUpdate.java +++ b/src/main/java/com/datadog/api/client/v2/model/GitlabAPIKeyUpdate.java @@ -27,7 +27,7 @@ public class GitlabAPIKeyUpdate { @JsonIgnore public boolean unparsed = false; public static final String JSON_PROPERTY_API_TOKEN = "api_token"; - private String apiToken; + private GitlabAPIKeyUpdateApiToken apiToken; public static final String JSON_PROPERTY_TYPE = "type"; private GitlabAPIKeyType type; @@ -41,8 +41,9 @@ public GitlabAPIKeyUpdate( this.unparsed |= !type.isValid(); } - public GitlabAPIKeyUpdate apiToken(String apiToken) { + public GitlabAPIKeyUpdate apiToken(GitlabAPIKeyUpdateApiToken apiToken) { this.apiToken = apiToken; + this.unparsed |= apiToken.unparsed; return this; } @@ -54,12 +55,15 @@ public GitlabAPIKeyUpdate apiToken(String apiToken) { @jakarta.annotation.Nullable @JsonProperty(JSON_PROPERTY_API_TOKEN) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public String getApiToken() { + public GitlabAPIKeyUpdateApiToken getApiToken() { return apiToken; } - public void setApiToken(String apiToken) { + public void setApiToken(GitlabAPIKeyUpdateApiToken apiToken) { this.apiToken = apiToken; + if (apiToken != null) { + this.unparsed |= apiToken.unparsed; + } } public GitlabAPIKeyUpdate type(GitlabAPIKeyType type) { diff --git a/src/main/java/com/datadog/api/client/v2/model/GitlabAPIKeyUpdateApiToken.java b/src/main/java/com/datadog/api/client/v2/model/GitlabAPIKeyUpdateApiToken.java new file mode 100644 index 00000000000..fb94876c76d --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/GitlabAPIKeyUpdateApiToken.java @@ -0,0 +1,289 @@ +/* + * 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 = GitlabAPIKeyUpdateApiToken.GitlabAPIKeyUpdateApiTokenDeserializer.class) +@JsonSerialize(using = GitlabAPIKeyUpdateApiToken.GitlabAPIKeyUpdateApiTokenSerializer.class) +public class GitlabAPIKeyUpdateApiToken extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(GitlabAPIKeyUpdateApiToken.class.getName()); + + @JsonIgnore public boolean unparsed = false; + + public static class GitlabAPIKeyUpdateApiTokenSerializer + extends StdSerializer { + public GitlabAPIKeyUpdateApiTokenSerializer(Class t) { + super(t); + } + + public GitlabAPIKeyUpdateApiTokenSerializer() { + this(null); + } + + @Override + public void serialize( + GitlabAPIKeyUpdateApiToken value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class GitlabAPIKeyUpdateApiTokenDeserializer + extends StdDeserializer { + public GitlabAPIKeyUpdateApiTokenDeserializer() { + this(GitlabAPIKeyUpdateApiToken.class); + } + + public GitlabAPIKeyUpdateApiTokenDeserializer(Class vc) { + super(vc); + } + + @Override + public GitlabAPIKeyUpdateApiToken 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 String + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (String.class.equals(Integer.class) + || String.class.equals(Long.class) + || String.class.equals(Float.class) + || String.class.equals(Double.class) + || String.class.equals(Boolean.class) + || String.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((String.class.equals(Integer.class) || String.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((String.class.equals(Float.class) || String.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (String.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (String.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(String.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. + deserialized = tmp; + match++; + + log.log(Level.FINER, "Input data matches schema 'String'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'String'", e); + } + + // deserialize ActionConnectionAWSSecretsManagerReference + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = + tree.traverse(jp.getCodec()) + .readValueAs(ActionConnectionAWSSecretsManagerReference.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 (!((ActionConnectionAWSSecretsManagerReference) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log( + Level.FINER, + "Input data matches schema 'ActionConnectionAWSSecretsManagerReference'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'ActionConnectionAWSSecretsManagerReference'", + e); + } + + GitlabAPIKeyUpdateApiToken ret = new GitlabAPIKeyUpdateApiToken(); + 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 GitlabAPIKeyUpdateApiToken getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + throw new JsonMappingException(ctxt.getParser(), "GitlabAPIKeyUpdateApiToken cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public GitlabAPIKeyUpdateApiToken() { + super("oneOf", Boolean.FALSE); + } + + public GitlabAPIKeyUpdateApiToken(String o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public GitlabAPIKeyUpdateApiToken(ActionConnectionAWSSecretsManagerReference o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("String", new GenericType() {}); + schemas.put( + "ActionConnectionAWSSecretsManagerReference", + new GenericType() {}); + JSON.registerDescendants( + GitlabAPIKeyUpdateApiToken.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map getSchemas() { + return GitlabAPIKeyUpdateApiToken.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: String, ActionConnectionAWSSecretsManagerReference + * + *

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(String.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + if (JSON.isInstanceOf( + ActionConnectionAWSSecretsManagerReference.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 String, ActionConnectionAWSSecretsManagerReference"); + } + + /** + * Get the actual instance, which can be the following: String, + * ActionConnectionAWSSecretsManagerReference + * + * @return The actual instance (String, ActionConnectionAWSSecretsManagerReference) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `String`. If the actual instance is not `String`, the + * ClassCastException will be thrown. + * + * @return The actual instance of `String` + * @throws ClassCastException if the instance is not `String` + */ + public String getString() throws ClassCastException { + return (String) super.getActualInstance(); + } + + /** + * Get the actual instance of `ActionConnectionAWSSecretsManagerReference`. If the actual instance + * is not `ActionConnectionAWSSecretsManagerReference`, the ClassCastException will be thrown. + * + * @return The actual instance of `ActionConnectionAWSSecretsManagerReference` + * @throws ClassCastException if the instance is not `ActionConnectionAWSSecretsManagerReference` + */ + public ActionConnectionAWSSecretsManagerReference getActionConnectionAWSSecretsManagerReference() + throws ClassCastException { + return (ActionConnectionAWSSecretsManagerReference) super.getActualInstance(); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/GreyNoiseAPIKey.java b/src/main/java/com/datadog/api/client/v2/model/GreyNoiseAPIKey.java index 6c9b2447aff..132cdb67197 100644 --- a/src/main/java/com/datadog/api/client/v2/model/GreyNoiseAPIKey.java +++ b/src/main/java/com/datadog/api/client/v2/model/GreyNoiseAPIKey.java @@ -24,7 +24,7 @@ public class GreyNoiseAPIKey { @JsonIgnore public boolean unparsed = false; public static final String JSON_PROPERTY_API_KEY = "api_key"; - private String apiKey; + private GreyNoiseAPIKeyApiKey apiKey; public static final String JSON_PROPERTY_TYPE = "type"; private GreyNoiseAPIKeyType type; @@ -33,15 +33,17 @@ public GreyNoiseAPIKey() {} @JsonCreator public GreyNoiseAPIKey( - @JsonProperty(required = true, value = JSON_PROPERTY_API_KEY) String apiKey, + @JsonProperty(required = true, value = JSON_PROPERTY_API_KEY) GreyNoiseAPIKeyApiKey apiKey, @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) GreyNoiseAPIKeyType type) { this.apiKey = apiKey; + this.unparsed |= apiKey.unparsed; this.type = type; this.unparsed |= !type.isValid(); } - public GreyNoiseAPIKey apiKey(String apiKey) { + public GreyNoiseAPIKey apiKey(GreyNoiseAPIKeyApiKey apiKey) { this.apiKey = apiKey; + this.unparsed |= apiKey.unparsed; return this; } @@ -52,12 +54,15 @@ public GreyNoiseAPIKey apiKey(String apiKey) { */ @JsonProperty(JSON_PROPERTY_API_KEY) @JsonInclude(value = JsonInclude.Include.ALWAYS) - public String getApiKey() { + public GreyNoiseAPIKeyApiKey getApiKey() { return apiKey; } - public void setApiKey(String apiKey) { + public void setApiKey(GreyNoiseAPIKeyApiKey apiKey) { this.apiKey = apiKey; + if (apiKey != null) { + this.unparsed |= apiKey.unparsed; + } } public GreyNoiseAPIKey type(GreyNoiseAPIKeyType type) { diff --git a/src/main/java/com/datadog/api/client/v2/model/GreyNoiseAPIKeyApiKey.java b/src/main/java/com/datadog/api/client/v2/model/GreyNoiseAPIKeyApiKey.java new file mode 100644 index 00000000000..fa07191e591 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/GreyNoiseAPIKeyApiKey.java @@ -0,0 +1,287 @@ +/* + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.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 = GreyNoiseAPIKeyApiKey.GreyNoiseAPIKeyApiKeyDeserializer.class) +@JsonSerialize(using = GreyNoiseAPIKeyApiKey.GreyNoiseAPIKeyApiKeySerializer.class) +public class GreyNoiseAPIKeyApiKey extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(GreyNoiseAPIKeyApiKey.class.getName()); + + @JsonIgnore public boolean unparsed = false; + + public static class GreyNoiseAPIKeyApiKeySerializer extends StdSerializer { + public GreyNoiseAPIKeyApiKeySerializer(Class t) { + super(t); + } + + public GreyNoiseAPIKeyApiKeySerializer() { + this(null); + } + + @Override + public void serialize( + GreyNoiseAPIKeyApiKey value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class GreyNoiseAPIKeyApiKeyDeserializer + extends StdDeserializer { + public GreyNoiseAPIKeyApiKeyDeserializer() { + this(GreyNoiseAPIKeyApiKey.class); + } + + public GreyNoiseAPIKeyApiKeyDeserializer(Class vc) { + super(vc); + } + + @Override + public GreyNoiseAPIKeyApiKey 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 String + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (String.class.equals(Integer.class) + || String.class.equals(Long.class) + || String.class.equals(Float.class) + || String.class.equals(Double.class) + || String.class.equals(Boolean.class) + || String.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((String.class.equals(Integer.class) || String.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((String.class.equals(Float.class) || String.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (String.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (String.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(String.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. + deserialized = tmp; + match++; + + log.log(Level.FINER, "Input data matches schema 'String'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'String'", e); + } + + // deserialize ActionConnectionAWSSecretsManagerReference + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = + tree.traverse(jp.getCodec()) + .readValueAs(ActionConnectionAWSSecretsManagerReference.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 (!((ActionConnectionAWSSecretsManagerReference) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log( + Level.FINER, + "Input data matches schema 'ActionConnectionAWSSecretsManagerReference'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'ActionConnectionAWSSecretsManagerReference'", + e); + } + + GreyNoiseAPIKeyApiKey ret = new GreyNoiseAPIKeyApiKey(); + 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 GreyNoiseAPIKeyApiKey getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + throw new JsonMappingException(ctxt.getParser(), "GreyNoiseAPIKeyApiKey cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public GreyNoiseAPIKeyApiKey() { + super("oneOf", Boolean.FALSE); + } + + public GreyNoiseAPIKeyApiKey(String o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public GreyNoiseAPIKeyApiKey(ActionConnectionAWSSecretsManagerReference o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("String", new GenericType() {}); + schemas.put( + "ActionConnectionAWSSecretsManagerReference", + new GenericType() {}); + JSON.registerDescendants(GreyNoiseAPIKeyApiKey.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map getSchemas() { + return GreyNoiseAPIKeyApiKey.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: String, ActionConnectionAWSSecretsManagerReference + * + *

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(String.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + if (JSON.isInstanceOf( + ActionConnectionAWSSecretsManagerReference.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 String, ActionConnectionAWSSecretsManagerReference"); + } + + /** + * Get the actual instance, which can be the following: String, + * ActionConnectionAWSSecretsManagerReference + * + * @return The actual instance (String, ActionConnectionAWSSecretsManagerReference) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `String`. If the actual instance is not `String`, the + * ClassCastException will be thrown. + * + * @return The actual instance of `String` + * @throws ClassCastException if the instance is not `String` + */ + public String getString() throws ClassCastException { + return (String) super.getActualInstance(); + } + + /** + * Get the actual instance of `ActionConnectionAWSSecretsManagerReference`. If the actual instance + * is not `ActionConnectionAWSSecretsManagerReference`, the ClassCastException will be thrown. + * + * @return The actual instance of `ActionConnectionAWSSecretsManagerReference` + * @throws ClassCastException if the instance is not `ActionConnectionAWSSecretsManagerReference` + */ + public ActionConnectionAWSSecretsManagerReference getActionConnectionAWSSecretsManagerReference() + throws ClassCastException { + return (ActionConnectionAWSSecretsManagerReference) super.getActualInstance(); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/GreyNoiseAPIKeyUpdate.java b/src/main/java/com/datadog/api/client/v2/model/GreyNoiseAPIKeyUpdate.java index 0c85c8c2a39..42ec902e884 100644 --- a/src/main/java/com/datadog/api/client/v2/model/GreyNoiseAPIKeyUpdate.java +++ b/src/main/java/com/datadog/api/client/v2/model/GreyNoiseAPIKeyUpdate.java @@ -27,7 +27,7 @@ public class GreyNoiseAPIKeyUpdate { @JsonIgnore public boolean unparsed = false; public static final String JSON_PROPERTY_API_KEY = "api_key"; - private String apiKey; + private GreyNoiseAPIKeyUpdateApiKey apiKey; public static final String JSON_PROPERTY_TYPE = "type"; private GreyNoiseAPIKeyType type; @@ -41,8 +41,9 @@ public GreyNoiseAPIKeyUpdate( this.unparsed |= !type.isValid(); } - public GreyNoiseAPIKeyUpdate apiKey(String apiKey) { + public GreyNoiseAPIKeyUpdate apiKey(GreyNoiseAPIKeyUpdateApiKey apiKey) { this.apiKey = apiKey; + this.unparsed |= apiKey.unparsed; return this; } @@ -54,12 +55,15 @@ public GreyNoiseAPIKeyUpdate apiKey(String apiKey) { @jakarta.annotation.Nullable @JsonProperty(JSON_PROPERTY_API_KEY) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public String getApiKey() { + public GreyNoiseAPIKeyUpdateApiKey getApiKey() { return apiKey; } - public void setApiKey(String apiKey) { + public void setApiKey(GreyNoiseAPIKeyUpdateApiKey apiKey) { this.apiKey = apiKey; + if (apiKey != null) { + this.unparsed |= apiKey.unparsed; + } } public GreyNoiseAPIKeyUpdate type(GreyNoiseAPIKeyType type) { diff --git a/src/main/java/com/datadog/api/client/v2/model/GreyNoiseAPIKeyUpdateApiKey.java b/src/main/java/com/datadog/api/client/v2/model/GreyNoiseAPIKeyUpdateApiKey.java new file mode 100644 index 00000000000..2f035dd7f95 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/GreyNoiseAPIKeyUpdateApiKey.java @@ -0,0 +1,290 @@ +/* + * 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 = GreyNoiseAPIKeyUpdateApiKey.GreyNoiseAPIKeyUpdateApiKeyDeserializer.class) +@JsonSerialize(using = GreyNoiseAPIKeyUpdateApiKey.GreyNoiseAPIKeyUpdateApiKeySerializer.class) +public class GreyNoiseAPIKeyUpdateApiKey extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(GreyNoiseAPIKeyUpdateApiKey.class.getName()); + + @JsonIgnore public boolean unparsed = false; + + public static class GreyNoiseAPIKeyUpdateApiKeySerializer + extends StdSerializer { + public GreyNoiseAPIKeyUpdateApiKeySerializer(Class t) { + super(t); + } + + public GreyNoiseAPIKeyUpdateApiKeySerializer() { + this(null); + } + + @Override + public void serialize( + GreyNoiseAPIKeyUpdateApiKey value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class GreyNoiseAPIKeyUpdateApiKeyDeserializer + extends StdDeserializer { + public GreyNoiseAPIKeyUpdateApiKeyDeserializer() { + this(GreyNoiseAPIKeyUpdateApiKey.class); + } + + public GreyNoiseAPIKeyUpdateApiKeyDeserializer(Class vc) { + super(vc); + } + + @Override + public GreyNoiseAPIKeyUpdateApiKey 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 String + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (String.class.equals(Integer.class) + || String.class.equals(Long.class) + || String.class.equals(Float.class) + || String.class.equals(Double.class) + || String.class.equals(Boolean.class) + || String.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((String.class.equals(Integer.class) || String.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((String.class.equals(Float.class) || String.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (String.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (String.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(String.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. + deserialized = tmp; + match++; + + log.log(Level.FINER, "Input data matches schema 'String'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'String'", e); + } + + // deserialize ActionConnectionAWSSecretsManagerReference + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = + tree.traverse(jp.getCodec()) + .readValueAs(ActionConnectionAWSSecretsManagerReference.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 (!((ActionConnectionAWSSecretsManagerReference) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log( + Level.FINER, + "Input data matches schema 'ActionConnectionAWSSecretsManagerReference'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'ActionConnectionAWSSecretsManagerReference'", + e); + } + + GreyNoiseAPIKeyUpdateApiKey ret = new GreyNoiseAPIKeyUpdateApiKey(); + 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 GreyNoiseAPIKeyUpdateApiKey getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + throw new JsonMappingException( + ctxt.getParser(), "GreyNoiseAPIKeyUpdateApiKey cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public GreyNoiseAPIKeyUpdateApiKey() { + super("oneOf", Boolean.FALSE); + } + + public GreyNoiseAPIKeyUpdateApiKey(String o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public GreyNoiseAPIKeyUpdateApiKey(ActionConnectionAWSSecretsManagerReference o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("String", new GenericType() {}); + schemas.put( + "ActionConnectionAWSSecretsManagerReference", + new GenericType() {}); + JSON.registerDescendants( + GreyNoiseAPIKeyUpdateApiKey.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map getSchemas() { + return GreyNoiseAPIKeyUpdateApiKey.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: String, ActionConnectionAWSSecretsManagerReference + * + *

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(String.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + if (JSON.isInstanceOf( + ActionConnectionAWSSecretsManagerReference.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 String, ActionConnectionAWSSecretsManagerReference"); + } + + /** + * Get the actual instance, which can be the following: String, + * ActionConnectionAWSSecretsManagerReference + * + * @return The actual instance (String, ActionConnectionAWSSecretsManagerReference) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `String`. If the actual instance is not `String`, the + * ClassCastException will be thrown. + * + * @return The actual instance of `String` + * @throws ClassCastException if the instance is not `String` + */ + public String getString() throws ClassCastException { + return (String) super.getActualInstance(); + } + + /** + * Get the actual instance of `ActionConnectionAWSSecretsManagerReference`. If the actual instance + * is not `ActionConnectionAWSSecretsManagerReference`, the ClassCastException will be thrown. + * + * @return The actual instance of `ActionConnectionAWSSecretsManagerReference` + * @throws ClassCastException if the instance is not `ActionConnectionAWSSecretsManagerReference` + */ + public ActionConnectionAWSSecretsManagerReference getActionConnectionAWSSecretsManagerReference() + throws ClassCastException { + return (ActionConnectionAWSSecretsManagerReference) super.getActualInstance(); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/HTTPToken.java b/src/main/java/com/datadog/api/client/v2/model/HTTPToken.java index 2bc103efce1..2a80dedfbf3 100644 --- a/src/main/java/com/datadog/api/client/v2/model/HTTPToken.java +++ b/src/main/java/com/datadog/api/client/v2/model/HTTPToken.java @@ -34,7 +34,7 @@ public class HTTPToken { private TokenType type; public static final String JSON_PROPERTY_VALUE = "value"; - private String value; + private HTTPTokenValue value; public HTTPToken() {} @@ -42,11 +42,12 @@ public HTTPToken() {} public HTTPToken( @JsonProperty(required = true, value = JSON_PROPERTY_NAME) String name, @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) TokenType type, - @JsonProperty(required = true, value = JSON_PROPERTY_VALUE) String value) { + @JsonProperty(required = true, value = JSON_PROPERTY_VALUE) HTTPTokenValue value) { this.name = name; this.type = type; this.unparsed |= !type.isValid(); this.value = value; + this.unparsed |= value.unparsed; } public HTTPToken name(String name) { @@ -93,8 +94,9 @@ public void setType(TokenType type) { this.type = type; } - public HTTPToken value(String value) { + public HTTPToken value(HTTPTokenValue value) { this.value = value; + this.unparsed |= value.unparsed; return this; } @@ -105,12 +107,15 @@ public HTTPToken value(String value) { */ @JsonProperty(JSON_PROPERTY_VALUE) @JsonInclude(value = JsonInclude.Include.ALWAYS) - public String getValue() { + public HTTPTokenValue getValue() { return value; } - public void setValue(String value) { + public void setValue(HTTPTokenValue value) { this.value = value; + if (value != null) { + this.unparsed |= value.unparsed; + } } /** diff --git a/src/main/java/com/datadog/api/client/v2/model/HTTPTokenAuth.java b/src/main/java/com/datadog/api/client/v2/model/HTTPTokenAuth.java index 4a26fbb2414..737471b0f63 100644 --- a/src/main/java/com/datadog/api/client/v2/model/HTTPTokenAuth.java +++ b/src/main/java/com/datadog/api/client/v2/model/HTTPTokenAuth.java @@ -23,6 +23,7 @@ @JsonPropertyOrder({ HTTPTokenAuth.JSON_PROPERTY_BODY, HTTPTokenAuth.JSON_PROPERTY_HEADERS, + HTTPTokenAuth.JSON_PROPERTY_HTTP_TOKENS, HTTPTokenAuth.JSON_PROPERTY_TOKENS, HTTPTokenAuth.JSON_PROPERTY_TYPE, HTTPTokenAuth.JSON_PROPERTY_URL_PARAMETERS @@ -37,6 +38,9 @@ public class HTTPTokenAuth { public static final String JSON_PROPERTY_HEADERS = "headers"; private List headers = null; + public static final String JSON_PROPERTY_HTTP_TOKENS = "http_tokens"; + private List httpTokens = null; + public static final String JSON_PROPERTY_TOKENS = "tokens"; private List tokens = null; @@ -120,6 +124,19 @@ public void setHeaders(List headers) { } } + /** + * HTTP authentication tokens returned by the API. Use tokens when creating or + * updating tokens. + * + * @return httpTokens + */ + @jakarta.annotation.Nullable + @JsonProperty(JSON_PROPERTY_HTTP_TOKENS) + @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) + public List getHttpTokens() { + return httpTokens; + } + public HTTPTokenAuth tokens(List tokens) { this.tokens = tokens; if (tokens != null) { @@ -282,6 +299,7 @@ public boolean equals(Object o) { HTTPTokenAuth httpTokenAuth = (HTTPTokenAuth) o; return Objects.equals(this.body, httpTokenAuth.body) && Objects.equals(this.headers, httpTokenAuth.headers) + && Objects.equals(this.httpTokens, httpTokenAuth.httpTokens) && Objects.equals(this.tokens, httpTokenAuth.tokens) && Objects.equals(this.type, httpTokenAuth.type) && Objects.equals(this.urlParameters, httpTokenAuth.urlParameters) @@ -290,7 +308,8 @@ public boolean equals(Object o) { @Override public int hashCode() { - return Objects.hash(body, headers, tokens, type, urlParameters, additionalProperties); + return Objects.hash( + body, headers, httpTokens, tokens, type, urlParameters, additionalProperties); } @Override @@ -299,6 +318,7 @@ public String toString() { sb.append("class HTTPTokenAuth {\n"); sb.append(" body: ").append(toIndentedString(body)).append("\n"); sb.append(" headers: ").append(toIndentedString(headers)).append("\n"); + sb.append(" httpTokens: ").append(toIndentedString(httpTokens)).append("\n"); sb.append(" tokens: ").append(toIndentedString(tokens)).append("\n"); sb.append(" type: ").append(toIndentedString(type)).append("\n"); sb.append(" urlParameters: ").append(toIndentedString(urlParameters)).append("\n"); diff --git a/src/main/java/com/datadog/api/client/v2/model/HTTPTokenResponse.java b/src/main/java/com/datadog/api/client/v2/model/HTTPTokenResponse.java new file mode 100644 index 00000000000..410f3187988 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/HTTPTokenResponse.java @@ -0,0 +1,175 @@ +/* + * 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; + +/** An HTTP authentication token returned by the API. Its type is implicitly SECRET. */ +@JsonPropertyOrder({HTTPTokenResponse.JSON_PROPERTY_NAME, HTTPTokenResponse.JSON_PROPERTY_VALUE}) +@jakarta.annotation.Generated( + value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator") +public class HTTPTokenResponse { + @JsonIgnore public boolean unparsed = false; + public static final String JSON_PROPERTY_NAME = "name"; + private String name; + + public static final String JSON_PROPERTY_VALUE = "value"; + private HTTPTokenResponseValue value; + + public HTTPTokenResponse() {} + + @JsonCreator + public HTTPTokenResponse( + @JsonProperty(required = true, value = JSON_PROPERTY_NAME) String name, + @JsonProperty(required = true, value = JSON_PROPERTY_VALUE) HTTPTokenResponseValue value) { + this.name = name; + this.value = value; + this.unparsed |= value.unparsed; + } + + public HTTPTokenResponse name(String name) { + this.name = name; + return this; + } + + /** + * Name of the HTTP authentication token. + * + * @return name + */ + @JsonProperty(JSON_PROPERTY_NAME) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public HTTPTokenResponse value(HTTPTokenResponseValue value) { + this.value = value; + this.unparsed |= value.unparsed; + return this; + } + + /** + * The HTTPTokenResponse value. + * + * @return value + */ + @JsonProperty(JSON_PROPERTY_VALUE) + @JsonInclude(value = JsonInclude.Include.ALWAYS) + public HTTPTokenResponseValue getValue() { + return value; + } + + public void setValue(HTTPTokenResponseValue value) { + this.value = value; + if (value != null) { + this.unparsed |= value.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 HTTPTokenResponse + */ + @JsonAnySetter + public HTTPTokenResponse 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 HTTPTokenResponse object is equal to o. */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + HTTPTokenResponse httpTokenResponse = (HTTPTokenResponse) o; + return Objects.equals(this.name, httpTokenResponse.name) + && Objects.equals(this.value, httpTokenResponse.value) + && Objects.equals(this.additionalProperties, httpTokenResponse.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(name, value, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class HTTPTokenResponse {\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" value: ").append(toIndentedString(value)).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/HTTPTokenResponseValue.java b/src/main/java/com/datadog/api/client/v2/model/HTTPTokenResponseValue.java new file mode 100644 index 00000000000..2ccc80a8e57 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/HTTPTokenResponseValue.java @@ -0,0 +1,288 @@ +/* + * 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 = HTTPTokenResponseValue.HTTPTokenResponseValueDeserializer.class) +@JsonSerialize(using = HTTPTokenResponseValue.HTTPTokenResponseValueSerializer.class) +public class HTTPTokenResponseValue extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(HTTPTokenResponseValue.class.getName()); + + @JsonIgnore public boolean unparsed = false; + + public static class HTTPTokenResponseValueSerializer + extends StdSerializer { + public HTTPTokenResponseValueSerializer(Class t) { + super(t); + } + + public HTTPTokenResponseValueSerializer() { + this(null); + } + + @Override + public void serialize( + HTTPTokenResponseValue value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class HTTPTokenResponseValueDeserializer + extends StdDeserializer { + public HTTPTokenResponseValueDeserializer() { + this(HTTPTokenResponseValue.class); + } + + public HTTPTokenResponseValueDeserializer(Class vc) { + super(vc); + } + + @Override + public HTTPTokenResponseValue 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 String + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (String.class.equals(Integer.class) + || String.class.equals(Long.class) + || String.class.equals(Float.class) + || String.class.equals(Double.class) + || String.class.equals(Boolean.class) + || String.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((String.class.equals(Integer.class) || String.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((String.class.equals(Float.class) || String.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (String.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (String.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(String.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. + deserialized = tmp; + match++; + + log.log(Level.FINER, "Input data matches schema 'String'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'String'", e); + } + + // deserialize ActionConnectionAWSSecretsManagerReference + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = + tree.traverse(jp.getCodec()) + .readValueAs(ActionConnectionAWSSecretsManagerReference.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 (!((ActionConnectionAWSSecretsManagerReference) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log( + Level.FINER, + "Input data matches schema 'ActionConnectionAWSSecretsManagerReference'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'ActionConnectionAWSSecretsManagerReference'", + e); + } + + HTTPTokenResponseValue ret = new HTTPTokenResponseValue(); + 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 HTTPTokenResponseValue getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + throw new JsonMappingException(ctxt.getParser(), "HTTPTokenResponseValue cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public HTTPTokenResponseValue() { + super("oneOf", Boolean.FALSE); + } + + public HTTPTokenResponseValue(String o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public HTTPTokenResponseValue(ActionConnectionAWSSecretsManagerReference o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("String", new GenericType() {}); + schemas.put( + "ActionConnectionAWSSecretsManagerReference", + new GenericType() {}); + JSON.registerDescendants(HTTPTokenResponseValue.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map getSchemas() { + return HTTPTokenResponseValue.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: String, ActionConnectionAWSSecretsManagerReference + * + *

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(String.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + if (JSON.isInstanceOf( + ActionConnectionAWSSecretsManagerReference.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 String, ActionConnectionAWSSecretsManagerReference"); + } + + /** + * Get the actual instance, which can be the following: String, + * ActionConnectionAWSSecretsManagerReference + * + * @return The actual instance (String, ActionConnectionAWSSecretsManagerReference) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `String`. If the actual instance is not `String`, the + * ClassCastException will be thrown. + * + * @return The actual instance of `String` + * @throws ClassCastException if the instance is not `String` + */ + public String getString() throws ClassCastException { + return (String) super.getActualInstance(); + } + + /** + * Get the actual instance of `ActionConnectionAWSSecretsManagerReference`. If the actual instance + * is not `ActionConnectionAWSSecretsManagerReference`, the ClassCastException will be thrown. + * + * @return The actual instance of `ActionConnectionAWSSecretsManagerReference` + * @throws ClassCastException if the instance is not `ActionConnectionAWSSecretsManagerReference` + */ + public ActionConnectionAWSSecretsManagerReference getActionConnectionAWSSecretsManagerReference() + throws ClassCastException { + return (ActionConnectionAWSSecretsManagerReference) super.getActualInstance(); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/HTTPTokenUpdate.java b/src/main/java/com/datadog/api/client/v2/model/HTTPTokenUpdate.java index 3e682d44aa8..bc355a382f6 100644 --- a/src/main/java/com/datadog/api/client/v2/model/HTTPTokenUpdate.java +++ b/src/main/java/com/datadog/api/client/v2/model/HTTPTokenUpdate.java @@ -38,7 +38,7 @@ public class HTTPTokenUpdate { private TokenType type; public static final String JSON_PROPERTY_VALUE = "value"; - private String value; + private HTTPTokenValue value; public HTTPTokenUpdate() {} @@ -46,11 +46,12 @@ public HTTPTokenUpdate() {} public HTTPTokenUpdate( @JsonProperty(required = true, value = JSON_PROPERTY_NAME) String name, @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) TokenType type, - @JsonProperty(required = true, value = JSON_PROPERTY_VALUE) String value) { + @JsonProperty(required = true, value = JSON_PROPERTY_VALUE) HTTPTokenValue value) { this.name = name; this.type = type; this.unparsed |= !type.isValid(); this.value = value; + this.unparsed |= value.unparsed; } public HTTPTokenUpdate deleted(Boolean deleted) { @@ -118,8 +119,9 @@ public void setType(TokenType type) { this.type = type; } - public HTTPTokenUpdate value(String value) { + public HTTPTokenUpdate value(HTTPTokenValue value) { this.value = value; + this.unparsed |= value.unparsed; return this; } @@ -130,12 +132,15 @@ public HTTPTokenUpdate value(String value) { */ @JsonProperty(JSON_PROPERTY_VALUE) @JsonInclude(value = JsonInclude.Include.ALWAYS) - public String getValue() { + public HTTPTokenValue getValue() { return value; } - public void setValue(String value) { + public void setValue(HTTPTokenValue value) { this.value = value; + if (value != null) { + this.unparsed |= value.unparsed; + } } /** diff --git a/src/main/java/com/datadog/api/client/v2/model/HTTPTokenValue.java b/src/main/java/com/datadog/api/client/v2/model/HTTPTokenValue.java new file mode 100644 index 00000000000..ed49228891d --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/HTTPTokenValue.java @@ -0,0 +1,284 @@ +/* + * 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 = HTTPTokenValue.HTTPTokenValueDeserializer.class) +@JsonSerialize(using = HTTPTokenValue.HTTPTokenValueSerializer.class) +public class HTTPTokenValue extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(HTTPTokenValue.class.getName()); + + @JsonIgnore public boolean unparsed = false; + + public static class HTTPTokenValueSerializer extends StdSerializer { + public HTTPTokenValueSerializer(Class t) { + super(t); + } + + public HTTPTokenValueSerializer() { + this(null); + } + + @Override + public void serialize(HTTPTokenValue value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class HTTPTokenValueDeserializer extends StdDeserializer { + public HTTPTokenValueDeserializer() { + this(HTTPTokenValue.class); + } + + public HTTPTokenValueDeserializer(Class vc) { + super(vc); + } + + @Override + public HTTPTokenValue 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 String + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (String.class.equals(Integer.class) + || String.class.equals(Long.class) + || String.class.equals(Float.class) + || String.class.equals(Double.class) + || String.class.equals(Boolean.class) + || String.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((String.class.equals(Integer.class) || String.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((String.class.equals(Float.class) || String.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (String.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (String.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(String.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. + deserialized = tmp; + match++; + + log.log(Level.FINER, "Input data matches schema 'String'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'String'", e); + } + + // deserialize ActionConnectionAWSSecretsManagerReference + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = + tree.traverse(jp.getCodec()) + .readValueAs(ActionConnectionAWSSecretsManagerReference.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 (!((ActionConnectionAWSSecretsManagerReference) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log( + Level.FINER, + "Input data matches schema 'ActionConnectionAWSSecretsManagerReference'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'ActionConnectionAWSSecretsManagerReference'", + e); + } + + HTTPTokenValue ret = new HTTPTokenValue(); + 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 HTTPTokenValue getNullValue(DeserializationContext ctxt) throws JsonMappingException { + throw new JsonMappingException(ctxt.getParser(), "HTTPTokenValue cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public HTTPTokenValue() { + super("oneOf", Boolean.FALSE); + } + + public HTTPTokenValue(String o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public HTTPTokenValue(ActionConnectionAWSSecretsManagerReference o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("String", new GenericType() {}); + schemas.put( + "ActionConnectionAWSSecretsManagerReference", + new GenericType() {}); + JSON.registerDescendants(HTTPTokenValue.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map getSchemas() { + return HTTPTokenValue.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: String, ActionConnectionAWSSecretsManagerReference + * + *

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(String.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + if (JSON.isInstanceOf( + ActionConnectionAWSSecretsManagerReference.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 String, ActionConnectionAWSSecretsManagerReference"); + } + + /** + * Get the actual instance, which can be the following: String, + * ActionConnectionAWSSecretsManagerReference + * + * @return The actual instance (String, ActionConnectionAWSSecretsManagerReference) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `String`. If the actual instance is not `String`, the + * ClassCastException will be thrown. + * + * @return The actual instance of `String` + * @throws ClassCastException if the instance is not `String` + */ + public String getString() throws ClassCastException { + return (String) super.getActualInstance(); + } + + /** + * Get the actual instance of `ActionConnectionAWSSecretsManagerReference`. If the actual instance + * is not `ActionConnectionAWSSecretsManagerReference`, the ClassCastException will be thrown. + * + * @return The actual instance of `ActionConnectionAWSSecretsManagerReference` + * @throws ClassCastException if the instance is not `ActionConnectionAWSSecretsManagerReference` + */ + public ActionConnectionAWSSecretsManagerReference getActionConnectionAWSSecretsManagerReference() + throws ClassCastException { + return (ActionConnectionAWSSecretsManagerReference) super.getActualInstance(); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/LaunchDarklyAPIKey.java b/src/main/java/com/datadog/api/client/v2/model/LaunchDarklyAPIKey.java index 22bd38f3a72..72357503269 100644 --- a/src/main/java/com/datadog/api/client/v2/model/LaunchDarklyAPIKey.java +++ b/src/main/java/com/datadog/api/client/v2/model/LaunchDarklyAPIKey.java @@ -27,7 +27,7 @@ public class LaunchDarklyAPIKey { @JsonIgnore public boolean unparsed = false; public static final String JSON_PROPERTY_API_TOKEN = "api_token"; - private String apiToken; + private LaunchDarklyAPIKeyApiToken apiToken; public static final String JSON_PROPERTY_TYPE = "type"; private LaunchDarklyAPIKeyType type; @@ -36,15 +36,18 @@ public LaunchDarklyAPIKey() {} @JsonCreator public LaunchDarklyAPIKey( - @JsonProperty(required = true, value = JSON_PROPERTY_API_TOKEN) String apiToken, + @JsonProperty(required = true, value = JSON_PROPERTY_API_TOKEN) + LaunchDarklyAPIKeyApiToken apiToken, @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) LaunchDarklyAPIKeyType type) { this.apiToken = apiToken; + this.unparsed |= apiToken.unparsed; this.type = type; this.unparsed |= !type.isValid(); } - public LaunchDarklyAPIKey apiToken(String apiToken) { + public LaunchDarklyAPIKey apiToken(LaunchDarklyAPIKeyApiToken apiToken) { this.apiToken = apiToken; + this.unparsed |= apiToken.unparsed; return this; } @@ -55,12 +58,15 @@ public LaunchDarklyAPIKey apiToken(String apiToken) { */ @JsonProperty(JSON_PROPERTY_API_TOKEN) @JsonInclude(value = JsonInclude.Include.ALWAYS) - public String getApiToken() { + public LaunchDarklyAPIKeyApiToken getApiToken() { return apiToken; } - public void setApiToken(String apiToken) { + public void setApiToken(LaunchDarklyAPIKeyApiToken apiToken) { this.apiToken = apiToken; + if (apiToken != null) { + this.unparsed |= apiToken.unparsed; + } } public LaunchDarklyAPIKey type(LaunchDarklyAPIKeyType type) { diff --git a/src/main/java/com/datadog/api/client/v2/model/LaunchDarklyAPIKeyApiToken.java b/src/main/java/com/datadog/api/client/v2/model/LaunchDarklyAPIKeyApiToken.java new file mode 100644 index 00000000000..ecbe78519c2 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/LaunchDarklyAPIKeyApiToken.java @@ -0,0 +1,289 @@ +/* + * 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 = LaunchDarklyAPIKeyApiToken.LaunchDarklyAPIKeyApiTokenDeserializer.class) +@JsonSerialize(using = LaunchDarklyAPIKeyApiToken.LaunchDarklyAPIKeyApiTokenSerializer.class) +public class LaunchDarklyAPIKeyApiToken extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(LaunchDarklyAPIKeyApiToken.class.getName()); + + @JsonIgnore public boolean unparsed = false; + + public static class LaunchDarklyAPIKeyApiTokenSerializer + extends StdSerializer { + public LaunchDarklyAPIKeyApiTokenSerializer(Class t) { + super(t); + } + + public LaunchDarklyAPIKeyApiTokenSerializer() { + this(null); + } + + @Override + public void serialize( + LaunchDarklyAPIKeyApiToken value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class LaunchDarklyAPIKeyApiTokenDeserializer + extends StdDeserializer { + public LaunchDarklyAPIKeyApiTokenDeserializer() { + this(LaunchDarklyAPIKeyApiToken.class); + } + + public LaunchDarklyAPIKeyApiTokenDeserializer(Class vc) { + super(vc); + } + + @Override + public LaunchDarklyAPIKeyApiToken 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 String + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (String.class.equals(Integer.class) + || String.class.equals(Long.class) + || String.class.equals(Float.class) + || String.class.equals(Double.class) + || String.class.equals(Boolean.class) + || String.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((String.class.equals(Integer.class) || String.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((String.class.equals(Float.class) || String.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (String.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (String.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(String.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. + deserialized = tmp; + match++; + + log.log(Level.FINER, "Input data matches schema 'String'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'String'", e); + } + + // deserialize ActionConnectionAWSSecretsManagerReference + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = + tree.traverse(jp.getCodec()) + .readValueAs(ActionConnectionAWSSecretsManagerReference.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 (!((ActionConnectionAWSSecretsManagerReference) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log( + Level.FINER, + "Input data matches schema 'ActionConnectionAWSSecretsManagerReference'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'ActionConnectionAWSSecretsManagerReference'", + e); + } + + LaunchDarklyAPIKeyApiToken ret = new LaunchDarklyAPIKeyApiToken(); + 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 LaunchDarklyAPIKeyApiToken getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + throw new JsonMappingException(ctxt.getParser(), "LaunchDarklyAPIKeyApiToken cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public LaunchDarklyAPIKeyApiToken() { + super("oneOf", Boolean.FALSE); + } + + public LaunchDarklyAPIKeyApiToken(String o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public LaunchDarklyAPIKeyApiToken(ActionConnectionAWSSecretsManagerReference o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("String", new GenericType() {}); + schemas.put( + "ActionConnectionAWSSecretsManagerReference", + new GenericType() {}); + JSON.registerDescendants( + LaunchDarklyAPIKeyApiToken.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map getSchemas() { + return LaunchDarklyAPIKeyApiToken.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: String, ActionConnectionAWSSecretsManagerReference + * + *

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(String.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + if (JSON.isInstanceOf( + ActionConnectionAWSSecretsManagerReference.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 String, ActionConnectionAWSSecretsManagerReference"); + } + + /** + * Get the actual instance, which can be the following: String, + * ActionConnectionAWSSecretsManagerReference + * + * @return The actual instance (String, ActionConnectionAWSSecretsManagerReference) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `String`. If the actual instance is not `String`, the + * ClassCastException will be thrown. + * + * @return The actual instance of `String` + * @throws ClassCastException if the instance is not `String` + */ + public String getString() throws ClassCastException { + return (String) super.getActualInstance(); + } + + /** + * Get the actual instance of `ActionConnectionAWSSecretsManagerReference`. If the actual instance + * is not `ActionConnectionAWSSecretsManagerReference`, the ClassCastException will be thrown. + * + * @return The actual instance of `ActionConnectionAWSSecretsManagerReference` + * @throws ClassCastException if the instance is not `ActionConnectionAWSSecretsManagerReference` + */ + public ActionConnectionAWSSecretsManagerReference getActionConnectionAWSSecretsManagerReference() + throws ClassCastException { + return (ActionConnectionAWSSecretsManagerReference) super.getActualInstance(); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/LaunchDarklyAPIKeyUpdate.java b/src/main/java/com/datadog/api/client/v2/model/LaunchDarklyAPIKeyUpdate.java index 4832b74f5ee..d2808c9ced5 100644 --- a/src/main/java/com/datadog/api/client/v2/model/LaunchDarklyAPIKeyUpdate.java +++ b/src/main/java/com/datadog/api/client/v2/model/LaunchDarklyAPIKeyUpdate.java @@ -27,7 +27,7 @@ public class LaunchDarklyAPIKeyUpdate { @JsonIgnore public boolean unparsed = false; public static final String JSON_PROPERTY_API_TOKEN = "api_token"; - private String apiToken; + private LaunchDarklyAPIKeyUpdateApiToken apiToken; public static final String JSON_PROPERTY_TYPE = "type"; private LaunchDarklyAPIKeyType type; @@ -41,8 +41,9 @@ public LaunchDarklyAPIKeyUpdate( this.unparsed |= !type.isValid(); } - public LaunchDarklyAPIKeyUpdate apiToken(String apiToken) { + public LaunchDarklyAPIKeyUpdate apiToken(LaunchDarklyAPIKeyUpdateApiToken apiToken) { this.apiToken = apiToken; + this.unparsed |= apiToken.unparsed; return this; } @@ -54,12 +55,15 @@ public LaunchDarklyAPIKeyUpdate apiToken(String apiToken) { @jakarta.annotation.Nullable @JsonProperty(JSON_PROPERTY_API_TOKEN) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public String getApiToken() { + public LaunchDarklyAPIKeyUpdateApiToken getApiToken() { return apiToken; } - public void setApiToken(String apiToken) { + public void setApiToken(LaunchDarklyAPIKeyUpdateApiToken apiToken) { this.apiToken = apiToken; + if (apiToken != null) { + this.unparsed |= apiToken.unparsed; + } } public LaunchDarklyAPIKeyUpdate type(LaunchDarklyAPIKeyType type) { diff --git a/src/main/java/com/datadog/api/client/v2/model/LaunchDarklyAPIKeyUpdateApiToken.java b/src/main/java/com/datadog/api/client/v2/model/LaunchDarklyAPIKeyUpdateApiToken.java new file mode 100644 index 00000000000..1dae1478b9c --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/LaunchDarklyAPIKeyUpdateApiToken.java @@ -0,0 +1,293 @@ +/* + * 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 = LaunchDarklyAPIKeyUpdateApiToken.LaunchDarklyAPIKeyUpdateApiTokenDeserializer.class) +@JsonSerialize( + using = LaunchDarklyAPIKeyUpdateApiToken.LaunchDarklyAPIKeyUpdateApiTokenSerializer.class) +public class LaunchDarklyAPIKeyUpdateApiToken extends AbstractOpenApiSchema { + private static final Logger log = + Logger.getLogger(LaunchDarklyAPIKeyUpdateApiToken.class.getName()); + + @JsonIgnore public boolean unparsed = false; + + public static class LaunchDarklyAPIKeyUpdateApiTokenSerializer + extends StdSerializer { + public LaunchDarklyAPIKeyUpdateApiTokenSerializer(Class t) { + super(t); + } + + public LaunchDarklyAPIKeyUpdateApiTokenSerializer() { + this(null); + } + + @Override + public void serialize( + LaunchDarklyAPIKeyUpdateApiToken value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class LaunchDarklyAPIKeyUpdateApiTokenDeserializer + extends StdDeserializer { + public LaunchDarklyAPIKeyUpdateApiTokenDeserializer() { + this(LaunchDarklyAPIKeyUpdateApiToken.class); + } + + public LaunchDarklyAPIKeyUpdateApiTokenDeserializer(Class vc) { + super(vc); + } + + @Override + public LaunchDarklyAPIKeyUpdateApiToken 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 String + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (String.class.equals(Integer.class) + || String.class.equals(Long.class) + || String.class.equals(Float.class) + || String.class.equals(Double.class) + || String.class.equals(Boolean.class) + || String.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((String.class.equals(Integer.class) || String.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((String.class.equals(Float.class) || String.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (String.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (String.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(String.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. + deserialized = tmp; + match++; + + log.log(Level.FINER, "Input data matches schema 'String'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'String'", e); + } + + // deserialize ActionConnectionAWSSecretsManagerReference + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = + tree.traverse(jp.getCodec()) + .readValueAs(ActionConnectionAWSSecretsManagerReference.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 (!((ActionConnectionAWSSecretsManagerReference) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log( + Level.FINER, + "Input data matches schema 'ActionConnectionAWSSecretsManagerReference'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'ActionConnectionAWSSecretsManagerReference'", + e); + } + + LaunchDarklyAPIKeyUpdateApiToken ret = new LaunchDarklyAPIKeyUpdateApiToken(); + 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 LaunchDarklyAPIKeyUpdateApiToken getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + throw new JsonMappingException( + ctxt.getParser(), "LaunchDarklyAPIKeyUpdateApiToken cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public LaunchDarklyAPIKeyUpdateApiToken() { + super("oneOf", Boolean.FALSE); + } + + public LaunchDarklyAPIKeyUpdateApiToken(String o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public LaunchDarklyAPIKeyUpdateApiToken(ActionConnectionAWSSecretsManagerReference o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("String", new GenericType() {}); + schemas.put( + "ActionConnectionAWSSecretsManagerReference", + new GenericType() {}); + JSON.registerDescendants( + LaunchDarklyAPIKeyUpdateApiToken.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map getSchemas() { + return LaunchDarklyAPIKeyUpdateApiToken.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: String, ActionConnectionAWSSecretsManagerReference + * + *

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(String.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + if (JSON.isInstanceOf( + ActionConnectionAWSSecretsManagerReference.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 String, ActionConnectionAWSSecretsManagerReference"); + } + + /** + * Get the actual instance, which can be the following: String, + * ActionConnectionAWSSecretsManagerReference + * + * @return The actual instance (String, ActionConnectionAWSSecretsManagerReference) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `String`. If the actual instance is not `String`, the + * ClassCastException will be thrown. + * + * @return The actual instance of `String` + * @throws ClassCastException if the instance is not `String` + */ + public String getString() throws ClassCastException { + return (String) super.getActualInstance(); + } + + /** + * Get the actual instance of `ActionConnectionAWSSecretsManagerReference`. If the actual instance + * is not `ActionConnectionAWSSecretsManagerReference`, the ClassCastException will be thrown. + * + * @return The actual instance of `ActionConnectionAWSSecretsManagerReference` + * @throws ClassCastException if the instance is not `ActionConnectionAWSSecretsManagerReference` + */ + public ActionConnectionAWSSecretsManagerReference getActionConnectionAWSSecretsManagerReference() + throws ClassCastException { + return (ActionConnectionAWSSecretsManagerReference) super.getActualInstance(); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/NotionAPIKey.java b/src/main/java/com/datadog/api/client/v2/model/NotionAPIKey.java index bd99a700773..21856341dff 100644 --- a/src/main/java/com/datadog/api/client/v2/model/NotionAPIKey.java +++ b/src/main/java/com/datadog/api/client/v2/model/NotionAPIKey.java @@ -24,7 +24,7 @@ public class NotionAPIKey { @JsonIgnore public boolean unparsed = false; public static final String JSON_PROPERTY_API_TOKEN = "api_token"; - private String apiToken; + private NotionAPIKeyApiToken apiToken; public static final String JSON_PROPERTY_TYPE = "type"; private NotionAPIKeyType type; @@ -33,15 +33,17 @@ public NotionAPIKey() {} @JsonCreator public NotionAPIKey( - @JsonProperty(required = true, value = JSON_PROPERTY_API_TOKEN) String apiToken, + @JsonProperty(required = true, value = JSON_PROPERTY_API_TOKEN) NotionAPIKeyApiToken apiToken, @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) NotionAPIKeyType type) { this.apiToken = apiToken; + this.unparsed |= apiToken.unparsed; this.type = type; this.unparsed |= !type.isValid(); } - public NotionAPIKey apiToken(String apiToken) { + public NotionAPIKey apiToken(NotionAPIKeyApiToken apiToken) { this.apiToken = apiToken; + this.unparsed |= apiToken.unparsed; return this; } @@ -52,12 +54,15 @@ public NotionAPIKey apiToken(String apiToken) { */ @JsonProperty(JSON_PROPERTY_API_TOKEN) @JsonInclude(value = JsonInclude.Include.ALWAYS) - public String getApiToken() { + public NotionAPIKeyApiToken getApiToken() { return apiToken; } - public void setApiToken(String apiToken) { + public void setApiToken(NotionAPIKeyApiToken apiToken) { this.apiToken = apiToken; + if (apiToken != null) { + this.unparsed |= apiToken.unparsed; + } } public NotionAPIKey type(NotionAPIKeyType type) { diff --git a/src/main/java/com/datadog/api/client/v2/model/NotionAPIKeyApiToken.java b/src/main/java/com/datadog/api/client/v2/model/NotionAPIKeyApiToken.java new file mode 100644 index 00000000000..0b23473f8b6 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/NotionAPIKeyApiToken.java @@ -0,0 +1,287 @@ +/* + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.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 = NotionAPIKeyApiToken.NotionAPIKeyApiTokenDeserializer.class) +@JsonSerialize(using = NotionAPIKeyApiToken.NotionAPIKeyApiTokenSerializer.class) +public class NotionAPIKeyApiToken extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(NotionAPIKeyApiToken.class.getName()); + + @JsonIgnore public boolean unparsed = false; + + public static class NotionAPIKeyApiTokenSerializer extends StdSerializer { + public NotionAPIKeyApiTokenSerializer(Class t) { + super(t); + } + + public NotionAPIKeyApiTokenSerializer() { + this(null); + } + + @Override + public void serialize( + NotionAPIKeyApiToken value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class NotionAPIKeyApiTokenDeserializer + extends StdDeserializer { + public NotionAPIKeyApiTokenDeserializer() { + this(NotionAPIKeyApiToken.class); + } + + public NotionAPIKeyApiTokenDeserializer(Class vc) { + super(vc); + } + + @Override + public NotionAPIKeyApiToken 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 String + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (String.class.equals(Integer.class) + || String.class.equals(Long.class) + || String.class.equals(Float.class) + || String.class.equals(Double.class) + || String.class.equals(Boolean.class) + || String.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((String.class.equals(Integer.class) || String.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((String.class.equals(Float.class) || String.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (String.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (String.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(String.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. + deserialized = tmp; + match++; + + log.log(Level.FINER, "Input data matches schema 'String'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'String'", e); + } + + // deserialize ActionConnectionAWSSecretsManagerReference + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = + tree.traverse(jp.getCodec()) + .readValueAs(ActionConnectionAWSSecretsManagerReference.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 (!((ActionConnectionAWSSecretsManagerReference) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log( + Level.FINER, + "Input data matches schema 'ActionConnectionAWSSecretsManagerReference'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'ActionConnectionAWSSecretsManagerReference'", + e); + } + + NotionAPIKeyApiToken ret = new NotionAPIKeyApiToken(); + 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 NotionAPIKeyApiToken getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + throw new JsonMappingException(ctxt.getParser(), "NotionAPIKeyApiToken cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public NotionAPIKeyApiToken() { + super("oneOf", Boolean.FALSE); + } + + public NotionAPIKeyApiToken(String o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public NotionAPIKeyApiToken(ActionConnectionAWSSecretsManagerReference o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("String", new GenericType() {}); + schemas.put( + "ActionConnectionAWSSecretsManagerReference", + new GenericType() {}); + JSON.registerDescendants(NotionAPIKeyApiToken.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map getSchemas() { + return NotionAPIKeyApiToken.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: String, ActionConnectionAWSSecretsManagerReference + * + *

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(String.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + if (JSON.isInstanceOf( + ActionConnectionAWSSecretsManagerReference.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 String, ActionConnectionAWSSecretsManagerReference"); + } + + /** + * Get the actual instance, which can be the following: String, + * ActionConnectionAWSSecretsManagerReference + * + * @return The actual instance (String, ActionConnectionAWSSecretsManagerReference) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `String`. If the actual instance is not `String`, the + * ClassCastException will be thrown. + * + * @return The actual instance of `String` + * @throws ClassCastException if the instance is not `String` + */ + public String getString() throws ClassCastException { + return (String) super.getActualInstance(); + } + + /** + * Get the actual instance of `ActionConnectionAWSSecretsManagerReference`. If the actual instance + * is not `ActionConnectionAWSSecretsManagerReference`, the ClassCastException will be thrown. + * + * @return The actual instance of `ActionConnectionAWSSecretsManagerReference` + * @throws ClassCastException if the instance is not `ActionConnectionAWSSecretsManagerReference` + */ + public ActionConnectionAWSSecretsManagerReference getActionConnectionAWSSecretsManagerReference() + throws ClassCastException { + return (ActionConnectionAWSSecretsManagerReference) super.getActualInstance(); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/NotionAPIKeyUpdate.java b/src/main/java/com/datadog/api/client/v2/model/NotionAPIKeyUpdate.java index d930cff5199..732a8488f81 100644 --- a/src/main/java/com/datadog/api/client/v2/model/NotionAPIKeyUpdate.java +++ b/src/main/java/com/datadog/api/client/v2/model/NotionAPIKeyUpdate.java @@ -27,7 +27,7 @@ public class NotionAPIKeyUpdate { @JsonIgnore public boolean unparsed = false; public static final String JSON_PROPERTY_API_TOKEN = "api_token"; - private String apiToken; + private NotionAPIKeyUpdateApiToken apiToken; public static final String JSON_PROPERTY_TYPE = "type"; private NotionAPIKeyType type; @@ -41,8 +41,9 @@ public NotionAPIKeyUpdate( this.unparsed |= !type.isValid(); } - public NotionAPIKeyUpdate apiToken(String apiToken) { + public NotionAPIKeyUpdate apiToken(NotionAPIKeyUpdateApiToken apiToken) { this.apiToken = apiToken; + this.unparsed |= apiToken.unparsed; return this; } @@ -54,12 +55,15 @@ public NotionAPIKeyUpdate apiToken(String apiToken) { @jakarta.annotation.Nullable @JsonProperty(JSON_PROPERTY_API_TOKEN) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public String getApiToken() { + public NotionAPIKeyUpdateApiToken getApiToken() { return apiToken; } - public void setApiToken(String apiToken) { + public void setApiToken(NotionAPIKeyUpdateApiToken apiToken) { this.apiToken = apiToken; + if (apiToken != null) { + this.unparsed |= apiToken.unparsed; + } } public NotionAPIKeyUpdate type(NotionAPIKeyType type) { diff --git a/src/main/java/com/datadog/api/client/v2/model/NotionAPIKeyUpdateApiToken.java b/src/main/java/com/datadog/api/client/v2/model/NotionAPIKeyUpdateApiToken.java new file mode 100644 index 00000000000..43fe88f3dae --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/NotionAPIKeyUpdateApiToken.java @@ -0,0 +1,289 @@ +/* + * 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 = NotionAPIKeyUpdateApiToken.NotionAPIKeyUpdateApiTokenDeserializer.class) +@JsonSerialize(using = NotionAPIKeyUpdateApiToken.NotionAPIKeyUpdateApiTokenSerializer.class) +public class NotionAPIKeyUpdateApiToken extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(NotionAPIKeyUpdateApiToken.class.getName()); + + @JsonIgnore public boolean unparsed = false; + + public static class NotionAPIKeyUpdateApiTokenSerializer + extends StdSerializer { + public NotionAPIKeyUpdateApiTokenSerializer(Class t) { + super(t); + } + + public NotionAPIKeyUpdateApiTokenSerializer() { + this(null); + } + + @Override + public void serialize( + NotionAPIKeyUpdateApiToken value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class NotionAPIKeyUpdateApiTokenDeserializer + extends StdDeserializer { + public NotionAPIKeyUpdateApiTokenDeserializer() { + this(NotionAPIKeyUpdateApiToken.class); + } + + public NotionAPIKeyUpdateApiTokenDeserializer(Class vc) { + super(vc); + } + + @Override + public NotionAPIKeyUpdateApiToken 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 String + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (String.class.equals(Integer.class) + || String.class.equals(Long.class) + || String.class.equals(Float.class) + || String.class.equals(Double.class) + || String.class.equals(Boolean.class) + || String.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((String.class.equals(Integer.class) || String.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((String.class.equals(Float.class) || String.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (String.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (String.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(String.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. + deserialized = tmp; + match++; + + log.log(Level.FINER, "Input data matches schema 'String'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'String'", e); + } + + // deserialize ActionConnectionAWSSecretsManagerReference + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = + tree.traverse(jp.getCodec()) + .readValueAs(ActionConnectionAWSSecretsManagerReference.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 (!((ActionConnectionAWSSecretsManagerReference) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log( + Level.FINER, + "Input data matches schema 'ActionConnectionAWSSecretsManagerReference'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'ActionConnectionAWSSecretsManagerReference'", + e); + } + + NotionAPIKeyUpdateApiToken ret = new NotionAPIKeyUpdateApiToken(); + 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 NotionAPIKeyUpdateApiToken getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + throw new JsonMappingException(ctxt.getParser(), "NotionAPIKeyUpdateApiToken cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public NotionAPIKeyUpdateApiToken() { + super("oneOf", Boolean.FALSE); + } + + public NotionAPIKeyUpdateApiToken(String o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public NotionAPIKeyUpdateApiToken(ActionConnectionAWSSecretsManagerReference o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("String", new GenericType() {}); + schemas.put( + "ActionConnectionAWSSecretsManagerReference", + new GenericType() {}); + JSON.registerDescendants( + NotionAPIKeyUpdateApiToken.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map getSchemas() { + return NotionAPIKeyUpdateApiToken.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: String, ActionConnectionAWSSecretsManagerReference + * + *

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(String.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + if (JSON.isInstanceOf( + ActionConnectionAWSSecretsManagerReference.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 String, ActionConnectionAWSSecretsManagerReference"); + } + + /** + * Get the actual instance, which can be the following: String, + * ActionConnectionAWSSecretsManagerReference + * + * @return The actual instance (String, ActionConnectionAWSSecretsManagerReference) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `String`. If the actual instance is not `String`, the + * ClassCastException will be thrown. + * + * @return The actual instance of `String` + * @throws ClassCastException if the instance is not `String` + */ + public String getString() throws ClassCastException { + return (String) super.getActualInstance(); + } + + /** + * Get the actual instance of `ActionConnectionAWSSecretsManagerReference`. If the actual instance + * is not `ActionConnectionAWSSecretsManagerReference`, the ClassCastException will be thrown. + * + * @return The actual instance of `ActionConnectionAWSSecretsManagerReference` + * @throws ClassCastException if the instance is not `ActionConnectionAWSSecretsManagerReference` + */ + public ActionConnectionAWSSecretsManagerReference getActionConnectionAWSSecretsManagerReference() + throws ClassCastException { + return (ActionConnectionAWSSecretsManagerReference) super.getActualInstance(); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/OktaAPIToken.java b/src/main/java/com/datadog/api/client/v2/model/OktaAPIToken.java index 5e1dba16292..700e4bb6a10 100644 --- a/src/main/java/com/datadog/api/client/v2/model/OktaAPIToken.java +++ b/src/main/java/com/datadog/api/client/v2/model/OktaAPIToken.java @@ -28,10 +28,10 @@ public class OktaAPIToken { @JsonIgnore public boolean unparsed = false; public static final String JSON_PROPERTY_API_TOKEN = "api_token"; - private String apiToken; + private OktaAPITokenApiToken apiToken; public static final String JSON_PROPERTY_DOMAIN = "domain"; - private String domain; + private OktaAPITokenDomain domain; public static final String JSON_PROPERTY_TYPE = "type"; private OktaAPITokenType type; @@ -40,17 +40,20 @@ public OktaAPIToken() {} @JsonCreator public OktaAPIToken( - @JsonProperty(required = true, value = JSON_PROPERTY_API_TOKEN) String apiToken, - @JsonProperty(required = true, value = JSON_PROPERTY_DOMAIN) String domain, + @JsonProperty(required = true, value = JSON_PROPERTY_API_TOKEN) OktaAPITokenApiToken apiToken, + @JsonProperty(required = true, value = JSON_PROPERTY_DOMAIN) OktaAPITokenDomain domain, @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) OktaAPITokenType type) { this.apiToken = apiToken; + this.unparsed |= apiToken.unparsed; this.domain = domain; + this.unparsed |= domain.unparsed; this.type = type; this.unparsed |= !type.isValid(); } - public OktaAPIToken apiToken(String apiToken) { + public OktaAPIToken apiToken(OktaAPITokenApiToken apiToken) { this.apiToken = apiToken; + this.unparsed |= apiToken.unparsed; return this; } @@ -61,16 +64,20 @@ public OktaAPIToken apiToken(String apiToken) { */ @JsonProperty(JSON_PROPERTY_API_TOKEN) @JsonInclude(value = JsonInclude.Include.ALWAYS) - public String getApiToken() { + public OktaAPITokenApiToken getApiToken() { return apiToken; } - public void setApiToken(String apiToken) { + public void setApiToken(OktaAPITokenApiToken apiToken) { this.apiToken = apiToken; + if (apiToken != null) { + this.unparsed |= apiToken.unparsed; + } } - public OktaAPIToken domain(String domain) { + public OktaAPIToken domain(OktaAPITokenDomain domain) { this.domain = domain; + this.unparsed |= domain.unparsed; return this; } @@ -81,12 +88,15 @@ public OktaAPIToken domain(String domain) { */ @JsonProperty(JSON_PROPERTY_DOMAIN) @JsonInclude(value = JsonInclude.Include.ALWAYS) - public String getDomain() { + public OktaAPITokenDomain getDomain() { return domain; } - public void setDomain(String domain) { + public void setDomain(OktaAPITokenDomain domain) { this.domain = domain; + if (domain != null) { + this.unparsed |= domain.unparsed; + } } public OktaAPIToken type(OktaAPITokenType type) { diff --git a/src/main/java/com/datadog/api/client/v2/model/OktaAPITokenApiToken.java b/src/main/java/com/datadog/api/client/v2/model/OktaAPITokenApiToken.java new file mode 100644 index 00000000000..6b3810e08b2 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/OktaAPITokenApiToken.java @@ -0,0 +1,287 @@ +/* + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.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 = OktaAPITokenApiToken.OktaAPITokenApiTokenDeserializer.class) +@JsonSerialize(using = OktaAPITokenApiToken.OktaAPITokenApiTokenSerializer.class) +public class OktaAPITokenApiToken extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(OktaAPITokenApiToken.class.getName()); + + @JsonIgnore public boolean unparsed = false; + + public static class OktaAPITokenApiTokenSerializer extends StdSerializer { + public OktaAPITokenApiTokenSerializer(Class t) { + super(t); + } + + public OktaAPITokenApiTokenSerializer() { + this(null); + } + + @Override + public void serialize( + OktaAPITokenApiToken value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class OktaAPITokenApiTokenDeserializer + extends StdDeserializer { + public OktaAPITokenApiTokenDeserializer() { + this(OktaAPITokenApiToken.class); + } + + public OktaAPITokenApiTokenDeserializer(Class vc) { + super(vc); + } + + @Override + public OktaAPITokenApiToken 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 String + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (String.class.equals(Integer.class) + || String.class.equals(Long.class) + || String.class.equals(Float.class) + || String.class.equals(Double.class) + || String.class.equals(Boolean.class) + || String.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((String.class.equals(Integer.class) || String.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((String.class.equals(Float.class) || String.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (String.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (String.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(String.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. + deserialized = tmp; + match++; + + log.log(Level.FINER, "Input data matches schema 'String'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'String'", e); + } + + // deserialize ActionConnectionAWSSecretsManagerReference + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = + tree.traverse(jp.getCodec()) + .readValueAs(ActionConnectionAWSSecretsManagerReference.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 (!((ActionConnectionAWSSecretsManagerReference) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log( + Level.FINER, + "Input data matches schema 'ActionConnectionAWSSecretsManagerReference'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'ActionConnectionAWSSecretsManagerReference'", + e); + } + + OktaAPITokenApiToken ret = new OktaAPITokenApiToken(); + 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 OktaAPITokenApiToken getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + throw new JsonMappingException(ctxt.getParser(), "OktaAPITokenApiToken cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public OktaAPITokenApiToken() { + super("oneOf", Boolean.FALSE); + } + + public OktaAPITokenApiToken(String o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public OktaAPITokenApiToken(ActionConnectionAWSSecretsManagerReference o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("String", new GenericType() {}); + schemas.put( + "ActionConnectionAWSSecretsManagerReference", + new GenericType() {}); + JSON.registerDescendants(OktaAPITokenApiToken.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map getSchemas() { + return OktaAPITokenApiToken.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: String, ActionConnectionAWSSecretsManagerReference + * + *

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(String.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + if (JSON.isInstanceOf( + ActionConnectionAWSSecretsManagerReference.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 String, ActionConnectionAWSSecretsManagerReference"); + } + + /** + * Get the actual instance, which can be the following: String, + * ActionConnectionAWSSecretsManagerReference + * + * @return The actual instance (String, ActionConnectionAWSSecretsManagerReference) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `String`. If the actual instance is not `String`, the + * ClassCastException will be thrown. + * + * @return The actual instance of `String` + * @throws ClassCastException if the instance is not `String` + */ + public String getString() throws ClassCastException { + return (String) super.getActualInstance(); + } + + /** + * Get the actual instance of `ActionConnectionAWSSecretsManagerReference`. If the actual instance + * is not `ActionConnectionAWSSecretsManagerReference`, the ClassCastException will be thrown. + * + * @return The actual instance of `ActionConnectionAWSSecretsManagerReference` + * @throws ClassCastException if the instance is not `ActionConnectionAWSSecretsManagerReference` + */ + public ActionConnectionAWSSecretsManagerReference getActionConnectionAWSSecretsManagerReference() + throws ClassCastException { + return (ActionConnectionAWSSecretsManagerReference) super.getActualInstance(); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/OktaAPITokenDomain.java b/src/main/java/com/datadog/api/client/v2/model/OktaAPITokenDomain.java new file mode 100644 index 00000000000..8c838609f21 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/OktaAPITokenDomain.java @@ -0,0 +1,285 @@ +/* + * 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 = OktaAPITokenDomain.OktaAPITokenDomainDeserializer.class) +@JsonSerialize(using = OktaAPITokenDomain.OktaAPITokenDomainSerializer.class) +public class OktaAPITokenDomain extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(OktaAPITokenDomain.class.getName()); + + @JsonIgnore public boolean unparsed = false; + + public static class OktaAPITokenDomainSerializer extends StdSerializer { + public OktaAPITokenDomainSerializer(Class t) { + super(t); + } + + public OktaAPITokenDomainSerializer() { + this(null); + } + + @Override + public void serialize(OktaAPITokenDomain value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class OktaAPITokenDomainDeserializer extends StdDeserializer { + public OktaAPITokenDomainDeserializer() { + this(OktaAPITokenDomain.class); + } + + public OktaAPITokenDomainDeserializer(Class vc) { + super(vc); + } + + @Override + public OktaAPITokenDomain 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 String + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (String.class.equals(Integer.class) + || String.class.equals(Long.class) + || String.class.equals(Float.class) + || String.class.equals(Double.class) + || String.class.equals(Boolean.class) + || String.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((String.class.equals(Integer.class) || String.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((String.class.equals(Float.class) || String.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (String.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (String.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(String.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. + deserialized = tmp; + match++; + + log.log(Level.FINER, "Input data matches schema 'String'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'String'", e); + } + + // deserialize ActionConnectionAWSSecretsManagerReference + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = + tree.traverse(jp.getCodec()) + .readValueAs(ActionConnectionAWSSecretsManagerReference.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 (!((ActionConnectionAWSSecretsManagerReference) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log( + Level.FINER, + "Input data matches schema 'ActionConnectionAWSSecretsManagerReference'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'ActionConnectionAWSSecretsManagerReference'", + e); + } + + OktaAPITokenDomain ret = new OktaAPITokenDomain(); + 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 OktaAPITokenDomain getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + throw new JsonMappingException(ctxt.getParser(), "OktaAPITokenDomain cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public OktaAPITokenDomain() { + super("oneOf", Boolean.FALSE); + } + + public OktaAPITokenDomain(String o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public OktaAPITokenDomain(ActionConnectionAWSSecretsManagerReference o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("String", new GenericType() {}); + schemas.put( + "ActionConnectionAWSSecretsManagerReference", + new GenericType() {}); + JSON.registerDescendants(OktaAPITokenDomain.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map getSchemas() { + return OktaAPITokenDomain.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: String, ActionConnectionAWSSecretsManagerReference + * + *

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(String.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + if (JSON.isInstanceOf( + ActionConnectionAWSSecretsManagerReference.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 String, ActionConnectionAWSSecretsManagerReference"); + } + + /** + * Get the actual instance, which can be the following: String, + * ActionConnectionAWSSecretsManagerReference + * + * @return The actual instance (String, ActionConnectionAWSSecretsManagerReference) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `String`. If the actual instance is not `String`, the + * ClassCastException will be thrown. + * + * @return The actual instance of `String` + * @throws ClassCastException if the instance is not `String` + */ + public String getString() throws ClassCastException { + return (String) super.getActualInstance(); + } + + /** + * Get the actual instance of `ActionConnectionAWSSecretsManagerReference`. If the actual instance + * is not `ActionConnectionAWSSecretsManagerReference`, the ClassCastException will be thrown. + * + * @return The actual instance of `ActionConnectionAWSSecretsManagerReference` + * @throws ClassCastException if the instance is not `ActionConnectionAWSSecretsManagerReference` + */ + public ActionConnectionAWSSecretsManagerReference getActionConnectionAWSSecretsManagerReference() + throws ClassCastException { + return (ActionConnectionAWSSecretsManagerReference) super.getActualInstance(); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/OktaAPITokenUpdate.java b/src/main/java/com/datadog/api/client/v2/model/OktaAPITokenUpdate.java index a5b1ab42f71..504c24ac5bd 100644 --- a/src/main/java/com/datadog/api/client/v2/model/OktaAPITokenUpdate.java +++ b/src/main/java/com/datadog/api/client/v2/model/OktaAPITokenUpdate.java @@ -28,10 +28,10 @@ public class OktaAPITokenUpdate { @JsonIgnore public boolean unparsed = false; public static final String JSON_PROPERTY_API_TOKEN = "api_token"; - private String apiToken; + private OktaAPITokenUpdateApiToken apiToken; public static final String JSON_PROPERTY_DOMAIN = "domain"; - private String domain; + private OktaAPITokenUpdateDomain domain; public static final String JSON_PROPERTY_TYPE = "type"; private OktaAPITokenType type; @@ -45,8 +45,9 @@ public OktaAPITokenUpdate( this.unparsed |= !type.isValid(); } - public OktaAPITokenUpdate apiToken(String apiToken) { + public OktaAPITokenUpdate apiToken(OktaAPITokenUpdateApiToken apiToken) { this.apiToken = apiToken; + this.unparsed |= apiToken.unparsed; return this; } @@ -58,16 +59,20 @@ public OktaAPITokenUpdate apiToken(String apiToken) { @jakarta.annotation.Nullable @JsonProperty(JSON_PROPERTY_API_TOKEN) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public String getApiToken() { + public OktaAPITokenUpdateApiToken getApiToken() { return apiToken; } - public void setApiToken(String apiToken) { + public void setApiToken(OktaAPITokenUpdateApiToken apiToken) { this.apiToken = apiToken; + if (apiToken != null) { + this.unparsed |= apiToken.unparsed; + } } - public OktaAPITokenUpdate domain(String domain) { + public OktaAPITokenUpdate domain(OktaAPITokenUpdateDomain domain) { this.domain = domain; + this.unparsed |= domain.unparsed; return this; } @@ -79,12 +84,15 @@ public OktaAPITokenUpdate domain(String domain) { @jakarta.annotation.Nullable @JsonProperty(JSON_PROPERTY_DOMAIN) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public String getDomain() { + public OktaAPITokenUpdateDomain getDomain() { return domain; } - public void setDomain(String domain) { + public void setDomain(OktaAPITokenUpdateDomain domain) { this.domain = domain; + if (domain != null) { + this.unparsed |= domain.unparsed; + } } public OktaAPITokenUpdate type(OktaAPITokenType type) { diff --git a/src/main/java/com/datadog/api/client/v2/model/OktaAPITokenUpdateApiToken.java b/src/main/java/com/datadog/api/client/v2/model/OktaAPITokenUpdateApiToken.java new file mode 100644 index 00000000000..c8edef00640 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/OktaAPITokenUpdateApiToken.java @@ -0,0 +1,289 @@ +/* + * 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 = OktaAPITokenUpdateApiToken.OktaAPITokenUpdateApiTokenDeserializer.class) +@JsonSerialize(using = OktaAPITokenUpdateApiToken.OktaAPITokenUpdateApiTokenSerializer.class) +public class OktaAPITokenUpdateApiToken extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(OktaAPITokenUpdateApiToken.class.getName()); + + @JsonIgnore public boolean unparsed = false; + + public static class OktaAPITokenUpdateApiTokenSerializer + extends StdSerializer { + public OktaAPITokenUpdateApiTokenSerializer(Class t) { + super(t); + } + + public OktaAPITokenUpdateApiTokenSerializer() { + this(null); + } + + @Override + public void serialize( + OktaAPITokenUpdateApiToken value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class OktaAPITokenUpdateApiTokenDeserializer + extends StdDeserializer { + public OktaAPITokenUpdateApiTokenDeserializer() { + this(OktaAPITokenUpdateApiToken.class); + } + + public OktaAPITokenUpdateApiTokenDeserializer(Class vc) { + super(vc); + } + + @Override + public OktaAPITokenUpdateApiToken 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 String + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (String.class.equals(Integer.class) + || String.class.equals(Long.class) + || String.class.equals(Float.class) + || String.class.equals(Double.class) + || String.class.equals(Boolean.class) + || String.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((String.class.equals(Integer.class) || String.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((String.class.equals(Float.class) || String.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (String.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (String.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(String.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. + deserialized = tmp; + match++; + + log.log(Level.FINER, "Input data matches schema 'String'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'String'", e); + } + + // deserialize ActionConnectionAWSSecretsManagerReference + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = + tree.traverse(jp.getCodec()) + .readValueAs(ActionConnectionAWSSecretsManagerReference.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 (!((ActionConnectionAWSSecretsManagerReference) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log( + Level.FINER, + "Input data matches schema 'ActionConnectionAWSSecretsManagerReference'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'ActionConnectionAWSSecretsManagerReference'", + e); + } + + OktaAPITokenUpdateApiToken ret = new OktaAPITokenUpdateApiToken(); + 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 OktaAPITokenUpdateApiToken getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + throw new JsonMappingException(ctxt.getParser(), "OktaAPITokenUpdateApiToken cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public OktaAPITokenUpdateApiToken() { + super("oneOf", Boolean.FALSE); + } + + public OktaAPITokenUpdateApiToken(String o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public OktaAPITokenUpdateApiToken(ActionConnectionAWSSecretsManagerReference o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("String", new GenericType() {}); + schemas.put( + "ActionConnectionAWSSecretsManagerReference", + new GenericType() {}); + JSON.registerDescendants( + OktaAPITokenUpdateApiToken.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map getSchemas() { + return OktaAPITokenUpdateApiToken.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: String, ActionConnectionAWSSecretsManagerReference + * + *

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(String.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + if (JSON.isInstanceOf( + ActionConnectionAWSSecretsManagerReference.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 String, ActionConnectionAWSSecretsManagerReference"); + } + + /** + * Get the actual instance, which can be the following: String, + * ActionConnectionAWSSecretsManagerReference + * + * @return The actual instance (String, ActionConnectionAWSSecretsManagerReference) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `String`. If the actual instance is not `String`, the + * ClassCastException will be thrown. + * + * @return The actual instance of `String` + * @throws ClassCastException if the instance is not `String` + */ + public String getString() throws ClassCastException { + return (String) super.getActualInstance(); + } + + /** + * Get the actual instance of `ActionConnectionAWSSecretsManagerReference`. If the actual instance + * is not `ActionConnectionAWSSecretsManagerReference`, the ClassCastException will be thrown. + * + * @return The actual instance of `ActionConnectionAWSSecretsManagerReference` + * @throws ClassCastException if the instance is not `ActionConnectionAWSSecretsManagerReference` + */ + public ActionConnectionAWSSecretsManagerReference getActionConnectionAWSSecretsManagerReference() + throws ClassCastException { + return (ActionConnectionAWSSecretsManagerReference) super.getActualInstance(); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/OktaAPITokenUpdateDomain.java b/src/main/java/com/datadog/api/client/v2/model/OktaAPITokenUpdateDomain.java new file mode 100644 index 00000000000..dd2ee349e12 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/OktaAPITokenUpdateDomain.java @@ -0,0 +1,288 @@ +/* + * 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 = OktaAPITokenUpdateDomain.OktaAPITokenUpdateDomainDeserializer.class) +@JsonSerialize(using = OktaAPITokenUpdateDomain.OktaAPITokenUpdateDomainSerializer.class) +public class OktaAPITokenUpdateDomain extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(OktaAPITokenUpdateDomain.class.getName()); + + @JsonIgnore public boolean unparsed = false; + + public static class OktaAPITokenUpdateDomainSerializer + extends StdSerializer { + public OktaAPITokenUpdateDomainSerializer(Class t) { + super(t); + } + + public OktaAPITokenUpdateDomainSerializer() { + this(null); + } + + @Override + public void serialize( + OktaAPITokenUpdateDomain value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class OktaAPITokenUpdateDomainDeserializer + extends StdDeserializer { + public OktaAPITokenUpdateDomainDeserializer() { + this(OktaAPITokenUpdateDomain.class); + } + + public OktaAPITokenUpdateDomainDeserializer(Class vc) { + super(vc); + } + + @Override + public OktaAPITokenUpdateDomain 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 String + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (String.class.equals(Integer.class) + || String.class.equals(Long.class) + || String.class.equals(Float.class) + || String.class.equals(Double.class) + || String.class.equals(Boolean.class) + || String.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((String.class.equals(Integer.class) || String.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((String.class.equals(Float.class) || String.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (String.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (String.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(String.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. + deserialized = tmp; + match++; + + log.log(Level.FINER, "Input data matches schema 'String'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'String'", e); + } + + // deserialize ActionConnectionAWSSecretsManagerReference + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = + tree.traverse(jp.getCodec()) + .readValueAs(ActionConnectionAWSSecretsManagerReference.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 (!((ActionConnectionAWSSecretsManagerReference) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log( + Level.FINER, + "Input data matches schema 'ActionConnectionAWSSecretsManagerReference'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'ActionConnectionAWSSecretsManagerReference'", + e); + } + + OktaAPITokenUpdateDomain ret = new OktaAPITokenUpdateDomain(); + 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 OktaAPITokenUpdateDomain getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + throw new JsonMappingException(ctxt.getParser(), "OktaAPITokenUpdateDomain cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public OktaAPITokenUpdateDomain() { + super("oneOf", Boolean.FALSE); + } + + public OktaAPITokenUpdateDomain(String o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public OktaAPITokenUpdateDomain(ActionConnectionAWSSecretsManagerReference o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("String", new GenericType() {}); + schemas.put( + "ActionConnectionAWSSecretsManagerReference", + new GenericType() {}); + JSON.registerDescendants(OktaAPITokenUpdateDomain.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map getSchemas() { + return OktaAPITokenUpdateDomain.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: String, ActionConnectionAWSSecretsManagerReference + * + *

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(String.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + if (JSON.isInstanceOf( + ActionConnectionAWSSecretsManagerReference.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 String, ActionConnectionAWSSecretsManagerReference"); + } + + /** + * Get the actual instance, which can be the following: String, + * ActionConnectionAWSSecretsManagerReference + * + * @return The actual instance (String, ActionConnectionAWSSecretsManagerReference) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `String`. If the actual instance is not `String`, the + * ClassCastException will be thrown. + * + * @return The actual instance of `String` + * @throws ClassCastException if the instance is not `String` + */ + public String getString() throws ClassCastException { + return (String) super.getActualInstance(); + } + + /** + * Get the actual instance of `ActionConnectionAWSSecretsManagerReference`. If the actual instance + * is not `ActionConnectionAWSSecretsManagerReference`, the ClassCastException will be thrown. + * + * @return The actual instance of `ActionConnectionAWSSecretsManagerReference` + * @throws ClassCastException if the instance is not `ActionConnectionAWSSecretsManagerReference` + */ + public ActionConnectionAWSSecretsManagerReference getActionConnectionAWSSecretsManagerReference() + throws ClassCastException { + return (ActionConnectionAWSSecretsManagerReference) super.getActualInstance(); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/OpenAIAPIKey.java b/src/main/java/com/datadog/api/client/v2/model/OpenAIAPIKey.java index 7d36ac3596f..60c95efb307 100644 --- a/src/main/java/com/datadog/api/client/v2/model/OpenAIAPIKey.java +++ b/src/main/java/com/datadog/api/client/v2/model/OpenAIAPIKey.java @@ -24,7 +24,7 @@ public class OpenAIAPIKey { @JsonIgnore public boolean unparsed = false; public static final String JSON_PROPERTY_API_TOKEN = "api_token"; - private String apiToken; + private OpenAIAPIKeyApiToken apiToken; public static final String JSON_PROPERTY_TYPE = "type"; private OpenAIAPIKeyType type; @@ -33,15 +33,17 @@ public OpenAIAPIKey() {} @JsonCreator public OpenAIAPIKey( - @JsonProperty(required = true, value = JSON_PROPERTY_API_TOKEN) String apiToken, + @JsonProperty(required = true, value = JSON_PROPERTY_API_TOKEN) OpenAIAPIKeyApiToken apiToken, @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) OpenAIAPIKeyType type) { this.apiToken = apiToken; + this.unparsed |= apiToken.unparsed; this.type = type; this.unparsed |= !type.isValid(); } - public OpenAIAPIKey apiToken(String apiToken) { + public OpenAIAPIKey apiToken(OpenAIAPIKeyApiToken apiToken) { this.apiToken = apiToken; + this.unparsed |= apiToken.unparsed; return this; } @@ -52,12 +54,15 @@ public OpenAIAPIKey apiToken(String apiToken) { */ @JsonProperty(JSON_PROPERTY_API_TOKEN) @JsonInclude(value = JsonInclude.Include.ALWAYS) - public String getApiToken() { + public OpenAIAPIKeyApiToken getApiToken() { return apiToken; } - public void setApiToken(String apiToken) { + public void setApiToken(OpenAIAPIKeyApiToken apiToken) { this.apiToken = apiToken; + if (apiToken != null) { + this.unparsed |= apiToken.unparsed; + } } public OpenAIAPIKey type(OpenAIAPIKeyType type) { diff --git a/src/main/java/com/datadog/api/client/v2/model/OpenAIAPIKeyApiToken.java b/src/main/java/com/datadog/api/client/v2/model/OpenAIAPIKeyApiToken.java new file mode 100644 index 00000000000..8283423d76c --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/OpenAIAPIKeyApiToken.java @@ -0,0 +1,287 @@ +/* + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2019-Present Datadog, Inc. + */ + +package com.datadog.api.client.v2.model; + +import com.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 = OpenAIAPIKeyApiToken.OpenAIAPIKeyApiTokenDeserializer.class) +@JsonSerialize(using = OpenAIAPIKeyApiToken.OpenAIAPIKeyApiTokenSerializer.class) +public class OpenAIAPIKeyApiToken extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(OpenAIAPIKeyApiToken.class.getName()); + + @JsonIgnore public boolean unparsed = false; + + public static class OpenAIAPIKeyApiTokenSerializer extends StdSerializer { + public OpenAIAPIKeyApiTokenSerializer(Class t) { + super(t); + } + + public OpenAIAPIKeyApiTokenSerializer() { + this(null); + } + + @Override + public void serialize( + OpenAIAPIKeyApiToken value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class OpenAIAPIKeyApiTokenDeserializer + extends StdDeserializer { + public OpenAIAPIKeyApiTokenDeserializer() { + this(OpenAIAPIKeyApiToken.class); + } + + public OpenAIAPIKeyApiTokenDeserializer(Class vc) { + super(vc); + } + + @Override + public OpenAIAPIKeyApiToken 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 String + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (String.class.equals(Integer.class) + || String.class.equals(Long.class) + || String.class.equals(Float.class) + || String.class.equals(Double.class) + || String.class.equals(Boolean.class) + || String.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((String.class.equals(Integer.class) || String.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((String.class.equals(Float.class) || String.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (String.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (String.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(String.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. + deserialized = tmp; + match++; + + log.log(Level.FINER, "Input data matches schema 'String'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'String'", e); + } + + // deserialize ActionConnectionAWSSecretsManagerReference + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = + tree.traverse(jp.getCodec()) + .readValueAs(ActionConnectionAWSSecretsManagerReference.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 (!((ActionConnectionAWSSecretsManagerReference) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log( + Level.FINER, + "Input data matches schema 'ActionConnectionAWSSecretsManagerReference'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'ActionConnectionAWSSecretsManagerReference'", + e); + } + + OpenAIAPIKeyApiToken ret = new OpenAIAPIKeyApiToken(); + 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 OpenAIAPIKeyApiToken getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + throw new JsonMappingException(ctxt.getParser(), "OpenAIAPIKeyApiToken cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public OpenAIAPIKeyApiToken() { + super("oneOf", Boolean.FALSE); + } + + public OpenAIAPIKeyApiToken(String o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public OpenAIAPIKeyApiToken(ActionConnectionAWSSecretsManagerReference o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("String", new GenericType() {}); + schemas.put( + "ActionConnectionAWSSecretsManagerReference", + new GenericType() {}); + JSON.registerDescendants(OpenAIAPIKeyApiToken.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map getSchemas() { + return OpenAIAPIKeyApiToken.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: String, ActionConnectionAWSSecretsManagerReference + * + *

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(String.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + if (JSON.isInstanceOf( + ActionConnectionAWSSecretsManagerReference.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 String, ActionConnectionAWSSecretsManagerReference"); + } + + /** + * Get the actual instance, which can be the following: String, + * ActionConnectionAWSSecretsManagerReference + * + * @return The actual instance (String, ActionConnectionAWSSecretsManagerReference) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `String`. If the actual instance is not `String`, the + * ClassCastException will be thrown. + * + * @return The actual instance of `String` + * @throws ClassCastException if the instance is not `String` + */ + public String getString() throws ClassCastException { + return (String) super.getActualInstance(); + } + + /** + * Get the actual instance of `ActionConnectionAWSSecretsManagerReference`. If the actual instance + * is not `ActionConnectionAWSSecretsManagerReference`, the ClassCastException will be thrown. + * + * @return The actual instance of `ActionConnectionAWSSecretsManagerReference` + * @throws ClassCastException if the instance is not `ActionConnectionAWSSecretsManagerReference` + */ + public ActionConnectionAWSSecretsManagerReference getActionConnectionAWSSecretsManagerReference() + throws ClassCastException { + return (ActionConnectionAWSSecretsManagerReference) super.getActualInstance(); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/OpenAIAPIKeyUpdate.java b/src/main/java/com/datadog/api/client/v2/model/OpenAIAPIKeyUpdate.java index 23bc4cd0ea5..58604888985 100644 --- a/src/main/java/com/datadog/api/client/v2/model/OpenAIAPIKeyUpdate.java +++ b/src/main/java/com/datadog/api/client/v2/model/OpenAIAPIKeyUpdate.java @@ -27,7 +27,7 @@ public class OpenAIAPIKeyUpdate { @JsonIgnore public boolean unparsed = false; public static final String JSON_PROPERTY_API_TOKEN = "api_token"; - private String apiToken; + private OpenAIAPIKeyUpdateApiToken apiToken; public static final String JSON_PROPERTY_TYPE = "type"; private OpenAIAPIKeyType type; @@ -41,8 +41,9 @@ public OpenAIAPIKeyUpdate( this.unparsed |= !type.isValid(); } - public OpenAIAPIKeyUpdate apiToken(String apiToken) { + public OpenAIAPIKeyUpdate apiToken(OpenAIAPIKeyUpdateApiToken apiToken) { this.apiToken = apiToken; + this.unparsed |= apiToken.unparsed; return this; } @@ -54,12 +55,15 @@ public OpenAIAPIKeyUpdate apiToken(String apiToken) { @jakarta.annotation.Nullable @JsonProperty(JSON_PROPERTY_API_TOKEN) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public String getApiToken() { + public OpenAIAPIKeyUpdateApiToken getApiToken() { return apiToken; } - public void setApiToken(String apiToken) { + public void setApiToken(OpenAIAPIKeyUpdateApiToken apiToken) { this.apiToken = apiToken; + if (apiToken != null) { + this.unparsed |= apiToken.unparsed; + } } public OpenAIAPIKeyUpdate type(OpenAIAPIKeyType type) { diff --git a/src/main/java/com/datadog/api/client/v2/model/OpenAIAPIKeyUpdateApiToken.java b/src/main/java/com/datadog/api/client/v2/model/OpenAIAPIKeyUpdateApiToken.java new file mode 100644 index 00000000000..99136bef7e7 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/OpenAIAPIKeyUpdateApiToken.java @@ -0,0 +1,289 @@ +/* + * 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 = OpenAIAPIKeyUpdateApiToken.OpenAIAPIKeyUpdateApiTokenDeserializer.class) +@JsonSerialize(using = OpenAIAPIKeyUpdateApiToken.OpenAIAPIKeyUpdateApiTokenSerializer.class) +public class OpenAIAPIKeyUpdateApiToken extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(OpenAIAPIKeyUpdateApiToken.class.getName()); + + @JsonIgnore public boolean unparsed = false; + + public static class OpenAIAPIKeyUpdateApiTokenSerializer + extends StdSerializer { + public OpenAIAPIKeyUpdateApiTokenSerializer(Class t) { + super(t); + } + + public OpenAIAPIKeyUpdateApiTokenSerializer() { + this(null); + } + + @Override + public void serialize( + OpenAIAPIKeyUpdateApiToken value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class OpenAIAPIKeyUpdateApiTokenDeserializer + extends StdDeserializer { + public OpenAIAPIKeyUpdateApiTokenDeserializer() { + this(OpenAIAPIKeyUpdateApiToken.class); + } + + public OpenAIAPIKeyUpdateApiTokenDeserializer(Class vc) { + super(vc); + } + + @Override + public OpenAIAPIKeyUpdateApiToken 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 String + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (String.class.equals(Integer.class) + || String.class.equals(Long.class) + || String.class.equals(Float.class) + || String.class.equals(Double.class) + || String.class.equals(Boolean.class) + || String.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((String.class.equals(Integer.class) || String.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((String.class.equals(Float.class) || String.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (String.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (String.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(String.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. + deserialized = tmp; + match++; + + log.log(Level.FINER, "Input data matches schema 'String'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'String'", e); + } + + // deserialize ActionConnectionAWSSecretsManagerReference + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = + tree.traverse(jp.getCodec()) + .readValueAs(ActionConnectionAWSSecretsManagerReference.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 (!((ActionConnectionAWSSecretsManagerReference) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log( + Level.FINER, + "Input data matches schema 'ActionConnectionAWSSecretsManagerReference'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'ActionConnectionAWSSecretsManagerReference'", + e); + } + + OpenAIAPIKeyUpdateApiToken ret = new OpenAIAPIKeyUpdateApiToken(); + 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 OpenAIAPIKeyUpdateApiToken getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + throw new JsonMappingException(ctxt.getParser(), "OpenAIAPIKeyUpdateApiToken cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public OpenAIAPIKeyUpdateApiToken() { + super("oneOf", Boolean.FALSE); + } + + public OpenAIAPIKeyUpdateApiToken(String o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public OpenAIAPIKeyUpdateApiToken(ActionConnectionAWSSecretsManagerReference o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("String", new GenericType() {}); + schemas.put( + "ActionConnectionAWSSecretsManagerReference", + new GenericType() {}); + JSON.registerDescendants( + OpenAIAPIKeyUpdateApiToken.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map getSchemas() { + return OpenAIAPIKeyUpdateApiToken.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: String, ActionConnectionAWSSecretsManagerReference + * + *

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(String.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + if (JSON.isInstanceOf( + ActionConnectionAWSSecretsManagerReference.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 String, ActionConnectionAWSSecretsManagerReference"); + } + + /** + * Get the actual instance, which can be the following: String, + * ActionConnectionAWSSecretsManagerReference + * + * @return The actual instance (String, ActionConnectionAWSSecretsManagerReference) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `String`. If the actual instance is not `String`, the + * ClassCastException will be thrown. + * + * @return The actual instance of `String` + * @throws ClassCastException if the instance is not `String` + */ + public String getString() throws ClassCastException { + return (String) super.getActualInstance(); + } + + /** + * Get the actual instance of `ActionConnectionAWSSecretsManagerReference`. If the actual instance + * is not `ActionConnectionAWSSecretsManagerReference`, the ClassCastException will be thrown. + * + * @return The actual instance of `ActionConnectionAWSSecretsManagerReference` + * @throws ClassCastException if the instance is not `ActionConnectionAWSSecretsManagerReference` + */ + public ActionConnectionAWSSecretsManagerReference getActionConnectionAWSSecretsManagerReference() + throws ClassCastException { + return (ActionConnectionAWSSecretsManagerReference) super.getActualInstance(); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/ServiceNowBasicAuth.java b/src/main/java/com/datadog/api/client/v2/model/ServiceNowBasicAuth.java index 7017c0e73ab..5d701f5de45 100644 --- a/src/main/java/com/datadog/api/client/v2/model/ServiceNowBasicAuth.java +++ b/src/main/java/com/datadog/api/client/v2/model/ServiceNowBasicAuth.java @@ -29,34 +29,41 @@ public class ServiceNowBasicAuth { @JsonIgnore public boolean unparsed = false; public static final String JSON_PROPERTY_INSTANCE = "instance"; - private String instance; + private ServiceNowBasicAuthInstance instance; public static final String JSON_PROPERTY_PASSWORD = "password"; - private String password; + private ServiceNowBasicAuthPassword password; public static final String JSON_PROPERTY_TYPE = "type"; private ServiceNowBasicAuthType type; public static final String JSON_PROPERTY_USERNAME = "username"; - private String username; + private ServiceNowBasicAuthUsername username; public ServiceNowBasicAuth() {} @JsonCreator public ServiceNowBasicAuth( - @JsonProperty(required = true, value = JSON_PROPERTY_INSTANCE) String instance, - @JsonProperty(required = true, value = JSON_PROPERTY_PASSWORD) String password, + @JsonProperty(required = true, value = JSON_PROPERTY_INSTANCE) + ServiceNowBasicAuthInstance instance, + @JsonProperty(required = true, value = JSON_PROPERTY_PASSWORD) + ServiceNowBasicAuthPassword password, @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) ServiceNowBasicAuthType type, - @JsonProperty(required = true, value = JSON_PROPERTY_USERNAME) String username) { + @JsonProperty(required = true, value = JSON_PROPERTY_USERNAME) + ServiceNowBasicAuthUsername username) { this.instance = instance; + this.unparsed |= instance.unparsed; this.password = password; + this.unparsed |= password.unparsed; this.type = type; this.unparsed |= !type.isValid(); this.username = username; + this.unparsed |= username.unparsed; } - public ServiceNowBasicAuth instance(String instance) { + public ServiceNowBasicAuth instance(ServiceNowBasicAuthInstance instance) { this.instance = instance; + this.unparsed |= instance.unparsed; return this; } @@ -67,16 +74,20 @@ public ServiceNowBasicAuth instance(String instance) { */ @JsonProperty(JSON_PROPERTY_INSTANCE) @JsonInclude(value = JsonInclude.Include.ALWAYS) - public String getInstance() { + public ServiceNowBasicAuthInstance getInstance() { return instance; } - public void setInstance(String instance) { + public void setInstance(ServiceNowBasicAuthInstance instance) { this.instance = instance; + if (instance != null) { + this.unparsed |= instance.unparsed; + } } - public ServiceNowBasicAuth password(String password) { + public ServiceNowBasicAuth password(ServiceNowBasicAuthPassword password) { this.password = password; + this.unparsed |= password.unparsed; return this; } @@ -87,12 +98,15 @@ public ServiceNowBasicAuth password(String password) { */ @JsonProperty(JSON_PROPERTY_PASSWORD) @JsonInclude(value = JsonInclude.Include.ALWAYS) - public String getPassword() { + public ServiceNowBasicAuthPassword getPassword() { return password; } - public void setPassword(String password) { + public void setPassword(ServiceNowBasicAuthPassword password) { this.password = password; + if (password != null) { + this.unparsed |= password.unparsed; + } } public ServiceNowBasicAuth type(ServiceNowBasicAuthType type) { @@ -119,8 +133,9 @@ public void setType(ServiceNowBasicAuthType type) { this.type = type; } - public ServiceNowBasicAuth username(String username) { + public ServiceNowBasicAuth username(ServiceNowBasicAuthUsername username) { this.username = username; + this.unparsed |= username.unparsed; return this; } @@ -131,12 +146,15 @@ public ServiceNowBasicAuth username(String username) { */ @JsonProperty(JSON_PROPERTY_USERNAME) @JsonInclude(value = JsonInclude.Include.ALWAYS) - public String getUsername() { + public ServiceNowBasicAuthUsername getUsername() { return username; } - public void setUsername(String username) { + public void setUsername(ServiceNowBasicAuthUsername username) { this.username = username; + if (username != null) { + this.unparsed |= username.unparsed; + } } /** diff --git a/src/main/java/com/datadog/api/client/v2/model/ServiceNowBasicAuthInstance.java b/src/main/java/com/datadog/api/client/v2/model/ServiceNowBasicAuthInstance.java new file mode 100644 index 00000000000..f8b859851eb --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ServiceNowBasicAuthInstance.java @@ -0,0 +1,290 @@ +/* + * 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 = ServiceNowBasicAuthInstance.ServiceNowBasicAuthInstanceDeserializer.class) +@JsonSerialize(using = ServiceNowBasicAuthInstance.ServiceNowBasicAuthInstanceSerializer.class) +public class ServiceNowBasicAuthInstance extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(ServiceNowBasicAuthInstance.class.getName()); + + @JsonIgnore public boolean unparsed = false; + + public static class ServiceNowBasicAuthInstanceSerializer + extends StdSerializer { + public ServiceNowBasicAuthInstanceSerializer(Class t) { + super(t); + } + + public ServiceNowBasicAuthInstanceSerializer() { + this(null); + } + + @Override + public void serialize( + ServiceNowBasicAuthInstance value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class ServiceNowBasicAuthInstanceDeserializer + extends StdDeserializer { + public ServiceNowBasicAuthInstanceDeserializer() { + this(ServiceNowBasicAuthInstance.class); + } + + public ServiceNowBasicAuthInstanceDeserializer(Class vc) { + super(vc); + } + + @Override + public ServiceNowBasicAuthInstance 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 String + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (String.class.equals(Integer.class) + || String.class.equals(Long.class) + || String.class.equals(Float.class) + || String.class.equals(Double.class) + || String.class.equals(Boolean.class) + || String.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((String.class.equals(Integer.class) || String.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((String.class.equals(Float.class) || String.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (String.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (String.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(String.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. + deserialized = tmp; + match++; + + log.log(Level.FINER, "Input data matches schema 'String'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'String'", e); + } + + // deserialize ActionConnectionAWSSecretsManagerReference + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = + tree.traverse(jp.getCodec()) + .readValueAs(ActionConnectionAWSSecretsManagerReference.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 (!((ActionConnectionAWSSecretsManagerReference) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log( + Level.FINER, + "Input data matches schema 'ActionConnectionAWSSecretsManagerReference'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'ActionConnectionAWSSecretsManagerReference'", + e); + } + + ServiceNowBasicAuthInstance ret = new ServiceNowBasicAuthInstance(); + 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 ServiceNowBasicAuthInstance getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + throw new JsonMappingException( + ctxt.getParser(), "ServiceNowBasicAuthInstance cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public ServiceNowBasicAuthInstance() { + super("oneOf", Boolean.FALSE); + } + + public ServiceNowBasicAuthInstance(String o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public ServiceNowBasicAuthInstance(ActionConnectionAWSSecretsManagerReference o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("String", new GenericType() {}); + schemas.put( + "ActionConnectionAWSSecretsManagerReference", + new GenericType() {}); + JSON.registerDescendants( + ServiceNowBasicAuthInstance.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map getSchemas() { + return ServiceNowBasicAuthInstance.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: String, ActionConnectionAWSSecretsManagerReference + * + *

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(String.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + if (JSON.isInstanceOf( + ActionConnectionAWSSecretsManagerReference.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 String, ActionConnectionAWSSecretsManagerReference"); + } + + /** + * Get the actual instance, which can be the following: String, + * ActionConnectionAWSSecretsManagerReference + * + * @return The actual instance (String, ActionConnectionAWSSecretsManagerReference) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `String`. If the actual instance is not `String`, the + * ClassCastException will be thrown. + * + * @return The actual instance of `String` + * @throws ClassCastException if the instance is not `String` + */ + public String getString() throws ClassCastException { + return (String) super.getActualInstance(); + } + + /** + * Get the actual instance of `ActionConnectionAWSSecretsManagerReference`. If the actual instance + * is not `ActionConnectionAWSSecretsManagerReference`, the ClassCastException will be thrown. + * + * @return The actual instance of `ActionConnectionAWSSecretsManagerReference` + * @throws ClassCastException if the instance is not `ActionConnectionAWSSecretsManagerReference` + */ + public ActionConnectionAWSSecretsManagerReference getActionConnectionAWSSecretsManagerReference() + throws ClassCastException { + return (ActionConnectionAWSSecretsManagerReference) super.getActualInstance(); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/ServiceNowBasicAuthPassword.java b/src/main/java/com/datadog/api/client/v2/model/ServiceNowBasicAuthPassword.java new file mode 100644 index 00000000000..306c0e8be31 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ServiceNowBasicAuthPassword.java @@ -0,0 +1,290 @@ +/* + * 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 = ServiceNowBasicAuthPassword.ServiceNowBasicAuthPasswordDeserializer.class) +@JsonSerialize(using = ServiceNowBasicAuthPassword.ServiceNowBasicAuthPasswordSerializer.class) +public class ServiceNowBasicAuthPassword extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(ServiceNowBasicAuthPassword.class.getName()); + + @JsonIgnore public boolean unparsed = false; + + public static class ServiceNowBasicAuthPasswordSerializer + extends StdSerializer { + public ServiceNowBasicAuthPasswordSerializer(Class t) { + super(t); + } + + public ServiceNowBasicAuthPasswordSerializer() { + this(null); + } + + @Override + public void serialize( + ServiceNowBasicAuthPassword value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class ServiceNowBasicAuthPasswordDeserializer + extends StdDeserializer { + public ServiceNowBasicAuthPasswordDeserializer() { + this(ServiceNowBasicAuthPassword.class); + } + + public ServiceNowBasicAuthPasswordDeserializer(Class vc) { + super(vc); + } + + @Override + public ServiceNowBasicAuthPassword 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 String + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (String.class.equals(Integer.class) + || String.class.equals(Long.class) + || String.class.equals(Float.class) + || String.class.equals(Double.class) + || String.class.equals(Boolean.class) + || String.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((String.class.equals(Integer.class) || String.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((String.class.equals(Float.class) || String.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (String.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (String.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(String.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. + deserialized = tmp; + match++; + + log.log(Level.FINER, "Input data matches schema 'String'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'String'", e); + } + + // deserialize ActionConnectionAWSSecretsManagerReference + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = + tree.traverse(jp.getCodec()) + .readValueAs(ActionConnectionAWSSecretsManagerReference.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 (!((ActionConnectionAWSSecretsManagerReference) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log( + Level.FINER, + "Input data matches schema 'ActionConnectionAWSSecretsManagerReference'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'ActionConnectionAWSSecretsManagerReference'", + e); + } + + ServiceNowBasicAuthPassword ret = new ServiceNowBasicAuthPassword(); + 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 ServiceNowBasicAuthPassword getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + throw new JsonMappingException( + ctxt.getParser(), "ServiceNowBasicAuthPassword cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public ServiceNowBasicAuthPassword() { + super("oneOf", Boolean.FALSE); + } + + public ServiceNowBasicAuthPassword(String o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public ServiceNowBasicAuthPassword(ActionConnectionAWSSecretsManagerReference o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("String", new GenericType() {}); + schemas.put( + "ActionConnectionAWSSecretsManagerReference", + new GenericType() {}); + JSON.registerDescendants( + ServiceNowBasicAuthPassword.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map getSchemas() { + return ServiceNowBasicAuthPassword.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: String, ActionConnectionAWSSecretsManagerReference + * + *

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(String.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + if (JSON.isInstanceOf( + ActionConnectionAWSSecretsManagerReference.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 String, ActionConnectionAWSSecretsManagerReference"); + } + + /** + * Get the actual instance, which can be the following: String, + * ActionConnectionAWSSecretsManagerReference + * + * @return The actual instance (String, ActionConnectionAWSSecretsManagerReference) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `String`. If the actual instance is not `String`, the + * ClassCastException will be thrown. + * + * @return The actual instance of `String` + * @throws ClassCastException if the instance is not `String` + */ + public String getString() throws ClassCastException { + return (String) super.getActualInstance(); + } + + /** + * Get the actual instance of `ActionConnectionAWSSecretsManagerReference`. If the actual instance + * is not `ActionConnectionAWSSecretsManagerReference`, the ClassCastException will be thrown. + * + * @return The actual instance of `ActionConnectionAWSSecretsManagerReference` + * @throws ClassCastException if the instance is not `ActionConnectionAWSSecretsManagerReference` + */ + public ActionConnectionAWSSecretsManagerReference getActionConnectionAWSSecretsManagerReference() + throws ClassCastException { + return (ActionConnectionAWSSecretsManagerReference) super.getActualInstance(); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/ServiceNowBasicAuthUpdate.java b/src/main/java/com/datadog/api/client/v2/model/ServiceNowBasicAuthUpdate.java index 851549e0987..d7d08393226 100644 --- a/src/main/java/com/datadog/api/client/v2/model/ServiceNowBasicAuthUpdate.java +++ b/src/main/java/com/datadog/api/client/v2/model/ServiceNowBasicAuthUpdate.java @@ -29,16 +29,16 @@ public class ServiceNowBasicAuthUpdate { @JsonIgnore public boolean unparsed = false; public static final String JSON_PROPERTY_INSTANCE = "instance"; - private String instance; + private ServiceNowBasicAuthUpdateInstance instance; public static final String JSON_PROPERTY_PASSWORD = "password"; - private String password; + private ServiceNowBasicAuthUpdatePassword password; public static final String JSON_PROPERTY_TYPE = "type"; private ServiceNowBasicAuthType type; public static final String JSON_PROPERTY_USERNAME = "username"; - private String username; + private ServiceNowBasicAuthUpdateUsername username; public ServiceNowBasicAuthUpdate() {} @@ -49,8 +49,9 @@ public ServiceNowBasicAuthUpdate( this.unparsed |= !type.isValid(); } - public ServiceNowBasicAuthUpdate instance(String instance) { + public ServiceNowBasicAuthUpdate instance(ServiceNowBasicAuthUpdateInstance instance) { this.instance = instance; + this.unparsed |= instance.unparsed; return this; } @@ -62,16 +63,20 @@ public ServiceNowBasicAuthUpdate instance(String instance) { @jakarta.annotation.Nullable @JsonProperty(JSON_PROPERTY_INSTANCE) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public String getInstance() { + public ServiceNowBasicAuthUpdateInstance getInstance() { return instance; } - public void setInstance(String instance) { + public void setInstance(ServiceNowBasicAuthUpdateInstance instance) { this.instance = instance; + if (instance != null) { + this.unparsed |= instance.unparsed; + } } - public ServiceNowBasicAuthUpdate password(String password) { + public ServiceNowBasicAuthUpdate password(ServiceNowBasicAuthUpdatePassword password) { this.password = password; + this.unparsed |= password.unparsed; return this; } @@ -83,12 +88,15 @@ public ServiceNowBasicAuthUpdate password(String password) { @jakarta.annotation.Nullable @JsonProperty(JSON_PROPERTY_PASSWORD) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public String getPassword() { + public ServiceNowBasicAuthUpdatePassword getPassword() { return password; } - public void setPassword(String password) { + public void setPassword(ServiceNowBasicAuthUpdatePassword password) { this.password = password; + if (password != null) { + this.unparsed |= password.unparsed; + } } public ServiceNowBasicAuthUpdate type(ServiceNowBasicAuthType type) { @@ -115,8 +123,9 @@ public void setType(ServiceNowBasicAuthType type) { this.type = type; } - public ServiceNowBasicAuthUpdate username(String username) { + public ServiceNowBasicAuthUpdate username(ServiceNowBasicAuthUpdateUsername username) { this.username = username; + this.unparsed |= username.unparsed; return this; } @@ -128,12 +137,15 @@ public ServiceNowBasicAuthUpdate username(String username) { @jakarta.annotation.Nullable @JsonProperty(JSON_PROPERTY_USERNAME) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public String getUsername() { + public ServiceNowBasicAuthUpdateUsername getUsername() { return username; } - public void setUsername(String username) { + public void setUsername(ServiceNowBasicAuthUpdateUsername username) { this.username = username; + if (username != null) { + this.unparsed |= username.unparsed; + } } /** diff --git a/src/main/java/com/datadog/api/client/v2/model/ServiceNowBasicAuthUpdateInstance.java b/src/main/java/com/datadog/api/client/v2/model/ServiceNowBasicAuthUpdateInstance.java new file mode 100644 index 00000000000..145e6c1f753 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ServiceNowBasicAuthUpdateInstance.java @@ -0,0 +1,293 @@ +/* + * 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 = ServiceNowBasicAuthUpdateInstance.ServiceNowBasicAuthUpdateInstanceDeserializer.class) +@JsonSerialize( + using = ServiceNowBasicAuthUpdateInstance.ServiceNowBasicAuthUpdateInstanceSerializer.class) +public class ServiceNowBasicAuthUpdateInstance extends AbstractOpenApiSchema { + private static final Logger log = + Logger.getLogger(ServiceNowBasicAuthUpdateInstance.class.getName()); + + @JsonIgnore public boolean unparsed = false; + + public static class ServiceNowBasicAuthUpdateInstanceSerializer + extends StdSerializer { + public ServiceNowBasicAuthUpdateInstanceSerializer(Class t) { + super(t); + } + + public ServiceNowBasicAuthUpdateInstanceSerializer() { + this(null); + } + + @Override + public void serialize( + ServiceNowBasicAuthUpdateInstance value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class ServiceNowBasicAuthUpdateInstanceDeserializer + extends StdDeserializer { + public ServiceNowBasicAuthUpdateInstanceDeserializer() { + this(ServiceNowBasicAuthUpdateInstance.class); + } + + public ServiceNowBasicAuthUpdateInstanceDeserializer(Class vc) { + super(vc); + } + + @Override + public ServiceNowBasicAuthUpdateInstance 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 String + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (String.class.equals(Integer.class) + || String.class.equals(Long.class) + || String.class.equals(Float.class) + || String.class.equals(Double.class) + || String.class.equals(Boolean.class) + || String.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((String.class.equals(Integer.class) || String.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((String.class.equals(Float.class) || String.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (String.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (String.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(String.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. + deserialized = tmp; + match++; + + log.log(Level.FINER, "Input data matches schema 'String'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'String'", e); + } + + // deserialize ActionConnectionAWSSecretsManagerReference + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = + tree.traverse(jp.getCodec()) + .readValueAs(ActionConnectionAWSSecretsManagerReference.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 (!((ActionConnectionAWSSecretsManagerReference) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log( + Level.FINER, + "Input data matches schema 'ActionConnectionAWSSecretsManagerReference'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'ActionConnectionAWSSecretsManagerReference'", + e); + } + + ServiceNowBasicAuthUpdateInstance ret = new ServiceNowBasicAuthUpdateInstance(); + 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 ServiceNowBasicAuthUpdateInstance getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + throw new JsonMappingException( + ctxt.getParser(), "ServiceNowBasicAuthUpdateInstance cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public ServiceNowBasicAuthUpdateInstance() { + super("oneOf", Boolean.FALSE); + } + + public ServiceNowBasicAuthUpdateInstance(String o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public ServiceNowBasicAuthUpdateInstance(ActionConnectionAWSSecretsManagerReference o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("String", new GenericType() {}); + schemas.put( + "ActionConnectionAWSSecretsManagerReference", + new GenericType() {}); + JSON.registerDescendants( + ServiceNowBasicAuthUpdateInstance.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map getSchemas() { + return ServiceNowBasicAuthUpdateInstance.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: String, ActionConnectionAWSSecretsManagerReference + * + *

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(String.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + if (JSON.isInstanceOf( + ActionConnectionAWSSecretsManagerReference.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 String, ActionConnectionAWSSecretsManagerReference"); + } + + /** + * Get the actual instance, which can be the following: String, + * ActionConnectionAWSSecretsManagerReference + * + * @return The actual instance (String, ActionConnectionAWSSecretsManagerReference) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `String`. If the actual instance is not `String`, the + * ClassCastException will be thrown. + * + * @return The actual instance of `String` + * @throws ClassCastException if the instance is not `String` + */ + public String getString() throws ClassCastException { + return (String) super.getActualInstance(); + } + + /** + * Get the actual instance of `ActionConnectionAWSSecretsManagerReference`. If the actual instance + * is not `ActionConnectionAWSSecretsManagerReference`, the ClassCastException will be thrown. + * + * @return The actual instance of `ActionConnectionAWSSecretsManagerReference` + * @throws ClassCastException if the instance is not `ActionConnectionAWSSecretsManagerReference` + */ + public ActionConnectionAWSSecretsManagerReference getActionConnectionAWSSecretsManagerReference() + throws ClassCastException { + return (ActionConnectionAWSSecretsManagerReference) super.getActualInstance(); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/ServiceNowBasicAuthUpdatePassword.java b/src/main/java/com/datadog/api/client/v2/model/ServiceNowBasicAuthUpdatePassword.java new file mode 100644 index 00000000000..0cbbe0a2abc --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ServiceNowBasicAuthUpdatePassword.java @@ -0,0 +1,293 @@ +/* + * 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 = ServiceNowBasicAuthUpdatePassword.ServiceNowBasicAuthUpdatePasswordDeserializer.class) +@JsonSerialize( + using = ServiceNowBasicAuthUpdatePassword.ServiceNowBasicAuthUpdatePasswordSerializer.class) +public class ServiceNowBasicAuthUpdatePassword extends AbstractOpenApiSchema { + private static final Logger log = + Logger.getLogger(ServiceNowBasicAuthUpdatePassword.class.getName()); + + @JsonIgnore public boolean unparsed = false; + + public static class ServiceNowBasicAuthUpdatePasswordSerializer + extends StdSerializer { + public ServiceNowBasicAuthUpdatePasswordSerializer(Class t) { + super(t); + } + + public ServiceNowBasicAuthUpdatePasswordSerializer() { + this(null); + } + + @Override + public void serialize( + ServiceNowBasicAuthUpdatePassword value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class ServiceNowBasicAuthUpdatePasswordDeserializer + extends StdDeserializer { + public ServiceNowBasicAuthUpdatePasswordDeserializer() { + this(ServiceNowBasicAuthUpdatePassword.class); + } + + public ServiceNowBasicAuthUpdatePasswordDeserializer(Class vc) { + super(vc); + } + + @Override + public ServiceNowBasicAuthUpdatePassword 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 String + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (String.class.equals(Integer.class) + || String.class.equals(Long.class) + || String.class.equals(Float.class) + || String.class.equals(Double.class) + || String.class.equals(Boolean.class) + || String.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((String.class.equals(Integer.class) || String.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((String.class.equals(Float.class) || String.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (String.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (String.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(String.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. + deserialized = tmp; + match++; + + log.log(Level.FINER, "Input data matches schema 'String'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'String'", e); + } + + // deserialize ActionConnectionAWSSecretsManagerReference + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = + tree.traverse(jp.getCodec()) + .readValueAs(ActionConnectionAWSSecretsManagerReference.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 (!((ActionConnectionAWSSecretsManagerReference) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log( + Level.FINER, + "Input data matches schema 'ActionConnectionAWSSecretsManagerReference'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'ActionConnectionAWSSecretsManagerReference'", + e); + } + + ServiceNowBasicAuthUpdatePassword ret = new ServiceNowBasicAuthUpdatePassword(); + 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 ServiceNowBasicAuthUpdatePassword getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + throw new JsonMappingException( + ctxt.getParser(), "ServiceNowBasicAuthUpdatePassword cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public ServiceNowBasicAuthUpdatePassword() { + super("oneOf", Boolean.FALSE); + } + + public ServiceNowBasicAuthUpdatePassword(String o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public ServiceNowBasicAuthUpdatePassword(ActionConnectionAWSSecretsManagerReference o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("String", new GenericType() {}); + schemas.put( + "ActionConnectionAWSSecretsManagerReference", + new GenericType() {}); + JSON.registerDescendants( + ServiceNowBasicAuthUpdatePassword.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map getSchemas() { + return ServiceNowBasicAuthUpdatePassword.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: String, ActionConnectionAWSSecretsManagerReference + * + *

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(String.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + if (JSON.isInstanceOf( + ActionConnectionAWSSecretsManagerReference.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 String, ActionConnectionAWSSecretsManagerReference"); + } + + /** + * Get the actual instance, which can be the following: String, + * ActionConnectionAWSSecretsManagerReference + * + * @return The actual instance (String, ActionConnectionAWSSecretsManagerReference) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `String`. If the actual instance is not `String`, the + * ClassCastException will be thrown. + * + * @return The actual instance of `String` + * @throws ClassCastException if the instance is not `String` + */ + public String getString() throws ClassCastException { + return (String) super.getActualInstance(); + } + + /** + * Get the actual instance of `ActionConnectionAWSSecretsManagerReference`. If the actual instance + * is not `ActionConnectionAWSSecretsManagerReference`, the ClassCastException will be thrown. + * + * @return The actual instance of `ActionConnectionAWSSecretsManagerReference` + * @throws ClassCastException if the instance is not `ActionConnectionAWSSecretsManagerReference` + */ + public ActionConnectionAWSSecretsManagerReference getActionConnectionAWSSecretsManagerReference() + throws ClassCastException { + return (ActionConnectionAWSSecretsManagerReference) super.getActualInstance(); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/ServiceNowBasicAuthUpdateUsername.java b/src/main/java/com/datadog/api/client/v2/model/ServiceNowBasicAuthUpdateUsername.java new file mode 100644 index 00000000000..777cef8fa78 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ServiceNowBasicAuthUpdateUsername.java @@ -0,0 +1,293 @@ +/* + * 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 = ServiceNowBasicAuthUpdateUsername.ServiceNowBasicAuthUpdateUsernameDeserializer.class) +@JsonSerialize( + using = ServiceNowBasicAuthUpdateUsername.ServiceNowBasicAuthUpdateUsernameSerializer.class) +public class ServiceNowBasicAuthUpdateUsername extends AbstractOpenApiSchema { + private static final Logger log = + Logger.getLogger(ServiceNowBasicAuthUpdateUsername.class.getName()); + + @JsonIgnore public boolean unparsed = false; + + public static class ServiceNowBasicAuthUpdateUsernameSerializer + extends StdSerializer { + public ServiceNowBasicAuthUpdateUsernameSerializer(Class t) { + super(t); + } + + public ServiceNowBasicAuthUpdateUsernameSerializer() { + this(null); + } + + @Override + public void serialize( + ServiceNowBasicAuthUpdateUsername value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class ServiceNowBasicAuthUpdateUsernameDeserializer + extends StdDeserializer { + public ServiceNowBasicAuthUpdateUsernameDeserializer() { + this(ServiceNowBasicAuthUpdateUsername.class); + } + + public ServiceNowBasicAuthUpdateUsernameDeserializer(Class vc) { + super(vc); + } + + @Override + public ServiceNowBasicAuthUpdateUsername 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 String + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (String.class.equals(Integer.class) + || String.class.equals(Long.class) + || String.class.equals(Float.class) + || String.class.equals(Double.class) + || String.class.equals(Boolean.class) + || String.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((String.class.equals(Integer.class) || String.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((String.class.equals(Float.class) || String.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (String.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (String.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(String.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. + deserialized = tmp; + match++; + + log.log(Level.FINER, "Input data matches schema 'String'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'String'", e); + } + + // deserialize ActionConnectionAWSSecretsManagerReference + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = + tree.traverse(jp.getCodec()) + .readValueAs(ActionConnectionAWSSecretsManagerReference.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 (!((ActionConnectionAWSSecretsManagerReference) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log( + Level.FINER, + "Input data matches schema 'ActionConnectionAWSSecretsManagerReference'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'ActionConnectionAWSSecretsManagerReference'", + e); + } + + ServiceNowBasicAuthUpdateUsername ret = new ServiceNowBasicAuthUpdateUsername(); + 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 ServiceNowBasicAuthUpdateUsername getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + throw new JsonMappingException( + ctxt.getParser(), "ServiceNowBasicAuthUpdateUsername cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public ServiceNowBasicAuthUpdateUsername() { + super("oneOf", Boolean.FALSE); + } + + public ServiceNowBasicAuthUpdateUsername(String o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public ServiceNowBasicAuthUpdateUsername(ActionConnectionAWSSecretsManagerReference o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("String", new GenericType() {}); + schemas.put( + "ActionConnectionAWSSecretsManagerReference", + new GenericType() {}); + JSON.registerDescendants( + ServiceNowBasicAuthUpdateUsername.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map getSchemas() { + return ServiceNowBasicAuthUpdateUsername.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: String, ActionConnectionAWSSecretsManagerReference + * + *

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(String.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + if (JSON.isInstanceOf( + ActionConnectionAWSSecretsManagerReference.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 String, ActionConnectionAWSSecretsManagerReference"); + } + + /** + * Get the actual instance, which can be the following: String, + * ActionConnectionAWSSecretsManagerReference + * + * @return The actual instance (String, ActionConnectionAWSSecretsManagerReference) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `String`. If the actual instance is not `String`, the + * ClassCastException will be thrown. + * + * @return The actual instance of `String` + * @throws ClassCastException if the instance is not `String` + */ + public String getString() throws ClassCastException { + return (String) super.getActualInstance(); + } + + /** + * Get the actual instance of `ActionConnectionAWSSecretsManagerReference`. If the actual instance + * is not `ActionConnectionAWSSecretsManagerReference`, the ClassCastException will be thrown. + * + * @return The actual instance of `ActionConnectionAWSSecretsManagerReference` + * @throws ClassCastException if the instance is not `ActionConnectionAWSSecretsManagerReference` + */ + public ActionConnectionAWSSecretsManagerReference getActionConnectionAWSSecretsManagerReference() + throws ClassCastException { + return (ActionConnectionAWSSecretsManagerReference) super.getActualInstance(); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/ServiceNowBasicAuthUsername.java b/src/main/java/com/datadog/api/client/v2/model/ServiceNowBasicAuthUsername.java new file mode 100644 index 00000000000..bb70d5943f1 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/ServiceNowBasicAuthUsername.java @@ -0,0 +1,290 @@ +/* + * 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 = ServiceNowBasicAuthUsername.ServiceNowBasicAuthUsernameDeserializer.class) +@JsonSerialize(using = ServiceNowBasicAuthUsername.ServiceNowBasicAuthUsernameSerializer.class) +public class ServiceNowBasicAuthUsername extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(ServiceNowBasicAuthUsername.class.getName()); + + @JsonIgnore public boolean unparsed = false; + + public static class ServiceNowBasicAuthUsernameSerializer + extends StdSerializer { + public ServiceNowBasicAuthUsernameSerializer(Class t) { + super(t); + } + + public ServiceNowBasicAuthUsernameSerializer() { + this(null); + } + + @Override + public void serialize( + ServiceNowBasicAuthUsername value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class ServiceNowBasicAuthUsernameDeserializer + extends StdDeserializer { + public ServiceNowBasicAuthUsernameDeserializer() { + this(ServiceNowBasicAuthUsername.class); + } + + public ServiceNowBasicAuthUsernameDeserializer(Class vc) { + super(vc); + } + + @Override + public ServiceNowBasicAuthUsername 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 String + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (String.class.equals(Integer.class) + || String.class.equals(Long.class) + || String.class.equals(Float.class) + || String.class.equals(Double.class) + || String.class.equals(Boolean.class) + || String.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((String.class.equals(Integer.class) || String.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((String.class.equals(Float.class) || String.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (String.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (String.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(String.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. + deserialized = tmp; + match++; + + log.log(Level.FINER, "Input data matches schema 'String'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'String'", e); + } + + // deserialize ActionConnectionAWSSecretsManagerReference + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = + tree.traverse(jp.getCodec()) + .readValueAs(ActionConnectionAWSSecretsManagerReference.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 (!((ActionConnectionAWSSecretsManagerReference) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log( + Level.FINER, + "Input data matches schema 'ActionConnectionAWSSecretsManagerReference'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'ActionConnectionAWSSecretsManagerReference'", + e); + } + + ServiceNowBasicAuthUsername ret = new ServiceNowBasicAuthUsername(); + 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 ServiceNowBasicAuthUsername getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + throw new JsonMappingException( + ctxt.getParser(), "ServiceNowBasicAuthUsername cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public ServiceNowBasicAuthUsername() { + super("oneOf", Boolean.FALSE); + } + + public ServiceNowBasicAuthUsername(String o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public ServiceNowBasicAuthUsername(ActionConnectionAWSSecretsManagerReference o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("String", new GenericType() {}); + schemas.put( + "ActionConnectionAWSSecretsManagerReference", + new GenericType() {}); + JSON.registerDescendants( + ServiceNowBasicAuthUsername.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map getSchemas() { + return ServiceNowBasicAuthUsername.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: String, ActionConnectionAWSSecretsManagerReference + * + *

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(String.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + if (JSON.isInstanceOf( + ActionConnectionAWSSecretsManagerReference.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 String, ActionConnectionAWSSecretsManagerReference"); + } + + /** + * Get the actual instance, which can be the following: String, + * ActionConnectionAWSSecretsManagerReference + * + * @return The actual instance (String, ActionConnectionAWSSecretsManagerReference) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `String`. If the actual instance is not `String`, the + * ClassCastException will be thrown. + * + * @return The actual instance of `String` + * @throws ClassCastException if the instance is not `String` + */ + public String getString() throws ClassCastException { + return (String) super.getActualInstance(); + } + + /** + * Get the actual instance of `ActionConnectionAWSSecretsManagerReference`. If the actual instance + * is not `ActionConnectionAWSSecretsManagerReference`, the ClassCastException will be thrown. + * + * @return The actual instance of `ActionConnectionAWSSecretsManagerReference` + * @throws ClassCastException if the instance is not `ActionConnectionAWSSecretsManagerReference` + */ + public ActionConnectionAWSSecretsManagerReference getActionConnectionAWSSecretsManagerReference() + throws ClassCastException { + return (ActionConnectionAWSSecretsManagerReference) super.getActualInstance(); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/SplitAPIKey.java b/src/main/java/com/datadog/api/client/v2/model/SplitAPIKey.java index c2b33f1c98f..45c602cf6b2 100644 --- a/src/main/java/com/datadog/api/client/v2/model/SplitAPIKey.java +++ b/src/main/java/com/datadog/api/client/v2/model/SplitAPIKey.java @@ -24,7 +24,7 @@ public class SplitAPIKey { @JsonIgnore public boolean unparsed = false; public static final String JSON_PROPERTY_API_KEY = "api_key"; - private String apiKey; + private SplitAPIKeyApiKey apiKey; public static final String JSON_PROPERTY_TYPE = "type"; private SplitAPIKeyType type; @@ -33,15 +33,17 @@ public SplitAPIKey() {} @JsonCreator public SplitAPIKey( - @JsonProperty(required = true, value = JSON_PROPERTY_API_KEY) String apiKey, + @JsonProperty(required = true, value = JSON_PROPERTY_API_KEY) SplitAPIKeyApiKey apiKey, @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) SplitAPIKeyType type) { this.apiKey = apiKey; + this.unparsed |= apiKey.unparsed; this.type = type; this.unparsed |= !type.isValid(); } - public SplitAPIKey apiKey(String apiKey) { + public SplitAPIKey apiKey(SplitAPIKeyApiKey apiKey) { this.apiKey = apiKey; + this.unparsed |= apiKey.unparsed; return this; } @@ -52,12 +54,15 @@ public SplitAPIKey apiKey(String apiKey) { */ @JsonProperty(JSON_PROPERTY_API_KEY) @JsonInclude(value = JsonInclude.Include.ALWAYS) - public String getApiKey() { + public SplitAPIKeyApiKey getApiKey() { return apiKey; } - public void setApiKey(String apiKey) { + public void setApiKey(SplitAPIKeyApiKey apiKey) { this.apiKey = apiKey; + if (apiKey != null) { + this.unparsed |= apiKey.unparsed; + } } public SplitAPIKey type(SplitAPIKeyType type) { diff --git a/src/main/java/com/datadog/api/client/v2/model/SplitAPIKeyApiKey.java b/src/main/java/com/datadog/api/client/v2/model/SplitAPIKeyApiKey.java new file mode 100644 index 00000000000..9e6affe86c5 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/SplitAPIKeyApiKey.java @@ -0,0 +1,284 @@ +/* + * 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 = SplitAPIKeyApiKey.SplitAPIKeyApiKeyDeserializer.class) +@JsonSerialize(using = SplitAPIKeyApiKey.SplitAPIKeyApiKeySerializer.class) +public class SplitAPIKeyApiKey extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(SplitAPIKeyApiKey.class.getName()); + + @JsonIgnore public boolean unparsed = false; + + public static class SplitAPIKeyApiKeySerializer extends StdSerializer { + public SplitAPIKeyApiKeySerializer(Class t) { + super(t); + } + + public SplitAPIKeyApiKeySerializer() { + this(null); + } + + @Override + public void serialize(SplitAPIKeyApiKey value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class SplitAPIKeyApiKeyDeserializer extends StdDeserializer { + public SplitAPIKeyApiKeyDeserializer() { + this(SplitAPIKeyApiKey.class); + } + + public SplitAPIKeyApiKeyDeserializer(Class vc) { + super(vc); + } + + @Override + public SplitAPIKeyApiKey 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 String + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (String.class.equals(Integer.class) + || String.class.equals(Long.class) + || String.class.equals(Float.class) + || String.class.equals(Double.class) + || String.class.equals(Boolean.class) + || String.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((String.class.equals(Integer.class) || String.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((String.class.equals(Float.class) || String.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (String.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (String.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(String.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. + deserialized = tmp; + match++; + + log.log(Level.FINER, "Input data matches schema 'String'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'String'", e); + } + + // deserialize ActionConnectionAWSSecretsManagerReference + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = + tree.traverse(jp.getCodec()) + .readValueAs(ActionConnectionAWSSecretsManagerReference.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 (!((ActionConnectionAWSSecretsManagerReference) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log( + Level.FINER, + "Input data matches schema 'ActionConnectionAWSSecretsManagerReference'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'ActionConnectionAWSSecretsManagerReference'", + e); + } + + SplitAPIKeyApiKey ret = new SplitAPIKeyApiKey(); + 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 SplitAPIKeyApiKey getNullValue(DeserializationContext ctxt) throws JsonMappingException { + throw new JsonMappingException(ctxt.getParser(), "SplitAPIKeyApiKey cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public SplitAPIKeyApiKey() { + super("oneOf", Boolean.FALSE); + } + + public SplitAPIKeyApiKey(String o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public SplitAPIKeyApiKey(ActionConnectionAWSSecretsManagerReference o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("String", new GenericType() {}); + schemas.put( + "ActionConnectionAWSSecretsManagerReference", + new GenericType() {}); + JSON.registerDescendants(SplitAPIKeyApiKey.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map getSchemas() { + return SplitAPIKeyApiKey.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: String, ActionConnectionAWSSecretsManagerReference + * + *

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(String.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + if (JSON.isInstanceOf( + ActionConnectionAWSSecretsManagerReference.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 String, ActionConnectionAWSSecretsManagerReference"); + } + + /** + * Get the actual instance, which can be the following: String, + * ActionConnectionAWSSecretsManagerReference + * + * @return The actual instance (String, ActionConnectionAWSSecretsManagerReference) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `String`. If the actual instance is not `String`, the + * ClassCastException will be thrown. + * + * @return The actual instance of `String` + * @throws ClassCastException if the instance is not `String` + */ + public String getString() throws ClassCastException { + return (String) super.getActualInstance(); + } + + /** + * Get the actual instance of `ActionConnectionAWSSecretsManagerReference`. If the actual instance + * is not `ActionConnectionAWSSecretsManagerReference`, the ClassCastException will be thrown. + * + * @return The actual instance of `ActionConnectionAWSSecretsManagerReference` + * @throws ClassCastException if the instance is not `ActionConnectionAWSSecretsManagerReference` + */ + public ActionConnectionAWSSecretsManagerReference getActionConnectionAWSSecretsManagerReference() + throws ClassCastException { + return (ActionConnectionAWSSecretsManagerReference) super.getActualInstance(); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/SplitAPIKeyUpdate.java b/src/main/java/com/datadog/api/client/v2/model/SplitAPIKeyUpdate.java index aa23ca8729d..32d987cd8aa 100644 --- a/src/main/java/com/datadog/api/client/v2/model/SplitAPIKeyUpdate.java +++ b/src/main/java/com/datadog/api/client/v2/model/SplitAPIKeyUpdate.java @@ -24,7 +24,7 @@ public class SplitAPIKeyUpdate { @JsonIgnore public boolean unparsed = false; public static final String JSON_PROPERTY_API_KEY = "api_key"; - private String apiKey; + private SplitAPIKeyUpdateApiKey apiKey; public static final String JSON_PROPERTY_TYPE = "type"; private SplitAPIKeyType type; @@ -38,8 +38,9 @@ public SplitAPIKeyUpdate( this.unparsed |= !type.isValid(); } - public SplitAPIKeyUpdate apiKey(String apiKey) { + public SplitAPIKeyUpdate apiKey(SplitAPIKeyUpdateApiKey apiKey) { this.apiKey = apiKey; + this.unparsed |= apiKey.unparsed; return this; } @@ -51,12 +52,15 @@ public SplitAPIKeyUpdate apiKey(String apiKey) { @jakarta.annotation.Nullable @JsonProperty(JSON_PROPERTY_API_KEY) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public String getApiKey() { + public SplitAPIKeyUpdateApiKey getApiKey() { return apiKey; } - public void setApiKey(String apiKey) { + public void setApiKey(SplitAPIKeyUpdateApiKey apiKey) { this.apiKey = apiKey; + if (apiKey != null) { + this.unparsed |= apiKey.unparsed; + } } public SplitAPIKeyUpdate type(SplitAPIKeyType type) { diff --git a/src/main/java/com/datadog/api/client/v2/model/SplitAPIKeyUpdateApiKey.java b/src/main/java/com/datadog/api/client/v2/model/SplitAPIKeyUpdateApiKey.java new file mode 100644 index 00000000000..1100d0a711e --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/SplitAPIKeyUpdateApiKey.java @@ -0,0 +1,288 @@ +/* + * 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 = SplitAPIKeyUpdateApiKey.SplitAPIKeyUpdateApiKeyDeserializer.class) +@JsonSerialize(using = SplitAPIKeyUpdateApiKey.SplitAPIKeyUpdateApiKeySerializer.class) +public class SplitAPIKeyUpdateApiKey extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(SplitAPIKeyUpdateApiKey.class.getName()); + + @JsonIgnore public boolean unparsed = false; + + public static class SplitAPIKeyUpdateApiKeySerializer + extends StdSerializer { + public SplitAPIKeyUpdateApiKeySerializer(Class t) { + super(t); + } + + public SplitAPIKeyUpdateApiKeySerializer() { + this(null); + } + + @Override + public void serialize( + SplitAPIKeyUpdateApiKey value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class SplitAPIKeyUpdateApiKeyDeserializer + extends StdDeserializer { + public SplitAPIKeyUpdateApiKeyDeserializer() { + this(SplitAPIKeyUpdateApiKey.class); + } + + public SplitAPIKeyUpdateApiKeyDeserializer(Class vc) { + super(vc); + } + + @Override + public SplitAPIKeyUpdateApiKey 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 String + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (String.class.equals(Integer.class) + || String.class.equals(Long.class) + || String.class.equals(Float.class) + || String.class.equals(Double.class) + || String.class.equals(Boolean.class) + || String.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((String.class.equals(Integer.class) || String.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((String.class.equals(Float.class) || String.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (String.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (String.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(String.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. + deserialized = tmp; + match++; + + log.log(Level.FINER, "Input data matches schema 'String'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'String'", e); + } + + // deserialize ActionConnectionAWSSecretsManagerReference + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = + tree.traverse(jp.getCodec()) + .readValueAs(ActionConnectionAWSSecretsManagerReference.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 (!((ActionConnectionAWSSecretsManagerReference) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log( + Level.FINER, + "Input data matches schema 'ActionConnectionAWSSecretsManagerReference'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'ActionConnectionAWSSecretsManagerReference'", + e); + } + + SplitAPIKeyUpdateApiKey ret = new SplitAPIKeyUpdateApiKey(); + 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 SplitAPIKeyUpdateApiKey getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + throw new JsonMappingException(ctxt.getParser(), "SplitAPIKeyUpdateApiKey cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public SplitAPIKeyUpdateApiKey() { + super("oneOf", Boolean.FALSE); + } + + public SplitAPIKeyUpdateApiKey(String o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public SplitAPIKeyUpdateApiKey(ActionConnectionAWSSecretsManagerReference o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("String", new GenericType() {}); + schemas.put( + "ActionConnectionAWSSecretsManagerReference", + new GenericType() {}); + JSON.registerDescendants(SplitAPIKeyUpdateApiKey.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map getSchemas() { + return SplitAPIKeyUpdateApiKey.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: String, ActionConnectionAWSSecretsManagerReference + * + *

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(String.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + if (JSON.isInstanceOf( + ActionConnectionAWSSecretsManagerReference.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 String, ActionConnectionAWSSecretsManagerReference"); + } + + /** + * Get the actual instance, which can be the following: String, + * ActionConnectionAWSSecretsManagerReference + * + * @return The actual instance (String, ActionConnectionAWSSecretsManagerReference) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `String`. If the actual instance is not `String`, the + * ClassCastException will be thrown. + * + * @return The actual instance of `String` + * @throws ClassCastException if the instance is not `String` + */ + public String getString() throws ClassCastException { + return (String) super.getActualInstance(); + } + + /** + * Get the actual instance of `ActionConnectionAWSSecretsManagerReference`. If the actual instance + * is not `ActionConnectionAWSSecretsManagerReference`, the ClassCastException will be thrown. + * + * @return The actual instance of `ActionConnectionAWSSecretsManagerReference` + * @throws ClassCastException if the instance is not `ActionConnectionAWSSecretsManagerReference` + */ + public ActionConnectionAWSSecretsManagerReference getActionConnectionAWSSecretsManagerReference() + throws ClassCastException { + return (ActionConnectionAWSSecretsManagerReference) super.getActualInstance(); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/StatsigAPIKey.java b/src/main/java/com/datadog/api/client/v2/model/StatsigAPIKey.java index 531212a4b59..9609901dfd1 100644 --- a/src/main/java/com/datadog/api/client/v2/model/StatsigAPIKey.java +++ b/src/main/java/com/datadog/api/client/v2/model/StatsigAPIKey.java @@ -24,7 +24,7 @@ public class StatsigAPIKey { @JsonIgnore public boolean unparsed = false; public static final String JSON_PROPERTY_API_KEY = "api_key"; - private String apiKey; + private StatsigAPIKeyApiKey apiKey; public static final String JSON_PROPERTY_TYPE = "type"; private StatsigAPIKeyType type; @@ -33,15 +33,17 @@ public StatsigAPIKey() {} @JsonCreator public StatsigAPIKey( - @JsonProperty(required = true, value = JSON_PROPERTY_API_KEY) String apiKey, + @JsonProperty(required = true, value = JSON_PROPERTY_API_KEY) StatsigAPIKeyApiKey apiKey, @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) StatsigAPIKeyType type) { this.apiKey = apiKey; + this.unparsed |= apiKey.unparsed; this.type = type; this.unparsed |= !type.isValid(); } - public StatsigAPIKey apiKey(String apiKey) { + public StatsigAPIKey apiKey(StatsigAPIKeyApiKey apiKey) { this.apiKey = apiKey; + this.unparsed |= apiKey.unparsed; return this; } @@ -52,12 +54,15 @@ public StatsigAPIKey apiKey(String apiKey) { */ @JsonProperty(JSON_PROPERTY_API_KEY) @JsonInclude(value = JsonInclude.Include.ALWAYS) - public String getApiKey() { + public StatsigAPIKeyApiKey getApiKey() { return apiKey; } - public void setApiKey(String apiKey) { + public void setApiKey(StatsigAPIKeyApiKey apiKey) { this.apiKey = apiKey; + if (apiKey != null) { + this.unparsed |= apiKey.unparsed; + } } public StatsigAPIKey type(StatsigAPIKeyType type) { diff --git a/src/main/java/com/datadog/api/client/v2/model/StatsigAPIKeyApiKey.java b/src/main/java/com/datadog/api/client/v2/model/StatsigAPIKeyApiKey.java new file mode 100644 index 00000000000..c194461d8de --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/StatsigAPIKeyApiKey.java @@ -0,0 +1,286 @@ +/* + * 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 = StatsigAPIKeyApiKey.StatsigAPIKeyApiKeyDeserializer.class) +@JsonSerialize(using = StatsigAPIKeyApiKey.StatsigAPIKeyApiKeySerializer.class) +public class StatsigAPIKeyApiKey extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(StatsigAPIKeyApiKey.class.getName()); + + @JsonIgnore public boolean unparsed = false; + + public static class StatsigAPIKeyApiKeySerializer extends StdSerializer { + public StatsigAPIKeyApiKeySerializer(Class t) { + super(t); + } + + public StatsigAPIKeyApiKeySerializer() { + this(null); + } + + @Override + public void serialize( + StatsigAPIKeyApiKey value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class StatsigAPIKeyApiKeyDeserializer extends StdDeserializer { + public StatsigAPIKeyApiKeyDeserializer() { + this(StatsigAPIKeyApiKey.class); + } + + public StatsigAPIKeyApiKeyDeserializer(Class vc) { + super(vc); + } + + @Override + public StatsigAPIKeyApiKey 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 String + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (String.class.equals(Integer.class) + || String.class.equals(Long.class) + || String.class.equals(Float.class) + || String.class.equals(Double.class) + || String.class.equals(Boolean.class) + || String.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((String.class.equals(Integer.class) || String.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((String.class.equals(Float.class) || String.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (String.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (String.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(String.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. + deserialized = tmp; + match++; + + log.log(Level.FINER, "Input data matches schema 'String'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'String'", e); + } + + // deserialize ActionConnectionAWSSecretsManagerReference + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = + tree.traverse(jp.getCodec()) + .readValueAs(ActionConnectionAWSSecretsManagerReference.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 (!((ActionConnectionAWSSecretsManagerReference) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log( + Level.FINER, + "Input data matches schema 'ActionConnectionAWSSecretsManagerReference'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'ActionConnectionAWSSecretsManagerReference'", + e); + } + + StatsigAPIKeyApiKey ret = new StatsigAPIKeyApiKey(); + 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 StatsigAPIKeyApiKey getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + throw new JsonMappingException(ctxt.getParser(), "StatsigAPIKeyApiKey cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public StatsigAPIKeyApiKey() { + super("oneOf", Boolean.FALSE); + } + + public StatsigAPIKeyApiKey(String o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public StatsigAPIKeyApiKey(ActionConnectionAWSSecretsManagerReference o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("String", new GenericType() {}); + schemas.put( + "ActionConnectionAWSSecretsManagerReference", + new GenericType() {}); + JSON.registerDescendants(StatsigAPIKeyApiKey.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map getSchemas() { + return StatsigAPIKeyApiKey.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: String, ActionConnectionAWSSecretsManagerReference + * + *

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(String.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + if (JSON.isInstanceOf( + ActionConnectionAWSSecretsManagerReference.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 String, ActionConnectionAWSSecretsManagerReference"); + } + + /** + * Get the actual instance, which can be the following: String, + * ActionConnectionAWSSecretsManagerReference + * + * @return The actual instance (String, ActionConnectionAWSSecretsManagerReference) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `String`. If the actual instance is not `String`, the + * ClassCastException will be thrown. + * + * @return The actual instance of `String` + * @throws ClassCastException if the instance is not `String` + */ + public String getString() throws ClassCastException { + return (String) super.getActualInstance(); + } + + /** + * Get the actual instance of `ActionConnectionAWSSecretsManagerReference`. If the actual instance + * is not `ActionConnectionAWSSecretsManagerReference`, the ClassCastException will be thrown. + * + * @return The actual instance of `ActionConnectionAWSSecretsManagerReference` + * @throws ClassCastException if the instance is not `ActionConnectionAWSSecretsManagerReference` + */ + public ActionConnectionAWSSecretsManagerReference getActionConnectionAWSSecretsManagerReference() + throws ClassCastException { + return (ActionConnectionAWSSecretsManagerReference) super.getActualInstance(); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/StatsigAPIKeyUpdate.java b/src/main/java/com/datadog/api/client/v2/model/StatsigAPIKeyUpdate.java index 912260c3ee3..54377a1fbeb 100644 --- a/src/main/java/com/datadog/api/client/v2/model/StatsigAPIKeyUpdate.java +++ b/src/main/java/com/datadog/api/client/v2/model/StatsigAPIKeyUpdate.java @@ -27,7 +27,7 @@ public class StatsigAPIKeyUpdate { @JsonIgnore public boolean unparsed = false; public static final String JSON_PROPERTY_API_KEY = "api_key"; - private String apiKey; + private StatsigAPIKeyUpdateApiKey apiKey; public static final String JSON_PROPERTY_TYPE = "type"; private StatsigAPIKeyType type; @@ -41,8 +41,9 @@ public StatsigAPIKeyUpdate( this.unparsed |= !type.isValid(); } - public StatsigAPIKeyUpdate apiKey(String apiKey) { + public StatsigAPIKeyUpdate apiKey(StatsigAPIKeyUpdateApiKey apiKey) { this.apiKey = apiKey; + this.unparsed |= apiKey.unparsed; return this; } @@ -54,12 +55,15 @@ public StatsigAPIKeyUpdate apiKey(String apiKey) { @jakarta.annotation.Nullable @JsonProperty(JSON_PROPERTY_API_KEY) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public String getApiKey() { + public StatsigAPIKeyUpdateApiKey getApiKey() { return apiKey; } - public void setApiKey(String apiKey) { + public void setApiKey(StatsigAPIKeyUpdateApiKey apiKey) { this.apiKey = apiKey; + if (apiKey != null) { + this.unparsed |= apiKey.unparsed; + } } public StatsigAPIKeyUpdate type(StatsigAPIKeyType type) { diff --git a/src/main/java/com/datadog/api/client/v2/model/StatsigAPIKeyUpdateApiKey.java b/src/main/java/com/datadog/api/client/v2/model/StatsigAPIKeyUpdateApiKey.java new file mode 100644 index 00000000000..8af9bc6f7b7 --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/StatsigAPIKeyUpdateApiKey.java @@ -0,0 +1,288 @@ +/* + * 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 = StatsigAPIKeyUpdateApiKey.StatsigAPIKeyUpdateApiKeyDeserializer.class) +@JsonSerialize(using = StatsigAPIKeyUpdateApiKey.StatsigAPIKeyUpdateApiKeySerializer.class) +public class StatsigAPIKeyUpdateApiKey extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(StatsigAPIKeyUpdateApiKey.class.getName()); + + @JsonIgnore public boolean unparsed = false; + + public static class StatsigAPIKeyUpdateApiKeySerializer + extends StdSerializer { + public StatsigAPIKeyUpdateApiKeySerializer(Class t) { + super(t); + } + + public StatsigAPIKeyUpdateApiKeySerializer() { + this(null); + } + + @Override + public void serialize( + StatsigAPIKeyUpdateApiKey value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class StatsigAPIKeyUpdateApiKeyDeserializer + extends StdDeserializer { + public StatsigAPIKeyUpdateApiKeyDeserializer() { + this(StatsigAPIKeyUpdateApiKey.class); + } + + public StatsigAPIKeyUpdateApiKeyDeserializer(Class vc) { + super(vc); + } + + @Override + public StatsigAPIKeyUpdateApiKey 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 String + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (String.class.equals(Integer.class) + || String.class.equals(Long.class) + || String.class.equals(Float.class) + || String.class.equals(Double.class) + || String.class.equals(Boolean.class) + || String.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((String.class.equals(Integer.class) || String.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((String.class.equals(Float.class) || String.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (String.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (String.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(String.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. + deserialized = tmp; + match++; + + log.log(Level.FINER, "Input data matches schema 'String'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'String'", e); + } + + // deserialize ActionConnectionAWSSecretsManagerReference + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = + tree.traverse(jp.getCodec()) + .readValueAs(ActionConnectionAWSSecretsManagerReference.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 (!((ActionConnectionAWSSecretsManagerReference) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log( + Level.FINER, + "Input data matches schema 'ActionConnectionAWSSecretsManagerReference'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'ActionConnectionAWSSecretsManagerReference'", + e); + } + + StatsigAPIKeyUpdateApiKey ret = new StatsigAPIKeyUpdateApiKey(); + 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 StatsigAPIKeyUpdateApiKey getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + throw new JsonMappingException(ctxt.getParser(), "StatsigAPIKeyUpdateApiKey cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public StatsigAPIKeyUpdateApiKey() { + super("oneOf", Boolean.FALSE); + } + + public StatsigAPIKeyUpdateApiKey(String o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public StatsigAPIKeyUpdateApiKey(ActionConnectionAWSSecretsManagerReference o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("String", new GenericType() {}); + schemas.put( + "ActionConnectionAWSSecretsManagerReference", + new GenericType() {}); + JSON.registerDescendants(StatsigAPIKeyUpdateApiKey.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map getSchemas() { + return StatsigAPIKeyUpdateApiKey.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: String, ActionConnectionAWSSecretsManagerReference + * + *

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(String.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + if (JSON.isInstanceOf( + ActionConnectionAWSSecretsManagerReference.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 String, ActionConnectionAWSSecretsManagerReference"); + } + + /** + * Get the actual instance, which can be the following: String, + * ActionConnectionAWSSecretsManagerReference + * + * @return The actual instance (String, ActionConnectionAWSSecretsManagerReference) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `String`. If the actual instance is not `String`, the + * ClassCastException will be thrown. + * + * @return The actual instance of `String` + * @throws ClassCastException if the instance is not `String` + */ + public String getString() throws ClassCastException { + return (String) super.getActualInstance(); + } + + /** + * Get the actual instance of `ActionConnectionAWSSecretsManagerReference`. If the actual instance + * is not `ActionConnectionAWSSecretsManagerReference`, the ClassCastException will be thrown. + * + * @return The actual instance of `ActionConnectionAWSSecretsManagerReference` + * @throws ClassCastException if the instance is not `ActionConnectionAWSSecretsManagerReference` + */ + public ActionConnectionAWSSecretsManagerReference getActionConnectionAWSSecretsManagerReference() + throws ClassCastException { + return (ActionConnectionAWSSecretsManagerReference) super.getActualInstance(); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/VirusTotalAPIKey.java b/src/main/java/com/datadog/api/client/v2/model/VirusTotalAPIKey.java index 51c10f43c7e..a762b8ee63d 100644 --- a/src/main/java/com/datadog/api/client/v2/model/VirusTotalAPIKey.java +++ b/src/main/java/com/datadog/api/client/v2/model/VirusTotalAPIKey.java @@ -24,7 +24,7 @@ public class VirusTotalAPIKey { @JsonIgnore public boolean unparsed = false; public static final String JSON_PROPERTY_API_KEY = "api_key"; - private String apiKey; + private VirusTotalAPIKeyApiKey apiKey; public static final String JSON_PROPERTY_TYPE = "type"; private VirusTotalAPIKeyType type; @@ -33,15 +33,17 @@ public VirusTotalAPIKey() {} @JsonCreator public VirusTotalAPIKey( - @JsonProperty(required = true, value = JSON_PROPERTY_API_KEY) String apiKey, + @JsonProperty(required = true, value = JSON_PROPERTY_API_KEY) VirusTotalAPIKeyApiKey apiKey, @JsonProperty(required = true, value = JSON_PROPERTY_TYPE) VirusTotalAPIKeyType type) { this.apiKey = apiKey; + this.unparsed |= apiKey.unparsed; this.type = type; this.unparsed |= !type.isValid(); } - public VirusTotalAPIKey apiKey(String apiKey) { + public VirusTotalAPIKey apiKey(VirusTotalAPIKeyApiKey apiKey) { this.apiKey = apiKey; + this.unparsed |= apiKey.unparsed; return this; } @@ -52,12 +54,15 @@ public VirusTotalAPIKey apiKey(String apiKey) { */ @JsonProperty(JSON_PROPERTY_API_KEY) @JsonInclude(value = JsonInclude.Include.ALWAYS) - public String getApiKey() { + public VirusTotalAPIKeyApiKey getApiKey() { return apiKey; } - public void setApiKey(String apiKey) { + public void setApiKey(VirusTotalAPIKeyApiKey apiKey) { this.apiKey = apiKey; + if (apiKey != null) { + this.unparsed |= apiKey.unparsed; + } } public VirusTotalAPIKey type(VirusTotalAPIKeyType type) { diff --git a/src/main/java/com/datadog/api/client/v2/model/VirusTotalAPIKeyApiKey.java b/src/main/java/com/datadog/api/client/v2/model/VirusTotalAPIKeyApiKey.java new file mode 100644 index 00000000000..0daeea9d7ac --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/VirusTotalAPIKeyApiKey.java @@ -0,0 +1,288 @@ +/* + * 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 = VirusTotalAPIKeyApiKey.VirusTotalAPIKeyApiKeyDeserializer.class) +@JsonSerialize(using = VirusTotalAPIKeyApiKey.VirusTotalAPIKeyApiKeySerializer.class) +public class VirusTotalAPIKeyApiKey extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(VirusTotalAPIKeyApiKey.class.getName()); + + @JsonIgnore public boolean unparsed = false; + + public static class VirusTotalAPIKeyApiKeySerializer + extends StdSerializer { + public VirusTotalAPIKeyApiKeySerializer(Class t) { + super(t); + } + + public VirusTotalAPIKeyApiKeySerializer() { + this(null); + } + + @Override + public void serialize( + VirusTotalAPIKeyApiKey value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class VirusTotalAPIKeyApiKeyDeserializer + extends StdDeserializer { + public VirusTotalAPIKeyApiKeyDeserializer() { + this(VirusTotalAPIKeyApiKey.class); + } + + public VirusTotalAPIKeyApiKeyDeserializer(Class vc) { + super(vc); + } + + @Override + public VirusTotalAPIKeyApiKey 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 String + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (String.class.equals(Integer.class) + || String.class.equals(Long.class) + || String.class.equals(Float.class) + || String.class.equals(Double.class) + || String.class.equals(Boolean.class) + || String.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((String.class.equals(Integer.class) || String.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((String.class.equals(Float.class) || String.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (String.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (String.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(String.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. + deserialized = tmp; + match++; + + log.log(Level.FINER, "Input data matches schema 'String'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'String'", e); + } + + // deserialize ActionConnectionAWSSecretsManagerReference + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = + tree.traverse(jp.getCodec()) + .readValueAs(ActionConnectionAWSSecretsManagerReference.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 (!((ActionConnectionAWSSecretsManagerReference) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log( + Level.FINER, + "Input data matches schema 'ActionConnectionAWSSecretsManagerReference'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'ActionConnectionAWSSecretsManagerReference'", + e); + } + + VirusTotalAPIKeyApiKey ret = new VirusTotalAPIKeyApiKey(); + 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 VirusTotalAPIKeyApiKey getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + throw new JsonMappingException(ctxt.getParser(), "VirusTotalAPIKeyApiKey cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public VirusTotalAPIKeyApiKey() { + super("oneOf", Boolean.FALSE); + } + + public VirusTotalAPIKeyApiKey(String o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public VirusTotalAPIKeyApiKey(ActionConnectionAWSSecretsManagerReference o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("String", new GenericType() {}); + schemas.put( + "ActionConnectionAWSSecretsManagerReference", + new GenericType() {}); + JSON.registerDescendants(VirusTotalAPIKeyApiKey.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map getSchemas() { + return VirusTotalAPIKeyApiKey.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: String, ActionConnectionAWSSecretsManagerReference + * + *

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(String.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + if (JSON.isInstanceOf( + ActionConnectionAWSSecretsManagerReference.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 String, ActionConnectionAWSSecretsManagerReference"); + } + + /** + * Get the actual instance, which can be the following: String, + * ActionConnectionAWSSecretsManagerReference + * + * @return The actual instance (String, ActionConnectionAWSSecretsManagerReference) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `String`. If the actual instance is not `String`, the + * ClassCastException will be thrown. + * + * @return The actual instance of `String` + * @throws ClassCastException if the instance is not `String` + */ + public String getString() throws ClassCastException { + return (String) super.getActualInstance(); + } + + /** + * Get the actual instance of `ActionConnectionAWSSecretsManagerReference`. If the actual instance + * is not `ActionConnectionAWSSecretsManagerReference`, the ClassCastException will be thrown. + * + * @return The actual instance of `ActionConnectionAWSSecretsManagerReference` + * @throws ClassCastException if the instance is not `ActionConnectionAWSSecretsManagerReference` + */ + public ActionConnectionAWSSecretsManagerReference getActionConnectionAWSSecretsManagerReference() + throws ClassCastException { + return (ActionConnectionAWSSecretsManagerReference) super.getActualInstance(); + } +} diff --git a/src/main/java/com/datadog/api/client/v2/model/VirusTotalAPIKeyUpdate.java b/src/main/java/com/datadog/api/client/v2/model/VirusTotalAPIKeyUpdate.java index 9a10cd3af45..41a3d790e31 100644 --- a/src/main/java/com/datadog/api/client/v2/model/VirusTotalAPIKeyUpdate.java +++ b/src/main/java/com/datadog/api/client/v2/model/VirusTotalAPIKeyUpdate.java @@ -27,7 +27,7 @@ public class VirusTotalAPIKeyUpdate { @JsonIgnore public boolean unparsed = false; public static final String JSON_PROPERTY_API_KEY = "api_key"; - private String apiKey; + private VirusTotalAPIKeyUpdateApiKey apiKey; public static final String JSON_PROPERTY_TYPE = "type"; private VirusTotalAPIKeyType type; @@ -41,8 +41,9 @@ public VirusTotalAPIKeyUpdate( this.unparsed |= !type.isValid(); } - public VirusTotalAPIKeyUpdate apiKey(String apiKey) { + public VirusTotalAPIKeyUpdate apiKey(VirusTotalAPIKeyUpdateApiKey apiKey) { this.apiKey = apiKey; + this.unparsed |= apiKey.unparsed; return this; } @@ -54,12 +55,15 @@ public VirusTotalAPIKeyUpdate apiKey(String apiKey) { @jakarta.annotation.Nullable @JsonProperty(JSON_PROPERTY_API_KEY) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public String getApiKey() { + public VirusTotalAPIKeyUpdateApiKey getApiKey() { return apiKey; } - public void setApiKey(String apiKey) { + public void setApiKey(VirusTotalAPIKeyUpdateApiKey apiKey) { this.apiKey = apiKey; + if (apiKey != null) { + this.unparsed |= apiKey.unparsed; + } } public VirusTotalAPIKeyUpdate type(VirusTotalAPIKeyType type) { diff --git a/src/main/java/com/datadog/api/client/v2/model/VirusTotalAPIKeyUpdateApiKey.java b/src/main/java/com/datadog/api/client/v2/model/VirusTotalAPIKeyUpdateApiKey.java new file mode 100644 index 00000000000..7b21305f4ab --- /dev/null +++ b/src/main/java/com/datadog/api/client/v2/model/VirusTotalAPIKeyUpdateApiKey.java @@ -0,0 +1,291 @@ +/* + * 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 = VirusTotalAPIKeyUpdateApiKey.VirusTotalAPIKeyUpdateApiKeyDeserializer.class) +@JsonSerialize(using = VirusTotalAPIKeyUpdateApiKey.VirusTotalAPIKeyUpdateApiKeySerializer.class) +public class VirusTotalAPIKeyUpdateApiKey extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(VirusTotalAPIKeyUpdateApiKey.class.getName()); + + @JsonIgnore public boolean unparsed = false; + + public static class VirusTotalAPIKeyUpdateApiKeySerializer + extends StdSerializer { + public VirusTotalAPIKeyUpdateApiKeySerializer(Class t) { + super(t); + } + + public VirusTotalAPIKeyUpdateApiKeySerializer() { + this(null); + } + + @Override + public void serialize( + VirusTotalAPIKeyUpdateApiKey value, JsonGenerator jgen, SerializerProvider provider) + throws IOException, JsonProcessingException { + jgen.writeObject(value.getActualInstance()); + } + } + + public static class VirusTotalAPIKeyUpdateApiKeyDeserializer + extends StdDeserializer { + public VirusTotalAPIKeyUpdateApiKeyDeserializer() { + this(VirusTotalAPIKeyUpdateApiKey.class); + } + + public VirusTotalAPIKeyUpdateApiKeyDeserializer(Class vc) { + super(vc); + } + + @Override + public VirusTotalAPIKeyUpdateApiKey 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 String + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (String.class.equals(Integer.class) + || String.class.equals(Long.class) + || String.class.equals(Float.class) + || String.class.equals(Double.class) + || String.class.equals(Boolean.class) + || String.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((String.class.equals(Integer.class) || String.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((String.class.equals(Float.class) || String.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (String.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (String.class.equals(String.class) && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = tree.traverse(jp.getCodec()).readValueAs(String.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. + deserialized = tmp; + match++; + + log.log(Level.FINER, "Input data matches schema 'String'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log(Level.FINER, "Input data does not match schema 'String'", e); + } + + // deserialize ActionConnectionAWSSecretsManagerReference + try { + boolean attemptParsing = true; + // ensure that we respect type coercion as set on the client ObjectMapper + if (ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(String.class)) { + attemptParsing = typeCoercion; + if (!attemptParsing) { + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Integer.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Long.class)) + && token == JsonToken.VALUE_NUMBER_INT); + attemptParsing |= + ((ActionConnectionAWSSecretsManagerReference.class.equals(Float.class) + || ActionConnectionAWSSecretsManagerReference.class.equals(Double.class)) + && (token == JsonToken.VALUE_NUMBER_FLOAT + || token == JsonToken.VALUE_NUMBER_INT)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(Boolean.class) + && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); + attemptParsing |= + (ActionConnectionAWSSecretsManagerReference.class.equals(String.class) + && token == JsonToken.VALUE_STRING); + } + } + if (attemptParsing) { + tmp = + tree.traverse(jp.getCodec()) + .readValueAs(ActionConnectionAWSSecretsManagerReference.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 (!((ActionConnectionAWSSecretsManagerReference) tmp).unparsed) { + deserialized = tmp; + match++; + } + log.log( + Level.FINER, + "Input data matches schema 'ActionConnectionAWSSecretsManagerReference'"); + } + } catch (Exception e) { + // deserialization failed, continue + log.log( + Level.FINER, + "Input data does not match schema 'ActionConnectionAWSSecretsManagerReference'", + e); + } + + VirusTotalAPIKeyUpdateApiKey ret = new VirusTotalAPIKeyUpdateApiKey(); + 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 VirusTotalAPIKeyUpdateApiKey getNullValue(DeserializationContext ctxt) + throws JsonMappingException { + throw new JsonMappingException( + ctxt.getParser(), "VirusTotalAPIKeyUpdateApiKey cannot be null"); + } + } + + // store a list of schema names defined in oneOf + public static final Map schemas = new HashMap(); + + public VirusTotalAPIKeyUpdateApiKey() { + super("oneOf", Boolean.FALSE); + } + + public VirusTotalAPIKeyUpdateApiKey(String o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + public VirusTotalAPIKeyUpdateApiKey(ActionConnectionAWSSecretsManagerReference o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("String", new GenericType() {}); + schemas.put( + "ActionConnectionAWSSecretsManagerReference", + new GenericType() {}); + JSON.registerDescendants( + VirusTotalAPIKeyUpdateApiKey.class, Collections.unmodifiableMap(schemas)); + } + + @Override + public Map getSchemas() { + return VirusTotalAPIKeyUpdateApiKey.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: String, ActionConnectionAWSSecretsManagerReference + * + *

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(String.class, instance, new HashSet>())) { + super.setActualInstance(instance); + return; + } + if (JSON.isInstanceOf( + ActionConnectionAWSSecretsManagerReference.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 String, ActionConnectionAWSSecretsManagerReference"); + } + + /** + * Get the actual instance, which can be the following: String, + * ActionConnectionAWSSecretsManagerReference + * + * @return The actual instance (String, ActionConnectionAWSSecretsManagerReference) + */ + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `String`. If the actual instance is not `String`, the + * ClassCastException will be thrown. + * + * @return The actual instance of `String` + * @throws ClassCastException if the instance is not `String` + */ + public String getString() throws ClassCastException { + return (String) super.getActualInstance(); + } + + /** + * Get the actual instance of `ActionConnectionAWSSecretsManagerReference`. If the actual instance + * is not `ActionConnectionAWSSecretsManagerReference`, the ClassCastException will be thrown. + * + * @return The actual instance of `ActionConnectionAWSSecretsManagerReference` + * @throws ClassCastException if the instance is not `ActionConnectionAWSSecretsManagerReference` + */ + public ActionConnectionAWSSecretsManagerReference getActionConnectionAWSSecretsManagerReference() + throws ClassCastException { + return (ActionConnectionAWSSecretsManagerReference) super.getActualInstance(); + } +} diff --git a/src/test/resources/com/datadog/api/client/v2/api/action_connection.feature b/src/test/resources/com/datadog/api/client/v2/api/action_connection.feature index 4779f0cb2aa..4f36f8db7c0 100644 --- a/src/test/resources/com/datadog/api/client/v2/api/action_connection.feature +++ b/src/test/resources/com/datadog/api/client/v2/api/action_connection.feature @@ -14,28 +14,79 @@ Feature: Action Connection And a valid "appKeyAuth" key in the system And an instance of "ActionConnection" API - @team:ddoghq/workflow-automation-dev + @team:ddoghq/action-platform + Scenario: Create a GCP Action Connection with AWS Secrets Manager references + Given there is a valid "action_connection" in the system + And new "CreateActionConnection" request + And body with value {"data":{"type":"action_connection","attributes":{"name":"GCP Secrets Manager Connection {{ unique_lower_alnum }}","external_secrets_manager":{"type":"aws_secrets_manager","connection_id":"{{ action_connection.data.id }}","region":"us-east-1"},"integration":{"type":"GCP","credentials":{"type":"GCPServiceAccount","private_key":{"type":"aws_secrets_manager","secret_id":"example/gcp/service-account","key":"private_key"},"service_account_email":{"type":"aws_secrets_manager","secret_id":"example/gcp/service-account","key":"client_email"}}}}}} + When the request is sent + Then the response status is 201 Successfully created Action Connection + And the response "data.attributes.external_secrets_manager.connection_id" has the same value as "action_connection.data.id" + And the response "data.attributes.external_secrets_manager.region" is equal to "us-east-1" + And the response "data.attributes.integration.credentials.private_key.secret_id" is equal to "example/gcp/service-account" + And the response "data.attributes.integration.credentials.private_key.key" is equal to "private_key" + And the response "data.attributes.integration.credentials.service_account_email.key" is equal to "client_email" + + @team:ddoghq/action-platform Scenario: Create a new Action Connection returns "Bad Request" response Given new "CreateActionConnection" request And body with value {"data":{"type":"action_connection","attributes":{"name":"Cassette Connection","integration":{"type":"AWS","credentials":{"type":"AWSAssumeRole","role":"MyRoleUpdated","account_id":"1"}}}}} When the request is sent Then the response status is 400 Bad Request - @team:ddoghq/workflow-automation-dev + @team:ddoghq/action-platform Scenario: Create a new Action Connection returns "Successfully created Action Connection" response Given new "CreateActionConnection" request And body with value {"data":{"type":"action_connection","attributes":{"name":"Cassette Connection {{ unique_lower_alnum }}","integration":{"type":"AWS","credentials":{"type":"AWSAssumeRole","role":"MyRoleUpdated","account_id":"123456789123"}}}}} When the request is sent Then the response status is 201 Successfully created Action Connection - @team:ddoghq/workflow-automation-dev + @team:ddoghq/action-platform + Scenario: Create an Action Connection rejects AWS references without connection-level settings + Given new "CreateActionConnection" request + And body with value {"data":{"type":"action_connection","attributes":{"name":"Missing Secrets Manager Settings {{ unique_lower_alnum }}","integration":{"type":"Anthropic","credentials":{"type":"AnthropicAPIKey","api_token":{"type":"aws_secrets_manager","secret_id":"example/anthropic","key":"api_token"}}}}}} + When the request is sent + Then the response status is 400 Bad Request + + @team:ddoghq/action-platform + Scenario: Create an Action Connection rejects conflicting AWS secret version selectors + Given there is a valid "action_connection" in the system + And new "CreateActionConnection" request + And body with value {"data":{"type":"action_connection","attributes":{"name":"Conflicting Secrets Manager Versions {{ unique_lower_alnum }}","external_secrets_manager":{"type":"aws_secrets_manager","connection_id":"{{ action_connection.data.id }}","region":"us-east-1"},"integration":{"type":"Anthropic","credentials":{"type":"AnthropicAPIKey","api_token":{"type":"aws_secrets_manager","secret_id":"example/anthropic","key":"api_token","version_id":"example-version","version_stage":"AWSCURRENT"}}}}}} + When the request is sent + Then the response status is 400 Bad Request + + @team:ddoghq/action-platform + Scenario: Create an Anthropic Action Connection with an AWS Secrets Manager API token + Given there is a valid "action_connection" in the system + And new "CreateActionConnection" request + And body with value {"data":{"type":"action_connection","attributes":{"name":"Anthropic Secrets Manager Connection {{ unique_lower_alnum }}","external_secrets_manager":{"type":"aws_secrets_manager","connection_id":"{{ action_connection.data.id }}","region":"us-east-1"},"integration":{"type":"Anthropic","credentials":{"type":"AnthropicAPIKey","api_token":{"type":"aws_secrets_manager","secret_id":"example/anthropic","key":"api_token"}}}}}} + When the request is sent + Then the response status is 201 Successfully created Action Connection + And the response "data.attributes.external_secrets_manager.connection_id" has the same value as "action_connection.data.id" + And the response "data.attributes.integration.credentials.api_token.type" is equal to "aws_secrets_manager" + And the response "data.attributes.integration.credentials.api_token.key" is equal to "api_token" + + @team:ddoghq/action-platform + Scenario: Create an HTTP Action Connection with an AWS Secrets Manager token + Given there is a valid "action_connection" in the system + And new "CreateActionConnection" request + And body with value {"data":{"type":"action_connection","attributes":{"name":"HTTP Secrets Manager Connection {{ unique_lower_alnum }}","external_secrets_manager":{"type":"aws_secrets_manager","connection_id":"{{ action_connection.data.id }}","region":"us-east-1"},"integration":{"type":"HTTP","base_url":"https://example.com","credentials":{"type":"HTTPTokenAuth","tokens":[{"name":"token","type":"SECRET","value":{"type":"aws_secrets_manager","secret_id":"example/http","key":"token"}}],"headers":[{"name":"ApiKey","value":"literal-value"}],"url_parameters":[{"name":"apiKey","value":"literal-value"}],"body":{"content_type":"application/json","content":"{\"example\":\"literal\"}"}}}}}} + When the request is sent + Then the response status is 201 Successfully created Action Connection + And the response "data.attributes.external_secrets_manager.connection_id" has the same value as "action_connection.data.id" + And the response "data.attributes.integration.base_url" is equal to "https://example.com" + And the response "data.attributes.integration.credentials.http_tokens[0].value.type" is equal to "aws_secrets_manager" + And the response "data.attributes.integration.credentials.http_tokens[0].value.key" is equal to "token" + + @team:ddoghq/action-platform Scenario: Delete an existing Action Connection returns "Not Found" response Given new "DeleteActionConnection" request And request contains "connection_id" parameter with value "aaa11111-aa11-aa11-aaaa-aaaaaa111111" When the request is sent Then the response status is 404 Not Found - @team:ddoghq/workflow-automation-dev + @team:ddoghq/action-platform Scenario: Delete an existing Action Connection returns "The resource was deleted successfully." response Given there is a valid "action_connection" in the system And new "DeleteActionConnection" request @@ -43,96 +94,124 @@ Feature: Action Connection When the request is sent Then the response status is 204 The resource was deleted successfully. - @team:ddoghq/workflow-automation-dev + @team:ddoghq/action-platform + Scenario: Get a GCP Action Connection preserves AWS Secrets Manager references + Given there is a valid "action_connection" in the system + And there is a valid "gcp_action_connection" in the system + And new "GetActionConnection" request + And request contains "connection_id" parameter from "gcp_action_connection.data.id" + When the request is sent + Then the response status is 200 Successfully get Action Connection + And the response "data.attributes.external_secrets_manager.connection_id" has the same value as "action_connection.data.id" + And the response "data.attributes.integration.credentials.private_key.type" is equal to "aws_secrets_manager" + And the response "data.attributes.integration.credentials.private_key.key" is equal to "private_key" + And the response "data.attributes.integration.credentials.service_account_email.key" is equal to "client_email" + + @team:ddoghq/action-platform Scenario: Get an existing Action Connection returns "Bad Request" response Given new "GetActionConnection" request And request contains "connection_id" parameter with value "bad-format" When the request is sent Then the response status is 400 Bad Request - @team:ddoghq/workflow-automation-dev + @team:ddoghq/action-platform Scenario: Get an existing Action Connection returns "Not Found" response Given new "GetActionConnection" request And request contains "connection_id" parameter with value "aaa11111-aa11-aa11-aaaa-aaaaaa111111" When the request is sent Then the response status is 404 Not Found - @team:ddoghq/workflow-automation-dev + @team:ddoghq/action-platform Scenario: Get an existing Action Connection returns "Successfully get Action Connection" response Given new "GetActionConnection" request And request contains "connection_id" parameter with value "cb460d51-3c88-4e87-adac-d47131d0423d" When the request is sent Then the response status is 200 Successfully get Action Connection - @team:ddoghq/workflow-automation-dev + @team:ddoghq/action-platform Scenario: Get an existing App Key Registration returns "Bad request" response Given new "GetAppKeyRegistration" request And request contains "app_key_id" parameter with value "not_valid_app_key_id" When the request is sent Then the response status is 400 Bad request - @team:ddoghq/workflow-automation-dev + @team:ddoghq/action-platform Scenario: Get an existing App Key Registration returns "Not found" response Given new "GetAppKeyRegistration" request And request contains "app_key_id" parameter with value "aaa11111-aa11-aa11-aaaa-aaaaaa111111" When the request is sent Then the response status is 404 Not found - @team:ddoghq/workflow-automation-dev + @team:ddoghq/action-platform Scenario: Get an existing App Key Registration returns "OK" response Given new "GetAppKeyRegistration" request And request contains "app_key_id" parameter with value "b7feea52-994e-4714-a100-1bd9eff5aee1" When the request is sent Then the response status is 200 OK - @skip @team:ddoghq/workflow-automation-dev + @skip @team:ddoghq/action-platform Scenario: List App Key Registrations returns "Bad request" response Given new "ListAppKeyRegistrations" request When the request is sent Then the response status is 400 Bad request - @team:ddoghq/workflow-automation-dev + @team:ddoghq/action-platform Scenario: List App Key Registrations returns "OK" response Given new "ListAppKeyRegistrations" request When the request is sent Then the response status is 200 OK - @team:ddoghq/workflow-automation-dev + @team:ddoghq/action-platform Scenario: Register a new App Key returns "Bad request" response Given new "RegisterAppKey" request And request contains "app_key_id" parameter with value "not_valid_app_key_id" When the request is sent Then the response status is 400 Bad request - @team:ddoghq/workflow-automation-dev + @team:ddoghq/action-platform Scenario: Register a new App Key returns "Created" response Given new "RegisterAppKey" request And request contains "app_key_id" parameter with value "b7feea52-994e-4714-a100-1bd9eff5aee1" When the request is sent Then the response status is 201 Created - @team:ddoghq/workflow-automation-dev + @team:ddoghq/action-platform Scenario: Unregister an App Key returns "Bad request" response Given new "UnregisterAppKey" request And request contains "app_key_id" parameter with value "not_valid_app_key_id" When the request is sent Then the response status is 400 Bad request - @skip @team:ddoghq/workflow-automation-dev + @skip @team:ddoghq/action-platform Scenario: Unregister an App Key returns "No Content" response Given new "UnregisterAppKey" request And request contains "app_key_id" parameter with value "57cc69ae-9214-4ecc-8df8-43ecc1d92d99" When the request is sent Then the response status is 204 No Content - @team:ddoghq/workflow-automation-dev + @team:ddoghq/action-platform Scenario: Unregister an App Key returns "Not found" response Given new "UnregisterAppKey" request And request contains "app_key_id" parameter with value "57cc69ae-9214-4ecc-8df8-43ecc1d92d99" When the request is sent Then the response status is 404 Not found - @team:ddoghq/workflow-automation-dev + @team:ddoghq/action-platform + Scenario: Update a GCP Action Connection with a versioned AWS Secrets Manager reference + Given there is a valid "action_connection" in the system + And there is a valid "gcp_action_connection" in the system + And new "UpdateActionConnection" request + And request contains "connection_id" parameter from "gcp_action_connection.data.id" + And body with value {"data":{"type":"action_connection","attributes":{"external_secrets_manager":{"type":"aws_secrets_manager","connection_id":"{{ action_connection.data.id }}","region":"us-east-1"},"integration":{"type":"GCP","credentials":{"type":"GCPServiceAccount","private_key":{"type":"aws_secrets_manager","secret_id":"example/gcp/service-account","key":"private_key","version_stage":"AWSCURRENT"},"service_account_email":{"type":"aws_secrets_manager","secret_id":"example/gcp/service-account","key":"client_email"}}}}}} + When the request is sent + Then the response status is 200 Successfully updated Action Connection + And the response "data.attributes.external_secrets_manager.connection_id" has the same value as "action_connection.data.id" + And the response "data.id" has the same value as "gcp_action_connection.data.id" + And the response "data.attributes.integration.credentials.private_key.version_stage" is equal to "AWSCURRENT" + And the response "data.attributes.integration.credentials.private_key.key" is equal to "private_key" + And the response "data.attributes.integration.credentials.service_account_email.key" is equal to "client_email" + + @team:ddoghq/action-platform Scenario: Update an existing Action Connection returns "Bad Request" response Given new "UpdateActionConnection" request And request contains "connection_id" parameter with value "cb460d51-3c88-4e87-adac-d47131d0423d" @@ -140,7 +219,7 @@ Feature: Action Connection When the request is sent Then the response status is 400 Bad Request - @team:ddoghq/workflow-automation-dev + @team:ddoghq/action-platform Scenario: Update an existing Action Connection returns "Not Found" response Given new "UpdateActionConnection" request And request contains "connection_id" parameter with value "aaa11111-aa11-aa11-aaaa-aaaaaa111111" @@ -148,7 +227,7 @@ Feature: Action Connection When the request is sent Then the response status is 404 Not Found - @team:ddoghq/workflow-automation-dev + @team:ddoghq/action-platform Scenario: Update an existing Action Connection returns "Successfully updated Action Connection" response Given new "UpdateActionConnection" request And request contains "connection_id" parameter with value "cb460d51-3c88-4e87-adac-d47131d0423d" diff --git a/src/test/resources/com/datadog/api/client/v2/api/given.json b/src/test/resources/com/datadog/api/client/v2/api/given.json index 9e00227eddf..604850914b8 100644 --- a/src/test/resources/com/datadog/api/client/v2/api/given.json +++ b/src/test/resources/com/datadog/api/client/v2/api/given.json @@ -52,6 +52,18 @@ "tag": "Action Connection", "operationId": "CreateActionConnection" }, + { + "parameters": [ + { + "name": "body", + "value": "{\n \"data\": {\n \"type\": \"action_connection\",\n \"attributes\": {\n \"name\": \"GCP Secrets Manager Connection {{ unique_lower_alnum }}\",\n \"external_secrets_manager\": {\n \"type\": \"aws_secrets_manager\",\n \"connection_id\": \"{{ action_connection.data.id }}\",\n \"region\": \"us-east-1\"\n },\n \"integration\": {\n \"type\": \"GCP\",\n \"credentials\": {\n \"type\": \"GCPServiceAccount\",\n \"private_key\": {\n \"type\": \"aws_secrets_manager\",\n \"secret_id\": \"example/gcp/service-account\",\n \"key\": \"private_key\"\n },\n \"service_account_email\": {\n \"type\": \"aws_secrets_manager\",\n \"secret_id\": \"example/gcp/service-account\",\n \"key\": \"client_email\"\n }\n }\n }\n }\n }\n}" + } + ], + "step": "there is a valid \"gcp_action_connection\" in the system", + "key": "gcp_action_connection", + "tag": "Action Connection", + "operationId": "CreateActionConnection" + }, { "parameters": [ { diff --git a/src/test/resources/generated-test/test-runner-data/manifest.json b/src/test/resources/generated-test/test-runner-data/manifest.json index b0e88f1ece3..4edae66abc3 100644 --- a/src/test/resources/generated-test/test-runner-data/manifest.json +++ b/src/test/resources/generated-test/test-runner-data/manifest.json @@ -2268,6 +2268,13 @@ "scenario": "Update a webhook returns \"OK\" response", "version": "v1" }, + { + "feature": "Action Connection", + "feature_file": "../../com/datadog/api/client/v2/api/action_connection.feature", + "file": "v2/action-connection/create-a-gcp-action-connection-with-aws-secrets-manager-references.json", + "scenario": "Create a GCP Action Connection with AWS Secrets Manager references", + "version": "v2" + }, { "feature": "Action Connection", "feature_file": "../../com/datadog/api/client/v2/api/action_connection.feature", @@ -2282,6 +2289,34 @@ "scenario": "Create a new Action Connection returns \"Successfully created Action Connection\" response", "version": "v2" }, + { + "feature": "Action Connection", + "feature_file": "../../com/datadog/api/client/v2/api/action_connection.feature", + "file": "v2/action-connection/create-an-action-connection-rejects-aws-references-without-connection-level-settings.json", + "scenario": "Create an Action Connection rejects AWS references without connection-level settings", + "version": "v2" + }, + { + "feature": "Action Connection", + "feature_file": "../../com/datadog/api/client/v2/api/action_connection.feature", + "file": "v2/action-connection/create-an-action-connection-rejects-conflicting-aws-secret-version-selectors.json", + "scenario": "Create an Action Connection rejects conflicting AWS secret version selectors", + "version": "v2" + }, + { + "feature": "Action Connection", + "feature_file": "../../com/datadog/api/client/v2/api/action_connection.feature", + "file": "v2/action-connection/create-an-anthropic-action-connection-with-an-aws-secrets-manager-api-token.json", + "scenario": "Create an Anthropic Action Connection with an AWS Secrets Manager API token", + "version": "v2" + }, + { + "feature": "Action Connection", + "feature_file": "../../com/datadog/api/client/v2/api/action_connection.feature", + "file": "v2/action-connection/create-an-http-action-connection-with-an-aws-secrets-manager-token.json", + "scenario": "Create an HTTP Action Connection with an AWS Secrets Manager token", + "version": "v2" + }, { "feature": "Action Connection", "feature_file": "../../com/datadog/api/client/v2/api/action_connection.feature", @@ -2296,6 +2331,13 @@ "scenario": "Delete an existing Action Connection returns \"The resource was deleted successfully.\" response", "version": "v2" }, + { + "feature": "Action Connection", + "feature_file": "../../com/datadog/api/client/v2/api/action_connection.feature", + "file": "v2/action-connection/get-a-gcp-action-connection-preserves-aws-secrets-manager-references.json", + "scenario": "Get a GCP Action Connection preserves AWS Secrets Manager references", + "version": "v2" + }, { "feature": "Action Connection", "feature_file": "../../com/datadog/api/client/v2/api/action_connection.feature", @@ -2373,6 +2415,13 @@ "scenario": "Unregister an App Key returns \"Not found\" response", "version": "v2" }, + { + "feature": "Action Connection", + "feature_file": "../../com/datadog/api/client/v2/api/action_connection.feature", + "file": "v2/action-connection/update-a-gcp-action-connection-with-a-versioned-aws-secrets-manager-reference.json", + "scenario": "Update a GCP Action Connection with a versioned AWS Secrets Manager reference", + "version": "v2" + }, { "feature": "Action Connection", "feature_file": "../../com/datadog/api/client/v2/api/action_connection.feature", diff --git a/src/test/resources/generated-test/test-runner-data/v2/action-connection/create-a-gcp-action-connection-with-aws-secrets-manager-references.json b/src/test/resources/generated-test/test-runner-data/v2/action-connection/create-a-gcp-action-connection-with-aws-secrets-manager-references.json new file mode 100644 index 00000000000..32345cf3cc4 --- /dev/null +++ b/src/test/resources/generated-test/test-runner-data/v2/action-connection/create-a-gcp-action-connection-with-aws-secrets-manager-references.json @@ -0,0 +1,54 @@ +{ + "api": "ActionConnection", + "expected_status": 201, + "feature": "Action Connection", + "id": "v2/Action Connection/Create a GCP Action Connection with AWS Secrets Manager references", + "operation_id": "CreateActionConnection", + "request": { + "body": { + "schema": { + "format": null, + "ref": "CreateActionConnectionRequest", + "type": "object" + }, + "source": "inline", + "value": { + "data": { + "attributes": { + "external_secrets_manager": { + "connection_id": "{{ action_connection.data.id }}", + "region": "us-east-1", + "type": "aws_secrets_manager" + }, + "integration": { + "credentials": { + "private_key": { + "key": "private_key", + "secret_id": "example/gcp/service-account", + "type": "aws_secrets_manager" + }, + "service_account_email": { + "key": "client_email", + "secret_id": "example/gcp/service-account", + "type": "aws_secrets_manager" + }, + "type": "GCPServiceAccount" + }, + "type": "GCP" + }, + "name": "GCP Secrets Manager Connection {{ unique_lower_alnum }}" + }, + "type": "action_connection" + } + } + }, + "content_type": "application/json", + "method": "POST", + "pagination": false, + "parameters": [], + "path": "/api/v2/actions/connections" + }, + "scenario": "Create a GCP Action Connection with AWS Secrets Manager references", + "schema_version": 1, + "version": "v2" +} diff --git a/src/test/resources/generated-test/test-runner-data/v2/action-connection/create-an-action-connection-rejects-aws-references-without-connection-level-settings.json b/src/test/resources/generated-test/test-runner-data/v2/action-connection/create-an-action-connection-rejects-aws-references-without-connection-level-settings.json new file mode 100644 index 00000000000..ca9c513e4d8 --- /dev/null +++ b/src/test/resources/generated-test/test-runner-data/v2/action-connection/create-an-action-connection-rejects-aws-references-without-connection-level-settings.json @@ -0,0 +1,44 @@ +{ + "api": "ActionConnection", + "expected_status": 400, + "feature": "Action Connection", + "id": "v2/Action Connection/Create an Action Connection rejects AWS references without connection-level settings", + "operation_id": "CreateActionConnection", + "request": { + "body": { + "schema": { + "format": null, + "ref": "CreateActionConnectionRequest", + "type": "object" + }, + "source": "inline", + "value": { + "data": { + "attributes": { + "integration": { + "credentials": { + "api_token": { + "key": "api_token", + "secret_id": "example/anthropic", + "type": "aws_secrets_manager" + }, + "type": "AnthropicAPIKey" + }, + "type": "Anthropic" + }, + "name": "Missing Secrets Manager Settings {{ unique_lower_alnum }}" + }, + "type": "action_connection" + } + } + }, + "content_type": "application/json", + "method": "POST", + "pagination": false, + "parameters": [], + "path": "/api/v2/actions/connections" + }, + "scenario": "Create an Action Connection rejects AWS references without connection-level settings", + "schema_version": 1, + "version": "v2" +} diff --git a/src/test/resources/generated-test/test-runner-data/v2/action-connection/create-an-action-connection-rejects-conflicting-aws-secret-version-selectors.json b/src/test/resources/generated-test/test-runner-data/v2/action-connection/create-an-action-connection-rejects-conflicting-aws-secret-version-selectors.json new file mode 100644 index 00000000000..58a12ad8e60 --- /dev/null +++ b/src/test/resources/generated-test/test-runner-data/v2/action-connection/create-an-action-connection-rejects-conflicting-aws-secret-version-selectors.json @@ -0,0 +1,51 @@ +{ + "api": "ActionConnection", + "expected_status": 400, + "feature": "Action Connection", + "id": "v2/Action Connection/Create an Action Connection rejects conflicting AWS secret version selectors", + "operation_id": "CreateActionConnection", + "request": { + "body": { + "schema": { + "format": null, + "ref": "CreateActionConnectionRequest", + "type": "object" + }, + "source": "inline", + "value": { + "data": { + "attributes": { + "external_secrets_manager": { + "connection_id": "{{ action_connection.data.id }}", + "region": "us-east-1", + "type": "aws_secrets_manager" + }, + "integration": { + "credentials": { + "api_token": { + "key": "api_token", + "secret_id": "example/anthropic", + "type": "aws_secrets_manager", + "version_id": "example-version", + "version_stage": "AWSCURRENT" + }, + "type": "AnthropicAPIKey" + }, + "type": "Anthropic" + }, + "name": "Conflicting Secrets Manager Versions {{ unique_lower_alnum }}" + }, + "type": "action_connection" + } + } + }, + "content_type": "application/json", + "method": "POST", + "pagination": false, + "parameters": [], + "path": "/api/v2/actions/connections" + }, + "scenario": "Create an Action Connection rejects conflicting AWS secret version selectors", + "schema_version": 1, + "version": "v2" +} diff --git a/src/test/resources/generated-test/test-runner-data/v2/action-connection/create-an-anthropic-action-connection-with-an-aws-secrets-manager-api-token.json b/src/test/resources/generated-test/test-runner-data/v2/action-connection/create-an-anthropic-action-connection-with-an-aws-secrets-manager-api-token.json new file mode 100644 index 00000000000..80919fd73c7 --- /dev/null +++ b/src/test/resources/generated-test/test-runner-data/v2/action-connection/create-an-anthropic-action-connection-with-an-aws-secrets-manager-api-token.json @@ -0,0 +1,49 @@ +{ + "api": "ActionConnection", + "expected_status": 201, + "feature": "Action Connection", + "id": "v2/Action Connection/Create an Anthropic Action Connection with an AWS Secrets Manager API token", + "operation_id": "CreateActionConnection", + "request": { + "body": { + "schema": { + "format": null, + "ref": "CreateActionConnectionRequest", + "type": "object" + }, + "source": "inline", + "value": { + "data": { + "attributes": { + "external_secrets_manager": { + "connection_id": "{{ action_connection.data.id }}", + "region": "us-east-1", + "type": "aws_secrets_manager" + }, + "integration": { + "credentials": { + "api_token": { + "key": "api_token", + "secret_id": "example/anthropic", + "type": "aws_secrets_manager" + }, + "type": "AnthropicAPIKey" + }, + "type": "Anthropic" + }, + "name": "Anthropic Secrets Manager Connection {{ unique_lower_alnum }}" + }, + "type": "action_connection" + } + } + }, + "content_type": "application/json", + "method": "POST", + "pagination": false, + "parameters": [], + "path": "/api/v2/actions/connections" + }, + "scenario": "Create an Anthropic Action Connection with an AWS Secrets Manager API token", + "schema_version": 1, + "version": "v2" +} diff --git a/src/test/resources/generated-test/test-runner-data/v2/action-connection/create-an-http-action-connection-with-an-aws-secrets-manager-token.json b/src/test/resources/generated-test/test-runner-data/v2/action-connection/create-an-http-action-connection-with-an-aws-secrets-manager-token.json new file mode 100644 index 00000000000..016ea300172 --- /dev/null +++ b/src/test/resources/generated-test/test-runner-data/v2/action-connection/create-an-http-action-connection-with-an-aws-secrets-manager-token.json @@ -0,0 +1,72 @@ +{ + "api": "ActionConnection", + "expected_status": 201, + "feature": "Action Connection", + "id": "v2/Action Connection/Create an HTTP Action Connection with an AWS Secrets Manager token", + "operation_id": "CreateActionConnection", + "request": { + "body": { + "schema": { + "format": null, + "ref": "CreateActionConnectionRequest", + "type": "object" + }, + "source": "inline", + "value": { + "data": { + "attributes": { + "external_secrets_manager": { + "connection_id": "{{ action_connection.data.id }}", + "region": "us-east-1", + "type": "aws_secrets_manager" + }, + "integration": { + "base_url": "https://example.com", + "credentials": { + "body": { + "content": "{\"example\":\"literal\"}", + "content_type": "application/json" + }, + "headers": [ + { + "name": "ApiKey", + "value": "literal-value" + } + ], + "tokens": [ + { + "name": "token", + "type": "SECRET", + "value": { + "key": "token", + "secret_id": "example/http", + "type": "aws_secrets_manager" + } + } + ], + "type": "HTTPTokenAuth", + "url_parameters": [ + { + "name": "apiKey", + "value": "literal-value" + } + ] + }, + "type": "HTTP" + }, + "name": "HTTP Secrets Manager Connection {{ unique_lower_alnum }}" + }, + "type": "action_connection" + } + } + }, + "content_type": "application/json", + "method": "POST", + "pagination": false, + "parameters": [], + "path": "/api/v2/actions/connections" + }, + "scenario": "Create an HTTP Action Connection with an AWS Secrets Manager token", + "schema_version": 1, + "version": "v2" +} diff --git a/src/test/resources/generated-test/test-runner-data/v2/action-connection/get-a-gcp-action-connection-preserves-aws-secrets-manager-references.json b/src/test/resources/generated-test/test-runner-data/v2/action-connection/get-a-gcp-action-connection-preserves-aws-secrets-manager-references.json new file mode 100644 index 00000000000..500ac1ae929 --- /dev/null +++ b/src/test/resources/generated-test/test-runner-data/v2/action-connection/get-a-gcp-action-connection-preserves-aws-secrets-manager-references.json @@ -0,0 +1,35 @@ +{ + "api": "ActionConnection", + "expected_status": 200, + "feature": "Action Connection", + "id": "v2/Action Connection/Get a GCP Action Connection preserves AWS Secrets Manager references", + "operation_id": "GetActionConnection", + "request": { + "body": null, + "content_type": null, + "method": "GET", + "pagination": false, + "parameters": [ + { + "explode": null, + "in": "path", + "name": "connection_id", + "required": true, + "schema": { + "format": null, + "ref": null, + "type": "string" + }, + "source": { + "path": "gcp_action_connection.data.id", + "type": "fixture" + }, + "style": null + } + ], + "path": "/api/v2/actions/connections/{connection_id}" + }, + "scenario": "Get a GCP Action Connection preserves AWS Secrets Manager references", + "schema_version": 1, + "version": "v2" +} diff --git a/src/test/resources/generated-test/test-runner-data/v2/action-connection/update-a-gcp-action-connection-with-a-versioned-aws-secrets-manager-reference.json b/src/test/resources/generated-test/test-runner-data/v2/action-connection/update-a-gcp-action-connection-with-a-versioned-aws-secrets-manager-reference.json new file mode 100644 index 00000000000..1cdb0b06550 --- /dev/null +++ b/src/test/resources/generated-test/test-runner-data/v2/action-connection/update-a-gcp-action-connection-with-a-versioned-aws-secrets-manager-reference.json @@ -0,0 +1,71 @@ +{ + "api": "ActionConnection", + "expected_status": 200, + "feature": "Action Connection", + "id": "v2/Action Connection/Update a GCP Action Connection with a versioned AWS Secrets Manager reference", + "operation_id": "UpdateActionConnection", + "request": { + "body": { + "schema": { + "format": null, + "ref": "UpdateActionConnectionRequest", + "type": "object" + }, + "source": "inline", + "value": { + "data": { + "attributes": { + "external_secrets_manager": { + "connection_id": "{{ action_connection.data.id }}", + "region": "us-east-1", + "type": "aws_secrets_manager" + }, + "integration": { + "credentials": { + "private_key": { + "key": "private_key", + "secret_id": "example/gcp/service-account", + "type": "aws_secrets_manager", + "version_stage": "AWSCURRENT" + }, + "service_account_email": { + "key": "client_email", + "secret_id": "example/gcp/service-account", + "type": "aws_secrets_manager" + }, + "type": "GCPServiceAccount" + }, + "type": "GCP" + } + }, + "type": "action_connection" + } + } + }, + "content_type": "application/json", + "method": "PATCH", + "pagination": false, + "parameters": [ + { + "explode": null, + "in": "path", + "name": "connection_id", + "required": true, + "schema": { + "format": null, + "ref": null, + "type": "string" + }, + "source": { + "path": "gcp_action_connection.data.id", + "type": "fixture" + }, + "style": null + } + ], + "path": "/api/v2/actions/connections/{connection_id}" + }, + "scenario": "Update a GCP Action Connection with a versioned AWS Secrets Manager reference", + "schema_version": 1, + "version": "v2" +} diff --git a/src/test/resources/generated-test/test-server-data/v2/action-connection.json b/src/test/resources/generated-test/test-server-data/v2/action-connection.json index 6eeb7706ab5..8e27e4d0453 100644 --- a/src/test/resources/generated-test/test-server-data/v2/action-connection.json +++ b/src/test/resources/generated-test/test-server-data/v2/action-connection.json @@ -1,6 +1,145 @@ { "feature": "Action Connection", "recordings": [ + { + "feature": "Action Connection", + "frozen_at": "2026-11-04T17:36:16.440Z", + "interactions": [ + { + "request": { + "body": { + "type": "json", + "value": { + "data": { + "attributes": { + "integration": { + "credentials": { + "account_id": "123456789123", + "role": "MyRole", + "type": "AWSAssumeRole" + }, + "type": "AWS" + }, + "name": "Cassette Connection testcreateagcpactionconnectionwithawssecretsmanagerreferences1793813776" + }, + "type": "action_connection" + } + } + }, + "content_type": "application/json", + "method": "POST", + "path": "/api/v2/actions/connections", + "query": [] + }, + "response": { + "body": { + "encoding": "text", + "value": "{\"data\":{\"id\":\"16285b12-4344-4969-844b-399b8fd5628a\",\"type\":\"action_connection\",\"attributes\":{\"acting_user_can_resolve\":false,\"environment\":\"DATACENTER\",\"external_secrets_manager\":null,\"integration\":{\"credentials\":{\"account_id\":\"123456789123\",\"external_id\":\"f5ad51a31e6f40138b2ec1a2955b9f8c\",\"principal_id\":\"464622532012\",\"role\":\"MyRole\",\"type\":\"AWSAssumeRole\"},\"type\":\"AWS\"},\"is_favorite\":false,\"name\":\"Cassette Connection testcreateagcpactionconnectionwithawssecretsmanagerreferences1793813776\"}}}" + }, + "headers": { + "content-type": "application/vnd.api+json" + }, + "reason": "Created", + "status": 201 + } + }, + { + "request": { + "body": { + "type": "json", + "value": { + "data": { + "attributes": { + "external_secrets_manager": { + "connection_id": "16285b12-4344-4969-844b-399b8fd5628a", + "region": "us-east-1", + "type": "aws_secrets_manager" + }, + "integration": { + "credentials": { + "private_key": { + "key": "private_key", + "secret_id": "example/gcp/service-account", + "type": "aws_secrets_manager" + }, + "service_account_email": { + "key": "client_email", + "secret_id": "example/gcp/service-account", + "type": "aws_secrets_manager" + }, + "type": "GCPServiceAccount" + }, + "type": "GCP" + }, + "name": "GCP Secrets Manager Connection testcreateagcpactionconnectionwithawssecretsmanagerreferences1793813776" + }, + "type": "action_connection" + } + } + }, + "content_type": "application/json", + "method": "POST", + "path": "/api/v2/actions/connections", + "query": [] + }, + "response": { + "body": { + "encoding": "text", + "value": "{\"data\":{\"id\":\"6fb06828-94d4-477b-9c2a-125a0b20b50b\",\"type\":\"action_connection\",\"attributes\":{\"acting_user_can_resolve\":false,\"environment\":\"DATACENTER\",\"external_secrets_manager\":{\"type\":\"aws_secrets_manager\",\"connection_id\":\"16285b12-4344-4969-844b-399b8fd5628a\",\"region\":\"us-east-1\"},\"integration\":{\"credentials\":{\"private_key\":{\"type\":\"aws_secrets_manager\",\"secret_id\":\"example/gcp/service-account\",\"key\":\"private_key\"},\"service_account_email\":{\"type\":\"aws_secrets_manager\",\"secret_id\":\"example/gcp/service-account\",\"key\":\"client_email\"},\"type\":\"GCPServiceAccount\"},\"type\":\"GCP\"},\"is_favorite\":false,\"name\":\"GCP Secrets Manager Connection testcreateagcpactionconnectionwithawssecretsmanagerreferences1793813776\"}}}" + }, + "headers": { + "content-type": "application/vnd.api+json" + }, + "reason": "Created", + "status": 201 + } + }, + { + "request": { + "body": { + "type": "empty", + "value": null + }, + "content_type": "", + "method": "DELETE", + "path": "/api/v2/actions/connections/6fb06828-94d4-477b-9c2a-125a0b20b50b", + "query": [] + }, + "response": { + "body": { + "encoding": "text", + "value": "" + }, + "headers": {}, + "reason": "No Content", + "status": 204 + } + }, + { + "request": { + "body": { + "type": "empty", + "value": null + }, + "content_type": "", + "method": "DELETE", + "path": "/api/v2/actions/connections/16285b12-4344-4969-844b-399b8fd5628a", + "query": [] + }, + "response": { + "body": { + "encoding": "text", + "value": "" + }, + "headers": {}, + "reason": "No Content", + "status": 204 + } + } + ], + "scenario": "Create a GCP Action Connection with AWS Secrets Manager references", + "version": "v2" + }, { "feature": "Action Connection", "frozen_at": "2025-03-26T20:24:59.622Z", @@ -44,12 +183,565 @@ } } ], - "scenario": "Create a new Action Connection returns \"Bad Request\" response", + "scenario": "Create a new Action Connection returns \"Bad Request\" response", + "version": "v2" + }, + { + "feature": "Action Connection", + "frozen_at": "2025-03-26T20:24:59.727Z", + "interactions": [ + { + "request": { + "body": { + "type": "json", + "value": { + "data": { + "attributes": { + "integration": { + "credentials": { + "account_id": "123456789123", + "role": "MyRoleUpdated", + "type": "AWSAssumeRole" + }, + "type": "AWS" + }, + "name": "Cassette Connection testcreateanewactionconnectionreturnssuccessfullycreatedactionconnectionresponse1743020699" + }, + "type": "action_connection" + } + } + }, + "content_type": "application/json", + "method": "POST", + "path": "/api/v2/actions/connections", + "query": [] + }, + "response": { + "body": { + "encoding": "text", + "value": "{\"data\":{\"id\":\"67aa2f61-266d-48d1-a1ee-cf7c3acc6b20\",\"type\":\"action_connection\",\"attributes\":{\"integration\":{\"credentials\":{\"account_id\":\"123456789123\",\"external_id\":\"70f4660c99684420821b0c13a67eb4d1\",\"principal_id\":\"464622532012\",\"role\":\"MyRoleUpdated\",\"type\":\"AWSAssumeRole\"},\"type\":\"AWS\"},\"name\":\"Cassette Connection testcreateanewactionconnectionreturnssuccessfullycreatedactionconnectionresponse1743020699\"}}}" + }, + "headers": { + "content-type": "application/vnd.api+json" + }, + "reason": "Created", + "status": 201 + } + }, + { + "request": { + "body": { + "type": "empty", + "value": null + }, + "content_type": "", + "method": "DELETE", + "path": "/api/v2/actions/connections/67aa2f61-266d-48d1-a1ee-cf7c3acc6b20", + "query": [] + }, + "response": { + "body": { + "encoding": "text", + "value": "" + }, + "headers": {}, + "reason": "No Content", + "status": 204 + } + } + ], + "scenario": "Create a new Action Connection returns \"Successfully created Action Connection\" response", + "version": "v2" + }, + { + "feature": "Action Connection", + "frozen_at": "2026-11-04T17:36:17.607Z", + "interactions": [ + { + "request": { + "body": { + "type": "json", + "value": { + "data": { + "attributes": { + "integration": { + "credentials": { + "api_token": { + "key": "api_token", + "secret_id": "example/anthropic", + "type": "aws_secrets_manager" + }, + "type": "AnthropicAPIKey" + }, + "type": "Anthropic" + }, + "name": "Missing Secrets Manager Settings testcreateanactionconnectionrejectsawsreferenceswithoutconnectionlevelsettings1793813777" + }, + "type": "action_connection" + } + } + }, + "content_type": "application/json", + "method": "POST", + "path": "/api/v2/actions/connections", + "query": [] + }, + "response": { + "body": { + "encoding": "text", + "value": "{\"errors\":[{\"title\":\"Generic Error\",\"detail\":\"error creating connection: failed to unmarshal property: api_token: secret backend \\\"aws_secrets_manager\\\" requires the connection's external_secrets_manager settings\"}]}" + }, + "headers": { + "content-type": "application/vnd.api+json" + }, + "reason": "Bad Request", + "status": 400 + } + } + ], + "scenario": "Create an Action Connection rejects AWS references without connection-level settings", + "version": "v2" + }, + { + "feature": "Action Connection", + "frozen_at": "2026-11-04T17:36:17.892Z", + "interactions": [ + { + "request": { + "body": { + "type": "json", + "value": { + "data": { + "attributes": { + "integration": { + "credentials": { + "account_id": "123456789123", + "role": "MyRole", + "type": "AWSAssumeRole" + }, + "type": "AWS" + }, + "name": "Cassette Connection testcreateanactionconnectionrejectsconflictingawssecretversionselectors1793813777" + }, + "type": "action_connection" + } + } + }, + "content_type": "application/json", + "method": "POST", + "path": "/api/v2/actions/connections", + "query": [] + }, + "response": { + "body": { + "encoding": "text", + "value": "{\"data\":{\"id\":\"7421d8d2-b0b7-4e71-a3d0-1358b2778c1f\",\"type\":\"action_connection\",\"attributes\":{\"acting_user_can_resolve\":false,\"environment\":\"DATACENTER\",\"external_secrets_manager\":null,\"integration\":{\"credentials\":{\"account_id\":\"123456789123\",\"external_id\":\"88f6fb0618d94675a25ec5fad793df11\",\"principal_id\":\"464622532012\",\"role\":\"MyRole\",\"type\":\"AWSAssumeRole\"},\"type\":\"AWS\"},\"is_favorite\":false,\"name\":\"Cassette Connection testcreateanactionconnectionrejectsconflictingawssecretversionselectors1793813777\"}}}" + }, + "headers": { + "content-type": "application/vnd.api+json" + }, + "reason": "Created", + "status": 201 + } + }, + { + "request": { + "body": { + "type": "json", + "value": { + "data": { + "attributes": { + "external_secrets_manager": { + "connection_id": "7421d8d2-b0b7-4e71-a3d0-1358b2778c1f", + "region": "us-east-1", + "type": "aws_secrets_manager" + }, + "integration": { + "credentials": { + "api_token": { + "key": "api_token", + "secret_id": "example/anthropic", + "type": "aws_secrets_manager", + "version_id": "example-version", + "version_stage": "AWSCURRENT" + }, + "type": "AnthropicAPIKey" + }, + "type": "Anthropic" + }, + "name": "Conflicting Secrets Manager Versions testcreateanactionconnectionrejectsconflictingawssecretversionselectors1793813777" + }, + "type": "action_connection" + } + } + }, + "content_type": "application/json", + "method": "POST", + "path": "/api/v2/actions/connections", + "query": [] + }, + "response": { + "body": { + "encoding": "text", + "value": "{\"errors\":[{\"title\":\"Generic Error\",\"detail\":\"error creating connection: failed to unmarshal property: api_token: secret backend \\\"aws_secrets_manager\\\" accepts \\\"version_id\\\" or \\\"version_stage\\\", not both\"}]}" + }, + "headers": { + "content-type": "application/vnd.api+json" + }, + "reason": "Bad Request", + "status": 400 + } + }, + { + "request": { + "body": { + "type": "empty", + "value": null + }, + "content_type": "", + "method": "DELETE", + "path": "/api/v2/actions/connections/7421d8d2-b0b7-4e71-a3d0-1358b2778c1f", + "query": [] + }, + "response": { + "body": { + "encoding": "text", + "value": "" + }, + "headers": {}, + "reason": "No Content", + "status": 204 + } + } + ], + "scenario": "Create an Action Connection rejects conflicting AWS secret version selectors", + "version": "v2" + }, + { + "feature": "Action Connection", + "frozen_at": "2026-11-04T17:36:18.822Z", + "interactions": [ + { + "request": { + "body": { + "type": "json", + "value": { + "data": { + "attributes": { + "integration": { + "credentials": { + "account_id": "123456789123", + "role": "MyRole", + "type": "AWSAssumeRole" + }, + "type": "AWS" + }, + "name": "Cassette Connection testcreateananthropicactionconnectionwithanawssecretsmanagerapitoken1793813778" + }, + "type": "action_connection" + } + } + }, + "content_type": "application/json", + "method": "POST", + "path": "/api/v2/actions/connections", + "query": [] + }, + "response": { + "body": { + "encoding": "text", + "value": "{\"data\":{\"id\":\"33762af9-cb56-4e96-b110-ea3404de12c4\",\"type\":\"action_connection\",\"attributes\":{\"acting_user_can_resolve\":false,\"environment\":\"DATACENTER\",\"external_secrets_manager\":null,\"integration\":{\"credentials\":{\"account_id\":\"123456789123\",\"external_id\":\"b7ab416bbc5242f3bb57a4430b611415\",\"principal_id\":\"464622532012\",\"role\":\"MyRole\",\"type\":\"AWSAssumeRole\"},\"type\":\"AWS\"},\"is_favorite\":false,\"name\":\"Cassette Connection testcreateananthropicactionconnectionwithanawssecretsmanagerapitoken1793813778\"}}}" + }, + "headers": { + "content-type": "application/vnd.api+json" + }, + "reason": "Created", + "status": 201 + } + }, + { + "request": { + "body": { + "type": "json", + "value": { + "data": { + "attributes": { + "external_secrets_manager": { + "connection_id": "33762af9-cb56-4e96-b110-ea3404de12c4", + "region": "us-east-1", + "type": "aws_secrets_manager" + }, + "integration": { + "credentials": { + "api_token": { + "key": "api_token", + "secret_id": "example/anthropic", + "type": "aws_secrets_manager" + }, + "type": "AnthropicAPIKey" + }, + "type": "Anthropic" + }, + "name": "Anthropic Secrets Manager Connection testcreateananthropicactionconnectionwithanawssecretsmanagerapitoken1793813778" + }, + "type": "action_connection" + } + } + }, + "content_type": "application/json", + "method": "POST", + "path": "/api/v2/actions/connections", + "query": [] + }, + "response": { + "body": { + "encoding": "text", + "value": "{\"data\":{\"id\":\"22ec59d2-048f-49ae-9f95-42dc5ba85f2d\",\"type\":\"action_connection\",\"attributes\":{\"acting_user_can_resolve\":false,\"environment\":\"DATACENTER\",\"external_secrets_manager\":{\"type\":\"aws_secrets_manager\",\"connection_id\":\"33762af9-cb56-4e96-b110-ea3404de12c4\",\"region\":\"us-east-1\"},\"integration\":{\"credentials\":{\"api_token\":{\"type\":\"aws_secrets_manager\",\"secret_id\":\"example/anthropic\",\"key\":\"api_token\"},\"type\":\"AnthropicAPIKey\"},\"type\":\"Anthropic\"},\"is_favorite\":false,\"name\":\"Anthropic Secrets Manager Connection testcreateananthropicactionconnectionwithanawssecretsmanagerapitoken1793813778\"}}}" + }, + "headers": { + "content-type": "application/vnd.api+json" + }, + "reason": "Created", + "status": 201 + } + }, + { + "request": { + "body": { + "type": "empty", + "value": null + }, + "content_type": "", + "method": "DELETE", + "path": "/api/v2/actions/connections/22ec59d2-048f-49ae-9f95-42dc5ba85f2d", + "query": [] + }, + "response": { + "body": { + "encoding": "text", + "value": "" + }, + "headers": {}, + "reason": "No Content", + "status": 204 + } + }, + { + "request": { + "body": { + "type": "empty", + "value": null + }, + "content_type": "", + "method": "DELETE", + "path": "/api/v2/actions/connections/33762af9-cb56-4e96-b110-ea3404de12c4", + "query": [] + }, + "response": { + "body": { + "encoding": "text", + "value": "" + }, + "headers": {}, + "reason": "No Content", + "status": 204 + } + } + ], + "scenario": "Create an Anthropic Action Connection with an AWS Secrets Manager API token", + "version": "v2" + }, + { + "feature": "Action Connection", + "frozen_at": "2026-11-04T17:36:20.097Z", + "interactions": [ + { + "request": { + "body": { + "type": "json", + "value": { + "data": { + "attributes": { + "integration": { + "credentials": { + "account_id": "123456789123", + "role": "MyRole", + "type": "AWSAssumeRole" + }, + "type": "AWS" + }, + "name": "Cassette Connection testcreateanhttpactionconnectionwithanawssecretsmanagertoken1793813780" + }, + "type": "action_connection" + } + } + }, + "content_type": "application/json", + "method": "POST", + "path": "/api/v2/actions/connections", + "query": [] + }, + "response": { + "body": { + "encoding": "text", + "value": "{\"data\":{\"id\":\"ec728a53-f24a-47f5-b3ff-629649fe7243\",\"type\":\"action_connection\",\"attributes\":{\"acting_user_can_resolve\":false,\"environment\":\"DATACENTER\",\"external_secrets_manager\":null,\"integration\":{\"credentials\":{\"account_id\":\"123456789123\",\"external_id\":\"74215d6fad64427badcff94ad3f57bc2\",\"principal_id\":\"464622532012\",\"role\":\"MyRole\",\"type\":\"AWSAssumeRole\"},\"type\":\"AWS\"},\"is_favorite\":false,\"name\":\"Cassette Connection testcreateanhttpactionconnectionwithanawssecretsmanagertoken1793813780\"}}}" + }, + "headers": { + "content-type": "application/vnd.api+json" + }, + "reason": "Created", + "status": 201 + } + }, + { + "request": { + "body": { + "type": "json", + "value": { + "data": { + "attributes": { + "external_secrets_manager": { + "connection_id": "ec728a53-f24a-47f5-b3ff-629649fe7243", + "region": "us-east-1", + "type": "aws_secrets_manager" + }, + "integration": { + "base_url": "https://example.com", + "credentials": { + "body": { + "content": "{\"example\":\"literal\"}", + "content_type": "application/json" + }, + "headers": [ + { + "name": "ApiKey", + "value": "literal-value" + } + ], + "tokens": [ + { + "name": "token", + "type": "SECRET", + "value": { + "key": "token", + "secret_id": "example/http", + "type": "aws_secrets_manager" + } + } + ], + "type": "HTTPTokenAuth", + "url_parameters": [ + { + "name": "apiKey", + "value": "literal-value" + } + ] + }, + "type": "HTTP" + }, + "name": "HTTP Secrets Manager Connection testcreateanhttpactionconnectionwithanawssecretsmanagertoken1793813780" + }, + "type": "action_connection" + } + } + }, + "content_type": "application/json", + "method": "POST", + "path": "/api/v2/actions/connections", + "query": [] + }, + "response": { + "body": { + "encoding": "text", + "value": "{\"data\":{\"id\":\"dac8f688-e57e-4285-ab5d-dfe96fe3f49c\",\"type\":\"action_connection\",\"attributes\":{\"acting_user_can_resolve\":false,\"environment\":\"DATACENTER\",\"external_secrets_manager\":{\"type\":\"aws_secrets_manager\",\"connection_id\":\"ec728a53-f24a-47f5-b3ff-629649fe7243\",\"region\":\"us-east-1\"},\"integration\":{\"base_url\":\"https://example.com\",\"credentials\":{\"body\":{\"content\":\"{\\\"example\\\":\\\"literal\\\"}\",\"content_type\":\"application/json\"},\"headers\":[{\"name\":\"ApiKey\",\"value\":\"literal-value\"}],\"http_tokens\":[{\"name\":\"token\",\"value\":{\"type\":\"aws_secrets_manager\",\"secret_id\":\"example/http\",\"key\":\"token\"}}],\"type\":\"HTTPTokenAuth\",\"url_parameters\":[{\"name\":\"apiKey\",\"value\":\"literal-value\"}]},\"testing\":{},\"type\":\"HTTP\"},\"is_favorite\":false,\"name\":\"HTTP Secrets Manager Connection testcreateanhttpactionconnectionwithanawssecretsmanagertoken1793813780\"}}}" + }, + "headers": { + "content-type": "application/vnd.api+json" + }, + "reason": "Created", + "status": 201 + } + }, + { + "request": { + "body": { + "type": "empty", + "value": null + }, + "content_type": "", + "method": "DELETE", + "path": "/api/v2/actions/connections/dac8f688-e57e-4285-ab5d-dfe96fe3f49c", + "query": [] + }, + "response": { + "body": { + "encoding": "text", + "value": "" + }, + "headers": {}, + "reason": "No Content", + "status": 204 + } + }, + { + "request": { + "body": { + "type": "empty", + "value": null + }, + "content_type": "", + "method": "DELETE", + "path": "/api/v2/actions/connections/ec728a53-f24a-47f5-b3ff-629649fe7243", + "query": [] + }, + "response": { + "body": { + "encoding": "text", + "value": "" + }, + "headers": {}, + "reason": "No Content", + "status": 204 + } + } + ], + "scenario": "Create an HTTP Action Connection with an AWS Secrets Manager token", + "version": "v2" + }, + { + "feature": "Action Connection", + "frozen_at": "2025-03-26T20:25:00.311Z", + "interactions": [ + { + "request": { + "body": { + "type": "empty", + "value": null + }, + "content_type": "", + "method": "DELETE", + "path": "/api/v2/actions/connections/aaa11111-aa11-aa11-aaaa-aaaaaa111111", + "query": [] + }, + "response": { + "body": { + "encoding": "text", + "value": "{\"errors\":[{\"title\":\"Generic Error\",\"detail\":\"error deleting connection: rpc error: code = NotFound desc = connection not found\"}]}" + }, + "headers": { + "content-type": "application/vnd.api+json" + }, + "reason": "Not Found", + "status": 404 + } + } + ], + "scenario": "Delete an existing Action Connection returns \"Not Found\" response", "version": "v2" }, { "feature": "Action Connection", - "frozen_at": "2025-03-26T20:24:59.727Z", + "frozen_at": "2025-01-06T22:02:36.636Z", "interactions": [ { "request": { @@ -61,12 +753,12 @@ "integration": { "credentials": { "account_id": "123456789123", - "role": "MyRoleUpdated", + "role": "MyRole", "type": "AWSAssumeRole" }, "type": "AWS" }, - "name": "Cassette Connection testcreateanewactionconnectionreturnssuccessfullycreatedactionconnectionresponse1743020699" + "name": "Cassette Connection DELETE" }, "type": "action_connection" } @@ -80,7 +772,7 @@ "response": { "body": { "encoding": "text", - "value": "{\"data\":{\"id\":\"67aa2f61-266d-48d1-a1ee-cf7c3acc6b20\",\"type\":\"action_connection\",\"attributes\":{\"integration\":{\"credentials\":{\"account_id\":\"123456789123\",\"external_id\":\"70f4660c99684420821b0c13a67eb4d1\",\"principal_id\":\"464622532012\",\"role\":\"MyRoleUpdated\",\"type\":\"AWSAssumeRole\"},\"type\":\"AWS\"},\"name\":\"Cassette Connection testcreateanewactionconnectionreturnssuccessfullycreatedactionconnectionresponse1743020699\"}}}" + "value": "{\"data\":{\"id\":\"4b60345a-85b2-4417-94b2-72a9528b4060\",\"type\":\"action_connection\",\"attributes\":{\"integration\":{\"credentials\":{\"account_id\":\"123456789123\",\"role\":\"MyRole\",\"external_id\":\"3bceadebe70c4df7b8ec6abb789e08c0\",\"principal_id\":\"464622532012\",\"type\":\"AWSAssumeRole\"},\"type\":\"AWS\"},\"name\":\"Cassette Connection DELETE\"}}}" }, "headers": { "content-type": "application/vnd.api+json" @@ -97,7 +789,7 @@ }, "content_type": "", "method": "DELETE", - "path": "/api/v2/actions/connections/67aa2f61-266d-48d1-a1ee-cf7c3acc6b20", + "path": "/api/v2/actions/connections/4b60345a-85b2-4417-94b2-72a9528b4060", "query": [] }, "response": { @@ -109,15 +801,7 @@ "reason": "No Content", "status": 204 } - } - ], - "scenario": "Create a new Action Connection returns \"Successfully created Action Connection\" response", - "version": "v2" - }, - { - "feature": "Action Connection", - "frozen_at": "2025-03-26T20:25:00.311Z", - "interactions": [ + }, { "request": { "body": { @@ -126,7 +810,7 @@ }, "content_type": "", "method": "DELETE", - "path": "/api/v2/actions/connections/aaa11111-aa11-aa11-aaaa-aaaaaa111111", + "path": "/api/v2/actions/connections/4b60345a-85b2-4417-94b2-72a9528b4060", "query": [] }, "response": { @@ -142,12 +826,12 @@ } } ], - "scenario": "Delete an existing Action Connection returns \"Not Found\" response", + "scenario": "Delete an existing Action Connection returns \"Successfully deleted Action Connection\" response", "version": "v2" }, { "feature": "Action Connection", - "frozen_at": "2025-01-06T22:02:36.636Z", + "frozen_at": "2025-03-26T20:25:00.458Z", "interactions": [ { "request": { @@ -164,7 +848,7 @@ }, "type": "AWS" }, - "name": "Cassette Connection DELETE" + "name": "Cassette Connection testdeleteanexistingactionconnectionreturnstheresourcewasdeletedsuccessfullyresponse1743020700" }, "type": "action_connection" } @@ -178,7 +862,7 @@ "response": { "body": { "encoding": "text", - "value": "{\"data\":{\"id\":\"4b60345a-85b2-4417-94b2-72a9528b4060\",\"type\":\"action_connection\",\"attributes\":{\"integration\":{\"credentials\":{\"account_id\":\"123456789123\",\"role\":\"MyRole\",\"external_id\":\"3bceadebe70c4df7b8ec6abb789e08c0\",\"principal_id\":\"464622532012\",\"type\":\"AWSAssumeRole\"},\"type\":\"AWS\"},\"name\":\"Cassette Connection DELETE\"}}}" + "value": "{\"data\":{\"id\":\"c3c3d83b-c495-4c1b-bb1d-592825d21db0\",\"type\":\"action_connection\",\"attributes\":{\"integration\":{\"credentials\":{\"account_id\":\"123456789123\",\"external_id\":\"6183670d1ceb4278808cf2df9aa03a07\",\"principal_id\":\"464622532012\",\"role\":\"MyRole\",\"type\":\"AWSAssumeRole\"},\"type\":\"AWS\"},\"name\":\"Cassette Connection testdeleteanexistingactionconnectionreturnstheresourcewasdeletedsuccessfullyresponse1743020700\"}}}" }, "headers": { "content-type": "application/vnd.api+json" @@ -195,7 +879,7 @@ }, "content_type": "", "method": "DELETE", - "path": "/api/v2/actions/connections/4b60345a-85b2-4417-94b2-72a9528b4060", + "path": "/api/v2/actions/connections/c3c3d83b-c495-4c1b-bb1d-592825d21db0", "query": [] }, "response": { @@ -216,7 +900,7 @@ }, "content_type": "", "method": "DELETE", - "path": "/api/v2/actions/connections/4b60345a-85b2-4417-94b2-72a9528b4060", + "path": "/api/v2/actions/connections/c3c3d83b-c495-4c1b-bb1d-592825d21db0", "query": [] }, "response": { @@ -232,12 +916,12 @@ } } ], - "scenario": "Delete an existing Action Connection returns \"Successfully deleted Action Connection\" response", + "scenario": "Delete an existing Action Connection returns \"The resource was deleted successfully.\" response", "version": "v2" }, { "feature": "Action Connection", - "frozen_at": "2025-03-26T20:25:00.458Z", + "frozen_at": "2026-11-04T17:36:21.394Z", "interactions": [ { "request": { @@ -254,7 +938,7 @@ }, "type": "AWS" }, - "name": "Cassette Connection testdeleteanexistingactionconnectionreturnstheresourcewasdeletedsuccessfullyresponse1743020700" + "name": "Cassette Connection testgetagcpactionconnectionpreservesawssecretsmanagerreferences1793813781" }, "type": "action_connection" } @@ -268,7 +952,58 @@ "response": { "body": { "encoding": "text", - "value": "{\"data\":{\"id\":\"c3c3d83b-c495-4c1b-bb1d-592825d21db0\",\"type\":\"action_connection\",\"attributes\":{\"integration\":{\"credentials\":{\"account_id\":\"123456789123\",\"external_id\":\"6183670d1ceb4278808cf2df9aa03a07\",\"principal_id\":\"464622532012\",\"role\":\"MyRole\",\"type\":\"AWSAssumeRole\"},\"type\":\"AWS\"},\"name\":\"Cassette Connection testdeleteanexistingactionconnectionreturnstheresourcewasdeletedsuccessfullyresponse1743020700\"}}}" + "value": "{\"data\":{\"id\":\"b82305cf-0fdb-4e70-bb5d-9b36dce0db8c\",\"type\":\"action_connection\",\"attributes\":{\"acting_user_can_resolve\":false,\"environment\":\"DATACENTER\",\"external_secrets_manager\":null,\"integration\":{\"credentials\":{\"account_id\":\"123456789123\",\"external_id\":\"ccbe077e89354310ba02f52d05a61f28\",\"principal_id\":\"464622532012\",\"role\":\"MyRole\",\"type\":\"AWSAssumeRole\"},\"type\":\"AWS\"},\"is_favorite\":false,\"name\":\"Cassette Connection testgetagcpactionconnectionpreservesawssecretsmanagerreferences1793813781\"}}}" + }, + "headers": { + "content-type": "application/vnd.api+json" + }, + "reason": "Created", + "status": 201 + } + }, + { + "request": { + "body": { + "type": "json", + "value": { + "data": { + "attributes": { + "external_secrets_manager": { + "connection_id": "b82305cf-0fdb-4e70-bb5d-9b36dce0db8c", + "region": "us-east-1", + "type": "aws_secrets_manager" + }, + "integration": { + "credentials": { + "private_key": { + "key": "private_key", + "secret_id": "example/gcp/service-account", + "type": "aws_secrets_manager" + }, + "service_account_email": { + "key": "client_email", + "secret_id": "example/gcp/service-account", + "type": "aws_secrets_manager" + }, + "type": "GCPServiceAccount" + }, + "type": "GCP" + }, + "name": "GCP Secrets Manager Connection testgetagcpactionconnectionpreservesawssecretsmanagerreferences1793813781" + }, + "type": "action_connection" + } + } + }, + "content_type": "application/json", + "method": "POST", + "path": "/api/v2/actions/connections", + "query": [] + }, + "response": { + "body": { + "encoding": "text", + "value": "{\"data\":{\"id\":\"f0ad07f0-e57d-4830-9943-4f516d9c575f\",\"type\":\"action_connection\",\"attributes\":{\"acting_user_can_resolve\":false,\"environment\":\"DATACENTER\",\"external_secrets_manager\":{\"type\":\"aws_secrets_manager\",\"connection_id\":\"b82305cf-0fdb-4e70-bb5d-9b36dce0db8c\",\"region\":\"us-east-1\"},\"integration\":{\"credentials\":{\"private_key\":{\"type\":\"aws_secrets_manager\",\"secret_id\":\"example/gcp/service-account\",\"key\":\"private_key\"},\"service_account_email\":{\"type\":\"aws_secrets_manager\",\"secret_id\":\"example/gcp/service-account\",\"key\":\"client_email\"},\"type\":\"GCPServiceAccount\"},\"type\":\"GCP\"},\"is_favorite\":false,\"name\":\"GCP Secrets Manager Connection testgetagcpactionconnectionpreservesawssecretsmanagerreferences1793813781\"}}}" }, "headers": { "content-type": "application/vnd.api+json" @@ -277,6 +1012,29 @@ "status": 201 } }, + { + "request": { + "body": { + "type": "empty", + "value": null + }, + "content_type": "", + "method": "GET", + "path": "/api/v2/actions/connections/f0ad07f0-e57d-4830-9943-4f516d9c575f", + "query": [] + }, + "response": { + "body": { + "encoding": "text", + "value": "{\"data\":{\"id\":\"f0ad07f0-e57d-4830-9943-4f516d9c575f\",\"type\":\"action_connection\",\"attributes\":{\"acting_user_can_resolve\":true,\"created_at\":\"2026-11-04 17:36:22.420788 +0000 UTC\",\"environment\":\"DATACENTER\",\"external_secrets_manager\":{\"type\":\"aws_secrets_manager\",\"connection_id\":\"b82305cf-0fdb-4e70-bb5d-9b36dce0db8c\",\"region\":\"us-east-1\"},\"integration\":{\"credentials\":{\"private_key\":{\"type\":\"aws_secrets_manager\",\"secret_id\":\"example/gcp/service-account\",\"key\":\"private_key\"},\"service_account_email\":{\"type\":\"aws_secrets_manager\",\"secret_id\":\"example/gcp/service-account\",\"key\":\"client_email\"},\"type\":\"GCPServiceAccount\"},\"type\":\"GCP\"},\"is_favorite\":false,\"last_updated\":\"2026-11-04 17:36:22.420788 +0000 UTC\",\"name\":\"GCP Secrets Manager Connection testgetagcpactionconnectionpreservesawssecretsmanagerreferences1793813781\"},\"relationships\":{\"created_by\":{\"data\":{\"id\":\"3ad549bf-eba0-11e9-a77a-0705486660d0\",\"type\":\"created_by\"}}}}}" + }, + "headers": { + "content-type": "application/vnd.api+json" + }, + "reason": "OK", + "status": 200 + } + }, { "request": { "body": { @@ -285,7 +1043,7 @@ }, "content_type": "", "method": "DELETE", - "path": "/api/v2/actions/connections/c3c3d83b-c495-4c1b-bb1d-592825d21db0", + "path": "/api/v2/actions/connections/f0ad07f0-e57d-4830-9943-4f516d9c575f", "query": [] }, "response": { @@ -306,23 +1064,21 @@ }, "content_type": "", "method": "DELETE", - "path": "/api/v2/actions/connections/c3c3d83b-c495-4c1b-bb1d-592825d21db0", + "path": "/api/v2/actions/connections/b82305cf-0fdb-4e70-bb5d-9b36dce0db8c", "query": [] }, "response": { "body": { "encoding": "text", - "value": "{\"errors\":[{\"title\":\"Generic Error\",\"detail\":\"error deleting connection: rpc error: code = NotFound desc = connection not found\"}]}" - }, - "headers": { - "content-type": "application/vnd.api+json" + "value": "" }, - "reason": "Not Found", - "status": 404 + "headers": {}, + "reason": "No Content", + "status": 204 } } ], - "scenario": "Delete an existing Action Connection returns \"The resource was deleted successfully.\" response", + "scenario": "Get a GCP Action Connection preserves AWS Secrets Manager references", "version": "v2" }, { @@ -666,6 +1422,196 @@ "scenario": "Unregister an App Key returns \"Not found\" response", "version": "v2" }, + { + "feature": "Action Connection", + "frozen_at": "2026-11-04T17:36:23.044Z", + "interactions": [ + { + "request": { + "body": { + "type": "json", + "value": { + "data": { + "attributes": { + "integration": { + "credentials": { + "account_id": "123456789123", + "role": "MyRole", + "type": "AWSAssumeRole" + }, + "type": "AWS" + }, + "name": "Cassette Connection testupdateagcpactionconnectionwithaversionedawssecretsmanagerreference1793813783" + }, + "type": "action_connection" + } + } + }, + "content_type": "application/json", + "method": "POST", + "path": "/api/v2/actions/connections", + "query": [] + }, + "response": { + "body": { + "encoding": "text", + "value": "{\"data\":{\"id\":\"04a464b2-ad07-4fcd-ab75-6204e72cdbcc\",\"type\":\"action_connection\",\"attributes\":{\"acting_user_can_resolve\":false,\"environment\":\"DATACENTER\",\"external_secrets_manager\":null,\"integration\":{\"credentials\":{\"account_id\":\"123456789123\",\"external_id\":\"a914cb3f791f40f5996a10c44e224efe\",\"principal_id\":\"464622532012\",\"role\":\"MyRole\",\"type\":\"AWSAssumeRole\"},\"type\":\"AWS\"},\"is_favorite\":false,\"name\":\"Cassette Connection testupdateagcpactionconnectionwithaversionedawssecretsmanagerreference1793813783\"}}}" + }, + "headers": { + "content-type": "application/vnd.api+json" + }, + "reason": "Created", + "status": 201 + } + }, + { + "request": { + "body": { + "type": "json", + "value": { + "data": { + "attributes": { + "external_secrets_manager": { + "connection_id": "04a464b2-ad07-4fcd-ab75-6204e72cdbcc", + "region": "us-east-1", + "type": "aws_secrets_manager" + }, + "integration": { + "credentials": { + "private_key": { + "key": "private_key", + "secret_id": "example/gcp/service-account", + "type": "aws_secrets_manager" + }, + "service_account_email": { + "key": "client_email", + "secret_id": "example/gcp/service-account", + "type": "aws_secrets_manager" + }, + "type": "GCPServiceAccount" + }, + "type": "GCP" + }, + "name": "GCP Secrets Manager Connection testupdateagcpactionconnectionwithaversionedawssecretsmanagerreference1793813783" + }, + "type": "action_connection" + } + } + }, + "content_type": "application/json", + "method": "POST", + "path": "/api/v2/actions/connections", + "query": [] + }, + "response": { + "body": { + "encoding": "text", + "value": "{\"data\":{\"id\":\"24752e26-a728-4c52-a795-39086e2669a6\",\"type\":\"action_connection\",\"attributes\":{\"acting_user_can_resolve\":false,\"environment\":\"DATACENTER\",\"external_secrets_manager\":{\"type\":\"aws_secrets_manager\",\"connection_id\":\"04a464b2-ad07-4fcd-ab75-6204e72cdbcc\",\"region\":\"us-east-1\"},\"integration\":{\"credentials\":{\"private_key\":{\"type\":\"aws_secrets_manager\",\"secret_id\":\"example/gcp/service-account\",\"key\":\"private_key\"},\"service_account_email\":{\"type\":\"aws_secrets_manager\",\"secret_id\":\"example/gcp/service-account\",\"key\":\"client_email\"},\"type\":\"GCPServiceAccount\"},\"type\":\"GCP\"},\"is_favorite\":false,\"name\":\"GCP Secrets Manager Connection testupdateagcpactionconnectionwithaversionedawssecretsmanagerreference1793813783\"}}}" + }, + "headers": { + "content-type": "application/vnd.api+json" + }, + "reason": "Created", + "status": 201 + } + }, + { + "request": { + "body": { + "type": "json", + "value": { + "data": { + "attributes": { + "external_secrets_manager": { + "connection_id": "04a464b2-ad07-4fcd-ab75-6204e72cdbcc", + "region": "us-east-1", + "type": "aws_secrets_manager" + }, + "integration": { + "credentials": { + "private_key": { + "key": "private_key", + "secret_id": "example/gcp/service-account", + "type": "aws_secrets_manager", + "version_stage": "AWSCURRENT" + }, + "service_account_email": { + "key": "client_email", + "secret_id": "example/gcp/service-account", + "type": "aws_secrets_manager" + }, + "type": "GCPServiceAccount" + }, + "type": "GCP" + } + }, + "type": "action_connection" + } + } + }, + "content_type": "application/json", + "method": "PATCH", + "path": "/api/v2/actions/connections/24752e26-a728-4c52-a795-39086e2669a6", + "query": [] + }, + "response": { + "body": { + "encoding": "text", + "value": "{\"data\":{\"id\":\"24752e26-a728-4c52-a795-39086e2669a6\",\"type\":\"action_connection\",\"attributes\":{\"acting_user_can_resolve\":false,\"created_at\":\"2026-11-04 17:36:24.057283 +0000 UTC\",\"environment\":\"DATACENTER\",\"external_secrets_manager\":{\"type\":\"aws_secrets_manager\",\"connection_id\":\"04a464b2-ad07-4fcd-ab75-6204e72cdbcc\",\"region\":\"us-east-1\"},\"integration\":{\"credentials\":{\"private_key\":{\"type\":\"aws_secrets_manager\",\"secret_id\":\"example/gcp/service-account\",\"key\":\"private_key\",\"version_stage\":\"AWSCURRENT\"},\"service_account_email\":{\"type\":\"aws_secrets_manager\",\"secret_id\":\"example/gcp/service-account\",\"key\":\"client_email\"},\"type\":\"GCPServiceAccount\"},\"type\":\"GCP\"},\"is_favorite\":false,\"last_updated\":\"2026-11-04 17:36:24.406864 +0000 UTC\",\"name\":\"GCP Secrets Manager Connection testupdateagcpactionconnectionwithaversionedawssecretsmanagerreference1793813783\"},\"relationships\":{\"created_by\":{\"data\":{\"id\":\"3ad549bf-eba0-11e9-a77a-0705486660d0\",\"type\":\"created_by\"}}}}}" + }, + "headers": { + "content-type": "application/vnd.api+json" + }, + "reason": "OK", + "status": 200 + } + }, + { + "request": { + "body": { + "type": "empty", + "value": null + }, + "content_type": "", + "method": "DELETE", + "path": "/api/v2/actions/connections/24752e26-a728-4c52-a795-39086e2669a6", + "query": [] + }, + "response": { + "body": { + "encoding": "text", + "value": "" + }, + "headers": {}, + "reason": "No Content", + "status": 204 + } + }, + { + "request": { + "body": { + "type": "empty", + "value": null + }, + "content_type": "", + "method": "DELETE", + "path": "/api/v2/actions/connections/04a464b2-ad07-4fcd-ab75-6204e72cdbcc", + "query": [] + }, + "response": { + "body": { + "encoding": "text", + "value": "" + }, + "headers": {}, + "reason": "No Content", + "status": 204 + } + } + ], + "scenario": "Update a GCP Action Connection with a versioned AWS Secrets Manager reference", + "version": "v2" + }, { "feature": "Action Connection", "frozen_at": "2025-03-26T20:25:01.521Z",