From eec26160b9fb11ccb02bdac8e7cd0c1789978166 Mon Sep 17 00:00:00 2001 From: "ci.datadog-api-spec" Date: Wed, 17 Jun 2026 21:46:25 +0000 Subject: [PATCH] Regenerate client from commit ffdfd1c of spec repo --- .generator/schemas/v2/openapi.yaml | 773 ++++++++++++ .../v2_aws-wif_CreateAwsWifIntakeMapping.rs | 25 + .../v2_aws-wif_CreateAwsWifPersonaMapping.rs | 26 + .../v2_aws-wif_DeleteAwsWifIntakeMapping.rs | 20 + .../v2_aws-wif_DeleteAwsWifPersonaMapping.rs | 20 + examples/v2_aws-wif_GetAwsWifIntakeMapping.rs | 20 + .../v2_aws-wif_GetAwsWifPersonaMapping.rs | 20 + .../v2_aws-wif_ListAwsWifIntakeMappings.rs | 15 + .../v2_aws-wif_ListAwsWifPersonaMappings.rs | 15 + .../v2_delegated-token_GetDelegatedToken.rs | 15 + examples/v2_intake-key_GetIntakeKey.rs | 15 + src/datadogV2/api/api_aws_wif.rs | 1094 +++++++++++++++++ src/datadogV2/api/api_delegated_token.rs | 201 +++ src/datadogV2/api/api_intake_key.rs | 199 +++ src/datadogV2/api/mod.rs | 3 + src/datadogV2/mod.rs | 3 + src/datadogV2/model/mod.rs | 46 + ...model_aws_wif_intake_mapping_attributes.rs | 95 ++ ...odel_aws_wif_intake_mapping_create_data.rs | 114 ++ ...l_aws_wif_intake_mapping_create_request.rs | 94 ++ .../model_aws_wif_intake_mapping_data.rs | 125 ++ .../model_aws_wif_intake_mapping_response.rs | 94 ++ .../model_aws_wif_intake_mapping_type.rs | 48 + .../model_aws_wif_intake_mappings_response.rs | 93 ++ ...odel_aws_wif_persona_mapping_attributes.rs | 125 ++ ...s_wif_persona_mapping_create_attributes.rs | 110 ++ ...del_aws_wif_persona_mapping_create_data.rs | 115 ++ ..._aws_wif_persona_mapping_create_request.rs | 95 ++ .../model_aws_wif_persona_mapping_data.rs | 126 ++ .../model_aws_wif_persona_mapping_response.rs | 94 ++ .../model_aws_wif_persona_mapping_type.rs | 48 + ...model_aws_wif_persona_mappings_response.rs | 93 ++ .../model/model_delegated_token_attributes.rs | 107 ++ .../model/model_delegated_token_data.rs | 127 ++ .../model/model_delegated_token_response.rs | 92 ++ .../model/model_delegated_token_type.rs | 48 + .../model/model_intake_api_key_attributes.rs | 102 ++ .../model/model_intake_api_key_data.rs | 126 ++ .../model/model_intake_api_key_response.rs | 92 ++ .../model/model_intake_api_key_type.rs | 48 + tests/scenarios/features/v2/aws_wif.feature | 149 +++ .../features/v2/cloud_authentication.feature | 18 +- .../features/v2/delegated_token.feature | 13 + .../scenarios/features/v2/intake_key.feature | 13 + tests/scenarios/features/v2/undo.json | 74 ++ tests/scenarios/function_mappings.rs | 338 +++++ 46 files changed, 5317 insertions(+), 9 deletions(-) create mode 100644 examples/v2_aws-wif_CreateAwsWifIntakeMapping.rs create mode 100644 examples/v2_aws-wif_CreateAwsWifPersonaMapping.rs create mode 100644 examples/v2_aws-wif_DeleteAwsWifIntakeMapping.rs create mode 100644 examples/v2_aws-wif_DeleteAwsWifPersonaMapping.rs create mode 100644 examples/v2_aws-wif_GetAwsWifIntakeMapping.rs create mode 100644 examples/v2_aws-wif_GetAwsWifPersonaMapping.rs create mode 100644 examples/v2_aws-wif_ListAwsWifIntakeMappings.rs create mode 100644 examples/v2_aws-wif_ListAwsWifPersonaMappings.rs create mode 100644 examples/v2_delegated-token_GetDelegatedToken.rs create mode 100644 examples/v2_intake-key_GetIntakeKey.rs create mode 100644 src/datadogV2/api/api_aws_wif.rs create mode 100644 src/datadogV2/api/api_delegated_token.rs create mode 100644 src/datadogV2/api/api_intake_key.rs create mode 100644 src/datadogV2/model/model_aws_wif_intake_mapping_attributes.rs create mode 100644 src/datadogV2/model/model_aws_wif_intake_mapping_create_data.rs create mode 100644 src/datadogV2/model/model_aws_wif_intake_mapping_create_request.rs create mode 100644 src/datadogV2/model/model_aws_wif_intake_mapping_data.rs create mode 100644 src/datadogV2/model/model_aws_wif_intake_mapping_response.rs create mode 100644 src/datadogV2/model/model_aws_wif_intake_mapping_type.rs create mode 100644 src/datadogV2/model/model_aws_wif_intake_mappings_response.rs create mode 100644 src/datadogV2/model/model_aws_wif_persona_mapping_attributes.rs create mode 100644 src/datadogV2/model/model_aws_wif_persona_mapping_create_attributes.rs create mode 100644 src/datadogV2/model/model_aws_wif_persona_mapping_create_data.rs create mode 100644 src/datadogV2/model/model_aws_wif_persona_mapping_create_request.rs create mode 100644 src/datadogV2/model/model_aws_wif_persona_mapping_data.rs create mode 100644 src/datadogV2/model/model_aws_wif_persona_mapping_response.rs create mode 100644 src/datadogV2/model/model_aws_wif_persona_mapping_type.rs create mode 100644 src/datadogV2/model/model_aws_wif_persona_mappings_response.rs create mode 100644 src/datadogV2/model/model_delegated_token_attributes.rs create mode 100644 src/datadogV2/model/model_delegated_token_data.rs create mode 100644 src/datadogV2/model/model_delegated_token_response.rs create mode 100644 src/datadogV2/model/model_delegated_token_type.rs create mode 100644 src/datadogV2/model/model_intake_api_key_attributes.rs create mode 100644 src/datadogV2/model/model_intake_api_key_data.rs create mode 100644 src/datadogV2/model/model_intake_api_key_response.rs create mode 100644 src/datadogV2/model/model_intake_api_key_type.rs create mode 100644 tests/scenarios/features/v2/aws_wif.feature create mode 100644 tests/scenarios/features/v2/delegated_token.feature create mode 100644 tests/scenarios/features/v2/intake_key.feature diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index b17c8433bd..a07ab7db9f 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -1932,6 +1932,15 @@ components: required: false schema: $ref: "#/components/schemas/WebhooksAuthMethodProtocol" + WifConfigUUID: + description: The UUID of the WIF configuration to operate on. + example: c5c758c6-18c2-4484-ae3f-46b84128404a + in: path + name: config_uuid + required: true + schema: + format: uuid + type: string WorkflowId: description: The ID of the workflow. in: path @@ -12146,6 +12155,181 @@ components: required: - data type: object + AwsWifIntakeMappingAttributes: + description: Attributes of an AWS WIF intake mapping. + properties: + arn_pattern: + description: |- + The AWS IAM ARN pattern identifying the role or user permitted to obtain an intake API key. + Supports wildcards (`*`) to match multiple principals within an account. + example: "arn:aws:iam::123456789012:role/my-agent-role" + type: string + required: + - arn_pattern + type: object + AwsWifIntakeMappingCreateData: + description: Data for creating an AWS WIF intake mapping. + properties: + attributes: + $ref: "#/components/schemas/AwsWifIntakeMappingAttributes" + type: + $ref: "#/components/schemas/AwsWifIntakeMappingType" + required: + - type + - attributes + type: object + AwsWifIntakeMappingCreateRequest: + description: Request body for creating an AWS WIF intake mapping. + properties: + data: + $ref: "#/components/schemas/AwsWifIntakeMappingCreateData" + required: + - data + type: object + AwsWifIntakeMappingData: + description: An AWS WIF intake mapping resource. + properties: + attributes: + $ref: "#/components/schemas/AwsWifIntakeMappingAttributes" + id: + description: The UUID of the intake mapping. + example: "a1b2c3d4-e5f6-7890-abcd-ef1234567890" + format: uuid + type: string + type: + $ref: "#/components/schemas/AwsWifIntakeMappingType" + required: + - id + - type + - attributes + type: object + AwsWifIntakeMappingResponse: + description: Response containing a single AWS WIF intake mapping. + properties: + data: + $ref: "#/components/schemas/AwsWifIntakeMappingData" + required: + - data + type: object + AwsWifIntakeMappingType: + description: Type identifier for an AWS WIF intake mapping. + enum: + - aws_wif_intake_mapping + example: aws_wif_intake_mapping + type: string + x-enum-varnames: + - AWS_WIF_INTAKE_MAPPING + AwsWifIntakeMappingsResponse: + description: Response containing a list of AWS WIF intake mappings. + properties: + data: + items: + $ref: "#/components/schemas/AwsWifIntakeMappingData" + type: array + required: + - data + type: object + AwsWifPersonaMappingAttributes: + description: Attributes of an AWS WIF persona mapping. + properties: + account_identifier: + description: The Datadog user handle (email address) to map the AWS principal to. + example: "user@example.com" + type: string + account_uuid: + description: The Datadog user UUID corresponding to `account_identifier`. Read-only — set by the server. + example: "12bbdc5c-5966-47e0-8733-285f9e44bcf4" + format: uuid + type: string + arn_pattern: + description: |- + The AWS IAM ARN pattern identifying the role or user that will be mapped. + Supports wildcards (`*`) to match multiple principals within an account. + example: "arn:aws:iam::123456789012:role/my-workload-role" + type: string + required: + - arn_pattern + - account_identifier + type: object + AwsWifPersonaMappingCreateAttributes: + description: Attributes for creating an AWS WIF persona mapping. + properties: + account_identifier: + description: The Datadog user handle (email address) to map the AWS principal to. + example: "user@example.com" + type: string + arn_pattern: + description: |- + The AWS IAM ARN pattern identifying the role or user that will be mapped. + Supports wildcards (`*`) to match multiple principals within an account. + example: "arn:aws:iam::123456789012:role/my-workload-role" + type: string + required: + - arn_pattern + - account_identifier + type: object + AwsWifPersonaMappingCreateData: + description: Data for creating an AWS WIF persona mapping. + properties: + attributes: + $ref: "#/components/schemas/AwsWifPersonaMappingCreateAttributes" + type: + $ref: "#/components/schemas/AwsWifPersonaMappingType" + required: + - type + - attributes + type: object + AwsWifPersonaMappingCreateRequest: + description: Request body for creating an AWS WIF persona mapping. + properties: + data: + $ref: "#/components/schemas/AwsWifPersonaMappingCreateData" + required: + - data + type: object + AwsWifPersonaMappingData: + description: An AWS WIF persona mapping resource. + properties: + attributes: + $ref: "#/components/schemas/AwsWifPersonaMappingAttributes" + id: + description: The UUID of the persona mapping. + example: "c5c758c6-18c2-4484-ae3f-46b84128404a" + format: uuid + type: string + type: + $ref: "#/components/schemas/AwsWifPersonaMappingType" + required: + - id + - type + - attributes + type: object + AwsWifPersonaMappingResponse: + description: Response containing a single AWS WIF persona mapping. + properties: + data: + $ref: "#/components/schemas/AwsWifPersonaMappingData" + required: + - data + type: object + AwsWifPersonaMappingType: + description: Type identifier for an AWS WIF persona mapping. + enum: + - aws_wif_config + example: aws_wif_config + type: string + x-enum-varnames: + - AWS_WIF_CONFIG + AwsWifPersonaMappingsResponse: + description: Response containing a list of AWS WIF persona mappings. + properties: + data: + items: + $ref: "#/components/schemas/AwsWifPersonaMappingData" + type: array + required: + - data + type: object AzureCredentials: description: The definition of the `AzureCredentials` object. oneOf: @@ -29812,6 +29996,55 @@ components: oneOf: - $ref: "#/components/schemas/StatusPagesUser" - $ref: "#/components/schemas/StatusPageAsIncluded" + DelegatedTokenAttributes: + description: Attributes of a delegated token. + properties: + access_token: + description: A short-lived JWT representing the authenticated Datadog user. Pass this as a bearer token in subsequent API calls. + example: "eyJhbGciOiJQUzI1NiIsInR5cCI6IkpXVCJ9..." + type: string + expires: + description: The expiry time of the token. + example: "2024-01-15T11:30:00Z" + format: date-time + type: string + required: + - access_token + - expires + type: object + DelegatedTokenData: + description: A delegated token resource. + properties: + attributes: + $ref: "#/components/schemas/DelegatedTokenAttributes" + id: + description: A random UUID assigned to this token issuance. + example: "550e8400-e29b-41d4-a716-446655440000" + format: uuid + type: string + type: + $ref: "#/components/schemas/DelegatedTokenType" + required: + - id + - type + - attributes + type: object + DelegatedTokenResponse: + description: Response containing a delegated user token. + properties: + data: + $ref: "#/components/schemas/DelegatedTokenData" + required: + - data + type: object + DelegatedTokenType: + description: The resource type for a delegated token. + enum: + - token + example: token + type: string + x-enum-varnames: + - TOKEN DeleteAppResponse: description: The response object after an app is successfully deleted. properties: @@ -45556,6 +45789,54 @@ components: - ARRAY_NUMBER - ARRAY_BOOLEAN - ARRAY_OBJECT + IntakeAPIKeyAttributes: + description: Attributes of an intake API key returned after successful authentication. + properties: + api_key: + description: The Datadog API key the workload can use to send telemetry. + example: "abc123def456..." + type: string + org_id: + description: The numeric ID of the Datadog organization the API key belongs to. + example: 123456 + format: int64 + type: integer + required: + - api_key + - org_id + type: object + IntakeAPIKeyData: + description: An intake API key resource. + properties: + attributes: + $ref: "#/components/schemas/IntakeAPIKeyAttributes" + id: + description: A stable identifier for the intake key, scoped to the matched organization. + example: "intake-123456" + type: string + type: + $ref: "#/components/schemas/IntakeAPIKeyType" + required: + - id + - type + - attributes + type: object + IntakeAPIKeyResponse: + description: Response containing an intake API key for the authenticated cloud workload. + properties: + data: + $ref: "#/components/schemas/IntakeAPIKeyData" + required: + - data + type: object + IntakeAPIKeyType: + description: The resource type for an intake API key. + enum: + - intake_api_key + example: intake_api_key + type: string + x-enum-varnames: + - INTAKE_API_KEY IntakePayloadAccepted: description: The payload accepted for intake. properties: @@ -120040,6 +120321,7 @@ paths: - test_optimization_read /api/v2/cloud_auth/aws/persona_mapping: get: + deprecated: true description: List all AWS cloud authentication persona mappings. This endpoint retrieves all configured persona mappings that associate AWS IAM principals with Datadog users. operationId: ListAWSCloudAuthPersonaMappings responses: @@ -120076,10 +120358,14 @@ paths: summary: List AWS cloud authentication persona mappings tags: - Cloud Authentication + x-deprecated: |- + **Deprecated**: Use `ListAwsWifPersonaMappings` (`GET /api/v2/wif/aws/persona_mapping`) instead. + x-sunset: "2027-01-01" x-unstable: |- **Note**: This endpoint is in public beta and is subject to change. If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). post: + deprecated: true description: Create an AWS cloud authentication persona mapping. This endpoint associates an AWS IAM principal with a Datadog user. operationId: CreateAWSCloudAuthPersonaMapping requestBody: @@ -120137,11 +120423,15 @@ paths: tags: - Cloud Authentication x-codegen-request-body-name: body + x-deprecated: |- + **Deprecated**: Use `CreateAwsWifPersonaMapping` (`POST /api/v2/wif/aws/persona_mapping`) instead. + x-sunset: "2027-01-01" x-unstable: |- **Note**: This endpoint is in public beta and is subject to change. If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). /api/v2/cloud_auth/aws/persona_mapping/{persona_mapping_id}: delete: + deprecated: true description: Delete an AWS cloud authentication persona mapping by ID. This removes the association between an AWS IAM principal and a Datadog user. operationId: DeleteAWSCloudAuthPersonaMapping parameters: @@ -120166,10 +120456,14 @@ paths: summary: Delete an AWS cloud authentication persona mapping tags: - Cloud Authentication + x-deprecated: |- + **Deprecated**: Use `DeleteAwsWifPersonaMapping` (`DELETE /api/v2/wif/aws/persona_mapping/{config_uuid}`) instead. + x-sunset: "2027-01-01" x-unstable: |- **Note**: This endpoint is in public beta and is subject to change. If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). get: + deprecated: true description: Get a specific AWS cloud authentication persona mapping by ID. This endpoint retrieves a single configured persona mapping that associates an AWS IAM principal with a Datadog user. operationId: GetAWSCloudAuthPersonaMapping parameters: @@ -120208,6 +120502,9 @@ paths: summary: Get an AWS cloud authentication persona mapping tags: - Cloud Authentication + x-deprecated: |- + **Deprecated**: Use `GetAwsWifPersonaMapping` (`GET /api/v2/wif/aws/persona_mapping/{config_uuid}`) instead. + x-sunset: "2027-01-01" x-unstable: |- **Note**: This endpoint is in public beta and is subject to change. If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). @@ -127393,6 +127690,54 @@ paths: x-unstable: |- **Note: Data Access is in preview. If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).** + /api/v2/delegated-token: + post: + description: |- + Exchange a Workload Identity Federation (WIF) proof or Datadog credentials for a short-lived access token + scoped to a Datadog user. + + To authenticate with a WIF identity, pass the cloud-provider token in the `Authorization` header using + the `Bearer` or `Delegated` scheme. Datadog resolves the Datadog user from the persona mapping configured + for that cloud identity. + + To obtain a token for the calling user directly, authenticate with standard Datadog API and application keys. + + Use the returned `access_token` as a bearer token in subsequent API calls. + operationId: GetDelegatedToken + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + attributes: + access_token: "eyJhbGciOiJQUzI1NiIsInR5cCI6IkpXVCJ9..." + expires: "2024-01-15T11:30:00Z" + id: "550e8400-e29b-41d4-a716-446655440000" + type: token + schema: + $ref: "#/components/schemas/DelegatedTokenResponse" + description: OK + "401": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Unauthorized — missing or invalid authorization proof. + "403": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Forbidden — the cloud identity is not mapped to any Datadog user, or the authenticated user does not have access. + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: [] + summary: Get a delegated token + tags: + - Delegated Token /api/v2/deletion/data/{product}: post: description: Creates a data deletion request by providing a query and a timeframe targeting the proper data. @@ -136004,6 +136349,55 @@ paths: x-unstable: |- **Note**: This endpoint is in public beta. If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/). + /api/v2/intake-key: + post: + description: |- + Exchanges a Workload Identity Federation (WIF) identity proof for a Datadog API key associated with the matching WIF intake mapping. + + Pass a cloud-provider token in the `Authorization` header using the `Bearer` or `Delegated` scheme. + The token is validated against the WIF intake mappings configured for the caller's organization. On success, + a managed-rotation API key is returned that the workload can use to send telemetry to Datadog. + + Unlike the delegated-token endpoint (`POST /api/v2/delegated-token`), this endpoint authenticates + the cloud workload at the organization level rather than mapping it to a specific Datadog user. + + Standard Datadog API and application key authentication is not accepted. Authenticate using a + cloud-provider token in the `Authorization: Bearer` header. + operationId: GetIntakeKey + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + attributes: + api_key: "abc123def456..." + org_id: 123456 + id: "intake-123456" + type: intake_api_key + schema: + $ref: "#/components/schemas/IntakeAPIKeyResponse" + description: OK + "401": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Unauthorized — missing or invalid authorization proof. + "403": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Forbidden — the cloud identity is not matched by any intake mapping for this organization. + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: [] + summary: Get an intake API key + tags: + - Intake Key /api/v2/integration/aws/accounts: get: description: Get a list of AWS Account Integration Configs. @@ -189631,6 +190025,373 @@ paths: - generate_log_reports - manage_log_reports - product_analytics_saved_widgets_write + /api/v2/wif/aws/intake_mapping: + get: + description: List every AWS WIF intake mapping configured for the caller's organization. + operationId: ListAwsWifIntakeMappings + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + - attributes: + arn_pattern: "arn:aws:iam::123456789012:role/my-agent-role" + id: "a1b2c3d4-e5f6-7890-abcd-ef1234567890" + type: aws_wif_intake_mapping + schema: + $ref: "#/components/schemas/AwsWifIntakeMappingsResponse" + description: OK + "403": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Forbidden + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - workload_identity_federation_read + summary: List AWS WIF intake mappings + tags: + - AWS WIF + post: + description: Create an AWS WIF intake mapping. The mapping binds an IAM role ARN pattern to a managed-rotation API key, allowing AWS workloads to send telemetry to Datadog without requiring a delegated user token. + operationId: CreateAwsWifIntakeMapping + requestBody: + content: + application/json: + examples: + default: + value: + data: + attributes: + arn_pattern: "arn:aws:iam::123456789012:role/my-agent-role" + type: aws_wif_intake_mapping + schema: + $ref: "#/components/schemas/AwsWifIntakeMappingCreateRequest" + required: true + responses: + "201": + content: + application/json: + examples: + default: + value: + data: + attributes: + arn_pattern: "arn:aws:iam::123456789012:role/my-agent-role" + id: "a1b2c3d4-e5f6-7890-abcd-ef1234567890" + type: aws_wif_intake_mapping + schema: + $ref: "#/components/schemas/AwsWifIntakeMappingResponse" + description: Created + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Bad Request + "403": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Forbidden + "409": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Conflict + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - workload_identity_federation_write + summary: Create an AWS WIF intake mapping + tags: + - AWS WIF + x-codegen-request-body-name: body + /api/v2/wif/aws/intake_mapping/{config_uuid}: + delete: + description: Delete an AWS WIF intake mapping by UUID. The associated managed-rotation API key is left intact, but AWS workloads that previously matched this mapping will lose intake access. + operationId: DeleteAwsWifIntakeMapping + parameters: + - $ref: "#/components/parameters/WifConfigUUID" + responses: + "204": + description: No Content + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Bad Request + "403": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Forbidden + "404": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Not Found + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - workload_identity_federation_write + summary: Delete an AWS WIF intake mapping + tags: + - AWS WIF + get: + description: Retrieve a single AWS WIF intake mapping by UUID. + operationId: GetAwsWifIntakeMapping + parameters: + - $ref: "#/components/parameters/WifConfigUUID" + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + attributes: + arn_pattern: "arn:aws:iam::123456789012:role/my-agent-role" + id: "a1b2c3d4-e5f6-7890-abcd-ef1234567890" + type: aws_wif_intake_mapping + schema: + $ref: "#/components/schemas/AwsWifIntakeMappingResponse" + description: OK + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Bad Request + "403": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Forbidden + "404": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Not Found + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - workload_identity_federation_read + summary: Get an AWS WIF intake mapping + tags: + - AWS WIF + /api/v2/wif/aws/persona_mapping: + get: + description: List every AWS WIF persona mapping configured for the caller's organization. + operationId: ListAwsWifPersonaMappings + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + - attributes: + account_identifier: "user@example.com" + account_uuid: "12bbdc5c-5966-47e0-8733-285f9e44bcf4" + arn_pattern: "arn:aws:iam::123456789012:role/my-workload-role" + id: "c5c758c6-18c2-4484-ae3f-46b84128404a" + type: aws_wif_config + schema: + $ref: "#/components/schemas/AwsWifPersonaMappingsResponse" + description: OK + "403": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Forbidden + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - workload_identity_federation_read + summary: List AWS WIF persona mappings + tags: + - AWS WIF + post: + description: Create an AWS Workload Identity Federation (WIF) persona mapping. The mapping binds an IAM role ARN pattern to a Datadog user handle, which is used to authenticate delegated-token requests from that AWS identity. + operationId: CreateAwsWifPersonaMapping + requestBody: + content: + application/json: + examples: + default: + value: + data: + attributes: + account_identifier: "user@example.com" + arn_pattern: "arn:aws:iam::123456789012:role/my-workload-role" + type: aws_wif_config + schema: + $ref: "#/components/schemas/AwsWifPersonaMappingCreateRequest" + required: true + responses: + "201": + content: + application/json: + examples: + default: + value: + data: + attributes: + account_identifier: "user@example.com" + account_uuid: "12bbdc5c-5966-47e0-8733-285f9e44bcf4" + arn_pattern: "arn:aws:iam::123456789012:role/my-workload-role" + id: "c5c758c6-18c2-4484-ae3f-46b84128404a" + type: aws_wif_config + schema: + $ref: "#/components/schemas/AwsWifPersonaMappingResponse" + description: Created + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Bad Request + "403": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Forbidden + "409": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Conflict + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - workload_identity_federation_write + summary: Create an AWS WIF persona mapping + tags: + - AWS WIF + x-codegen-request-body-name: body + /api/v2/wif/aws/persona_mapping/{config_uuid}: + delete: + description: Delete an AWS WIF persona mapping by UUID. Subsequent delegated-token requests from the previously mapped AWS identity will be denied. + operationId: DeleteAwsWifPersonaMapping + parameters: + - $ref: "#/components/parameters/WifConfigUUID" + responses: + "204": + description: No Content + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Bad Request + "403": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Forbidden + "404": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Not Found + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - workload_identity_federation_write + summary: Delete an AWS WIF persona mapping + tags: + - AWS WIF + get: + description: Retrieve a single AWS WIF persona mapping by UUID. + operationId: GetAwsWifPersonaMapping + parameters: + - $ref: "#/components/parameters/WifConfigUUID" + responses: + "200": + content: + application/json: + examples: + default: + value: + data: + attributes: + account_identifier: "user@example.com" + account_uuid: "12bbdc5c-5966-47e0-8733-285f9e44bcf4" + arn_pattern: "arn:aws:iam::123456789012:role/my-workload-role" + id: "c5c758c6-18c2-4484-ae3f-46b84128404a" + type: aws_wif_config + schema: + $ref: "#/components/schemas/AwsWifPersonaMappingResponse" + description: OK + "400": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Bad Request + "403": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Forbidden + "404": + content: + application/json: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Not Found + "429": + $ref: "#/components/responses/TooManyRequestsResponse" + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - workload_identity_federation_read + summary: Get an AWS WIF persona mapping + tags: + - AWS WIF /api/v2/workflows: get: description: List all workflows in your organization. This API requires a [registered application key](https://docs.datadoghq.com/api/latest/action-connection/#register-a-new-app-key). Alternatively, you can configure these permissions [in the UI](https://docs.datadoghq.com/account_management/api-app-keys/#actions-api-access). @@ -190292,6 +191053,11 @@ tags: externalDocs: url: https://docs.datadoghq.com/integrations/amazon_web_services/#log-collection name: AWS Logs Integration + - description: |- + Manage AWS Workload Identity Federation (WIF) mappings. + Persona mappings link IAM role ARN patterns to Datadog users for delegated-token authentication. + Intake mappings link IAM role ARN patterns to managed-rotation API keys for agent telemetry ingestion. + name: AWS WIF - description: |- Action connections extend your installed integrations and allow you to take action in your third-party systems (e.g. AWS, GitLab, and Statuspage) with Datadog’s Workflow Automation and App Builder products. @@ -190463,6 +191229,10 @@ tags: access to sensitive data. By defining Restricted Datasets, you can ensure that only specific teams or roles can view certain types of telemetry (for example, logs, traces, metrics, and RUM data). name: Datasets + - description: |- + Exchange a cloud-provider identity proof or Datadog credential for a short-lived delegated-user JWT + via Workload Identity Federation. + name: Delegated Token - description: |- Manage Deployment Gates using this API to reduce the likelihood and impact of incidents caused by deployments. See the [Deployment Gates documentation](https://docs.datadoghq.com/deployment_gates/) for more information. name: Deployment Gates @@ -190547,6 +191317,9 @@ tags: name: IP Allowlist - description: Manage incident response, as well as associated attachments, metadata, and todos. See the [Incident Management page](https://docs.datadoghq.com/service_management/incident_management/) for more information. name: Incidents + - description: |- + Exchange a cloud-provider identity proof for a Datadog API key via Workload Identity Federation intake mappings. + name: Intake Key - description: |- The Integrations API is used to list available integrations and retrieve information about their installation status. diff --git a/examples/v2_aws-wif_CreateAwsWifIntakeMapping.rs b/examples/v2_aws-wif_CreateAwsWifIntakeMapping.rs new file mode 100644 index 0000000000..1f13090f26 --- /dev/null +++ b/examples/v2_aws-wif_CreateAwsWifIntakeMapping.rs @@ -0,0 +1,25 @@ +// Create an AWS WIF intake mapping returns "Created" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_awswif::AWSWIFAPI; +use datadog_api_client::datadogV2::model::AwsWifIntakeMappingAttributes; +use datadog_api_client::datadogV2::model::AwsWifIntakeMappingCreateData; +use datadog_api_client::datadogV2::model::AwsWifIntakeMappingCreateRequest; +use datadog_api_client::datadogV2::model::AwsWifIntakeMappingType; + +#[tokio::main] +async fn main() { + let body = AwsWifIntakeMappingCreateRequest::new(AwsWifIntakeMappingCreateData::new( + AwsWifIntakeMappingAttributes::new( + "arn:aws:iam::123456789012:role/my-agent-role".to_string(), + ), + AwsWifIntakeMappingType::AWS_WIF_INTAKE_MAPPING, + )); + let configuration = datadog::Configuration::new(); + let api = AWSWIFAPI::with_config(configuration); + let resp = api.create_aws_wif_intake_mapping(body).await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_aws-wif_CreateAwsWifPersonaMapping.rs b/examples/v2_aws-wif_CreateAwsWifPersonaMapping.rs new file mode 100644 index 0000000000..b4de675c9f --- /dev/null +++ b/examples/v2_aws-wif_CreateAwsWifPersonaMapping.rs @@ -0,0 +1,26 @@ +// Create an AWS WIF persona mapping returns "Created" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_awswif::AWSWIFAPI; +use datadog_api_client::datadogV2::model::AwsWifPersonaMappingCreateAttributes; +use datadog_api_client::datadogV2::model::AwsWifPersonaMappingCreateData; +use datadog_api_client::datadogV2::model::AwsWifPersonaMappingCreateRequest; +use datadog_api_client::datadogV2::model::AwsWifPersonaMappingType; + +#[tokio::main] +async fn main() { + let body = AwsWifPersonaMappingCreateRequest::new(AwsWifPersonaMappingCreateData::new( + AwsWifPersonaMappingCreateAttributes::new( + "user@example.com".to_string(), + "arn:aws:iam::123456789012:role/my-workload-role".to_string(), + ), + AwsWifPersonaMappingType::AWS_WIF_CONFIG, + )); + let configuration = datadog::Configuration::new(); + let api = AWSWIFAPI::with_config(configuration); + let resp = api.create_aws_wif_persona_mapping(body).await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_aws-wif_DeleteAwsWifIntakeMapping.rs b/examples/v2_aws-wif_DeleteAwsWifIntakeMapping.rs new file mode 100644 index 0000000000..5a4299523f --- /dev/null +++ b/examples/v2_aws-wif_DeleteAwsWifIntakeMapping.rs @@ -0,0 +1,20 @@ +// Delete an AWS WIF intake mapping returns "No Content" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_awswif::AWSWIFAPI; +use uuid::Uuid; + +#[tokio::main] +async fn main() { + let configuration = datadog::Configuration::new(); + let api = AWSWIFAPI::with_config(configuration); + let resp = api + .delete_aws_wif_intake_mapping( + Uuid::parse_str("00000000-0000-0000-0000-000000000000").expect("invalid UUID"), + ) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_aws-wif_DeleteAwsWifPersonaMapping.rs b/examples/v2_aws-wif_DeleteAwsWifPersonaMapping.rs new file mode 100644 index 0000000000..75f8622c22 --- /dev/null +++ b/examples/v2_aws-wif_DeleteAwsWifPersonaMapping.rs @@ -0,0 +1,20 @@ +// Delete an AWS WIF persona mapping returns "No Content" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_awswif::AWSWIFAPI; +use uuid::Uuid; + +#[tokio::main] +async fn main() { + let configuration = datadog::Configuration::new(); + let api = AWSWIFAPI::with_config(configuration); + let resp = api + .delete_aws_wif_persona_mapping( + Uuid::parse_str("00000000-0000-0000-0000-000000000000").expect("invalid UUID"), + ) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_aws-wif_GetAwsWifIntakeMapping.rs b/examples/v2_aws-wif_GetAwsWifIntakeMapping.rs new file mode 100644 index 0000000000..1a11650dad --- /dev/null +++ b/examples/v2_aws-wif_GetAwsWifIntakeMapping.rs @@ -0,0 +1,20 @@ +// Get an AWS WIF intake mapping returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_awswif::AWSWIFAPI; +use uuid::Uuid; + +#[tokio::main] +async fn main() { + let configuration = datadog::Configuration::new(); + let api = AWSWIFAPI::with_config(configuration); + let resp = api + .get_aws_wif_intake_mapping( + Uuid::parse_str("00000000-0000-0000-0000-000000000000").expect("invalid UUID"), + ) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_aws-wif_GetAwsWifPersonaMapping.rs b/examples/v2_aws-wif_GetAwsWifPersonaMapping.rs new file mode 100644 index 0000000000..bd97cd11ba --- /dev/null +++ b/examples/v2_aws-wif_GetAwsWifPersonaMapping.rs @@ -0,0 +1,20 @@ +// Get an AWS WIF persona mapping returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_awswif::AWSWIFAPI; +use uuid::Uuid; + +#[tokio::main] +async fn main() { + let configuration = datadog::Configuration::new(); + let api = AWSWIFAPI::with_config(configuration); + let resp = api + .get_aws_wif_persona_mapping( + Uuid::parse_str("00000000-0000-0000-0000-000000000000").expect("invalid UUID"), + ) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_aws-wif_ListAwsWifIntakeMappings.rs b/examples/v2_aws-wif_ListAwsWifIntakeMappings.rs new file mode 100644 index 0000000000..f1de6ffc8a --- /dev/null +++ b/examples/v2_aws-wif_ListAwsWifIntakeMappings.rs @@ -0,0 +1,15 @@ +// List AWS WIF intake mappings returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_awswif::AWSWIFAPI; + +#[tokio::main] +async fn main() { + let configuration = datadog::Configuration::new(); + let api = AWSWIFAPI::with_config(configuration); + let resp = api.list_aws_wif_intake_mappings().await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_aws-wif_ListAwsWifPersonaMappings.rs b/examples/v2_aws-wif_ListAwsWifPersonaMappings.rs new file mode 100644 index 0000000000..8ef36717b3 --- /dev/null +++ b/examples/v2_aws-wif_ListAwsWifPersonaMappings.rs @@ -0,0 +1,15 @@ +// List AWS WIF persona mappings returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_awswif::AWSWIFAPI; + +#[tokio::main] +async fn main() { + let configuration = datadog::Configuration::new(); + let api = AWSWIFAPI::with_config(configuration); + let resp = api.list_aws_wif_persona_mappings().await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_delegated-token_GetDelegatedToken.rs b/examples/v2_delegated-token_GetDelegatedToken.rs new file mode 100644 index 0000000000..1d9e22d389 --- /dev/null +++ b/examples/v2_delegated-token_GetDelegatedToken.rs @@ -0,0 +1,15 @@ +// Get a delegated token returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_delegated_token::DelegatedTokenAPI; + +#[tokio::main] +async fn main() { + let configuration = datadog::Configuration::new(); + let api = DelegatedTokenAPI::with_config(configuration); + let resp = api.get_delegated_token().await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_intake-key_GetIntakeKey.rs b/examples/v2_intake-key_GetIntakeKey.rs new file mode 100644 index 0000000000..92113f001a --- /dev/null +++ b/examples/v2_intake-key_GetIntakeKey.rs @@ -0,0 +1,15 @@ +// Get an intake API key returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_intake_key::IntakeKeyAPI; + +#[tokio::main] +async fn main() { + let configuration = datadog::Configuration::new(); + let api = IntakeKeyAPI::with_config(configuration); + let resp = api.get_intake_key().await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/src/datadogV2/api/api_aws_wif.rs b/src/datadogV2/api/api_aws_wif.rs new file mode 100644 index 0000000000..f91ad1eb38 --- /dev/null +++ b/src/datadogV2/api/api_aws_wif.rs @@ -0,0 +1,1094 @@ +// 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. +use crate::datadog; +use flate2::{ + write::{GzEncoder, ZlibEncoder}, + Compression, +}; +use reqwest::header::{HeaderMap, HeaderValue}; +use serde::{Deserialize, Serialize}; +use std::io::Write; + +/// CreateAwsWifIntakeMappingError is a struct for typed errors of method [`AWSWIFAPI::create_aws_wif_intake_mapping`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CreateAwsWifIntakeMappingError { + JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse), + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// CreateAwsWifPersonaMappingError is a struct for typed errors of method [`AWSWIFAPI::create_aws_wif_persona_mapping`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CreateAwsWifPersonaMappingError { + JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse), + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// DeleteAwsWifIntakeMappingError is a struct for typed errors of method [`AWSWIFAPI::delete_aws_wif_intake_mapping`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum DeleteAwsWifIntakeMappingError { + JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse), + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// DeleteAwsWifPersonaMappingError is a struct for typed errors of method [`AWSWIFAPI::delete_aws_wif_persona_mapping`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum DeleteAwsWifPersonaMappingError { + JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse), + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// GetAwsWifIntakeMappingError is a struct for typed errors of method [`AWSWIFAPI::get_aws_wif_intake_mapping`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetAwsWifIntakeMappingError { + JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse), + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// GetAwsWifPersonaMappingError is a struct for typed errors of method [`AWSWIFAPI::get_aws_wif_persona_mapping`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetAwsWifPersonaMappingError { + JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse), + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// ListAwsWifIntakeMappingsError is a struct for typed errors of method [`AWSWIFAPI::list_aws_wif_intake_mappings`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ListAwsWifIntakeMappingsError { + JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse), + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// ListAwsWifPersonaMappingsError is a struct for typed errors of method [`AWSWIFAPI::list_aws_wif_persona_mappings`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ListAwsWifPersonaMappingsError { + JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse), + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// Manage AWS Workload Identity Federation (WIF) mappings. +/// Persona mappings link IAM role ARN patterns to Datadog users for delegated-token authentication. +/// Intake mappings link IAM role ARN patterns to managed-rotation API keys for agent telemetry ingestion. +#[derive(Debug, Clone)] +pub struct AWSWIFAPI { + config: datadog::Configuration, + client: reqwest_middleware::ClientWithMiddleware, +} + +impl Default for AWSWIFAPI { + fn default() -> Self { + Self::with_config(datadog::Configuration::default()) + } +} + +impl AWSWIFAPI { + pub fn new() -> Self { + Self::default() + } + pub fn with_config(config: datadog::Configuration) -> Self { + let reqwest_client_builder = { + let builder = reqwest::Client::builder(); + #[cfg(not(target_arch = "wasm32"))] + let builder = if let Some(proxy_url) = &config.proxy_url { + builder.proxy(reqwest::Proxy::all(proxy_url).expect("Failed to parse proxy URL")) + } else { + builder + }; + builder + }; + + let middleware_client_builder = { + let builder = + reqwest_middleware::ClientBuilder::new(reqwest_client_builder.build().unwrap()); + #[cfg(feature = "retry")] + let builder = if config.enable_retry { + struct RetryableStatus; + impl reqwest_retry::RetryableStrategy for RetryableStatus { + fn handle( + &self, + res: &Result, + ) -> Option { + match res { + Ok(success) => reqwest_retry::default_on_request_success(success), + Err(_) => None, + } + } + } + let backoff_policy = reqwest_retry::policies::ExponentialBackoff::builder() + .build_with_max_retries(config.max_retries); + + let retry_middleware = + reqwest_retry::RetryTransientMiddleware::new_with_policy_and_strategy( + backoff_policy, + RetryableStatus, + ); + + builder.with(retry_middleware) + } else { + builder + }; + builder + }; + + let client = middleware_client_builder.build(); + + Self { config, client } + } + + pub fn with_client_and_config( + config: datadog::Configuration, + client: reqwest_middleware::ClientWithMiddleware, + ) -> Self { + Self { config, client } + } + + /// Create an AWS WIF intake mapping. The mapping binds an IAM role ARN pattern to a managed-rotation API key, allowing AWS workloads to send telemetry to Datadog without requiring a delegated user token. + pub async fn create_aws_wif_intake_mapping( + &self, + body: crate::datadogV2::model::AwsWifIntakeMappingCreateRequest, + ) -> Result< + crate::datadogV2::model::AwsWifIntakeMappingResponse, + datadog::Error, + > { + match self + .create_aws_wif_intake_mapping_with_http_info(body) + .await + { + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(datadog::Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } + Err(err) => Err(err), + } + } + + /// Create an AWS WIF intake mapping. The mapping binds an IAM role ARN pattern to a managed-rotation API key, allowing AWS workloads to send telemetry to Datadog without requiring a delegated user token. + pub async fn create_aws_wif_intake_mapping_with_http_info( + &self, + body: crate::datadogV2::model::AwsWifIntakeMappingCreateRequest, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.create_aws_wif_intake_mapping"; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/wif/aws/intake_mapping", + local_configuration.get_operation_host(operation_id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::POST, local_uri_str.as_str()); + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Content-Type", HeaderValue::from_static("application/json")); + headers.insert("Accept", HeaderValue::from_static("application/json")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + // build body parameters + let output = Vec::new(); + let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter); + if body.serialize(&mut ser).is_ok() { + if let Some(content_encoding) = headers.get("Content-Encoding") { + match content_encoding.to_str().unwrap_or_default() { + "gzip" => { + let mut enc = GzEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + "deflate" => { + let mut enc = ZlibEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + #[cfg(feature = "zstd")] + "zstd1" => { + let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap(); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + _ => { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + } else { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + match serde_json::from_str::( + &local_content, + ) { + Ok(e) => { + return Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: Some(e), + }) + } + Err(e) => return Err(datadog::Error::Serde(e)), + }; + } else { + let local_entity: Option = + serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } + + /// Create an AWS Workload Identity Federation (WIF) persona mapping. The mapping binds an IAM role ARN pattern to a Datadog user handle, which is used to authenticate delegated-token requests from that AWS identity. + pub async fn create_aws_wif_persona_mapping( + &self, + body: crate::datadogV2::model::AwsWifPersonaMappingCreateRequest, + ) -> Result< + crate::datadogV2::model::AwsWifPersonaMappingResponse, + datadog::Error, + > { + match self + .create_aws_wif_persona_mapping_with_http_info(body) + .await + { + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(datadog::Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } + Err(err) => Err(err), + } + } + + /// Create an AWS Workload Identity Federation (WIF) persona mapping. The mapping binds an IAM role ARN pattern to a Datadog user handle, which is used to authenticate delegated-token requests from that AWS identity. + pub async fn create_aws_wif_persona_mapping_with_http_info( + &self, + body: crate::datadogV2::model::AwsWifPersonaMappingCreateRequest, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.create_aws_wif_persona_mapping"; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/wif/aws/persona_mapping", + local_configuration.get_operation_host(operation_id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::POST, local_uri_str.as_str()); + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Content-Type", HeaderValue::from_static("application/json")); + headers.insert("Accept", HeaderValue::from_static("application/json")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + // build body parameters + let output = Vec::new(); + let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter); + if body.serialize(&mut ser).is_ok() { + if let Some(content_encoding) = headers.get("Content-Encoding") { + match content_encoding.to_str().unwrap_or_default() { + "gzip" => { + let mut enc = GzEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + "deflate" => { + let mut enc = ZlibEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + #[cfg(feature = "zstd")] + "zstd1" => { + let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap(); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + _ => { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + } else { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + match serde_json::from_str::( + &local_content, + ) { + Ok(e) => { + return Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: Some(e), + }) + } + Err(e) => return Err(datadog::Error::Serde(e)), + }; + } else { + let local_entity: Option = + serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } + + /// Delete an AWS WIF intake mapping by UUID. The associated managed-rotation API key is left intact, but AWS workloads that previously matched this mapping will lose intake access. + pub async fn delete_aws_wif_intake_mapping( + &self, + config_uuid: uuid::Uuid, + ) -> Result<(), datadog::Error> { + match self + .delete_aws_wif_intake_mapping_with_http_info(config_uuid) + .await + { + Ok(_) => Ok(()), + Err(err) => Err(err), + } + } + + /// Delete an AWS WIF intake mapping by UUID. The associated managed-rotation API key is left intact, but AWS workloads that previously matched this mapping will lose intake access. + pub async fn delete_aws_wif_intake_mapping_with_http_info( + &self, + config_uuid: uuid::Uuid, + ) -> Result, datadog::Error> { + let local_configuration = &self.config; + let operation_id = "v2.delete_aws_wif_intake_mapping"; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/wif/aws/intake_mapping/{config_uuid}", + local_configuration.get_operation_host(operation_id), + config_uuid = datadog::urlencode(config_uuid.to_string()) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::DELETE, local_uri_str.as_str()); + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Accept", HeaderValue::from_static("*/*")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: None, + }) + } else { + let local_entity: Option = + serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } + + /// Delete an AWS WIF persona mapping by UUID. Subsequent delegated-token requests from the previously mapped AWS identity will be denied. + pub async fn delete_aws_wif_persona_mapping( + &self, + config_uuid: uuid::Uuid, + ) -> Result<(), datadog::Error> { + match self + .delete_aws_wif_persona_mapping_with_http_info(config_uuid) + .await + { + Ok(_) => Ok(()), + Err(err) => Err(err), + } + } + + /// Delete an AWS WIF persona mapping by UUID. Subsequent delegated-token requests from the previously mapped AWS identity will be denied. + pub async fn delete_aws_wif_persona_mapping_with_http_info( + &self, + config_uuid: uuid::Uuid, + ) -> Result, datadog::Error> { + let local_configuration = &self.config; + let operation_id = "v2.delete_aws_wif_persona_mapping"; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/wif/aws/persona_mapping/{config_uuid}", + local_configuration.get_operation_host(operation_id), + config_uuid = datadog::urlencode(config_uuid.to_string()) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::DELETE, local_uri_str.as_str()); + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Accept", HeaderValue::from_static("*/*")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: None, + }) + } else { + let local_entity: Option = + serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } + + /// Retrieve a single AWS WIF intake mapping by UUID. + pub async fn get_aws_wif_intake_mapping( + &self, + config_uuid: uuid::Uuid, + ) -> Result< + crate::datadogV2::model::AwsWifIntakeMappingResponse, + datadog::Error, + > { + match self + .get_aws_wif_intake_mapping_with_http_info(config_uuid) + .await + { + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(datadog::Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } + Err(err) => Err(err), + } + } + + /// Retrieve a single AWS WIF intake mapping by UUID. + pub async fn get_aws_wif_intake_mapping_with_http_info( + &self, + config_uuid: uuid::Uuid, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.get_aws_wif_intake_mapping"; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/wif/aws/intake_mapping/{config_uuid}", + local_configuration.get_operation_host(operation_id), + config_uuid = datadog::urlencode(config_uuid.to_string()) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::GET, local_uri_str.as_str()); + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Accept", HeaderValue::from_static("application/json")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + match serde_json::from_str::( + &local_content, + ) { + Ok(e) => { + return Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: Some(e), + }) + } + Err(e) => return Err(datadog::Error::Serde(e)), + }; + } else { + let local_entity: Option = + serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } + + /// Retrieve a single AWS WIF persona mapping by UUID. + pub async fn get_aws_wif_persona_mapping( + &self, + config_uuid: uuid::Uuid, + ) -> Result< + crate::datadogV2::model::AwsWifPersonaMappingResponse, + datadog::Error, + > { + match self + .get_aws_wif_persona_mapping_with_http_info(config_uuid) + .await + { + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(datadog::Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } + Err(err) => Err(err), + } + } + + /// Retrieve a single AWS WIF persona mapping by UUID. + pub async fn get_aws_wif_persona_mapping_with_http_info( + &self, + config_uuid: uuid::Uuid, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.get_aws_wif_persona_mapping"; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/wif/aws/persona_mapping/{config_uuid}", + local_configuration.get_operation_host(operation_id), + config_uuid = datadog::urlencode(config_uuid.to_string()) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::GET, local_uri_str.as_str()); + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Accept", HeaderValue::from_static("application/json")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + match serde_json::from_str::( + &local_content, + ) { + Ok(e) => { + return Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: Some(e), + }) + } + Err(e) => return Err(datadog::Error::Serde(e)), + }; + } else { + let local_entity: Option = + serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } + + /// List every AWS WIF intake mapping configured for the caller's organization. + pub async fn list_aws_wif_intake_mappings( + &self, + ) -> Result< + crate::datadogV2::model::AwsWifIntakeMappingsResponse, + datadog::Error, + > { + match self.list_aws_wif_intake_mappings_with_http_info().await { + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(datadog::Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } + Err(err) => Err(err), + } + } + + /// List every AWS WIF intake mapping configured for the caller's organization. + pub async fn list_aws_wif_intake_mappings_with_http_info( + &self, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.list_aws_wif_intake_mappings"; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/wif/aws/intake_mapping", + local_configuration.get_operation_host(operation_id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::GET, local_uri_str.as_str()); + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Accept", HeaderValue::from_static("application/json")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + match serde_json::from_str::( + &local_content, + ) { + Ok(e) => { + return Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: Some(e), + }) + } + Err(e) => return Err(datadog::Error::Serde(e)), + }; + } else { + let local_entity: Option = + serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } + + /// List every AWS WIF persona mapping configured for the caller's organization. + pub async fn list_aws_wif_persona_mappings( + &self, + ) -> Result< + crate::datadogV2::model::AwsWifPersonaMappingsResponse, + datadog::Error, + > { + match self.list_aws_wif_persona_mappings_with_http_info().await { + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(datadog::Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } + Err(err) => Err(err), + } + } + + /// List every AWS WIF persona mapping configured for the caller's organization. + pub async fn list_aws_wif_persona_mappings_with_http_info( + &self, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.list_aws_wif_persona_mappings"; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/wif/aws/persona_mapping", + local_configuration.get_operation_host(operation_id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::GET, local_uri_str.as_str()); + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Accept", HeaderValue::from_static("application/json")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + match serde_json::from_str::( + &local_content, + ) { + Ok(e) => { + return Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: Some(e), + }) + } + Err(e) => return Err(datadog::Error::Serde(e)), + }; + } else { + let local_entity: Option = + serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } +} diff --git a/src/datadogV2/api/api_delegated_token.rs b/src/datadogV2/api/api_delegated_token.rs new file mode 100644 index 0000000000..9a9de60095 --- /dev/null +++ b/src/datadogV2/api/api_delegated_token.rs @@ -0,0 +1,201 @@ +// 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. +use crate::datadog; +use reqwest::header::{HeaderMap, HeaderValue}; +use serde::{Deserialize, Serialize}; + +/// GetDelegatedTokenError is a struct for typed errors of method [`DelegatedTokenAPI::get_delegated_token`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetDelegatedTokenError { + JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse), + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// Exchange a cloud-provider identity proof or Datadog credential for a short-lived delegated-user JWT +/// via Workload Identity Federation. +#[derive(Debug, Clone)] +pub struct DelegatedTokenAPI { + config: datadog::Configuration, + client: reqwest_middleware::ClientWithMiddleware, +} + +impl Default for DelegatedTokenAPI { + fn default() -> Self { + Self::with_config(datadog::Configuration::default()) + } +} + +impl DelegatedTokenAPI { + pub fn new() -> Self { + Self::default() + } + pub fn with_config(config: datadog::Configuration) -> Self { + let reqwest_client_builder = { + let builder = reqwest::Client::builder(); + #[cfg(not(target_arch = "wasm32"))] + let builder = if let Some(proxy_url) = &config.proxy_url { + builder.proxy(reqwest::Proxy::all(proxy_url).expect("Failed to parse proxy URL")) + } else { + builder + }; + builder + }; + + let middleware_client_builder = { + let builder = + reqwest_middleware::ClientBuilder::new(reqwest_client_builder.build().unwrap()); + #[cfg(feature = "retry")] + let builder = if config.enable_retry { + struct RetryableStatus; + impl reqwest_retry::RetryableStrategy for RetryableStatus { + fn handle( + &self, + res: &Result, + ) -> Option { + match res { + Ok(success) => reqwest_retry::default_on_request_success(success), + Err(_) => None, + } + } + } + let backoff_policy = reqwest_retry::policies::ExponentialBackoff::builder() + .build_with_max_retries(config.max_retries); + + let retry_middleware = + reqwest_retry::RetryTransientMiddleware::new_with_policy_and_strategy( + backoff_policy, + RetryableStatus, + ); + + builder.with(retry_middleware) + } else { + builder + }; + builder + }; + + let client = middleware_client_builder.build(); + + Self { config, client } + } + + pub fn with_client_and_config( + config: datadog::Configuration, + client: reqwest_middleware::ClientWithMiddleware, + ) -> Self { + Self { config, client } + } + + /// Exchange a Workload Identity Federation (WIF) proof or Datadog credentials for a short-lived access token + /// scoped to a Datadog user. + /// + /// To authenticate with a WIF identity, pass the cloud-provider token in the `Authorization` header using + /// the `Bearer` or `Delegated` scheme. Datadog resolves the Datadog user from the persona mapping configured + /// for that cloud identity. + /// + /// To obtain a token for the calling user directly, authenticate with standard Datadog API and application keys. + /// + /// Use the returned `access_token` as a bearer token in subsequent API calls. + pub async fn get_delegated_token( + &self, + ) -> Result< + crate::datadogV2::model::DelegatedTokenResponse, + datadog::Error, + > { + match self.get_delegated_token_with_http_info().await { + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(datadog::Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } + Err(err) => Err(err), + } + } + + /// Exchange a Workload Identity Federation (WIF) proof or Datadog credentials for a short-lived access token + /// scoped to a Datadog user. + /// + /// To authenticate with a WIF identity, pass the cloud-provider token in the `Authorization` header using + /// the `Bearer` or `Delegated` scheme. Datadog resolves the Datadog user from the persona mapping configured + /// for that cloud identity. + /// + /// To obtain a token for the calling user directly, authenticate with standard Datadog API and application keys. + /// + /// Use the returned `access_token` as a bearer token in subsequent API calls. + pub async fn get_delegated_token_with_http_info( + &self, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.get_delegated_token"; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/delegated-token", + local_configuration.get_operation_host(operation_id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::POST, local_uri_str.as_str()); + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Accept", HeaderValue::from_static("application/json")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + match serde_json::from_str::( + &local_content, + ) { + Ok(e) => { + return Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: Some(e), + }) + } + Err(e) => return Err(datadog::Error::Serde(e)), + }; + } else { + let local_entity: Option = + serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } +} diff --git a/src/datadogV2/api/api_intake_key.rs b/src/datadogV2/api/api_intake_key.rs new file mode 100644 index 0000000000..86218527b4 --- /dev/null +++ b/src/datadogV2/api/api_intake_key.rs @@ -0,0 +1,199 @@ +// 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. +use crate::datadog; +use reqwest::header::{HeaderMap, HeaderValue}; +use serde::{Deserialize, Serialize}; + +/// GetIntakeKeyError is a struct for typed errors of method [`IntakeKeyAPI::get_intake_key`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetIntakeKeyError { + JSONAPIErrorResponse(crate::datadogV2::model::JSONAPIErrorResponse), + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// Exchange a cloud-provider identity proof for a Datadog API key via Workload Identity Federation intake mappings. +#[derive(Debug, Clone)] +pub struct IntakeKeyAPI { + config: datadog::Configuration, + client: reqwest_middleware::ClientWithMiddleware, +} + +impl Default for IntakeKeyAPI { + fn default() -> Self { + Self::with_config(datadog::Configuration::default()) + } +} + +impl IntakeKeyAPI { + pub fn new() -> Self { + Self::default() + } + pub fn with_config(config: datadog::Configuration) -> Self { + let reqwest_client_builder = { + let builder = reqwest::Client::builder(); + #[cfg(not(target_arch = "wasm32"))] + let builder = if let Some(proxy_url) = &config.proxy_url { + builder.proxy(reqwest::Proxy::all(proxy_url).expect("Failed to parse proxy URL")) + } else { + builder + }; + builder + }; + + let middleware_client_builder = { + let builder = + reqwest_middleware::ClientBuilder::new(reqwest_client_builder.build().unwrap()); + #[cfg(feature = "retry")] + let builder = if config.enable_retry { + struct RetryableStatus; + impl reqwest_retry::RetryableStrategy for RetryableStatus { + fn handle( + &self, + res: &Result, + ) -> Option { + match res { + Ok(success) => reqwest_retry::default_on_request_success(success), + Err(_) => None, + } + } + } + let backoff_policy = reqwest_retry::policies::ExponentialBackoff::builder() + .build_with_max_retries(config.max_retries); + + let retry_middleware = + reqwest_retry::RetryTransientMiddleware::new_with_policy_and_strategy( + backoff_policy, + RetryableStatus, + ); + + builder.with(retry_middleware) + } else { + builder + }; + builder + }; + + let client = middleware_client_builder.build(); + + Self { config, client } + } + + pub fn with_client_and_config( + config: datadog::Configuration, + client: reqwest_middleware::ClientWithMiddleware, + ) -> Self { + Self { config, client } + } + + /// Exchanges a Workload Identity Federation (WIF) identity proof for a Datadog API key associated with the matching WIF intake mapping. + /// + /// Pass a cloud-provider token in the `Authorization` header using the `Bearer` or `Delegated` scheme. + /// The token is validated against the WIF intake mappings configured for the caller's organization. On success, + /// a managed-rotation API key is returned that the workload can use to send telemetry to Datadog. + /// + /// Unlike the delegated-token endpoint (`POST /api/v2/delegated-token`), this endpoint authenticates + /// the cloud workload at the organization level rather than mapping it to a specific Datadog user. + /// + /// Standard Datadog API and application key authentication is not accepted. Authenticate using a + /// cloud-provider token in the `Authorization: Bearer` header. + pub async fn get_intake_key( + &self, + ) -> Result> + { + match self.get_intake_key_with_http_info().await { + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(datadog::Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } + Err(err) => Err(err), + } + } + + /// Exchanges a Workload Identity Federation (WIF) identity proof for a Datadog API key associated with the matching WIF intake mapping. + /// + /// Pass a cloud-provider token in the `Authorization` header using the `Bearer` or `Delegated` scheme. + /// The token is validated against the WIF intake mappings configured for the caller's organization. On success, + /// a managed-rotation API key is returned that the workload can use to send telemetry to Datadog. + /// + /// Unlike the delegated-token endpoint (`POST /api/v2/delegated-token`), this endpoint authenticates + /// the cloud workload at the organization level rather than mapping it to a specific Datadog user. + /// + /// Standard Datadog API and application key authentication is not accepted. Authenticate using a + /// cloud-provider token in the `Authorization: Bearer` header. + pub async fn get_intake_key_with_http_info( + &self, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.get_intake_key"; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/intake-key", + local_configuration.get_operation_host(operation_id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::POST, local_uri_str.as_str()); + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Accept", HeaderValue::from_static("application/json")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + match serde_json::from_str::( + &local_content, + ) { + Ok(e) => { + return Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: Some(e), + }) + } + Err(e) => return Err(datadog::Error::Serde(e)), + }; + } else { + let local_entity: Option = serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } +} diff --git a/src/datadogV2/api/mod.rs b/src/datadogV2/api/mod.rs index 35d86a1bcf..cf4305beb2 100644 --- a/src/datadogV2/api/mod.rs +++ b/src/datadogV2/api/mod.rs @@ -16,6 +16,7 @@ pub mod api_audit; pub mod api_authn_mappings; pub mod api_aws_integration; pub mod api_aws_logs_integration; +pub mod api_aws_wif; pub mod api_bits_ai; pub mod api_case_management; pub mod api_case_management_attribute; @@ -45,6 +46,7 @@ pub mod api_dashboards; pub mod api_data_deletion; pub mod api_data_observability; pub mod api_datasets; +pub mod api_delegated_token; pub mod api_deployment_gates; pub mod api_domain_allowlist; pub mod api_dora_metrics; @@ -62,6 +64,7 @@ pub mod api_google_chat_integration; pub mod api_governance_insights; pub mod api_high_availability_multi_region; pub mod api_incidents; +pub mod api_intake_key; pub mod api_integrations; pub mod api_ip_allowlist; pub mod api_jira_integration; diff --git a/src/datadogV2/mod.rs b/src/datadogV2/mod.rs index 6f0e57e313..60d1bd8c65 100644 --- a/src/datadogV2/mod.rs +++ b/src/datadogV2/mod.rs @@ -17,6 +17,7 @@ pub use self::api::api_audit; pub use self::api::api_authn_mappings; pub use self::api::api_aws_integration; pub use self::api::api_aws_logs_integration; +pub use self::api::api_aws_wif; pub use self::api::api_bits_ai; pub use self::api::api_case_management; pub use self::api::api_case_management_attribute; @@ -46,6 +47,7 @@ pub use self::api::api_dashboards; pub use self::api::api_data_deletion; pub use self::api::api_data_observability; pub use self::api::api_datasets; +pub use self::api::api_delegated_token; pub use self::api::api_deployment_gates; pub use self::api::api_domain_allowlist; pub use self::api::api_dora_metrics; @@ -63,6 +65,7 @@ pub use self::api::api_google_chat_integration; pub use self::api::api_governance_insights; pub use self::api::api_high_availability_multi_region; pub use self::api::api_incidents; +pub use self::api::api_intake_key; pub use self::api::api_integrations; pub use self::api::api_ip_allowlist; pub use self::api::api_jira_integration; diff --git a/src/datadogV2/model/mod.rs b/src/datadogV2/model/mod.rs index 7665fe017b..0c0da65234 100644 --- a/src/datadogV2/model/mod.rs +++ b/src/datadogV2/model/mod.rs @@ -3414,6 +3414,14 @@ pub mod model_dataset_response_single; pub use self::model_dataset_response_single::DatasetResponseSingle; pub mod model_dataset_update_request; pub use self::model_dataset_update_request::DatasetUpdateRequest; +pub mod model_delegated_token_response; +pub use self::model_delegated_token_response::DelegatedTokenResponse; +pub mod model_delegated_token_data; +pub use self::model_delegated_token_data::DelegatedTokenData; +pub mod model_delegated_token_attributes; +pub use self::model_delegated_token_attributes::DelegatedTokenAttributes; +pub mod model_delegated_token_type; +pub use self::model_delegated_token_type::DelegatedTokenType; pub mod model_create_data_deletion_request_body; pub use self::model_create_data_deletion_request_body::CreateDataDeletionRequestBody; pub mod model_create_data_deletion_request_body_data; @@ -4744,6 +4752,14 @@ pub mod model_incident_todo_patch_request; pub use self::model_incident_todo_patch_request::IncidentTodoPatchRequest; pub mod model_incident_todo_patch_data; pub use self::model_incident_todo_patch_data::IncidentTodoPatchData; +pub mod model_intake_api_key_response; +pub use self::model_intake_api_key_response::IntakeAPIKeyResponse; +pub mod model_intake_api_key_data; +pub use self::model_intake_api_key_data::IntakeAPIKeyData; +pub mod model_intake_api_key_attributes; +pub use self::model_intake_api_key_attributes::IntakeAPIKeyAttributes; +pub mod model_intake_api_key_type; +pub use self::model_intake_api_key_type::IntakeAPIKeyType; pub mod model_aws_accounts_response; pub use self::model_aws_accounts_response::AWSAccountsResponse; pub mod model_aws_account_response_data; @@ -12928,6 +12944,36 @@ pub mod model_create_or_update_widget_request_attributes; pub use self::model_create_or_update_widget_request_attributes::CreateOrUpdateWidgetRequestAttributes; pub mod model_widget_response; pub use self::model_widget_response::WidgetResponse; +pub mod model_aws_wif_intake_mappings_response; +pub use self::model_aws_wif_intake_mappings_response::AwsWifIntakeMappingsResponse; +pub mod model_aws_wif_intake_mapping_data; +pub use self::model_aws_wif_intake_mapping_data::AwsWifIntakeMappingData; +pub mod model_aws_wif_intake_mapping_attributes; +pub use self::model_aws_wif_intake_mapping_attributes::AwsWifIntakeMappingAttributes; +pub mod model_aws_wif_intake_mapping_type; +pub use self::model_aws_wif_intake_mapping_type::AwsWifIntakeMappingType; +pub mod model_aws_wif_intake_mapping_create_request; +pub use self::model_aws_wif_intake_mapping_create_request::AwsWifIntakeMappingCreateRequest; +pub mod model_aws_wif_intake_mapping_create_data; +pub use self::model_aws_wif_intake_mapping_create_data::AwsWifIntakeMappingCreateData; +pub mod model_aws_wif_intake_mapping_response; +pub use self::model_aws_wif_intake_mapping_response::AwsWifIntakeMappingResponse; +pub mod model_aws_wif_persona_mappings_response; +pub use self::model_aws_wif_persona_mappings_response::AwsWifPersonaMappingsResponse; +pub mod model_aws_wif_persona_mapping_data; +pub use self::model_aws_wif_persona_mapping_data::AwsWifPersonaMappingData; +pub mod model_aws_wif_persona_mapping_attributes; +pub use self::model_aws_wif_persona_mapping_attributes::AwsWifPersonaMappingAttributes; +pub mod model_aws_wif_persona_mapping_type; +pub use self::model_aws_wif_persona_mapping_type::AwsWifPersonaMappingType; +pub mod model_aws_wif_persona_mapping_create_request; +pub use self::model_aws_wif_persona_mapping_create_request::AwsWifPersonaMappingCreateRequest; +pub mod model_aws_wif_persona_mapping_create_data; +pub use self::model_aws_wif_persona_mapping_create_data::AwsWifPersonaMappingCreateData; +pub mod model_aws_wif_persona_mapping_create_attributes; +pub use self::model_aws_wif_persona_mapping_create_attributes::AwsWifPersonaMappingCreateAttributes; +pub mod model_aws_wif_persona_mapping_response; +pub use self::model_aws_wif_persona_mapping_response::AwsWifPersonaMappingResponse; pub mod model_list_workflows_response; pub use self::model_list_workflows_response::ListWorkflowsResponse; pub mod model_workflow_list_item; diff --git a/src/datadogV2/model/model_aws_wif_intake_mapping_attributes.rs b/src/datadogV2/model/model_aws_wif_intake_mapping_attributes.rs new file mode 100644 index 0000000000..3d8354da49 --- /dev/null +++ b/src/datadogV2/model/model_aws_wif_intake_mapping_attributes.rs @@ -0,0 +1,95 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Attributes of an AWS WIF intake mapping. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct AwsWifIntakeMappingAttributes { + /// The AWS IAM ARN pattern identifying the role or user permitted to obtain an intake API key. + /// Supports wildcards (`*`) to match multiple principals within an account. + #[serde(rename = "arn_pattern")] + pub arn_pattern: String, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl AwsWifIntakeMappingAttributes { + pub fn new(arn_pattern: String) -> AwsWifIntakeMappingAttributes { + AwsWifIntakeMappingAttributes { + arn_pattern, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for AwsWifIntakeMappingAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct AwsWifIntakeMappingAttributesVisitor; + impl<'a> Visitor<'a> for AwsWifIntakeMappingAttributesVisitor { + type Value = AwsWifIntakeMappingAttributes; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut arn_pattern: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "arn_pattern" => { + arn_pattern = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let arn_pattern = + arn_pattern.ok_or_else(|| M::Error::missing_field("arn_pattern"))?; + + let content = AwsWifIntakeMappingAttributes { + arn_pattern, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(AwsWifIntakeMappingAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_aws_wif_intake_mapping_create_data.rs b/src/datadogV2/model/model_aws_wif_intake_mapping_create_data.rs new file mode 100644 index 0000000000..29dd62f2ac --- /dev/null +++ b/src/datadogV2/model/model_aws_wif_intake_mapping_create_data.rs @@ -0,0 +1,114 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Data for creating an AWS WIF intake mapping. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct AwsWifIntakeMappingCreateData { + /// Attributes of an AWS WIF intake mapping. + #[serde(rename = "attributes")] + pub attributes: crate::datadogV2::model::AwsWifIntakeMappingAttributes, + /// Type identifier for an AWS WIF intake mapping. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::AwsWifIntakeMappingType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl AwsWifIntakeMappingCreateData { + pub fn new( + attributes: crate::datadogV2::model::AwsWifIntakeMappingAttributes, + type_: crate::datadogV2::model::AwsWifIntakeMappingType, + ) -> AwsWifIntakeMappingCreateData { + AwsWifIntakeMappingCreateData { + attributes, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for AwsWifIntakeMappingCreateData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct AwsWifIntakeMappingCreateDataVisitor; + impl<'a> Visitor<'a> for AwsWifIntakeMappingCreateDataVisitor { + type Value = AwsWifIntakeMappingCreateData; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut attributes: Option = + None; + let mut type_: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "attributes" => { + attributes = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::AwsWifIntakeMappingType::UnparsedObject(_type_) => { + _unparsed = true; + }, + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let attributes = attributes.ok_or_else(|| M::Error::missing_field("attributes"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = AwsWifIntakeMappingCreateData { + attributes, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(AwsWifIntakeMappingCreateDataVisitor) + } +} diff --git a/src/datadogV2/model/model_aws_wif_intake_mapping_create_request.rs b/src/datadogV2/model/model_aws_wif_intake_mapping_create_request.rs new file mode 100644 index 0000000000..a00ba88557 --- /dev/null +++ b/src/datadogV2/model/model_aws_wif_intake_mapping_create_request.rs @@ -0,0 +1,94 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Request body for creating an AWS WIF intake mapping. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct AwsWifIntakeMappingCreateRequest { + /// Data for creating an AWS WIF intake mapping. + #[serde(rename = "data")] + pub data: crate::datadogV2::model::AwsWifIntakeMappingCreateData, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl AwsWifIntakeMappingCreateRequest { + pub fn new( + data: crate::datadogV2::model::AwsWifIntakeMappingCreateData, + ) -> AwsWifIntakeMappingCreateRequest { + AwsWifIntakeMappingCreateRequest { + data, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for AwsWifIntakeMappingCreateRequest { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct AwsWifIntakeMappingCreateRequestVisitor; + impl<'a> Visitor<'a> for AwsWifIntakeMappingCreateRequestVisitor { + type Value = AwsWifIntakeMappingCreateRequest; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "data" => { + data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let data = data.ok_or_else(|| M::Error::missing_field("data"))?; + + let content = AwsWifIntakeMappingCreateRequest { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(AwsWifIntakeMappingCreateRequestVisitor) + } +} diff --git a/src/datadogV2/model/model_aws_wif_intake_mapping_data.rs b/src/datadogV2/model/model_aws_wif_intake_mapping_data.rs new file mode 100644 index 0000000000..a5df46027f --- /dev/null +++ b/src/datadogV2/model/model_aws_wif_intake_mapping_data.rs @@ -0,0 +1,125 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// An AWS WIF intake mapping resource. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct AwsWifIntakeMappingData { + /// Attributes of an AWS WIF intake mapping. + #[serde(rename = "attributes")] + pub attributes: crate::datadogV2::model::AwsWifIntakeMappingAttributes, + /// The UUID of the intake mapping. + #[serde(rename = "id")] + pub id: uuid::Uuid, + /// Type identifier for an AWS WIF intake mapping. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::AwsWifIntakeMappingType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl AwsWifIntakeMappingData { + pub fn new( + attributes: crate::datadogV2::model::AwsWifIntakeMappingAttributes, + id: uuid::Uuid, + type_: crate::datadogV2::model::AwsWifIntakeMappingType, + ) -> AwsWifIntakeMappingData { + AwsWifIntakeMappingData { + attributes, + id, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for AwsWifIntakeMappingData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct AwsWifIntakeMappingDataVisitor; + impl<'a> Visitor<'a> for AwsWifIntakeMappingDataVisitor { + type Value = AwsWifIntakeMappingData; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut attributes: Option = + None; + let mut id: Option = None; + let mut type_: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "attributes" => { + attributes = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "id" => { + id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::AwsWifIntakeMappingType::UnparsedObject(_type_) => { + _unparsed = true; + }, + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let attributes = attributes.ok_or_else(|| M::Error::missing_field("attributes"))?; + let id = id.ok_or_else(|| M::Error::missing_field("id"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = AwsWifIntakeMappingData { + attributes, + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(AwsWifIntakeMappingDataVisitor) + } +} diff --git a/src/datadogV2/model/model_aws_wif_intake_mapping_response.rs b/src/datadogV2/model/model_aws_wif_intake_mapping_response.rs new file mode 100644 index 0000000000..217b4ec381 --- /dev/null +++ b/src/datadogV2/model/model_aws_wif_intake_mapping_response.rs @@ -0,0 +1,94 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Response containing a single AWS WIF intake mapping. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct AwsWifIntakeMappingResponse { + /// An AWS WIF intake mapping resource. + #[serde(rename = "data")] + pub data: crate::datadogV2::model::AwsWifIntakeMappingData, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl AwsWifIntakeMappingResponse { + pub fn new( + data: crate::datadogV2::model::AwsWifIntakeMappingData, + ) -> AwsWifIntakeMappingResponse { + AwsWifIntakeMappingResponse { + data, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for AwsWifIntakeMappingResponse { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct AwsWifIntakeMappingResponseVisitor; + impl<'a> Visitor<'a> for AwsWifIntakeMappingResponseVisitor { + type Value = AwsWifIntakeMappingResponse; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "data" => { + data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let data = data.ok_or_else(|| M::Error::missing_field("data"))?; + + let content = AwsWifIntakeMappingResponse { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(AwsWifIntakeMappingResponseVisitor) + } +} diff --git a/src/datadogV2/model/model_aws_wif_intake_mapping_type.rs b/src/datadogV2/model/model_aws_wif_intake_mapping_type.rs new file mode 100644 index 0000000000..6da0ad3232 --- /dev/null +++ b/src/datadogV2/model/model_aws_wif_intake_mapping_type.rs @@ -0,0 +1,48 @@ +// 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. + +use serde::{Deserialize, Deserializer, Serialize, Serializer}; + +#[non_exhaustive] +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum AwsWifIntakeMappingType { + AWS_WIF_INTAKE_MAPPING, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for AwsWifIntakeMappingType { + fn to_string(&self) -> String { + match self { + Self::AWS_WIF_INTAKE_MAPPING => String::from("aws_wif_intake_mapping"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for AwsWifIntakeMappingType { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match self { + Self::UnparsedObject(v) => v.serialize(serializer), + _ => serializer.serialize_str(self.to_string().as_str()), + } + } +} + +impl<'de> Deserialize<'de> for AwsWifIntakeMappingType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "aws_wif_intake_mapping" => Self::AWS_WIF_INTAKE_MAPPING, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_aws_wif_intake_mappings_response.rs b/src/datadogV2/model/model_aws_wif_intake_mappings_response.rs new file mode 100644 index 0000000000..7feb8baef6 --- /dev/null +++ b/src/datadogV2/model/model_aws_wif_intake_mappings_response.rs @@ -0,0 +1,93 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Response containing a list of AWS WIF intake mappings. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct AwsWifIntakeMappingsResponse { + #[serde(rename = "data")] + pub data: Vec, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl AwsWifIntakeMappingsResponse { + pub fn new( + data: Vec, + ) -> AwsWifIntakeMappingsResponse { + AwsWifIntakeMappingsResponse { + data, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for AwsWifIntakeMappingsResponse { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct AwsWifIntakeMappingsResponseVisitor; + impl<'a> Visitor<'a> for AwsWifIntakeMappingsResponseVisitor { + type Value = AwsWifIntakeMappingsResponse; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data: Option> = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "data" => { + data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let data = data.ok_or_else(|| M::Error::missing_field("data"))?; + + let content = AwsWifIntakeMappingsResponse { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(AwsWifIntakeMappingsResponseVisitor) + } +} diff --git a/src/datadogV2/model/model_aws_wif_persona_mapping_attributes.rs b/src/datadogV2/model/model_aws_wif_persona_mapping_attributes.rs new file mode 100644 index 0000000000..03c8c13ee2 --- /dev/null +++ b/src/datadogV2/model/model_aws_wif_persona_mapping_attributes.rs @@ -0,0 +1,125 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Attributes of an AWS WIF persona mapping. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct AwsWifPersonaMappingAttributes { + /// The Datadog user handle (email address) to map the AWS principal to. + #[serde(rename = "account_identifier")] + pub account_identifier: String, + /// The Datadog user UUID corresponding to `account_identifier`. Read-only — set by the server. + #[serde(rename = "account_uuid")] + pub account_uuid: Option, + /// The AWS IAM ARN pattern identifying the role or user that will be mapped. + /// Supports wildcards (`*`) to match multiple principals within an account. + #[serde(rename = "arn_pattern")] + pub arn_pattern: String, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl AwsWifPersonaMappingAttributes { + pub fn new(account_identifier: String, arn_pattern: String) -> AwsWifPersonaMappingAttributes { + AwsWifPersonaMappingAttributes { + account_identifier, + account_uuid: None, + arn_pattern, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn account_uuid(mut self, value: uuid::Uuid) -> Self { + self.account_uuid = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for AwsWifPersonaMappingAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct AwsWifPersonaMappingAttributesVisitor; + impl<'a> Visitor<'a> for AwsWifPersonaMappingAttributesVisitor { + type Value = AwsWifPersonaMappingAttributes; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut account_identifier: Option = None; + let mut account_uuid: Option = None; + let mut arn_pattern: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "account_identifier" => { + account_identifier = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "account_uuid" => { + if v.is_null() { + continue; + } + account_uuid = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "arn_pattern" => { + arn_pattern = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let account_identifier = account_identifier + .ok_or_else(|| M::Error::missing_field("account_identifier"))?; + let arn_pattern = + arn_pattern.ok_or_else(|| M::Error::missing_field("arn_pattern"))?; + + let content = AwsWifPersonaMappingAttributes { + account_identifier, + account_uuid, + arn_pattern, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(AwsWifPersonaMappingAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_aws_wif_persona_mapping_create_attributes.rs b/src/datadogV2/model/model_aws_wif_persona_mapping_create_attributes.rs new file mode 100644 index 0000000000..7fc3e6bb19 --- /dev/null +++ b/src/datadogV2/model/model_aws_wif_persona_mapping_create_attributes.rs @@ -0,0 +1,110 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Attributes for creating an AWS WIF persona mapping. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct AwsWifPersonaMappingCreateAttributes { + /// The Datadog user handle (email address) to map the AWS principal to. + #[serde(rename = "account_identifier")] + pub account_identifier: String, + /// The AWS IAM ARN pattern identifying the role or user that will be mapped. + /// Supports wildcards (`*`) to match multiple principals within an account. + #[serde(rename = "arn_pattern")] + pub arn_pattern: String, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl AwsWifPersonaMappingCreateAttributes { + pub fn new( + account_identifier: String, + arn_pattern: String, + ) -> AwsWifPersonaMappingCreateAttributes { + AwsWifPersonaMappingCreateAttributes { + account_identifier, + arn_pattern, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for AwsWifPersonaMappingCreateAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct AwsWifPersonaMappingCreateAttributesVisitor; + impl<'a> Visitor<'a> for AwsWifPersonaMappingCreateAttributesVisitor { + type Value = AwsWifPersonaMappingCreateAttributes; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut account_identifier: Option = None; + let mut arn_pattern: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "account_identifier" => { + account_identifier = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "arn_pattern" => { + arn_pattern = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let account_identifier = account_identifier + .ok_or_else(|| M::Error::missing_field("account_identifier"))?; + let arn_pattern = + arn_pattern.ok_or_else(|| M::Error::missing_field("arn_pattern"))?; + + let content = AwsWifPersonaMappingCreateAttributes { + account_identifier, + arn_pattern, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(AwsWifPersonaMappingCreateAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_aws_wif_persona_mapping_create_data.rs b/src/datadogV2/model/model_aws_wif_persona_mapping_create_data.rs new file mode 100644 index 0000000000..fdfd0c6882 --- /dev/null +++ b/src/datadogV2/model/model_aws_wif_persona_mapping_create_data.rs @@ -0,0 +1,115 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Data for creating an AWS WIF persona mapping. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct AwsWifPersonaMappingCreateData { + /// Attributes for creating an AWS WIF persona mapping. + #[serde(rename = "attributes")] + pub attributes: crate::datadogV2::model::AwsWifPersonaMappingCreateAttributes, + /// Type identifier for an AWS WIF persona mapping. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::AwsWifPersonaMappingType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl AwsWifPersonaMappingCreateData { + pub fn new( + attributes: crate::datadogV2::model::AwsWifPersonaMappingCreateAttributes, + type_: crate::datadogV2::model::AwsWifPersonaMappingType, + ) -> AwsWifPersonaMappingCreateData { + AwsWifPersonaMappingCreateData { + attributes, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for AwsWifPersonaMappingCreateData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct AwsWifPersonaMappingCreateDataVisitor; + impl<'a> Visitor<'a> for AwsWifPersonaMappingCreateDataVisitor { + type Value = AwsWifPersonaMappingCreateData; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut attributes: Option< + crate::datadogV2::model::AwsWifPersonaMappingCreateAttributes, + > = None; + let mut type_: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "attributes" => { + attributes = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::AwsWifPersonaMappingType::UnparsedObject(_type_) => { + _unparsed = true; + }, + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let attributes = attributes.ok_or_else(|| M::Error::missing_field("attributes"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = AwsWifPersonaMappingCreateData { + attributes, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(AwsWifPersonaMappingCreateDataVisitor) + } +} diff --git a/src/datadogV2/model/model_aws_wif_persona_mapping_create_request.rs b/src/datadogV2/model/model_aws_wif_persona_mapping_create_request.rs new file mode 100644 index 0000000000..61b800f6c5 --- /dev/null +++ b/src/datadogV2/model/model_aws_wif_persona_mapping_create_request.rs @@ -0,0 +1,95 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Request body for creating an AWS WIF persona mapping. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct AwsWifPersonaMappingCreateRequest { + /// Data for creating an AWS WIF persona mapping. + #[serde(rename = "data")] + pub data: crate::datadogV2::model::AwsWifPersonaMappingCreateData, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl AwsWifPersonaMappingCreateRequest { + pub fn new( + data: crate::datadogV2::model::AwsWifPersonaMappingCreateData, + ) -> AwsWifPersonaMappingCreateRequest { + AwsWifPersonaMappingCreateRequest { + data, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for AwsWifPersonaMappingCreateRequest { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct AwsWifPersonaMappingCreateRequestVisitor; + impl<'a> Visitor<'a> for AwsWifPersonaMappingCreateRequestVisitor { + type Value = AwsWifPersonaMappingCreateRequest; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data: Option = + None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "data" => { + data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let data = data.ok_or_else(|| M::Error::missing_field("data"))?; + + let content = AwsWifPersonaMappingCreateRequest { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(AwsWifPersonaMappingCreateRequestVisitor) + } +} diff --git a/src/datadogV2/model/model_aws_wif_persona_mapping_data.rs b/src/datadogV2/model/model_aws_wif_persona_mapping_data.rs new file mode 100644 index 0000000000..4d989a05df --- /dev/null +++ b/src/datadogV2/model/model_aws_wif_persona_mapping_data.rs @@ -0,0 +1,126 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// An AWS WIF persona mapping resource. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct AwsWifPersonaMappingData { + /// Attributes of an AWS WIF persona mapping. + #[serde(rename = "attributes")] + pub attributes: crate::datadogV2::model::AwsWifPersonaMappingAttributes, + /// The UUID of the persona mapping. + #[serde(rename = "id")] + pub id: uuid::Uuid, + /// Type identifier for an AWS WIF persona mapping. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::AwsWifPersonaMappingType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl AwsWifPersonaMappingData { + pub fn new( + attributes: crate::datadogV2::model::AwsWifPersonaMappingAttributes, + id: uuid::Uuid, + type_: crate::datadogV2::model::AwsWifPersonaMappingType, + ) -> AwsWifPersonaMappingData { + AwsWifPersonaMappingData { + attributes, + id, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for AwsWifPersonaMappingData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct AwsWifPersonaMappingDataVisitor; + impl<'a> Visitor<'a> for AwsWifPersonaMappingDataVisitor { + type Value = AwsWifPersonaMappingData; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut attributes: Option< + crate::datadogV2::model::AwsWifPersonaMappingAttributes, + > = None; + let mut id: Option = None; + let mut type_: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "attributes" => { + attributes = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "id" => { + id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::AwsWifPersonaMappingType::UnparsedObject(_type_) => { + _unparsed = true; + }, + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let attributes = attributes.ok_or_else(|| M::Error::missing_field("attributes"))?; + let id = id.ok_or_else(|| M::Error::missing_field("id"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = AwsWifPersonaMappingData { + attributes, + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(AwsWifPersonaMappingDataVisitor) + } +} diff --git a/src/datadogV2/model/model_aws_wif_persona_mapping_response.rs b/src/datadogV2/model/model_aws_wif_persona_mapping_response.rs new file mode 100644 index 0000000000..00a7d31e48 --- /dev/null +++ b/src/datadogV2/model/model_aws_wif_persona_mapping_response.rs @@ -0,0 +1,94 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Response containing a single AWS WIF persona mapping. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct AwsWifPersonaMappingResponse { + /// An AWS WIF persona mapping resource. + #[serde(rename = "data")] + pub data: crate::datadogV2::model::AwsWifPersonaMappingData, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl AwsWifPersonaMappingResponse { + pub fn new( + data: crate::datadogV2::model::AwsWifPersonaMappingData, + ) -> AwsWifPersonaMappingResponse { + AwsWifPersonaMappingResponse { + data, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for AwsWifPersonaMappingResponse { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct AwsWifPersonaMappingResponseVisitor; + impl<'a> Visitor<'a> for AwsWifPersonaMappingResponseVisitor { + type Value = AwsWifPersonaMappingResponse; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "data" => { + data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let data = data.ok_or_else(|| M::Error::missing_field("data"))?; + + let content = AwsWifPersonaMappingResponse { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(AwsWifPersonaMappingResponseVisitor) + } +} diff --git a/src/datadogV2/model/model_aws_wif_persona_mapping_type.rs b/src/datadogV2/model/model_aws_wif_persona_mapping_type.rs new file mode 100644 index 0000000000..b1d16c8a28 --- /dev/null +++ b/src/datadogV2/model/model_aws_wif_persona_mapping_type.rs @@ -0,0 +1,48 @@ +// 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. + +use serde::{Deserialize, Deserializer, Serialize, Serializer}; + +#[non_exhaustive] +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum AwsWifPersonaMappingType { + AWS_WIF_CONFIG, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for AwsWifPersonaMappingType { + fn to_string(&self) -> String { + match self { + Self::AWS_WIF_CONFIG => String::from("aws_wif_config"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for AwsWifPersonaMappingType { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match self { + Self::UnparsedObject(v) => v.serialize(serializer), + _ => serializer.serialize_str(self.to_string().as_str()), + } + } +} + +impl<'de> Deserialize<'de> for AwsWifPersonaMappingType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "aws_wif_config" => Self::AWS_WIF_CONFIG, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_aws_wif_persona_mappings_response.rs b/src/datadogV2/model/model_aws_wif_persona_mappings_response.rs new file mode 100644 index 0000000000..f5d3aaea99 --- /dev/null +++ b/src/datadogV2/model/model_aws_wif_persona_mappings_response.rs @@ -0,0 +1,93 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Response containing a list of AWS WIF persona mappings. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct AwsWifPersonaMappingsResponse { + #[serde(rename = "data")] + pub data: Vec, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl AwsWifPersonaMappingsResponse { + pub fn new( + data: Vec, + ) -> AwsWifPersonaMappingsResponse { + AwsWifPersonaMappingsResponse { + data, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for AwsWifPersonaMappingsResponse { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct AwsWifPersonaMappingsResponseVisitor; + impl<'a> Visitor<'a> for AwsWifPersonaMappingsResponseVisitor { + type Value = AwsWifPersonaMappingsResponse; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data: Option> = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "data" => { + data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let data = data.ok_or_else(|| M::Error::missing_field("data"))?; + + let content = AwsWifPersonaMappingsResponse { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(AwsWifPersonaMappingsResponseVisitor) + } +} diff --git a/src/datadogV2/model/model_delegated_token_attributes.rs b/src/datadogV2/model/model_delegated_token_attributes.rs new file mode 100644 index 0000000000..de9446c49c --- /dev/null +++ b/src/datadogV2/model/model_delegated_token_attributes.rs @@ -0,0 +1,107 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Attributes of a delegated token. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct DelegatedTokenAttributes { + /// A short-lived JWT representing the authenticated Datadog user. Pass this as a bearer token in subsequent API calls. + #[serde(rename = "access_token")] + pub access_token: String, + /// The expiry time of the token. + #[serde(rename = "expires")] + pub expires: chrono::DateTime, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl DelegatedTokenAttributes { + pub fn new( + access_token: String, + expires: chrono::DateTime, + ) -> DelegatedTokenAttributes { + DelegatedTokenAttributes { + access_token, + expires, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for DelegatedTokenAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct DelegatedTokenAttributesVisitor; + impl<'a> Visitor<'a> for DelegatedTokenAttributesVisitor { + type Value = DelegatedTokenAttributes; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut access_token: Option = None; + let mut expires: Option> = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "access_token" => { + access_token = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "expires" => { + expires = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let access_token = + access_token.ok_or_else(|| M::Error::missing_field("access_token"))?; + let expires = expires.ok_or_else(|| M::Error::missing_field("expires"))?; + + let content = DelegatedTokenAttributes { + access_token, + expires, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(DelegatedTokenAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_delegated_token_data.rs b/src/datadogV2/model/model_delegated_token_data.rs new file mode 100644 index 0000000000..1ef0412f41 --- /dev/null +++ b/src/datadogV2/model/model_delegated_token_data.rs @@ -0,0 +1,127 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// A delegated token resource. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct DelegatedTokenData { + /// Attributes of a delegated token. + #[serde(rename = "attributes")] + pub attributes: crate::datadogV2::model::DelegatedTokenAttributes, + /// A random UUID assigned to this token issuance. + #[serde(rename = "id")] + pub id: uuid::Uuid, + /// The resource type for a delegated token. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::DelegatedTokenType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl DelegatedTokenData { + pub fn new( + attributes: crate::datadogV2::model::DelegatedTokenAttributes, + id: uuid::Uuid, + type_: crate::datadogV2::model::DelegatedTokenType, + ) -> DelegatedTokenData { + DelegatedTokenData { + attributes, + id, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for DelegatedTokenData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct DelegatedTokenDataVisitor; + impl<'a> Visitor<'a> for DelegatedTokenDataVisitor { + type Value = DelegatedTokenData; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut attributes: Option = + None; + let mut id: Option = None; + let mut type_: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "attributes" => { + attributes = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "id" => { + id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::DelegatedTokenType::UnparsedObject( + _type_, + ) => { + _unparsed = true; + } + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let attributes = attributes.ok_or_else(|| M::Error::missing_field("attributes"))?; + let id = id.ok_or_else(|| M::Error::missing_field("id"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = DelegatedTokenData { + attributes, + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(DelegatedTokenDataVisitor) + } +} diff --git a/src/datadogV2/model/model_delegated_token_response.rs b/src/datadogV2/model/model_delegated_token_response.rs new file mode 100644 index 0000000000..b3841003df --- /dev/null +++ b/src/datadogV2/model/model_delegated_token_response.rs @@ -0,0 +1,92 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Response containing a delegated user token. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct DelegatedTokenResponse { + /// A delegated token resource. + #[serde(rename = "data")] + pub data: crate::datadogV2::model::DelegatedTokenData, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl DelegatedTokenResponse { + pub fn new(data: crate::datadogV2::model::DelegatedTokenData) -> DelegatedTokenResponse { + DelegatedTokenResponse { + data, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for DelegatedTokenResponse { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct DelegatedTokenResponseVisitor; + impl<'a> Visitor<'a> for DelegatedTokenResponseVisitor { + type Value = DelegatedTokenResponse; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "data" => { + data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let data = data.ok_or_else(|| M::Error::missing_field("data"))?; + + let content = DelegatedTokenResponse { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(DelegatedTokenResponseVisitor) + } +} diff --git a/src/datadogV2/model/model_delegated_token_type.rs b/src/datadogV2/model/model_delegated_token_type.rs new file mode 100644 index 0000000000..1d6bbeea3d --- /dev/null +++ b/src/datadogV2/model/model_delegated_token_type.rs @@ -0,0 +1,48 @@ +// 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. + +use serde::{Deserialize, Deserializer, Serialize, Serializer}; + +#[non_exhaustive] +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum DelegatedTokenType { + TOKEN, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for DelegatedTokenType { + fn to_string(&self) -> String { + match self { + Self::TOKEN => String::from("token"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for DelegatedTokenType { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match self { + Self::UnparsedObject(v) => v.serialize(serializer), + _ => serializer.serialize_str(self.to_string().as_str()), + } + } +} + +impl<'de> Deserialize<'de> for DelegatedTokenType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "token" => Self::TOKEN, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_intake_api_key_attributes.rs b/src/datadogV2/model/model_intake_api_key_attributes.rs new file mode 100644 index 0000000000..16cc9039f1 --- /dev/null +++ b/src/datadogV2/model/model_intake_api_key_attributes.rs @@ -0,0 +1,102 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Attributes of an intake API key returned after successful authentication. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct IntakeAPIKeyAttributes { + /// The Datadog API key the workload can use to send telemetry. + #[serde(rename = "api_key")] + pub api_key: String, + /// The numeric ID of the Datadog organization the API key belongs to. + #[serde(rename = "org_id")] + pub org_id: i64, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl IntakeAPIKeyAttributes { + pub fn new(api_key: String, org_id: i64) -> IntakeAPIKeyAttributes { + IntakeAPIKeyAttributes { + api_key, + org_id, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for IntakeAPIKeyAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct IntakeAPIKeyAttributesVisitor; + impl<'a> Visitor<'a> for IntakeAPIKeyAttributesVisitor { + type Value = IntakeAPIKeyAttributes; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut api_key: Option = None; + let mut org_id: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "api_key" => { + api_key = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "org_id" => { + org_id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let api_key = api_key.ok_or_else(|| M::Error::missing_field("api_key"))?; + let org_id = org_id.ok_or_else(|| M::Error::missing_field("org_id"))?; + + let content = IntakeAPIKeyAttributes { + api_key, + org_id, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(IntakeAPIKeyAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_intake_api_key_data.rs b/src/datadogV2/model/model_intake_api_key_data.rs new file mode 100644 index 0000000000..c7e82b4332 --- /dev/null +++ b/src/datadogV2/model/model_intake_api_key_data.rs @@ -0,0 +1,126 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// An intake API key resource. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct IntakeAPIKeyData { + /// Attributes of an intake API key returned after successful authentication. + #[serde(rename = "attributes")] + pub attributes: crate::datadogV2::model::IntakeAPIKeyAttributes, + /// A stable identifier for the intake key, scoped to the matched organization. + #[serde(rename = "id")] + pub id: String, + /// The resource type for an intake API key. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::IntakeAPIKeyType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl IntakeAPIKeyData { + pub fn new( + attributes: crate::datadogV2::model::IntakeAPIKeyAttributes, + id: String, + type_: crate::datadogV2::model::IntakeAPIKeyType, + ) -> IntakeAPIKeyData { + IntakeAPIKeyData { + attributes, + id, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for IntakeAPIKeyData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct IntakeAPIKeyDataVisitor; + impl<'a> Visitor<'a> for IntakeAPIKeyDataVisitor { + type Value = IntakeAPIKeyData; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut attributes: Option = None; + let mut id: Option = None; + let mut type_: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "attributes" => { + attributes = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "id" => { + id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::IntakeAPIKeyType::UnparsedObject( + _type_, + ) => { + _unparsed = true; + } + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let attributes = attributes.ok_or_else(|| M::Error::missing_field("attributes"))?; + let id = id.ok_or_else(|| M::Error::missing_field("id"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = IntakeAPIKeyData { + attributes, + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(IntakeAPIKeyDataVisitor) + } +} diff --git a/src/datadogV2/model/model_intake_api_key_response.rs b/src/datadogV2/model/model_intake_api_key_response.rs new file mode 100644 index 0000000000..b212b9e49f --- /dev/null +++ b/src/datadogV2/model/model_intake_api_key_response.rs @@ -0,0 +1,92 @@ +// 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. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Response containing an intake API key for the authenticated cloud workload. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct IntakeAPIKeyResponse { + /// An intake API key resource. + #[serde(rename = "data")] + pub data: crate::datadogV2::model::IntakeAPIKeyData, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl IntakeAPIKeyResponse { + pub fn new(data: crate::datadogV2::model::IntakeAPIKeyData) -> IntakeAPIKeyResponse { + IntakeAPIKeyResponse { + data, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for IntakeAPIKeyResponse { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct IntakeAPIKeyResponseVisitor; + impl<'a> Visitor<'a> for IntakeAPIKeyResponseVisitor { + type Value = IntakeAPIKeyResponse; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "data" => { + data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let data = data.ok_or_else(|| M::Error::missing_field("data"))?; + + let content = IntakeAPIKeyResponse { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(IntakeAPIKeyResponseVisitor) + } +} diff --git a/src/datadogV2/model/model_intake_api_key_type.rs b/src/datadogV2/model/model_intake_api_key_type.rs new file mode 100644 index 0000000000..eb7218a399 --- /dev/null +++ b/src/datadogV2/model/model_intake_api_key_type.rs @@ -0,0 +1,48 @@ +// 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. + +use serde::{Deserialize, Deserializer, Serialize, Serializer}; + +#[non_exhaustive] +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum IntakeAPIKeyType { + INTAKE_API_KEY, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for IntakeAPIKeyType { + fn to_string(&self) -> String { + match self { + Self::INTAKE_API_KEY => String::from("intake_api_key"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for IntakeAPIKeyType { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match self { + Self::UnparsedObject(v) => v.serialize(serializer), + _ => serializer.serialize_str(self.to_string().as_str()), + } + } +} + +impl<'de> Deserialize<'de> for IntakeAPIKeyType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "intake_api_key" => Self::INTAKE_API_KEY, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/tests/scenarios/features/v2/aws_wif.feature b/tests/scenarios/features/v2/aws_wif.feature new file mode 100644 index 0000000000..922431ffee --- /dev/null +++ b/tests/scenarios/features/v2/aws_wif.feature @@ -0,0 +1,149 @@ +@endpoint(aws-wif) @endpoint(aws-wif-v2) +Feature: AWS WIF + Manage AWS Workload Identity Federation (WIF) mappings. Persona mappings + link IAM role ARN patterns to Datadog users for delegated-token + authentication. Intake mappings link IAM role ARN patterns to managed- + rotation API keys for agent telemetry ingestion. + + Background: + Given a valid "apiKeyAuth" key in the system + And a valid "appKeyAuth" key in the system + And an instance of "AWSWIF" API + + @generated @skip @team:DataDog/delegated-auth-login + Scenario: Create an AWS WIF intake mapping returns "Bad Request" response + Given new "CreateAwsWifIntakeMapping" request + And body with value {"data": {"attributes": {"arn_pattern": "arn:aws:iam::123456789012:role/my-agent-role"}, "type": "aws_wif_intake_mapping"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/delegated-auth-login + Scenario: Create an AWS WIF intake mapping returns "Conflict" response + Given new "CreateAwsWifIntakeMapping" request + And body with value {"data": {"attributes": {"arn_pattern": "arn:aws:iam::123456789012:role/my-agent-role"}, "type": "aws_wif_intake_mapping"}} + When the request is sent + Then the response status is 409 Conflict + + @generated @skip @team:DataDog/delegated-auth-login + Scenario: Create an AWS WIF intake mapping returns "Created" response + Given new "CreateAwsWifIntakeMapping" request + And body with value {"data": {"attributes": {"arn_pattern": "arn:aws:iam::123456789012:role/my-agent-role"}, "type": "aws_wif_intake_mapping"}} + When the request is sent + Then the response status is 201 Created + + @generated @skip @team:DataDog/delegated-auth-login + Scenario: Create an AWS WIF persona mapping returns "Bad Request" response + Given new "CreateAwsWifPersonaMapping" request + And body with value {"data": {"attributes": {"account_identifier": "user@example.com", "arn_pattern": "arn:aws:iam::123456789012:role/my-workload-role"}, "type": "aws_wif_config"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/delegated-auth-login + Scenario: Create an AWS WIF persona mapping returns "Conflict" response + Given new "CreateAwsWifPersonaMapping" request + And body with value {"data": {"attributes": {"account_identifier": "user@example.com", "arn_pattern": "arn:aws:iam::123456789012:role/my-workload-role"}, "type": "aws_wif_config"}} + When the request is sent + Then the response status is 409 Conflict + + @generated @skip @team:DataDog/delegated-auth-login + Scenario: Create an AWS WIF persona mapping returns "Created" response + Given new "CreateAwsWifPersonaMapping" request + And body with value {"data": {"attributes": {"account_identifier": "user@example.com", "arn_pattern": "arn:aws:iam::123456789012:role/my-workload-role"}, "type": "aws_wif_config"}} + When the request is sent + Then the response status is 201 Created + + @generated @skip @team:DataDog/delegated-auth-login + Scenario: Delete an AWS WIF intake mapping returns "Bad Request" response + Given new "DeleteAwsWifIntakeMapping" request + And request contains "config_uuid" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/delegated-auth-login + Scenario: Delete an AWS WIF intake mapping returns "No Content" response + Given new "DeleteAwsWifIntakeMapping" request + And request contains "config_uuid" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 204 No Content + + @generated @skip @team:DataDog/delegated-auth-login + Scenario: Delete an AWS WIF intake mapping returns "Not Found" response + Given new "DeleteAwsWifIntakeMapping" request + And request contains "config_uuid" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/delegated-auth-login + Scenario: Delete an AWS WIF persona mapping returns "Bad Request" response + Given new "DeleteAwsWifPersonaMapping" request + And request contains "config_uuid" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/delegated-auth-login + Scenario: Delete an AWS WIF persona mapping returns "No Content" response + Given new "DeleteAwsWifPersonaMapping" request + And request contains "config_uuid" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 204 No Content + + @generated @skip @team:DataDog/delegated-auth-login + Scenario: Delete an AWS WIF persona mapping returns "Not Found" response + Given new "DeleteAwsWifPersonaMapping" request + And request contains "config_uuid" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/delegated-auth-login + Scenario: Get an AWS WIF intake mapping returns "Bad Request" response + Given new "GetAwsWifIntakeMapping" request + And request contains "config_uuid" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/delegated-auth-login + Scenario: Get an AWS WIF intake mapping returns "Not Found" response + Given new "GetAwsWifIntakeMapping" request + And request contains "config_uuid" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/delegated-auth-login + Scenario: Get an AWS WIF intake mapping returns "OK" response + Given new "GetAwsWifIntakeMapping" request + And request contains "config_uuid" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:DataDog/delegated-auth-login + Scenario: Get an AWS WIF persona mapping returns "Bad Request" response + Given new "GetAwsWifPersonaMapping" request + And request contains "config_uuid" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/delegated-auth-login + Scenario: Get an AWS WIF persona mapping returns "Not Found" response + Given new "GetAwsWifPersonaMapping" request + And request contains "config_uuid" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/delegated-auth-login + Scenario: Get an AWS WIF persona mapping returns "OK" response + Given new "GetAwsWifPersonaMapping" request + And request contains "config_uuid" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:DataDog/delegated-auth-login + Scenario: List AWS WIF intake mappings returns "OK" response + Given new "ListAwsWifIntakeMappings" request + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:DataDog/delegated-auth-login + Scenario: List AWS WIF persona mappings returns "OK" response + Given new "ListAwsWifPersonaMappings" request + When the request is sent + Then the response status is 200 OK diff --git a/tests/scenarios/features/v2/cloud_authentication.feature b/tests/scenarios/features/v2/cloud_authentication.feature index c444f1469c..03888e59bb 100644 --- a/tests/scenarios/features/v2/cloud_authentication.feature +++ b/tests/scenarios/features/v2/cloud_authentication.feature @@ -8,7 +8,7 @@ Feature: Cloud Authentication And a valid "appKeyAuth" key in the system And an instance of "CloudAuthentication" API - @generated @skip @team:DataDog/team-aaaauthn + @generated @skip @team:DataDog/delegated-auth-login Scenario: Create an AWS cloud authentication persona mapping returns "Bad Request" response Given operation "CreateAWSCloudAuthPersonaMapping" enabled And new "CreateAWSCloudAuthPersonaMapping" request @@ -16,7 +16,7 @@ Feature: Cloud Authentication When the request is sent Then the response status is 400 Bad Request - @generated @skip @team:DataDog/team-aaaauthn + @generated @skip @team:DataDog/delegated-auth-login Scenario: Create an AWS cloud authentication persona mapping returns "Conflict" response Given operation "CreateAWSCloudAuthPersonaMapping" enabled And new "CreateAWSCloudAuthPersonaMapping" request @@ -24,7 +24,7 @@ Feature: Cloud Authentication When the request is sent Then the response status is 409 Conflict - @generated @skip @team:DataDog/team-aaaauthn + @generated @skip @team:DataDog/delegated-auth-login Scenario: Create an AWS cloud authentication persona mapping returns "Created" response Given operation "CreateAWSCloudAuthPersonaMapping" enabled And new "CreateAWSCloudAuthPersonaMapping" request @@ -32,7 +32,7 @@ Feature: Cloud Authentication When the request is sent Then the response status is 201 Created - @generated @skip @team:DataDog/team-aaaauthn + @generated @skip @team:DataDog/delegated-auth-login Scenario: Delete an AWS cloud authentication persona mapping returns "No Content" response Given operation "DeleteAWSCloudAuthPersonaMapping" enabled And new "DeleteAWSCloudAuthPersonaMapping" request @@ -40,7 +40,7 @@ Feature: Cloud Authentication When the request is sent Then the response status is 204 No Content - @generated @skip @team:DataDog/team-aaaauthn + @generated @skip @team:DataDog/delegated-auth-login Scenario: Delete an AWS cloud authentication persona mapping returns "Not Found" response Given operation "DeleteAWSCloudAuthPersonaMapping" enabled And new "DeleteAWSCloudAuthPersonaMapping" request @@ -48,7 +48,7 @@ Feature: Cloud Authentication When the request is sent Then the response status is 404 Not Found - @generated @skip @team:DataDog/team-aaaauthn + @generated @skip @team:DataDog/delegated-auth-login Scenario: Get an AWS cloud authentication persona mapping returns "Not Found" response Given operation "GetAWSCloudAuthPersonaMapping" enabled And new "GetAWSCloudAuthPersonaMapping" request @@ -56,7 +56,7 @@ Feature: Cloud Authentication When the request is sent Then the response status is 404 Not Found - @generated @skip @team:DataDog/team-aaaauthn + @generated @skip @team:DataDog/delegated-auth-login Scenario: Get an AWS cloud authentication persona mapping returns "OK" response Given operation "GetAWSCloudAuthPersonaMapping" enabled And new "GetAWSCloudAuthPersonaMapping" request @@ -64,14 +64,14 @@ Feature: Cloud Authentication When the request is sent Then the response status is 200 OK - @generated @skip @team:DataDog/team-aaaauthn + @generated @skip @team:DataDog/delegated-auth-login Scenario: List AWS cloud authentication persona mappings returns "Bad Request" response Given operation "ListAWSCloudAuthPersonaMappings" enabled And new "ListAWSCloudAuthPersonaMappings" request When the request is sent Then the response status is 400 Bad Request - @generated @skip @team:DataDog/team-aaaauthn + @generated @skip @team:DataDog/delegated-auth-login Scenario: List AWS cloud authentication persona mappings returns "OK" response Given operation "ListAWSCloudAuthPersonaMappings" enabled And new "ListAWSCloudAuthPersonaMappings" request diff --git a/tests/scenarios/features/v2/delegated_token.feature b/tests/scenarios/features/v2/delegated_token.feature new file mode 100644 index 0000000000..343463af38 --- /dev/null +++ b/tests/scenarios/features/v2/delegated_token.feature @@ -0,0 +1,13 @@ +@endpoint(delegated-token) @endpoint(delegated-token-v2) +Feature: Delegated Token + Exchange a cloud-provider identity proof or Datadog credential for a + short-lived delegated-user JWT via Workload Identity Federation. + + @generated @skip @team:DataDog/delegated-auth-login + Scenario: Get a delegated token returns "OK" response + Given a valid "apiKeyAuth" key in the system + And a valid "appKeyAuth" key in the system + And an instance of "DelegatedToken" API + And new "GetDelegatedToken" request + When the request is sent + Then the response status is 200 OK diff --git a/tests/scenarios/features/v2/intake_key.feature b/tests/scenarios/features/v2/intake_key.feature new file mode 100644 index 0000000000..ddcc5a81f1 --- /dev/null +++ b/tests/scenarios/features/v2/intake_key.feature @@ -0,0 +1,13 @@ +@endpoint(intake-key) @endpoint(intake-key-v2) +Feature: Intake Key + Exchange a cloud-provider identity proof for a Datadog API key via + Workload Identity Federation intake mappings. + + @generated @skip @team:DataDog/credentials-management + Scenario: Get an intake API key returns "OK" response + Given a valid "apiKeyAuth" key in the system + And a valid "appKeyAuth" key in the system + And an instance of "IntakeKey" API + And new "GetIntakeKey" request + When the request is sent + Then the response status is 200 OK diff --git a/tests/scenarios/features/v2/undo.json b/tests/scenarios/features/v2/undo.json index 049cc12522..d96495cf27 100644 --- a/tests/scenarios/features/v2/undo.json +++ b/tests/scenarios/features/v2/undo.json @@ -2255,6 +2255,12 @@ "type": "idempotent" } }, + "GetDelegatedToken": { + "tag": "Delegated Token", + "undo": { + "type": "idempotent" + } + }, "CreateDataDeletionRequest": { "tag": "Data Deletion", "undo": { @@ -3233,6 +3239,12 @@ "type": "idempotent" } }, + "GetIntakeKey": { + "tag": "Intake Key", + "undo": { + "type": "idempotent" + } + }, "ListAWSAccounts": { "tag": "AWS Integration", "undo": { @@ -9246,6 +9258,68 @@ "type": "safe" } }, + "ListAwsWifIntakeMappings": { + "tag": "AWS WIF", + "undo": { + "type": "safe" + } + }, + "CreateAwsWifIntakeMapping": { + "tag": "AWS WIF", + "undo": { + "operationId": "DeleteAwsWifIntakeMapping", + "parameters": [ + { + "name": "config_uuid", + "source": "data.id" + } + ], + "type": "unsafe" + } + }, + "DeleteAwsWifIntakeMapping": { + "tag": "AWS WIF", + "undo": { + "type": "idempotent" + } + }, + "GetAwsWifIntakeMapping": { + "tag": "AWS WIF", + "undo": { + "type": "safe" + } + }, + "ListAwsWifPersonaMappings": { + "tag": "AWS WIF", + "undo": { + "type": "safe" + } + }, + "CreateAwsWifPersonaMapping": { + "tag": "AWS WIF", + "undo": { + "operationId": "DeleteAwsWifPersonaMapping", + "parameters": [ + { + "name": "config_uuid", + "source": "data.id" + } + ], + "type": "unsafe" + } + }, + "DeleteAwsWifPersonaMapping": { + "tag": "AWS WIF", + "undo": { + "type": "idempotent" + } + }, + "GetAwsWifPersonaMapping": { + "tag": "AWS WIF", + "undo": { + "type": "safe" + } + }, "ListWorkflows": { "tag": "Workflow Automation", "undo": { diff --git a/tests/scenarios/function_mappings.rs b/tests/scenarios/function_mappings.rs index 2f009617dc..8b8885990e 100644 --- a/tests/scenarios/function_mappings.rs +++ b/tests/scenarios/function_mappings.rs @@ -102,6 +102,7 @@ pub struct ApiInstances { pub v2_api_dashboards: Option, pub v2_api_data_observability: Option, pub v2_api_datasets: Option, + pub v2_api_delegated_token: Option, pub v2_api_data_deletion: Option, pub v2_api_deployment_gates: Option, pub v2_api_domain_allowlist: Option, @@ -119,6 +120,7 @@ pub struct ApiInstances { pub v2_api_entity_integration_configs: Option, pub v2_api_incidents: Option, + pub v2_api_intake_key: Option, pub v2_api_aws_integration: Option, pub v2_api_aws_logs_integration: Option, @@ -219,6 +221,7 @@ pub struct ApiInstances { pub v2_api_teams: Option, pub v2_api_web_integrations: Option, pub v2_api_widgets: Option, + pub v2_api_aws_wif: Option, pub v2_api_workflow_automation: Option, } @@ -850,6 +853,14 @@ pub fn initialize_api_instance(world: &mut DatadogWorld, api: String) { ), ); } + "DelegatedToken" => { + world.api_instances.v2_api_delegated_token = Some( + datadogV2::api_delegated_token::DelegatedTokenAPI::with_client_and_config( + world.config.clone(), + world.http_client.as_ref().unwrap().clone(), + ), + ); + } "DataDeletion" => { world.api_instances.v2_api_data_deletion = Some( datadogV2::api_data_deletion::DataDeletionAPI::with_client_and_config( @@ -933,6 +944,14 @@ pub fn initialize_api_instance(world: &mut DatadogWorld, api: String) { ), ); } + "IntakeKey" => { + world.api_instances.v2_api_intake_key = Some( + datadogV2::api_intake_key::IntakeKeyAPI::with_client_and_config( + world.config.clone(), + world.http_client.as_ref().unwrap().clone(), + ), + ); + } "GoogleChatIntegration" => { world.api_instances.v2_api_google_chat_integration = Some(datadogV2::api_google_chat_integration::GoogleChatIntegrationAPI::with_client_and_config( world.config.clone(), @@ -1405,6 +1424,13 @@ pub fn initialize_api_instance(world: &mut DatadogWorld, api: String) { world.http_client.as_ref().unwrap().clone(), )); } + "AWSWIF" => { + world.api_instances.v2_api_aws_wif = + Some(datadogV2::api_aws_wif::AWSWIFAPI::with_client_and_config( + world.config.clone(), + world.http_client.as_ref().unwrap().clone(), + )); + } "WorkflowAutomation" => { world.api_instances.v2_api_workflow_automation = Some( datadogV2::api_workflow_automation::WorkflowAutomationAPI::with_client_and_config( @@ -4416,6 +4442,9 @@ pub fn collect_function_calls(world: &mut DatadogWorld) { world .function_mappings .insert("v2.UpdateDataset".into(), test_v2_update_dataset); + world + .function_mappings + .insert("v2.GetDelegatedToken".into(), test_v2_get_delegated_token); world.function_mappings.insert( "v2.CreateDataDeletionRequest".into(), test_v2_create_data_deletion_request, @@ -4963,6 +4992,9 @@ pub fn collect_function_calls(world: &mut DatadogWorld) { world .function_mappings .insert("v2.UpdateIncidentTodo".into(), test_v2_update_incident_todo); + world + .function_mappings + .insert("v2.GetIntakeKey".into(), test_v2_get_intake_key); world .function_mappings .insert("v2.ListAWSAccounts".into(), test_v2_list_aws_accounts); @@ -7368,6 +7400,38 @@ pub fn collect_function_calls(world: &mut DatadogWorld) { world .function_mappings .insert("v2.UpdateWidget".into(), test_v2_update_widget); + world.function_mappings.insert( + "v2.ListAwsWifIntakeMappings".into(), + test_v2_list_aws_wif_intake_mappings, + ); + world.function_mappings.insert( + "v2.CreateAwsWifIntakeMapping".into(), + test_v2_create_aws_wif_intake_mapping, + ); + world.function_mappings.insert( + "v2.DeleteAwsWifIntakeMapping".into(), + test_v2_delete_aws_wif_intake_mapping, + ); + world.function_mappings.insert( + "v2.GetAwsWifIntakeMapping".into(), + test_v2_get_aws_wif_intake_mapping, + ); + world.function_mappings.insert( + "v2.ListAwsWifPersonaMappings".into(), + test_v2_list_aws_wif_persona_mappings, + ); + world.function_mappings.insert( + "v2.CreateAwsWifPersonaMapping".into(), + test_v2_create_aws_wif_persona_mapping, + ); + world.function_mappings.insert( + "v2.DeleteAwsWifPersonaMapping".into(), + test_v2_delete_aws_wif_persona_mapping, + ); + world.function_mappings.insert( + "v2.GetAwsWifPersonaMapping".into(), + test_v2_get_aws_wif_persona_mapping, + ); world .function_mappings .insert("v2.ListWorkflows".into(), test_v2_list_workflows); @@ -33600,6 +33664,30 @@ fn test_v2_update_dataset(world: &mut DatadogWorld, _parameters: &HashMap) { + let api = world + .api_instances + .v2_api_delegated_token + .as_ref() + .expect("api instance not found"); + let response = match block_on(api.get_delegated_token_with_http_info()) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + fn test_v2_create_data_deletion_request( world: &mut DatadogWorld, _parameters: &HashMap, @@ -38261,6 +38349,30 @@ fn test_v2_update_incident_todo(world: &mut DatadogWorld, _parameters: &HashMap< world.response.code = response.status.as_u16(); } +fn test_v2_get_intake_key(world: &mut DatadogWorld, _parameters: &HashMap) { + let api = world + .api_instances + .v2_api_intake_key + .as_ref() + .expect("api instance not found"); + let response = match block_on(api.get_intake_key_with_http_info()) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + fn test_v2_list_aws_accounts(world: &mut DatadogWorld, _parameters: &HashMap) { let api = world .api_instances @@ -58774,6 +58886,232 @@ fn test_v2_update_widget(world: &mut DatadogWorld, _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_aws_wif + .as_ref() + .expect("api instance not found"); + let response = match block_on(api.list_aws_wif_intake_mappings_with_http_info()) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + +fn test_v2_create_aws_wif_intake_mapping( + world: &mut DatadogWorld, + _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_aws_wif + .as_ref() + .expect("api instance not found"); + let body = serde_json::from_value(_parameters.get("body").unwrap().clone()).unwrap(); + let response = match block_on(api.create_aws_wif_intake_mapping_with_http_info(body)) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + +fn test_v2_delete_aws_wif_intake_mapping( + world: &mut DatadogWorld, + _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_aws_wif + .as_ref() + .expect("api instance not found"); + let config_uuid = + serde_json::from_value(_parameters.get("config_uuid").unwrap().clone()).unwrap(); + let response = match block_on(api.delete_aws_wif_intake_mapping_with_http_info(config_uuid)) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + +fn test_v2_get_aws_wif_intake_mapping( + world: &mut DatadogWorld, + _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_aws_wif + .as_ref() + .expect("api instance not found"); + let config_uuid = + serde_json::from_value(_parameters.get("config_uuid").unwrap().clone()).unwrap(); + let response = match block_on(api.get_aws_wif_intake_mapping_with_http_info(config_uuid)) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + +fn test_v2_list_aws_wif_persona_mappings( + world: &mut DatadogWorld, + _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_aws_wif + .as_ref() + .expect("api instance not found"); + let response = match block_on(api.list_aws_wif_persona_mappings_with_http_info()) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + +fn test_v2_create_aws_wif_persona_mapping( + world: &mut DatadogWorld, + _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_aws_wif + .as_ref() + .expect("api instance not found"); + let body = serde_json::from_value(_parameters.get("body").unwrap().clone()).unwrap(); + let response = match block_on(api.create_aws_wif_persona_mapping_with_http_info(body)) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + +fn test_v2_delete_aws_wif_persona_mapping( + world: &mut DatadogWorld, + _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_aws_wif + .as_ref() + .expect("api instance not found"); + let config_uuid = + serde_json::from_value(_parameters.get("config_uuid").unwrap().clone()).unwrap(); + let response = match block_on(api.delete_aws_wif_persona_mapping_with_http_info(config_uuid)) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + +fn test_v2_get_aws_wif_persona_mapping( + world: &mut DatadogWorld, + _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_aws_wif + .as_ref() + .expect("api instance not found"); + let config_uuid = + serde_json::from_value(_parameters.get("config_uuid").unwrap().clone()).unwrap(); + let response = match block_on(api.get_aws_wif_persona_mapping_with_http_info(config_uuid)) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + fn test_v2_list_workflows(world: &mut DatadogWorld, _parameters: &HashMap) { let api = world .api_instances