diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 93efc78e5..9632e2d7d 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -1157,6 +1157,24 @@ components: schema: $ref: '#/components/schemas/APIErrorResponse' description: Forbidden + HTTPCDGatesBadRequestResponse: + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPCDGatesBadRequestResponse' + description: Bad request. + HTTPCDGatesNotFoundResponse: + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPCDGatesNotFoundResponse' + description: Deployment gate not found. + HTTPCDRulesNotFoundResponse: + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPCDRulesNotFoundResponse' + description: Deployment rule not found. NotAuthorizedResponse: content: application/json: @@ -12576,6 +12594,91 @@ components: meta: $ref: '#/components/schemas/DataDeletionResponseMeta' type: object + CreateDeploymentGateParams: + description: Parameters for creating a deployment gate. + properties: + data: + $ref: '#/components/schemas/CreateDeploymentGateParamsData' + required: + - data + type: object + CreateDeploymentGateParamsData: + description: Parameters for creating a deployment gate. + properties: + attributes: + $ref: '#/components/schemas/CreateDeploymentGateParamsDataAttributes' + type: + $ref: '#/components/schemas/DeploymentGateDataType' + required: + - type + - attributes + type: object + CreateDeploymentGateParamsDataAttributes: + description: Parameters for creating a deployment gate. + properties: + dry_run: + default: false + description: Whether this gate is run in dry-run mode. + example: false + type: boolean + env: + description: The environment of the deployment gate. + example: production + type: string + identifier: + default: default + description: The identifier of the deployment gate. + example: pre + type: string + service: + description: The service of the deployment gate. + example: my-service + type: string + required: + - env + - service + type: object + CreateDeploymentRuleParams: + description: Parameters for creating a deployment rule. + properties: + data: + $ref: '#/components/schemas/CreateDeploymentRuleParamsData' + type: object + CreateDeploymentRuleParamsData: + description: Parameters for creating a deployment rule. + properties: + attributes: + $ref: '#/components/schemas/CreateDeploymentRuleParamsDataAttributes' + type: + $ref: '#/components/schemas/DeploymentRuleDataType' + required: + - type + - attributes + type: object + CreateDeploymentRuleParamsDataAttributes: + description: Parameters for creating a deployment rule. + properties: + dry_run: + default: false + description: Whether this rule is run in dry-run mode. + example: false + type: boolean + name: + description: The name of the deployment rule. + example: My deployment rule + type: string + options: + $ref: '#/components/schemas/DeploymentRulesOptions' + type: + description: The type of the deployment rule (faulty_deployment_detection + or monitor). + example: faulty_deployment_detection + type: string + required: + - name + - options + - type + type: object CreateIncidentNotificationRuleRequest: description: Create request for a notification rule. properties: @@ -16284,6 +16387,113 @@ components: format: uuid type: string type: object + DeploymentGateDataType: + description: Deployment gate resource type. + enum: + - deployment_gate + example: deployment_gate + type: string + x-enum-varnames: + - DEPLOYMENT_GATE + DeploymentGateResponse: + description: Response for a deployment gate. + properties: + data: + $ref: '#/components/schemas/DeploymentGateResponseData' + type: object + DeploymentGateResponseData: + description: Data for a deployment gate. + properties: + attributes: + $ref: '#/components/schemas/DeploymentGateResponseDataAttributes' + id: + description: Unique identifier of the deployment gate. + example: 1111-2222-3333-4444-555566667777 + type: string + type: + $ref: '#/components/schemas/DeploymentGateDataType' + required: + - type + - attributes + - id + type: object + DeploymentGateResponseDataAttributes: + description: Basic information about a deployment gate. + properties: + created_at: + description: The timestamp when the deployment gate was created. + example: '2021-01-01T00:00:00Z' + format: date-time + type: string + created_by: + $ref: '#/components/schemas/DeploymentGateResponseDataAttributesCreatedBy' + dry_run: + description: Whether this gate is run in dry-run mode. + example: false + type: boolean + env: + description: The environment of the deployment gate. + example: production + type: string + identifier: + description: The identifier of the deployment gate. + example: pre + type: string + service: + description: The service of the deployment gate. + example: my-service + type: string + updated_at: + description: The timestamp when the deployment gate was last updated. + example: '2021-01-01T00:00:00Z' + format: date-time + type: string + updated_by: + $ref: '#/components/schemas/DeploymentGateResponseDataAttributesUpdatedBy' + required: + - created_at + - created_by + - dry_run + - env + - identifier + - service + type: object + DeploymentGateResponseDataAttributesCreatedBy: + description: Information about the user who created the deployment gate. + properties: + handle: + description: The handle of the user who created the deployment rule. + example: test-user + type: string + id: + description: The ID of the user who created the deployment rule. + example: 1111-2222-3333-4444-555566667777 + type: string + name: + description: The name of the user who created the deployment rule. + example: Test User + type: string + required: + - id + type: object + DeploymentGateResponseDataAttributesUpdatedBy: + description: Information about the user who updated the deployment gate. + properties: + handle: + description: The handle of the user who updated the deployment rule. + example: test-user + type: string + id: + description: The ID of the user who updated the deployment rule. + example: 1111-2222-3333-4444-555566667777 + type: string + name: + description: The name of the user who updated the deployment rule. + example: Test User + type: string + required: + - id + type: object DeploymentMetadata: description: Metadata object containing the publication creation information. properties: @@ -16323,6 +16533,164 @@ components: type: $ref: '#/components/schemas/AppDeploymentType' type: object + DeploymentRuleDataType: + description: Deployment rule resource type. + enum: + - deployment_rule + example: deployment_rule + type: string + x-enum-varnames: + - DEPLOYMENT_RULE + DeploymentRuleOptionsFaultyDeploymentDetection: + additionalProperties: false + description: Faulty deployment detection options for deployment rules. + properties: + duration: + description: The duration for faulty deployment detection. + example: 3600 + format: int64 + type: integer + excluded_resources: + description: Resources to exclude from faulty deployment detection. + example: + - resource1 + - resource2 + items: + type: string + type: array + type: object + DeploymentRuleOptionsMonitor: + additionalProperties: false + description: Monitor options for deployment rules. + properties: + duration: + description: Seconds the monitor needs to stay in OK status for the rule + to pass. + example: 3600 + format: int64 + type: integer + query: + description: Monitors that match this query are evaluated. + example: service:my-service env:prod + type: string + required: + - query + type: object + DeploymentRuleResponse: + description: Response for a deployment rule. + properties: + data: + $ref: '#/components/schemas/DeploymentRuleResponseData' + type: object + DeploymentRuleResponseData: + description: Data for a deployment rule. + properties: + attributes: + $ref: '#/components/schemas/DeploymentRuleResponseDataAttributes' + id: + description: Unique identifier of the deployment rule. + example: 1111-2222-3333-4444-555566667777 + type: string + type: + $ref: '#/components/schemas/DeploymentRuleDataType' + required: + - type + - attributes + - id + type: object + DeploymentRuleResponseDataAttributes: + description: Basic information about a deployment rule. + properties: + created_at: + description: The timestamp when the deployment rule was created. + example: '2021-01-01T00:00:00Z' + format: date-time + type: string + created_by: + $ref: '#/components/schemas/DeploymentRuleResponseDataAttributesCreatedBy' + dry_run: + description: Whether this rule is run in dry-run mode. + example: false + type: boolean + gate_id: + description: The ID of the deployment gate. + example: 1111-2222-3333-4444-555566667777 + type: string + name: + description: The name of the deployment rule. + example: My deployment rule + type: string + options: + $ref: '#/components/schemas/DeploymentRulesOptions' + type: + $ref: '#/components/schemas/DeploymentRuleResponseDataAttributesType' + updated_at: + description: The timestamp when the deployment rule was last updated. + format: date-time + type: string + updated_by: + $ref: '#/components/schemas/DeploymentRuleResponseDataAttributesUpdatedBy' + required: + - created_at + - created_by + - dry_run + - gate_id + - name + - options + - type + type: object + DeploymentRuleResponseDataAttributesCreatedBy: + description: Information about the user who created the deployment rule. + properties: + handle: + description: The handle of the user who created the deployment rule. + example: test-user + type: string + id: + description: The ID of the user who created the deployment rule. + example: 1111-2222-3333-4444-555566667777 + type: string + name: + description: The name of the user who created the deployment rule. + example: Test User + type: string + required: + - id + type: object + DeploymentRuleResponseDataAttributesType: + description: The type of the deployment rule. + enum: + - faulty_deployment_detection + - monitor + example: faulty_deployment_detection + type: string + x-enum-varnames: + - FAULTY_DEPLOYMENT_DETECTION + - MONITOR + DeploymentRuleResponseDataAttributesUpdatedBy: + description: Information about the user who updated the deployment rule. + properties: + handle: + description: The handle of the user who updated the deployment rule. + example: test-user + type: string + id: + description: The ID of the user who updated the deployment rule. + example: 1111-2222-3333-4444-555566667777 + type: string + name: + description: The name of the user who updated the deployment rule. + example: Test User + type: string + required: + - id + type: object + DeploymentRulesOptions: + description: Options for deployment rule response representing either faulty + deployment detection or monitor options. + oneOf: + - $ref: '#/components/schemas/DeploymentRuleOptionsFaultyDeploymentDetection' + - $ref: '#/components/schemas/DeploymentRuleOptionsMonitor' DetailedFinding: description: A single finding with with message and resource configuration. properties: @@ -22414,6 +22782,33 @@ components: example: application/json type: string type: object + HTTPCDGatesBadRequestResponse: + description: Bad request. + properties: + errors: + description: Structured errors. + items: + $ref: '#/components/schemas/HTTPCIAppError' + type: array + type: object + HTTPCDGatesNotFoundResponse: + description: Deployment gate not found. + properties: + errors: + description: Structured errors. + items: + $ref: '#/components/schemas/HTTPCIAppError' + type: array + type: object + HTTPCDRulesNotFoundResponse: + description: Deployment rule not found. + properties: + errors: + description: Structured errors. + items: + $ref: '#/components/schemas/HTTPCIAppError' + type: array + type: object HTTPCIAppError: description: List of errors. properties: @@ -51896,6 +52291,77 @@ components: required: - data type: object + UpdateDeploymentGateParams: + description: Parameters for updating a deployment gate. + properties: + data: + $ref: '#/components/schemas/UpdateDeploymentGateParamsData' + required: + - data + type: object + UpdateDeploymentGateParamsData: + description: Parameters for updating a deployment gate. + properties: + attributes: + $ref: '#/components/schemas/UpdateDeploymentGateParamsDataAttributes' + id: + description: Unique identifier of the deployment gate. + example: 12345678-1234-1234-1234-123456789012 + type: string + type: + $ref: '#/components/schemas/DeploymentGateDataType' + required: + - type + - id + - attributes + type: object + UpdateDeploymentGateParamsDataAttributes: + description: Attributes for updating a deployment gate. + properties: + dry_run: + description: Whether to run in dry-run mode. + example: false + type: boolean + required: + - dry_run + type: object + UpdateDeploymentRuleParams: + description: Parameters for updating a deployment rule. + properties: + data: + $ref: '#/components/schemas/UpdateDeploymentRuleParamsData' + required: + - data + type: object + UpdateDeploymentRuleParamsData: + description: Parameters for updating a deployment rule. + properties: + attributes: + $ref: '#/components/schemas/UpdateDeploymentRuleParamsDataAttributes' + type: + $ref: '#/components/schemas/DeploymentRuleDataType' + required: + - type + - attributes + type: object + UpdateDeploymentRuleParamsDataAttributes: + description: Parameters for updating a deployment rule. + properties: + dry_run: + description: Whether to run this rule in dry-run mode. + example: false + type: boolean + name: + description: The name of the deployment rule. + example: Updated deployment rule + type: string + options: + $ref: '#/components/schemas/DeploymentRulesOptions' + required: + - dry_run + - name + - options + type: object UpdateOpenAPIResponse: description: Response for `UpdateOpenAPI`. properties: @@ -61541,6 +62007,403 @@ paths: x-unstable: '**Note**: This endpoint is in Preview. If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + /api/v2/deployment_gates: + post: + description: Endpoint to create a deployment gate. + operationId: CreateDeploymentGate + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/CreateDeploymentGateParams' + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/DeploymentGateResponse' + description: OK + '400': + $ref: '#/components/responses/HTTPCDGatesBadRequestResponse' + '401': + $ref: '#/components/responses/UnauthorizedResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + '500': + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPCIAppErrors' + description: Internal Server Error + security: + - apiKeyAuth: [] + appKeyAuth: [] + summary: Create deployment gate + tags: + - Deployment Gates + x-permission: + operator: OR + permissions: + - deployment_gates_write + x-unstable: '**Note**: This endpoint is in preview and may be subject to change. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + /api/v2/deployment_gates/{gate_id}/rules: + post: + description: Endpoint to create a deployment rule. A gate for the rule must + already exist. + operationId: CreateDeploymentRule + parameters: + - description: The ID of the deployment gate. + in: path + name: gate_id + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/CreateDeploymentRuleParams' + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/DeploymentRuleResponse' + description: OK + '400': + $ref: '#/components/responses/HTTPCDGatesBadRequestResponse' + '401': + $ref: '#/components/responses/UnauthorizedResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + '500': + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPCIAppErrors' + description: Internal Server Error + security: + - apiKeyAuth: [] + appKeyAuth: [] + summary: Create deployment rule + tags: + - Deployment Gates + x-permission: + operator: OR + permissions: + - deployment_gates_write + x-unstable: '**Note**: This endpoint is in preview and may be subject to change. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + /api/v2/deployment_gates/{gate_id}/rules/{id}: + delete: + description: Endpoint to delete a deployment rule. + operationId: DeleteDeploymentRule + parameters: + - description: The ID of the deployment gate. + in: path + name: gate_id + required: true + schema: + type: string + - description: The ID of the deployment rule. + in: path + name: id + required: true + schema: + type: string + responses: + '204': + description: No Content + '400': + $ref: '#/components/responses/HTTPCDGatesBadRequestResponse' + '401': + $ref: '#/components/responses/UnauthorizedResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '404': + $ref: '#/components/responses/HTTPCDGatesNotFoundResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + '500': + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPCIAppErrors' + description: Internal Server Error + security: + - apiKeyAuth: [] + appKeyAuth: [] + summary: Delete deployment rule + tags: + - Deployment Gates + x-permission: + operator: OR + permissions: + - deployment_gates_write + x-unstable: '**Note**: This endpoint is in preview and may be subject to change. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + get: + description: Endpoint to get a deployment rule. + operationId: GetDeploymentRule + parameters: + - description: The ID of the deployment gate. + in: path + name: gate_id + required: true + schema: + type: string + - description: The ID of the deployment rule. + in: path + name: id + required: true + schema: + type: string + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/DeploymentRuleResponse' + description: OK + '400': + $ref: '#/components/responses/HTTPCDGatesBadRequestResponse' + '401': + $ref: '#/components/responses/UnauthorizedResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '404': + $ref: '#/components/responses/HTTPCDRulesNotFoundResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + '500': + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPCIAppErrors' + description: Internal Server Error + security: + - apiKeyAuth: [] + appKeyAuth: [] + summary: Get deployment rule + tags: + - Deployment Gates + x-permission: + operator: OR + permissions: + - deployment_gates_read + x-unstable: '**Note**: This endpoint is in preview and may be subject to change. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + put: + description: Endpoint to update a deployment rule. + operationId: UpdateDeploymentRule + parameters: + - description: The ID of the deployment gate. + in: path + name: gate_id + required: true + schema: + type: string + - description: The ID of the deployment rule. + in: path + name: id + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/UpdateDeploymentRuleParams' + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/DeploymentRuleResponse' + description: OK + '400': + $ref: '#/components/responses/HTTPCDGatesBadRequestResponse' + '401': + $ref: '#/components/responses/UnauthorizedResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '404': + $ref: '#/components/responses/HTTPCDRulesNotFoundResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + '500': + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPCIAppErrors' + description: Internal Server Error + security: + - apiKeyAuth: [] + appKeyAuth: [] + summary: Update deployment rule + tags: + - Deployment Gates + x-permission: + operator: OR + permissions: + - deployment_gates_write + x-unstable: '**Note**: This endpoint is in preview and may be subject to change. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + /api/v2/deployment_gates/{id}: + delete: + description: Endpoint to delete a deployment gate. Rules associated with the + gate are also deleted. + operationId: DeleteDeploymentGate + parameters: + - description: The ID of the deployment gate. + in: path + name: id + required: true + schema: + type: string + responses: + '204': + description: No Content + '400': + $ref: '#/components/responses/HTTPCDGatesBadRequestResponse' + '401': + $ref: '#/components/responses/UnauthorizedResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '404': + $ref: '#/components/responses/HTTPCDGatesNotFoundResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + '500': + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPCIAppErrors' + description: Internal Server Error + security: + - apiKeyAuth: [] + appKeyAuth: [] + summary: Delete deployment gate + tags: + - Deployment Gates + x-permission: + operator: OR + permissions: + - deployment_gates_write + x-unstable: '**Note**: This endpoint is in preview and may be subject to change. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + get: + description: Endpoint to get a deployment gate. + operationId: GetDeploymentGate + parameters: + - description: The ID of the deployment gate. + in: path + name: id + required: true + schema: + type: string + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/DeploymentGateResponse' + description: OK + '400': + $ref: '#/components/responses/HTTPCDGatesBadRequestResponse' + '401': + $ref: '#/components/responses/UnauthorizedResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '404': + $ref: '#/components/responses/HTTPCDGatesNotFoundResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + '500': + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPCIAppErrors' + description: Internal Server Error + security: + - apiKeyAuth: [] + appKeyAuth: [] + summary: Get deployment gate + tags: + - Deployment Gates + x-permission: + operator: OR + permissions: + - deployment_gates_read + x-unstable: '**Note**: This endpoint is in preview and may be subject to change. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' + put: + description: Endpoint to update a deployment gate. + operationId: UpdateDeploymentGate + parameters: + - description: The ID of the deployment gate. + in: path + name: id + required: true + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/UpdateDeploymentGateParams' + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/DeploymentGateResponse' + description: OK + '400': + $ref: '#/components/responses/HTTPCDGatesBadRequestResponse' + '401': + $ref: '#/components/responses/UnauthorizedResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '404': + $ref: '#/components/responses/HTTPCDGatesNotFoundResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + '500': + content: + application/json: + schema: + $ref: '#/components/schemas/HTTPCIAppErrors' + description: Internal Server Error + security: + - apiKeyAuth: [] + appKeyAuth: [] + summary: Update deployment gate + tags: + - Deployment Gates + x-permission: + operator: OR + permissions: + - deployment_gates_write + x-unstable: '**Note**: This endpoint is in preview and may be subject to change. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' /api/v2/domain_allowlist: get: description: Get the domain allowlist for an organization. @@ -79554,8 +80417,7 @@ paths: operator: OR permissions: - test_optimization_read - x-unstable: '**Note**: This endpoint is in public beta and may be subject to - change. + x-unstable: '**Note**: This endpoint is in preview and may be subject to change. If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' /api/v2/usage/application_security: @@ -81289,6 +82151,10 @@ tags: view certain types of telemetry (for example, logs, traces, metrics, and RUM data).' name: Datasets +- 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 - description: 'Configure your Datadog Email Domain Allowlist directly through the Datadog API. diff --git a/examples/v2_deployment-gates_CreateDeploymentGate.rs b/examples/v2_deployment-gates_CreateDeploymentGate.rs new file mode 100644 index 000000000..efa61fc3a --- /dev/null +++ b/examples/v2_deployment-gates_CreateDeploymentGate.rs @@ -0,0 +1,29 @@ +// Create deployment gate returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_deployment_gates::DeploymentGatesAPI; +use datadog_api_client::datadogV2::model::CreateDeploymentGateParams; +use datadog_api_client::datadogV2::model::CreateDeploymentGateParamsData; +use datadog_api_client::datadogV2::model::CreateDeploymentGateParamsDataAttributes; +use datadog_api_client::datadogV2::model::DeploymentGateDataType; + +#[tokio::main] +async fn main() { + let body = CreateDeploymentGateParams::new(CreateDeploymentGateParamsData::new( + CreateDeploymentGateParamsDataAttributes::new( + "production".to_string(), + "my-service".to_string(), + ) + .dry_run(false) + .identifier("my-gate-1".to_string()), + DeploymentGateDataType::DEPLOYMENT_GATE, + )); + let mut configuration = datadog::Configuration::new(); + configuration.set_unstable_operation_enabled("v2.CreateDeploymentGate", true); + let api = DeploymentGatesAPI::with_config(configuration); + let resp = api.create_deployment_gate(body).await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_deployment-gates_CreateDeploymentRule.rs b/examples/v2_deployment-gates_CreateDeploymentRule.rs new file mode 100644 index 000000000..1c85310c7 --- /dev/null +++ b/examples/v2_deployment-gates_CreateDeploymentRule.rs @@ -0,0 +1,37 @@ +// Create deployment rule returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_deployment_gates::DeploymentGatesAPI; +use datadog_api_client::datadogV2::model::CreateDeploymentRuleParams; +use datadog_api_client::datadogV2::model::CreateDeploymentRuleParamsData; +use datadog_api_client::datadogV2::model::CreateDeploymentRuleParamsDataAttributes; +use datadog_api_client::datadogV2::model::DeploymentRuleDataType; +use datadog_api_client::datadogV2::model::DeploymentRuleOptionsFaultyDeploymentDetection; +use datadog_api_client::datadogV2::model::DeploymentRulesOptions; + +#[tokio::main] +async fn main() { + // there is a valid "deployment_gate" in the system + let deployment_gate_data_id = std::env::var("DEPLOYMENT_GATE_DATA_ID").unwrap(); + let body = CreateDeploymentRuleParams::new().data(CreateDeploymentRuleParamsData::new( + CreateDeploymentRuleParamsDataAttributes::new( + "My deployment rule".to_string(), + DeploymentRulesOptions::DeploymentRuleOptionsFaultyDeploymentDetection(Box::new( + DeploymentRuleOptionsFaultyDeploymentDetection::new().excluded_resources(vec![]), + )), + "faulty_deployment_detection".to_string(), + ) + .dry_run(false), + DeploymentRuleDataType::DEPLOYMENT_RULE, + )); + let mut configuration = datadog::Configuration::new(); + configuration.set_unstable_operation_enabled("v2.CreateDeploymentRule", true); + let api = DeploymentGatesAPI::with_config(configuration); + let resp = api + .create_deployment_rule(deployment_gate_data_id.clone(), body) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_deployment-gates_DeleteDeploymentGate.rs b/examples/v2_deployment-gates_DeleteDeploymentGate.rs new file mode 100644 index 000000000..4475133e5 --- /dev/null +++ b/examples/v2_deployment-gates_DeleteDeploymentGate.rs @@ -0,0 +1,20 @@ +// Delete deployment gate returns "No Content" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_deployment_gates::DeploymentGatesAPI; + +#[tokio::main] +async fn main() { + // there is a valid "deployment_gate" in the system + let deployment_gate_data_id = std::env::var("DEPLOYMENT_GATE_DATA_ID").unwrap(); + let mut configuration = datadog::Configuration::new(); + configuration.set_unstable_operation_enabled("v2.DeleteDeploymentGate", true); + let api = DeploymentGatesAPI::with_config(configuration); + let resp = api + .delete_deployment_gate(deployment_gate_data_id.clone()) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_deployment-gates_DeleteDeploymentRule.rs b/examples/v2_deployment-gates_DeleteDeploymentRule.rs new file mode 100644 index 000000000..e7671fb14 --- /dev/null +++ b/examples/v2_deployment-gates_DeleteDeploymentRule.rs @@ -0,0 +1,26 @@ +// Delete deployment rule returns "No Content" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_deployment_gates::DeploymentGatesAPI; + +#[tokio::main] +async fn main() { + // there is a valid "deployment_gate" in the system + let deployment_gate_data_id = std::env::var("DEPLOYMENT_GATE_DATA_ID").unwrap(); + + // there is a valid "deployment_rule" in the system + let deployment_rule_data_id = std::env::var("DEPLOYMENT_RULE_DATA_ID").unwrap(); + let mut configuration = datadog::Configuration::new(); + configuration.set_unstable_operation_enabled("v2.DeleteDeploymentRule", true); + let api = DeploymentGatesAPI::with_config(configuration); + let resp = api + .delete_deployment_rule( + deployment_gate_data_id.clone(), + deployment_rule_data_id.clone(), + ) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_deployment-gates_GetDeploymentGate.rs b/examples/v2_deployment-gates_GetDeploymentGate.rs new file mode 100644 index 000000000..3e1f3ed60 --- /dev/null +++ b/examples/v2_deployment-gates_GetDeploymentGate.rs @@ -0,0 +1,20 @@ +// Get deployment gate returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_deployment_gates::DeploymentGatesAPI; + +#[tokio::main] +async fn main() { + // there is a valid "deployment_gate" in the system + let deployment_gate_data_id = std::env::var("DEPLOYMENT_GATE_DATA_ID").unwrap(); + let mut configuration = datadog::Configuration::new(); + configuration.set_unstable_operation_enabled("v2.GetDeploymentGate", true); + let api = DeploymentGatesAPI::with_config(configuration); + let resp = api + .get_deployment_gate(deployment_gate_data_id.clone()) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_deployment-gates_GetDeploymentRule.rs b/examples/v2_deployment-gates_GetDeploymentRule.rs new file mode 100644 index 000000000..78a6c1669 --- /dev/null +++ b/examples/v2_deployment-gates_GetDeploymentRule.rs @@ -0,0 +1,26 @@ +// Get deployment rule returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_deployment_gates::DeploymentGatesAPI; + +#[tokio::main] +async fn main() { + // there is a valid "deployment_gate" in the system + let deployment_gate_data_id = std::env::var("DEPLOYMENT_GATE_DATA_ID").unwrap(); + + // there is a valid "deployment_rule" in the system + let deployment_rule_data_id = std::env::var("DEPLOYMENT_RULE_DATA_ID").unwrap(); + let mut configuration = datadog::Configuration::new(); + configuration.set_unstable_operation_enabled("v2.GetDeploymentRule", true); + let api = DeploymentGatesAPI::with_config(configuration); + let resp = api + .get_deployment_rule( + deployment_gate_data_id.clone(), + deployment_rule_data_id.clone(), + ) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_deployment-gates_UpdateDeploymentGate.rs b/examples/v2_deployment-gates_UpdateDeploymentGate.rs new file mode 100644 index 000000000..dafe45e08 --- /dev/null +++ b/examples/v2_deployment-gates_UpdateDeploymentGate.rs @@ -0,0 +1,29 @@ +// Update deployment gate returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_deployment_gates::DeploymentGatesAPI; +use datadog_api_client::datadogV2::model::DeploymentGateDataType; +use datadog_api_client::datadogV2::model::UpdateDeploymentGateParams; +use datadog_api_client::datadogV2::model::UpdateDeploymentGateParamsData; +use datadog_api_client::datadogV2::model::UpdateDeploymentGateParamsDataAttributes; + +#[tokio::main] +async fn main() { + // there is a valid "deployment_gate" in the system + let deployment_gate_data_id = std::env::var("DEPLOYMENT_GATE_DATA_ID").unwrap(); + let body = UpdateDeploymentGateParams::new(UpdateDeploymentGateParamsData::new( + UpdateDeploymentGateParamsDataAttributes::new(false), + "12345678-1234-1234-1234-123456789012".to_string(), + DeploymentGateDataType::DEPLOYMENT_GATE, + )); + let mut configuration = datadog::Configuration::new(); + configuration.set_unstable_operation_enabled("v2.UpdateDeploymentGate", true); + let api = DeploymentGatesAPI::with_config(configuration); + let resp = api + .update_deployment_gate(deployment_gate_data_id.clone(), body) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_deployment-gates_UpdateDeploymentRule.rs b/examples/v2_deployment-gates_UpdateDeploymentRule.rs new file mode 100644 index 000000000..2c9bfa03f --- /dev/null +++ b/examples/v2_deployment-gates_UpdateDeploymentRule.rs @@ -0,0 +1,43 @@ +// Update deployment rule returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_deployment_gates::DeploymentGatesAPI; +use datadog_api_client::datadogV2::model::DeploymentRuleDataType; +use datadog_api_client::datadogV2::model::DeploymentRuleOptionsFaultyDeploymentDetection; +use datadog_api_client::datadogV2::model::DeploymentRulesOptions; +use datadog_api_client::datadogV2::model::UpdateDeploymentRuleParams; +use datadog_api_client::datadogV2::model::UpdateDeploymentRuleParamsData; +use datadog_api_client::datadogV2::model::UpdateDeploymentRuleParamsDataAttributes; + +#[tokio::main] +async fn main() { + // there is a valid "deployment_gate" in the system + let deployment_gate_data_id = std::env::var("DEPLOYMENT_GATE_DATA_ID").unwrap(); + + // there is a valid "deployment_rule" in the system + let deployment_rule_data_id = std::env::var("DEPLOYMENT_RULE_DATA_ID").unwrap(); + let body = UpdateDeploymentRuleParams::new(UpdateDeploymentRuleParamsData::new( + UpdateDeploymentRuleParamsDataAttributes::new( + false, + "Updated deployment rule".to_string(), + DeploymentRulesOptions::DeploymentRuleOptionsFaultyDeploymentDetection(Box::new( + DeploymentRuleOptionsFaultyDeploymentDetection::new().excluded_resources(vec![]), + )), + ), + DeploymentRuleDataType::DEPLOYMENT_RULE, + )); + let mut configuration = datadog::Configuration::new(); + configuration.set_unstable_operation_enabled("v2.UpdateDeploymentRule", true); + let api = DeploymentGatesAPI::with_config(configuration); + let resp = api + .update_deployment_rule( + deployment_gate_data_id.clone(), + deployment_rule_data_id.clone(), + body, + ) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/src/datadog/configuration.rs b/src/datadog/configuration.rs index 0de39ef54..83d833ce8 100644 --- a/src/datadog/configuration.rs +++ b/src/datadog/configuration.rs @@ -166,6 +166,14 @@ impl Default for Configuration { ("v2.cancel_data_deletion_request".to_owned(), false), ("v2.create_data_deletion_request".to_owned(), false), ("v2.get_data_deletion_requests".to_owned(), false), + ("v2.create_deployment_gate".to_owned(), false), + ("v2.create_deployment_rule".to_owned(), false), + ("v2.delete_deployment_gate".to_owned(), false), + ("v2.delete_deployment_rule".to_owned(), false), + ("v2.get_deployment_gate".to_owned(), false), + ("v2.get_deployment_rule".to_owned(), false), + ("v2.update_deployment_gate".to_owned(), false), + ("v2.update_deployment_rule".to_owned(), false), ("v2.create_incident".to_owned(), false), ("v2.create_incident_impact".to_owned(), false), ("v2.create_incident_integration".to_owned(), false), diff --git a/src/datadogV2/api/api_deployment_gates.rs b/src/datadogV2/api/api_deployment_gates.rs new file mode 100644 index 000000000..bb6810ef0 --- /dev/null +++ b/src/datadogV2/api/api_deployment_gates.rs @@ -0,0 +1,1265 @@ +// 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 log::warn; +use reqwest::header::{HeaderMap, HeaderValue}; +use serde::{Deserialize, Serialize}; +use std::io::Write; + +/// CreateDeploymentGateError is a struct for typed errors of method [`DeploymentGatesAPI::create_deployment_gate`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CreateDeploymentGateError { + HTTPCDGatesBadRequestResponse(crate::datadogV2::model::HTTPCDGatesBadRequestResponse), + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + HTTPCIAppErrors(crate::datadogV2::model::HTTPCIAppErrors), + UnknownValue(serde_json::Value), +} + +/// CreateDeploymentRuleError is a struct for typed errors of method [`DeploymentGatesAPI::create_deployment_rule`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CreateDeploymentRuleError { + HTTPCDGatesBadRequestResponse(crate::datadogV2::model::HTTPCDGatesBadRequestResponse), + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + HTTPCIAppErrors(crate::datadogV2::model::HTTPCIAppErrors), + UnknownValue(serde_json::Value), +} + +/// DeleteDeploymentGateError is a struct for typed errors of method [`DeploymentGatesAPI::delete_deployment_gate`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum DeleteDeploymentGateError { + HTTPCDGatesBadRequestResponse(crate::datadogV2::model::HTTPCDGatesBadRequestResponse), + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + HTTPCDGatesNotFoundResponse(crate::datadogV2::model::HTTPCDGatesNotFoundResponse), + HTTPCIAppErrors(crate::datadogV2::model::HTTPCIAppErrors), + UnknownValue(serde_json::Value), +} + +/// DeleteDeploymentRuleError is a struct for typed errors of method [`DeploymentGatesAPI::delete_deployment_rule`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum DeleteDeploymentRuleError { + HTTPCDGatesBadRequestResponse(crate::datadogV2::model::HTTPCDGatesBadRequestResponse), + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + HTTPCDGatesNotFoundResponse(crate::datadogV2::model::HTTPCDGatesNotFoundResponse), + HTTPCIAppErrors(crate::datadogV2::model::HTTPCIAppErrors), + UnknownValue(serde_json::Value), +} + +/// GetDeploymentGateError is a struct for typed errors of method [`DeploymentGatesAPI::get_deployment_gate`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetDeploymentGateError { + HTTPCDGatesBadRequestResponse(crate::datadogV2::model::HTTPCDGatesBadRequestResponse), + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + HTTPCDGatesNotFoundResponse(crate::datadogV2::model::HTTPCDGatesNotFoundResponse), + HTTPCIAppErrors(crate::datadogV2::model::HTTPCIAppErrors), + UnknownValue(serde_json::Value), +} + +/// GetDeploymentRuleError is a struct for typed errors of method [`DeploymentGatesAPI::get_deployment_rule`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetDeploymentRuleError { + HTTPCDGatesBadRequestResponse(crate::datadogV2::model::HTTPCDGatesBadRequestResponse), + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + HTTPCDRulesNotFoundResponse(crate::datadogV2::model::HTTPCDRulesNotFoundResponse), + HTTPCIAppErrors(crate::datadogV2::model::HTTPCIAppErrors), + UnknownValue(serde_json::Value), +} + +/// UpdateDeploymentGateError is a struct for typed errors of method [`DeploymentGatesAPI::update_deployment_gate`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum UpdateDeploymentGateError { + HTTPCDGatesBadRequestResponse(crate::datadogV2::model::HTTPCDGatesBadRequestResponse), + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + HTTPCDGatesNotFoundResponse(crate::datadogV2::model::HTTPCDGatesNotFoundResponse), + HTTPCIAppErrors(crate::datadogV2::model::HTTPCIAppErrors), + UnknownValue(serde_json::Value), +} + +/// UpdateDeploymentRuleError is a struct for typed errors of method [`DeploymentGatesAPI::update_deployment_rule`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum UpdateDeploymentRuleError { + HTTPCDGatesBadRequestResponse(crate::datadogV2::model::HTTPCDGatesBadRequestResponse), + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + HTTPCDRulesNotFoundResponse(crate::datadogV2::model::HTTPCDRulesNotFoundResponse), + HTTPCIAppErrors(crate::datadogV2::model::HTTPCIAppErrors), + UnknownValue(serde_json::Value), +} + +/// Manage Deployment Gates using this API to reduce the likelihood and impact of incidents caused by deployments. See the [Deployment Gates documentation]() for more information. +#[derive(Debug, Clone)] +pub struct DeploymentGatesAPI { + config: datadog::Configuration, + client: reqwest_middleware::ClientWithMiddleware, +} + +impl Default for DeploymentGatesAPI { + fn default() -> Self { + Self::with_config(datadog::Configuration::default()) + } +} + +impl DeploymentGatesAPI { + pub fn new() -> Self { + Self::default() + } + pub fn with_config(config: datadog::Configuration) -> Self { + let mut reqwest_client_builder = reqwest::Client::builder(); + + if let Some(proxy_url) = &config.proxy_url { + let proxy = reqwest::Proxy::all(proxy_url).expect("Failed to parse proxy URL"); + reqwest_client_builder = reqwest_client_builder.proxy(proxy); + } + + let mut middleware_client_builder = + reqwest_middleware::ClientBuilder::new(reqwest_client_builder.build().unwrap()); + + 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, + ); + + middleware_client_builder = middleware_client_builder.with(retry_middleware); + } + + 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 } + } + + /// Endpoint to create a deployment gate. + pub async fn create_deployment_gate( + &self, + body: crate::datadogV2::model::CreateDeploymentGateParams, + ) -> Result< + crate::datadogV2::model::DeploymentGateResponse, + datadog::Error, + > { + match self.create_deployment_gate_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), + } + } + + /// Endpoint to create a deployment gate. + pub async fn create_deployment_gate_with_http_info( + &self, + body: crate::datadogV2::model::CreateDeploymentGateParams, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.create_deployment_gate"; + if local_configuration.is_unstable_operation_enabled(operation_id) { + warn!("Using unstable operation {operation_id}"); + } else { + let local_error = datadog::UnstableOperationDisabledError { + msg: "Operation 'v2.create_deployment_gate' is not enabled".to_string(), + }; + return Err(datadog::Error::UnstableOperationDisabledError(local_error)); + } + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/deployment_gates", + 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)), + } + } + "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)) + } + } + + /// Endpoint to create a deployment rule. A gate for the rule must already exist. + pub async fn create_deployment_rule( + &self, + gate_id: String, + body: crate::datadogV2::model::CreateDeploymentRuleParams, + ) -> Result< + crate::datadogV2::model::DeploymentRuleResponse, + datadog::Error, + > { + match self + .create_deployment_rule_with_http_info(gate_id, 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), + } + } + + /// Endpoint to create a deployment rule. A gate for the rule must already exist. + pub async fn create_deployment_rule_with_http_info( + &self, + gate_id: String, + body: crate::datadogV2::model::CreateDeploymentRuleParams, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.create_deployment_rule"; + if local_configuration.is_unstable_operation_enabled(operation_id) { + warn!("Using unstable operation {operation_id}"); + } else { + let local_error = datadog::UnstableOperationDisabledError { + msg: "Operation 'v2.create_deployment_rule' is not enabled".to_string(), + }; + return Err(datadog::Error::UnstableOperationDisabledError(local_error)); + } + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/deployment_gates/{gate_id}/rules", + local_configuration.get_operation_host(operation_id), + gate_id = datadog::urlencode(gate_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)), + } + } + "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)) + } + } + + /// Endpoint to delete a deployment gate. Rules associated with the gate are also deleted. + pub async fn delete_deployment_gate( + &self, + id: String, + ) -> Result<(), datadog::Error> { + match self.delete_deployment_gate_with_http_info(id).await { + Ok(_) => Ok(()), + Err(err) => Err(err), + } + } + + /// Endpoint to delete a deployment gate. Rules associated with the gate are also deleted. + pub async fn delete_deployment_gate_with_http_info( + &self, + id: String, + ) -> Result, datadog::Error> { + let local_configuration = &self.config; + let operation_id = "v2.delete_deployment_gate"; + if local_configuration.is_unstable_operation_enabled(operation_id) { + warn!("Using unstable operation {operation_id}"); + } else { + let local_error = datadog::UnstableOperationDisabledError { + msg: "Operation 'v2.delete_deployment_gate' is not enabled".to_string(), + }; + return Err(datadog::Error::UnstableOperationDisabledError(local_error)); + } + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/deployment_gates/{id}", + local_configuration.get_operation_host(operation_id), + id = datadog::urlencode(id) + ); + 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)) + } + } + + /// Endpoint to delete a deployment rule. + pub async fn delete_deployment_rule( + &self, + gate_id: String, + id: String, + ) -> Result<(), datadog::Error> { + match self + .delete_deployment_rule_with_http_info(gate_id, id) + .await + { + Ok(_) => Ok(()), + Err(err) => Err(err), + } + } + + /// Endpoint to delete a deployment rule. + pub async fn delete_deployment_rule_with_http_info( + &self, + gate_id: String, + id: String, + ) -> Result, datadog::Error> { + let local_configuration = &self.config; + let operation_id = "v2.delete_deployment_rule"; + if local_configuration.is_unstable_operation_enabled(operation_id) { + warn!("Using unstable operation {operation_id}"); + } else { + let local_error = datadog::UnstableOperationDisabledError { + msg: "Operation 'v2.delete_deployment_rule' is not enabled".to_string(), + }; + return Err(datadog::Error::UnstableOperationDisabledError(local_error)); + } + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/deployment_gates/{gate_id}/rules/{id}", + local_configuration.get_operation_host(operation_id), + gate_id = datadog::urlencode(gate_id), + id = datadog::urlencode(id) + ); + 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)) + } + } + + /// Endpoint to get a deployment gate. + pub async fn get_deployment_gate( + &self, + id: String, + ) -> Result< + crate::datadogV2::model::DeploymentGateResponse, + datadog::Error, + > { + match self.get_deployment_gate_with_http_info(id).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), + } + } + + /// Endpoint to get a deployment gate. + pub async fn get_deployment_gate_with_http_info( + &self, + id: String, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.get_deployment_gate"; + if local_configuration.is_unstable_operation_enabled(operation_id) { + warn!("Using unstable operation {operation_id}"); + } else { + let local_error = datadog::UnstableOperationDisabledError { + msg: "Operation 'v2.get_deployment_gate' is not enabled".to_string(), + }; + return Err(datadog::Error::UnstableOperationDisabledError(local_error)); + } + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/deployment_gates/{id}", + local_configuration.get_operation_host(operation_id), + id = datadog::urlencode(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)) + } + } + + /// Endpoint to get a deployment rule. + pub async fn get_deployment_rule( + &self, + gate_id: String, + id: String, + ) -> Result< + crate::datadogV2::model::DeploymentRuleResponse, + datadog::Error, + > { + match self.get_deployment_rule_with_http_info(gate_id, id).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), + } + } + + /// Endpoint to get a deployment rule. + pub async fn get_deployment_rule_with_http_info( + &self, + gate_id: String, + id: String, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.get_deployment_rule"; + if local_configuration.is_unstable_operation_enabled(operation_id) { + warn!("Using unstable operation {operation_id}"); + } else { + let local_error = datadog::UnstableOperationDisabledError { + msg: "Operation 'v2.get_deployment_rule' is not enabled".to_string(), + }; + return Err(datadog::Error::UnstableOperationDisabledError(local_error)); + } + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/deployment_gates/{gate_id}/rules/{id}", + local_configuration.get_operation_host(operation_id), + gate_id = datadog::urlencode(gate_id), + id = datadog::urlencode(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)) + } + } + + /// Endpoint to update a deployment gate. + pub async fn update_deployment_gate( + &self, + id: String, + body: crate::datadogV2::model::UpdateDeploymentGateParams, + ) -> Result< + crate::datadogV2::model::DeploymentGateResponse, + datadog::Error, + > { + match self.update_deployment_gate_with_http_info(id, 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), + } + } + + /// Endpoint to update a deployment gate. + pub async fn update_deployment_gate_with_http_info( + &self, + id: String, + body: crate::datadogV2::model::UpdateDeploymentGateParams, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.update_deployment_gate"; + if local_configuration.is_unstable_operation_enabled(operation_id) { + warn!("Using unstable operation {operation_id}"); + } else { + let local_error = datadog::UnstableOperationDisabledError { + msg: "Operation 'v2.update_deployment_gate' is not enabled".to_string(), + }; + return Err(datadog::Error::UnstableOperationDisabledError(local_error)); + } + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/deployment_gates/{id}", + local_configuration.get_operation_host(operation_id), + id = datadog::urlencode(id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::PUT, 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)), + } + } + "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)) + } + } + + /// Endpoint to update a deployment rule. + pub async fn update_deployment_rule( + &self, + gate_id: String, + id: String, + body: crate::datadogV2::model::UpdateDeploymentRuleParams, + ) -> Result< + crate::datadogV2::model::DeploymentRuleResponse, + datadog::Error, + > { + match self + .update_deployment_rule_with_http_info(gate_id, id, 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), + } + } + + /// Endpoint to update a deployment rule. + pub async fn update_deployment_rule_with_http_info( + &self, + gate_id: String, + id: String, + body: crate::datadogV2::model::UpdateDeploymentRuleParams, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.update_deployment_rule"; + if local_configuration.is_unstable_operation_enabled(operation_id) { + warn!("Using unstable operation {operation_id}"); + } else { + let local_error = datadog::UnstableOperationDisabledError { + msg: "Operation 'v2.update_deployment_rule' is not enabled".to_string(), + }; + return Err(datadog::Error::UnstableOperationDisabledError(local_error)); + } + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/deployment_gates/{gate_id}/rules/{id}", + local_configuration.get_operation_host(operation_id), + gate_id = datadog::urlencode(gate_id), + id = datadog::urlencode(id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::PUT, 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)), + } + } + "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)) + } + } +} diff --git a/src/datadogV2/api/mod.rs b/src/datadogV2/api/mod.rs index 4675e95e7..68998149b 100644 --- a/src/datadogV2/api/mod.rs +++ b/src/datadogV2/api/mod.rs @@ -30,6 +30,7 @@ pub mod api_csm_threats; pub mod api_dashboard_lists; pub mod api_data_deletion; pub mod api_datasets; +pub mod api_deployment_gates; pub mod api_domain_allowlist; pub mod api_dora_metrics; pub mod api_downtimes; diff --git a/src/datadogV2/mod.rs b/src/datadogV2/mod.rs index 17059324e..2ecac8a35 100644 --- a/src/datadogV2/mod.rs +++ b/src/datadogV2/mod.rs @@ -31,6 +31,7 @@ pub use self::api::api_csm_threats; pub use self::api::api_dashboard_lists; pub use self::api::api_data_deletion; pub use self::api::api_datasets; +pub use self::api::api_deployment_gates; pub use self::api::api_domain_allowlist; pub use self::api::api_dora_metrics; pub use self::api::api_downtimes; diff --git a/src/datadogV2/model/mod.rs b/src/datadogV2/model/mod.rs index 0a29a3b35..0bdae5157 100644 --- a/src/datadogV2/model/mod.rs +++ b/src/datadogV2/model/mod.rs @@ -2068,6 +2068,68 @@ pub mod model_get_data_deletions_response_body; pub use self::model_get_data_deletions_response_body::GetDataDeletionsResponseBody; pub mod model_cancel_data_deletion_response_body; pub use self::model_cancel_data_deletion_response_body::CancelDataDeletionResponseBody; +pub mod model_create_deployment_gate_params; +pub use self::model_create_deployment_gate_params::CreateDeploymentGateParams; +pub mod model_create_deployment_gate_params_data; +pub use self::model_create_deployment_gate_params_data::CreateDeploymentGateParamsData; +pub mod model_create_deployment_gate_params_data_attributes; +pub use self::model_create_deployment_gate_params_data_attributes::CreateDeploymentGateParamsDataAttributes; +pub mod model_deployment_gate_data_type; +pub use self::model_deployment_gate_data_type::DeploymentGateDataType; +pub mod model_deployment_gate_response; +pub use self::model_deployment_gate_response::DeploymentGateResponse; +pub mod model_deployment_gate_response_data; +pub use self::model_deployment_gate_response_data::DeploymentGateResponseData; +pub mod model_deployment_gate_response_data_attributes; +pub use self::model_deployment_gate_response_data_attributes::DeploymentGateResponseDataAttributes; +pub mod model_deployment_gate_response_data_attributes_created_by; +pub use self::model_deployment_gate_response_data_attributes_created_by::DeploymentGateResponseDataAttributesCreatedBy; +pub mod model_deployment_gate_response_data_attributes_updated_by; +pub use self::model_deployment_gate_response_data_attributes_updated_by::DeploymentGateResponseDataAttributesUpdatedBy; +pub mod model_httpcd_gates_bad_request_response; +pub use self::model_httpcd_gates_bad_request_response::HTTPCDGatesBadRequestResponse; +pub mod model_create_deployment_rule_params; +pub use self::model_create_deployment_rule_params::CreateDeploymentRuleParams; +pub mod model_create_deployment_rule_params_data; +pub use self::model_create_deployment_rule_params_data::CreateDeploymentRuleParamsData; +pub mod model_create_deployment_rule_params_data_attributes; +pub use self::model_create_deployment_rule_params_data_attributes::CreateDeploymentRuleParamsDataAttributes; +pub mod model_deployment_rule_options_faulty_deployment_detection; +pub use self::model_deployment_rule_options_faulty_deployment_detection::DeploymentRuleOptionsFaultyDeploymentDetection; +pub mod model_deployment_rule_options_monitor; +pub use self::model_deployment_rule_options_monitor::DeploymentRuleOptionsMonitor; +pub mod model_deployment_rules_options; +pub use self::model_deployment_rules_options::DeploymentRulesOptions; +pub mod model_deployment_rule_data_type; +pub use self::model_deployment_rule_data_type::DeploymentRuleDataType; +pub mod model_deployment_rule_response; +pub use self::model_deployment_rule_response::DeploymentRuleResponse; +pub mod model_deployment_rule_response_data; +pub use self::model_deployment_rule_response_data::DeploymentRuleResponseData; +pub mod model_deployment_rule_response_data_attributes; +pub use self::model_deployment_rule_response_data_attributes::DeploymentRuleResponseDataAttributes; +pub mod model_deployment_rule_response_data_attributes_created_by; +pub use self::model_deployment_rule_response_data_attributes_created_by::DeploymentRuleResponseDataAttributesCreatedBy; +pub mod model_deployment_rule_response_data_attributes_type; +pub use self::model_deployment_rule_response_data_attributes_type::DeploymentRuleResponseDataAttributesType; +pub mod model_deployment_rule_response_data_attributes_updated_by; +pub use self::model_deployment_rule_response_data_attributes_updated_by::DeploymentRuleResponseDataAttributesUpdatedBy; +pub mod model_httpcd_gates_not_found_response; +pub use self::model_httpcd_gates_not_found_response::HTTPCDGatesNotFoundResponse; +pub mod model_httpcd_rules_not_found_response; +pub use self::model_httpcd_rules_not_found_response::HTTPCDRulesNotFoundResponse; +pub mod model_update_deployment_rule_params; +pub use self::model_update_deployment_rule_params::UpdateDeploymentRuleParams; +pub mod model_update_deployment_rule_params_data; +pub use self::model_update_deployment_rule_params_data::UpdateDeploymentRuleParamsData; +pub mod model_update_deployment_rule_params_data_attributes; +pub use self::model_update_deployment_rule_params_data_attributes::UpdateDeploymentRuleParamsDataAttributes; +pub mod model_update_deployment_gate_params; +pub use self::model_update_deployment_gate_params::UpdateDeploymentGateParams; +pub mod model_update_deployment_gate_params_data; +pub use self::model_update_deployment_gate_params_data::UpdateDeploymentGateParamsData; +pub mod model_update_deployment_gate_params_data_attributes; +pub use self::model_update_deployment_gate_params_data_attributes::UpdateDeploymentGateParamsDataAttributes; pub mod model_domain_allowlist_response; pub use self::model_domain_allowlist_response::DomainAllowlistResponse; pub mod model_domain_allowlist_response_data; diff --git a/src/datadogV2/model/model_create_deployment_gate_params.rs b/src/datadogV2/model/model_create_deployment_gate_params.rs new file mode 100644 index 000000000..66420a6b5 --- /dev/null +++ b/src/datadogV2/model/model_create_deployment_gate_params.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}; + +/// Parameters for creating a deployment gate. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct CreateDeploymentGateParams { + /// Parameters for creating a deployment gate. + #[serde(rename = "data")] + pub data: crate::datadogV2::model::CreateDeploymentGateParamsData, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl CreateDeploymentGateParams { + pub fn new( + data: crate::datadogV2::model::CreateDeploymentGateParamsData, + ) -> CreateDeploymentGateParams { + CreateDeploymentGateParams { + 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 CreateDeploymentGateParams { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct CreateDeploymentGateParamsVisitor; + impl<'a> Visitor<'a> for CreateDeploymentGateParamsVisitor { + type Value = CreateDeploymentGateParams; + + 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 = CreateDeploymentGateParams { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(CreateDeploymentGateParamsVisitor) + } +} diff --git a/src/datadogV2/model/model_create_deployment_gate_params_data.rs b/src/datadogV2/model/model_create_deployment_gate_params_data.rs new file mode 100644 index 000000000..936da44ee --- /dev/null +++ b/src/datadogV2/model/model_create_deployment_gate_params_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}; + +/// Parameters for creating a deployment gate. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct CreateDeploymentGateParamsData { + /// Parameters for creating a deployment gate. + #[serde(rename = "attributes")] + pub attributes: crate::datadogV2::model::CreateDeploymentGateParamsDataAttributes, + /// Deployment gate resource type. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::DeploymentGateDataType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl CreateDeploymentGateParamsData { + pub fn new( + attributes: crate::datadogV2::model::CreateDeploymentGateParamsDataAttributes, + type_: crate::datadogV2::model::DeploymentGateDataType, + ) -> CreateDeploymentGateParamsData { + CreateDeploymentGateParamsData { + 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 CreateDeploymentGateParamsData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct CreateDeploymentGateParamsDataVisitor; + impl<'a> Visitor<'a> for CreateDeploymentGateParamsDataVisitor { + type Value = CreateDeploymentGateParamsData; + + 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::CreateDeploymentGateParamsDataAttributes, + > = 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::DeploymentGateDataType::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 = CreateDeploymentGateParamsData { + attributes, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(CreateDeploymentGateParamsDataVisitor) + } +} diff --git a/src/datadogV2/model/model_create_deployment_gate_params_data_attributes.rs b/src/datadogV2/model/model_create_deployment_gate_params_data_attributes.rs new file mode 100644 index 000000000..b929195f3 --- /dev/null +++ b/src/datadogV2/model/model_create_deployment_gate_params_data_attributes.rs @@ -0,0 +1,136 @@ +// 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}; + +/// Parameters for creating a deployment gate. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct CreateDeploymentGateParamsDataAttributes { + /// Whether this gate is run in dry-run mode. + #[serde(rename = "dry_run")] + pub dry_run: Option, + /// The environment of the deployment gate. + #[serde(rename = "env")] + pub env: String, + /// The identifier of the deployment gate. + #[serde(rename = "identifier")] + pub identifier: Option, + /// The service of the deployment gate. + #[serde(rename = "service")] + pub service: String, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl CreateDeploymentGateParamsDataAttributes { + pub fn new(env: String, service: String) -> CreateDeploymentGateParamsDataAttributes { + CreateDeploymentGateParamsDataAttributes { + dry_run: None, + env, + identifier: None, + service, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn dry_run(mut self, value: bool) -> Self { + self.dry_run = Some(value); + self + } + + pub fn identifier(mut self, value: String) -> Self { + self.identifier = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for CreateDeploymentGateParamsDataAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct CreateDeploymentGateParamsDataAttributesVisitor; + impl<'a> Visitor<'a> for CreateDeploymentGateParamsDataAttributesVisitor { + type Value = CreateDeploymentGateParamsDataAttributes; + + 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 dry_run: Option = None; + let mut env: Option = None; + let mut identifier: Option = None; + let mut service: 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() { + "dry_run" => { + if v.is_null() { + continue; + } + dry_run = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "env" => { + env = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "identifier" => { + if v.is_null() { + continue; + } + identifier = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "service" => { + service = 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 env = env.ok_or_else(|| M::Error::missing_field("env"))?; + let service = service.ok_or_else(|| M::Error::missing_field("service"))?; + + let content = CreateDeploymentGateParamsDataAttributes { + dry_run, + env, + identifier, + service, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(CreateDeploymentGateParamsDataAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_create_deployment_rule_params.rs b/src/datadogV2/model/model_create_deployment_rule_params.rs new file mode 100644 index 000000000..47b4c7758 --- /dev/null +++ b/src/datadogV2/model/model_create_deployment_rule_params.rs @@ -0,0 +1,106 @@ +// 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}; + +/// Parameters for creating a deployment rule. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct CreateDeploymentRuleParams { + /// Parameters for creating a deployment rule. + #[serde(rename = "data")] + pub data: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl CreateDeploymentRuleParams { + pub fn new() -> CreateDeploymentRuleParams { + CreateDeploymentRuleParams { + data: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn data(mut self, value: crate::datadogV2::model::CreateDeploymentRuleParamsData) -> Self { + self.data = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for CreateDeploymentRuleParams { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for CreateDeploymentRuleParams { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct CreateDeploymentRuleParamsVisitor; + impl<'a> Visitor<'a> for CreateDeploymentRuleParamsVisitor { + type Value = CreateDeploymentRuleParams; + + 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" => { + if v.is_null() { + continue; + } + 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 content = CreateDeploymentRuleParams { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(CreateDeploymentRuleParamsVisitor) + } +} diff --git a/src/datadogV2/model/model_create_deployment_rule_params_data.rs b/src/datadogV2/model/model_create_deployment_rule_params_data.rs new file mode 100644 index 000000000..ec3d933dd --- /dev/null +++ b/src/datadogV2/model/model_create_deployment_rule_params_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}; + +/// Parameters for creating a deployment rule. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct CreateDeploymentRuleParamsData { + /// Parameters for creating a deployment rule. + #[serde(rename = "attributes")] + pub attributes: crate::datadogV2::model::CreateDeploymentRuleParamsDataAttributes, + /// Deployment rule resource type. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::DeploymentRuleDataType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl CreateDeploymentRuleParamsData { + pub fn new( + attributes: crate::datadogV2::model::CreateDeploymentRuleParamsDataAttributes, + type_: crate::datadogV2::model::DeploymentRuleDataType, + ) -> CreateDeploymentRuleParamsData { + CreateDeploymentRuleParamsData { + 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 CreateDeploymentRuleParamsData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct CreateDeploymentRuleParamsDataVisitor; + impl<'a> Visitor<'a> for CreateDeploymentRuleParamsDataVisitor { + type Value = CreateDeploymentRuleParamsData; + + 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::CreateDeploymentRuleParamsDataAttributes, + > = 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::DeploymentRuleDataType::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 = CreateDeploymentRuleParamsData { + attributes, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(CreateDeploymentRuleParamsDataVisitor) + } +} diff --git a/src/datadogV2/model/model_create_deployment_rule_params_data_attributes.rs b/src/datadogV2/model/model_create_deployment_rule_params_data_attributes.rs new file mode 100644 index 000000000..35d244004 --- /dev/null +++ b/src/datadogV2/model/model_create_deployment_rule_params_data_attributes.rs @@ -0,0 +1,141 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Parameters for creating a deployment rule. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct CreateDeploymentRuleParamsDataAttributes { + /// Whether this rule is run in dry-run mode. + #[serde(rename = "dry_run")] + pub dry_run: Option, + /// The name of the deployment rule. + #[serde(rename = "name")] + pub name: String, + /// Options for deployment rule response representing either faulty deployment detection or monitor options. + #[serde(rename = "options")] + pub options: crate::datadogV2::model::DeploymentRulesOptions, + /// The type of the deployment rule (faulty_deployment_detection or monitor). + #[serde(rename = "type")] + pub type_: String, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl CreateDeploymentRuleParamsDataAttributes { + pub fn new( + name: String, + options: crate::datadogV2::model::DeploymentRulesOptions, + type_: String, + ) -> CreateDeploymentRuleParamsDataAttributes { + CreateDeploymentRuleParamsDataAttributes { + dry_run: None, + name, + options, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn dry_run(mut self, value: bool) -> Self { + self.dry_run = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for CreateDeploymentRuleParamsDataAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct CreateDeploymentRuleParamsDataAttributesVisitor; + impl<'a> Visitor<'a> for CreateDeploymentRuleParamsDataAttributesVisitor { + type Value = CreateDeploymentRuleParamsDataAttributes; + + 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 dry_run: Option = None; + let mut name: Option = None; + let mut options: 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() { + "dry_run" => { + if v.is_null() { + continue; + } + dry_run = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "name" => { + name = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "options" => { + options = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _options) = options { + match _options { + crate::datadogV2::model::DeploymentRulesOptions::UnparsedObject(_options) => { + _unparsed = true; + }, + _ => {} + } + } + } + "type" => { + type_ = 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 name = name.ok_or_else(|| M::Error::missing_field("name"))?; + let options = options.ok_or_else(|| M::Error::missing_field("options"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = CreateDeploymentRuleParamsDataAttributes { + dry_run, + name, + options, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(CreateDeploymentRuleParamsDataAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_deployment_gate_data_type.rs b/src/datadogV2/model/model_deployment_gate_data_type.rs new file mode 100644 index 000000000..638d775ae --- /dev/null +++ b/src/datadogV2/model/model_deployment_gate_data_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 DeploymentGateDataType { + DEPLOYMENT_GATE, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for DeploymentGateDataType { + fn to_string(&self) -> String { + match self { + Self::DEPLOYMENT_GATE => String::from("deployment_gate"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for DeploymentGateDataType { + 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 DeploymentGateDataType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "deployment_gate" => Self::DEPLOYMENT_GATE, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_deployment_gate_response.rs b/src/datadogV2/model/model_deployment_gate_response.rs new file mode 100644 index 000000000..ad5909926 --- /dev/null +++ b/src/datadogV2/model/model_deployment_gate_response.rs @@ -0,0 +1,105 @@ +// 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 for a deployment gate. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct DeploymentGateResponse { + /// Data for a deployment gate. + #[serde(rename = "data")] + pub data: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl DeploymentGateResponse { + pub fn new() -> DeploymentGateResponse { + DeploymentGateResponse { + data: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn data(mut self, value: crate::datadogV2::model::DeploymentGateResponseData) -> Self { + self.data = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for DeploymentGateResponse { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for DeploymentGateResponse { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct DeploymentGateResponseVisitor; + impl<'a> Visitor<'a> for DeploymentGateResponseVisitor { + type Value = DeploymentGateResponse; + + 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" => { + if v.is_null() { + continue; + } + 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 content = DeploymentGateResponse { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(DeploymentGateResponseVisitor) + } +} diff --git a/src/datadogV2/model/model_deployment_gate_response_data.rs b/src/datadogV2/model/model_deployment_gate_response_data.rs new file mode 100644 index 000000000..318163831 --- /dev/null +++ b/src/datadogV2/model/model_deployment_gate_response_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}; + +/// Data for a deployment gate. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct DeploymentGateResponseData { + /// Basic information about a deployment gate. + #[serde(rename = "attributes")] + pub attributes: crate::datadogV2::model::DeploymentGateResponseDataAttributes, + /// Unique identifier of the deployment gate. + #[serde(rename = "id")] + pub id: String, + /// Deployment gate resource type. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::DeploymentGateDataType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl DeploymentGateResponseData { + pub fn new( + attributes: crate::datadogV2::model::DeploymentGateResponseDataAttributes, + id: String, + type_: crate::datadogV2::model::DeploymentGateDataType, + ) -> DeploymentGateResponseData { + DeploymentGateResponseData { + 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 DeploymentGateResponseData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct DeploymentGateResponseDataVisitor; + impl<'a> Visitor<'a> for DeploymentGateResponseDataVisitor { + type Value = DeploymentGateResponseData; + + 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::DeploymentGateResponseDataAttributes, + > = 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::DeploymentGateDataType::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 = DeploymentGateResponseData { + attributes, + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(DeploymentGateResponseDataVisitor) + } +} diff --git a/src/datadogV2/model/model_deployment_gate_response_data_attributes.rs b/src/datadogV2/model/model_deployment_gate_response_data_attributes.rs new file mode 100644 index 000000000..85562c891 --- /dev/null +++ b/src/datadogV2/model/model_deployment_gate_response_data_attributes.rs @@ -0,0 +1,190 @@ +// 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}; + +/// Basic information about a deployment gate. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct DeploymentGateResponseDataAttributes { + /// The timestamp when the deployment gate was created. + #[serde(rename = "created_at")] + pub created_at: chrono::DateTime, + /// Information about the user who created the deployment gate. + #[serde(rename = "created_by")] + pub created_by: crate::datadogV2::model::DeploymentGateResponseDataAttributesCreatedBy, + /// Whether this gate is run in dry-run mode. + #[serde(rename = "dry_run")] + pub dry_run: bool, + /// The environment of the deployment gate. + #[serde(rename = "env")] + pub env: String, + /// The identifier of the deployment gate. + #[serde(rename = "identifier")] + pub identifier: String, + /// The service of the deployment gate. + #[serde(rename = "service")] + pub service: String, + /// The timestamp when the deployment gate was last updated. + #[serde(rename = "updated_at")] + pub updated_at: Option>, + /// Information about the user who updated the deployment gate. + #[serde(rename = "updated_by")] + pub updated_by: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl DeploymentGateResponseDataAttributes { + pub fn new( + created_at: chrono::DateTime, + created_by: crate::datadogV2::model::DeploymentGateResponseDataAttributesCreatedBy, + dry_run: bool, + env: String, + identifier: String, + service: String, + ) -> DeploymentGateResponseDataAttributes { + DeploymentGateResponseDataAttributes { + created_at, + created_by, + dry_run, + env, + identifier, + service, + updated_at: None, + updated_by: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn updated_at(mut self, value: chrono::DateTime) -> Self { + self.updated_at = Some(value); + self + } + + pub fn updated_by( + mut self, + value: crate::datadogV2::model::DeploymentGateResponseDataAttributesUpdatedBy, + ) -> Self { + self.updated_by = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for DeploymentGateResponseDataAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct DeploymentGateResponseDataAttributesVisitor; + impl<'a> Visitor<'a> for DeploymentGateResponseDataAttributesVisitor { + type Value = DeploymentGateResponseDataAttributes; + + 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 created_at: Option> = None; + let mut created_by: Option< + crate::datadogV2::model::DeploymentGateResponseDataAttributesCreatedBy, + > = None; + let mut dry_run: Option = None; + let mut env: Option = None; + let mut identifier: Option = None; + let mut service: Option = None; + let mut updated_at: Option> = None; + let mut updated_by: Option< + crate::datadogV2::model::DeploymentGateResponseDataAttributesUpdatedBy, + > = 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() { + "created_at" => { + created_at = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "created_by" => { + created_by = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "dry_run" => { + dry_run = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "env" => { + env = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "identifier" => { + identifier = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "service" => { + service = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "updated_at" => { + if v.is_null() { + continue; + } + updated_at = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "updated_by" => { + if v.is_null() { + continue; + } + updated_by = 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 created_at = created_at.ok_or_else(|| M::Error::missing_field("created_at"))?; + let created_by = created_by.ok_or_else(|| M::Error::missing_field("created_by"))?; + let dry_run = dry_run.ok_or_else(|| M::Error::missing_field("dry_run"))?; + let env = env.ok_or_else(|| M::Error::missing_field("env"))?; + let identifier = identifier.ok_or_else(|| M::Error::missing_field("identifier"))?; + let service = service.ok_or_else(|| M::Error::missing_field("service"))?; + + let content = DeploymentGateResponseDataAttributes { + created_at, + created_by, + dry_run, + env, + identifier, + service, + updated_at, + updated_by, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(DeploymentGateResponseDataAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_deployment_gate_response_data_attributes_created_by.rs b/src/datadogV2/model/model_deployment_gate_response_data_attributes_created_by.rs new file mode 100644 index 000000000..866ea6324 --- /dev/null +++ b/src/datadogV2/model/model_deployment_gate_response_data_attributes_created_by.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}; + +/// Information about the user who created the deployment gate. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct DeploymentGateResponseDataAttributesCreatedBy { + /// The handle of the user who created the deployment rule. + #[serde(rename = "handle")] + pub handle: Option, + /// The ID of the user who created the deployment rule. + #[serde(rename = "id")] + pub id: String, + /// The name of the user who created the deployment rule. + #[serde(rename = "name")] + pub name: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl DeploymentGateResponseDataAttributesCreatedBy { + pub fn new(id: String) -> DeploymentGateResponseDataAttributesCreatedBy { + DeploymentGateResponseDataAttributesCreatedBy { + handle: None, + id, + name: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn handle(mut self, value: String) -> Self { + self.handle = Some(value); + self + } + + pub fn name(mut self, value: String) -> Self { + self.name = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for DeploymentGateResponseDataAttributesCreatedBy { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct DeploymentGateResponseDataAttributesCreatedByVisitor; + impl<'a> Visitor<'a> for DeploymentGateResponseDataAttributesCreatedByVisitor { + type Value = DeploymentGateResponseDataAttributesCreatedBy; + + 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 handle: Option = None; + let mut id: Option = None; + let mut name: 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() { + "handle" => { + if v.is_null() { + continue; + } + handle = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "id" => { + id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "name" => { + if v.is_null() { + continue; + } + name = 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 id = id.ok_or_else(|| M::Error::missing_field("id"))?; + + let content = DeploymentGateResponseDataAttributesCreatedBy { + handle, + id, + name, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(DeploymentGateResponseDataAttributesCreatedByVisitor) + } +} diff --git a/src/datadogV2/model/model_deployment_gate_response_data_attributes_updated_by.rs b/src/datadogV2/model/model_deployment_gate_response_data_attributes_updated_by.rs new file mode 100644 index 000000000..6d99d2596 --- /dev/null +++ b/src/datadogV2/model/model_deployment_gate_response_data_attributes_updated_by.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}; + +/// Information about the user who updated the deployment gate. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct DeploymentGateResponseDataAttributesUpdatedBy { + /// The handle of the user who updated the deployment rule. + #[serde(rename = "handle")] + pub handle: Option, + /// The ID of the user who updated the deployment rule. + #[serde(rename = "id")] + pub id: String, + /// The name of the user who updated the deployment rule. + #[serde(rename = "name")] + pub name: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl DeploymentGateResponseDataAttributesUpdatedBy { + pub fn new(id: String) -> DeploymentGateResponseDataAttributesUpdatedBy { + DeploymentGateResponseDataAttributesUpdatedBy { + handle: None, + id, + name: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn handle(mut self, value: String) -> Self { + self.handle = Some(value); + self + } + + pub fn name(mut self, value: String) -> Self { + self.name = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for DeploymentGateResponseDataAttributesUpdatedBy { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct DeploymentGateResponseDataAttributesUpdatedByVisitor; + impl<'a> Visitor<'a> for DeploymentGateResponseDataAttributesUpdatedByVisitor { + type Value = DeploymentGateResponseDataAttributesUpdatedBy; + + 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 handle: Option = None; + let mut id: Option = None; + let mut name: 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() { + "handle" => { + if v.is_null() { + continue; + } + handle = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "id" => { + id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "name" => { + if v.is_null() { + continue; + } + name = 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 id = id.ok_or_else(|| M::Error::missing_field("id"))?; + + let content = DeploymentGateResponseDataAttributesUpdatedBy { + handle, + id, + name, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(DeploymentGateResponseDataAttributesUpdatedByVisitor) + } +} diff --git a/src/datadogV2/model/model_deployment_rule_data_type.rs b/src/datadogV2/model/model_deployment_rule_data_type.rs new file mode 100644 index 000000000..b341763da --- /dev/null +++ b/src/datadogV2/model/model_deployment_rule_data_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 DeploymentRuleDataType { + DEPLOYMENT_RULE, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for DeploymentRuleDataType { + fn to_string(&self) -> String { + match self { + Self::DEPLOYMENT_RULE => String::from("deployment_rule"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for DeploymentRuleDataType { + 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 DeploymentRuleDataType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "deployment_rule" => Self::DEPLOYMENT_RULE, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_deployment_rule_options_faulty_deployment_detection.rs b/src/datadogV2/model/model_deployment_rule_options_faulty_deployment_detection.rs new file mode 100644 index 000000000..a73fade48 --- /dev/null +++ b/src/datadogV2/model/model_deployment_rule_options_faulty_deployment_detection.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}; + +/// Faulty deployment detection options for deployment rules. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct DeploymentRuleOptionsFaultyDeploymentDetection { + /// The duration for faulty deployment detection. + #[serde(rename = "duration")] + pub duration: Option, + /// Resources to exclude from faulty deployment detection. + #[serde(rename = "excluded_resources")] + pub excluded_resources: Option>, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl DeploymentRuleOptionsFaultyDeploymentDetection { + pub fn new() -> DeploymentRuleOptionsFaultyDeploymentDetection { + DeploymentRuleOptionsFaultyDeploymentDetection { + duration: None, + excluded_resources: None, + _unparsed: false, + } + } + + pub fn duration(mut self, value: i64) -> Self { + self.duration = Some(value); + self + } + + pub fn excluded_resources(mut self, value: Vec) -> Self { + self.excluded_resources = Some(value); + self + } +} + +impl Default for DeploymentRuleOptionsFaultyDeploymentDetection { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for DeploymentRuleOptionsFaultyDeploymentDetection { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct DeploymentRuleOptionsFaultyDeploymentDetectionVisitor; + impl<'a> Visitor<'a> for DeploymentRuleOptionsFaultyDeploymentDetectionVisitor { + type Value = DeploymentRuleOptionsFaultyDeploymentDetection; + + 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 duration: Option = None; + let mut excluded_resources: Option> = None; + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "duration" => { + if v.is_null() { + continue; + } + duration = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "excluded_resources" => { + if v.is_null() { + continue; + } + excluded_resources = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + return Err(serde::de::Error::custom( + "Additional properties not allowed", + )); + } + } + } + + let content = DeploymentRuleOptionsFaultyDeploymentDetection { + duration, + excluded_resources, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(DeploymentRuleOptionsFaultyDeploymentDetectionVisitor) + } +} diff --git a/src/datadogV2/model/model_deployment_rule_options_monitor.rs b/src/datadogV2/model/model_deployment_rule_options_monitor.rs new file mode 100644 index 000000000..e6d6b284f --- /dev/null +++ b/src/datadogV2/model/model_deployment_rule_options_monitor.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}; + +/// Monitor options for deployment rules. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct DeploymentRuleOptionsMonitor { + /// Seconds the monitor needs to stay in OK status for the rule to pass. + #[serde(rename = "duration")] + pub duration: Option, + /// Monitors that match this query are evaluated. + #[serde(rename = "query")] + pub query: String, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl DeploymentRuleOptionsMonitor { + pub fn new(query: String) -> DeploymentRuleOptionsMonitor { + DeploymentRuleOptionsMonitor { + duration: None, + query, + _unparsed: false, + } + } + + pub fn duration(mut self, value: i64) -> Self { + self.duration = Some(value); + self + } +} + +impl<'de> Deserialize<'de> for DeploymentRuleOptionsMonitor { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct DeploymentRuleOptionsMonitorVisitor; + impl<'a> Visitor<'a> for DeploymentRuleOptionsMonitorVisitor { + type Value = DeploymentRuleOptionsMonitor; + + 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 duration: Option = None; + let mut query: Option = None; + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "duration" => { + if v.is_null() { + continue; + } + duration = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "query" => { + query = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + return Err(serde::de::Error::custom( + "Additional properties not allowed", + )); + } + } + } + let query = query.ok_or_else(|| M::Error::missing_field("query"))?; + + let content = DeploymentRuleOptionsMonitor { + duration, + query, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(DeploymentRuleOptionsMonitorVisitor) + } +} diff --git a/src/datadogV2/model/model_deployment_rule_response.rs b/src/datadogV2/model/model_deployment_rule_response.rs new file mode 100644 index 000000000..7b8d652ad --- /dev/null +++ b/src/datadogV2/model/model_deployment_rule_response.rs @@ -0,0 +1,105 @@ +// 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 for a deployment rule. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct DeploymentRuleResponse { + /// Data for a deployment rule. + #[serde(rename = "data")] + pub data: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl DeploymentRuleResponse { + pub fn new() -> DeploymentRuleResponse { + DeploymentRuleResponse { + data: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn data(mut self, value: crate::datadogV2::model::DeploymentRuleResponseData) -> Self { + self.data = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for DeploymentRuleResponse { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for DeploymentRuleResponse { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct DeploymentRuleResponseVisitor; + impl<'a> Visitor<'a> for DeploymentRuleResponseVisitor { + type Value = DeploymentRuleResponse; + + 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" => { + if v.is_null() { + continue; + } + 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 content = DeploymentRuleResponse { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(DeploymentRuleResponseVisitor) + } +} diff --git a/src/datadogV2/model/model_deployment_rule_response_data.rs b/src/datadogV2/model/model_deployment_rule_response_data.rs new file mode 100644 index 000000000..85d24f7a8 --- /dev/null +++ b/src/datadogV2/model/model_deployment_rule_response_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}; + +/// Data for a deployment rule. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct DeploymentRuleResponseData { + /// Basic information about a deployment rule. + #[serde(rename = "attributes")] + pub attributes: crate::datadogV2::model::DeploymentRuleResponseDataAttributes, + /// Unique identifier of the deployment rule. + #[serde(rename = "id")] + pub id: String, + /// Deployment rule resource type. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::DeploymentRuleDataType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl DeploymentRuleResponseData { + pub fn new( + attributes: crate::datadogV2::model::DeploymentRuleResponseDataAttributes, + id: String, + type_: crate::datadogV2::model::DeploymentRuleDataType, + ) -> DeploymentRuleResponseData { + DeploymentRuleResponseData { + 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 DeploymentRuleResponseData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct DeploymentRuleResponseDataVisitor; + impl<'a> Visitor<'a> for DeploymentRuleResponseDataVisitor { + type Value = DeploymentRuleResponseData; + + 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::DeploymentRuleResponseDataAttributes, + > = 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::DeploymentRuleDataType::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 = DeploymentRuleResponseData { + attributes, + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(DeploymentRuleResponseDataVisitor) + } +} diff --git a/src/datadogV2/model/model_deployment_rule_response_data_attributes.rs b/src/datadogV2/model/model_deployment_rule_response_data_attributes.rs new file mode 100644 index 000000000..ac4e07140 --- /dev/null +++ b/src/datadogV2/model/model_deployment_rule_response_data_attributes.rs @@ -0,0 +1,219 @@ +// 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}; + +/// Basic information about a deployment rule. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct DeploymentRuleResponseDataAttributes { + /// The timestamp when the deployment rule was created. + #[serde(rename = "created_at")] + pub created_at: chrono::DateTime, + /// Information about the user who created the deployment rule. + #[serde(rename = "created_by")] + pub created_by: crate::datadogV2::model::DeploymentRuleResponseDataAttributesCreatedBy, + /// Whether this rule is run in dry-run mode. + #[serde(rename = "dry_run")] + pub dry_run: bool, + /// The ID of the deployment gate. + #[serde(rename = "gate_id")] + pub gate_id: String, + /// The name of the deployment rule. + #[serde(rename = "name")] + pub name: String, + /// Options for deployment rule response representing either faulty deployment detection or monitor options. + #[serde(rename = "options")] + pub options: crate::datadogV2::model::DeploymentRulesOptions, + /// The type of the deployment rule. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::DeploymentRuleResponseDataAttributesType, + /// The timestamp when the deployment rule was last updated. + #[serde(rename = "updated_at")] + pub updated_at: Option>, + /// Information about the user who updated the deployment rule. + #[serde(rename = "updated_by")] + pub updated_by: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl DeploymentRuleResponseDataAttributes { + pub fn new( + created_at: chrono::DateTime, + created_by: crate::datadogV2::model::DeploymentRuleResponseDataAttributesCreatedBy, + dry_run: bool, + gate_id: String, + name: String, + options: crate::datadogV2::model::DeploymentRulesOptions, + type_: crate::datadogV2::model::DeploymentRuleResponseDataAttributesType, + ) -> DeploymentRuleResponseDataAttributes { + DeploymentRuleResponseDataAttributes { + created_at, + created_by, + dry_run, + gate_id, + name, + options, + type_, + updated_at: None, + updated_by: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn updated_at(mut self, value: chrono::DateTime) -> Self { + self.updated_at = Some(value); + self + } + + pub fn updated_by( + mut self, + value: crate::datadogV2::model::DeploymentRuleResponseDataAttributesUpdatedBy, + ) -> Self { + self.updated_by = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for DeploymentRuleResponseDataAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct DeploymentRuleResponseDataAttributesVisitor; + impl<'a> Visitor<'a> for DeploymentRuleResponseDataAttributesVisitor { + type Value = DeploymentRuleResponseDataAttributes; + + 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 created_at: Option> = None; + let mut created_by: Option< + crate::datadogV2::model::DeploymentRuleResponseDataAttributesCreatedBy, + > = None; + let mut dry_run: Option = None; + let mut gate_id: Option = None; + let mut name: Option = None; + let mut options: Option = None; + let mut type_: Option< + crate::datadogV2::model::DeploymentRuleResponseDataAttributesType, + > = None; + let mut updated_at: Option> = None; + let mut updated_by: Option< + crate::datadogV2::model::DeploymentRuleResponseDataAttributesUpdatedBy, + > = 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() { + "created_at" => { + created_at = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "created_by" => { + created_by = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "dry_run" => { + dry_run = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "gate_id" => { + gate_id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "name" => { + name = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "options" => { + options = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _options) = options { + match _options { + crate::datadogV2::model::DeploymentRulesOptions::UnparsedObject(_options) => { + _unparsed = true; + }, + _ => {} + } + } + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::DeploymentRuleResponseDataAttributesType::UnparsedObject(_type_) => { + _unparsed = true; + }, + _ => {} + } + } + } + "updated_at" => { + if v.is_null() { + continue; + } + updated_at = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "updated_by" => { + if v.is_null() { + continue; + } + updated_by = 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 created_at = created_at.ok_or_else(|| M::Error::missing_field("created_at"))?; + let created_by = created_by.ok_or_else(|| M::Error::missing_field("created_by"))?; + let dry_run = dry_run.ok_or_else(|| M::Error::missing_field("dry_run"))?; + let gate_id = gate_id.ok_or_else(|| M::Error::missing_field("gate_id"))?; + let name = name.ok_or_else(|| M::Error::missing_field("name"))?; + let options = options.ok_or_else(|| M::Error::missing_field("options"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = DeploymentRuleResponseDataAttributes { + created_at, + created_by, + dry_run, + gate_id, + name, + options, + type_, + updated_at, + updated_by, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(DeploymentRuleResponseDataAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_deployment_rule_response_data_attributes_created_by.rs b/src/datadogV2/model/model_deployment_rule_response_data_attributes_created_by.rs new file mode 100644 index 000000000..0b1a70259 --- /dev/null +++ b/src/datadogV2/model/model_deployment_rule_response_data_attributes_created_by.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}; + +/// Information about the user who created the deployment rule. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct DeploymentRuleResponseDataAttributesCreatedBy { + /// The handle of the user who created the deployment rule. + #[serde(rename = "handle")] + pub handle: Option, + /// The ID of the user who created the deployment rule. + #[serde(rename = "id")] + pub id: String, + /// The name of the user who created the deployment rule. + #[serde(rename = "name")] + pub name: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl DeploymentRuleResponseDataAttributesCreatedBy { + pub fn new(id: String) -> DeploymentRuleResponseDataAttributesCreatedBy { + DeploymentRuleResponseDataAttributesCreatedBy { + handle: None, + id, + name: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn handle(mut self, value: String) -> Self { + self.handle = Some(value); + self + } + + pub fn name(mut self, value: String) -> Self { + self.name = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for DeploymentRuleResponseDataAttributesCreatedBy { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct DeploymentRuleResponseDataAttributesCreatedByVisitor; + impl<'a> Visitor<'a> for DeploymentRuleResponseDataAttributesCreatedByVisitor { + type Value = DeploymentRuleResponseDataAttributesCreatedBy; + + 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 handle: Option = None; + let mut id: Option = None; + let mut name: 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() { + "handle" => { + if v.is_null() { + continue; + } + handle = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "id" => { + id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "name" => { + if v.is_null() { + continue; + } + name = 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 id = id.ok_or_else(|| M::Error::missing_field("id"))?; + + let content = DeploymentRuleResponseDataAttributesCreatedBy { + handle, + id, + name, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(DeploymentRuleResponseDataAttributesCreatedByVisitor) + } +} diff --git a/src/datadogV2/model/model_deployment_rule_response_data_attributes_type.rs b/src/datadogV2/model/model_deployment_rule_response_data_attributes_type.rs new file mode 100644 index 000000000..e6ebe8946 --- /dev/null +++ b/src/datadogV2/model/model_deployment_rule_response_data_attributes_type.rs @@ -0,0 +1,51 @@ +// 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 DeploymentRuleResponseDataAttributesType { + FAULTY_DEPLOYMENT_DETECTION, + MONITOR, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for DeploymentRuleResponseDataAttributesType { + fn to_string(&self) -> String { + match self { + Self::FAULTY_DEPLOYMENT_DETECTION => String::from("faulty_deployment_detection"), + Self::MONITOR => String::from("monitor"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for DeploymentRuleResponseDataAttributesType { + 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 DeploymentRuleResponseDataAttributesType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "faulty_deployment_detection" => Self::FAULTY_DEPLOYMENT_DETECTION, + "monitor" => Self::MONITOR, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_deployment_rule_response_data_attributes_updated_by.rs b/src/datadogV2/model/model_deployment_rule_response_data_attributes_updated_by.rs new file mode 100644 index 000000000..0d5906685 --- /dev/null +++ b/src/datadogV2/model/model_deployment_rule_response_data_attributes_updated_by.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}; + +/// Information about the user who updated the deployment rule. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct DeploymentRuleResponseDataAttributesUpdatedBy { + /// The handle of the user who updated the deployment rule. + #[serde(rename = "handle")] + pub handle: Option, + /// The ID of the user who updated the deployment rule. + #[serde(rename = "id")] + pub id: String, + /// The name of the user who updated the deployment rule. + #[serde(rename = "name")] + pub name: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl DeploymentRuleResponseDataAttributesUpdatedBy { + pub fn new(id: String) -> DeploymentRuleResponseDataAttributesUpdatedBy { + DeploymentRuleResponseDataAttributesUpdatedBy { + handle: None, + id, + name: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn handle(mut self, value: String) -> Self { + self.handle = Some(value); + self + } + + pub fn name(mut self, value: String) -> Self { + self.name = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for DeploymentRuleResponseDataAttributesUpdatedBy { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct DeploymentRuleResponseDataAttributesUpdatedByVisitor; + impl<'a> Visitor<'a> for DeploymentRuleResponseDataAttributesUpdatedByVisitor { + type Value = DeploymentRuleResponseDataAttributesUpdatedBy; + + 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 handle: Option = None; + let mut id: Option = None; + let mut name: 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() { + "handle" => { + if v.is_null() { + continue; + } + handle = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "id" => { + id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "name" => { + if v.is_null() { + continue; + } + name = 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 id = id.ok_or_else(|| M::Error::missing_field("id"))?; + + let content = DeploymentRuleResponseDataAttributesUpdatedBy { + handle, + id, + name, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(DeploymentRuleResponseDataAttributesUpdatedByVisitor) + } +} diff --git a/src/datadogV2/model/model_deployment_rules_options.rs b/src/datadogV2/model/model_deployment_rules_options.rs new file mode 100644 index 000000000..30b1bf64d --- /dev/null +++ b/src/datadogV2/model/model_deployment_rules_options.rs @@ -0,0 +1,47 @@ +// 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}; + +/// Options for deployment rule response representing either faulty deployment detection or monitor options. +#[non_exhaustive] +#[derive(Clone, Debug, PartialEq, Serialize)] +#[serde(untagged)] +pub enum DeploymentRulesOptions { + DeploymentRuleOptionsFaultyDeploymentDetection( + Box, + ), + DeploymentRuleOptionsMonitor(Box), + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl<'de> Deserialize<'de> for DeploymentRulesOptions { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let value: serde_json::Value = Deserialize::deserialize(deserializer)?; + if let Ok(_v) = serde_json::from_value::< + Box, + >(value.clone()) + { + if !_v._unparsed { + return Ok( + DeploymentRulesOptions::DeploymentRuleOptionsFaultyDeploymentDetection(_v), + ); + } + } + if let Ok(_v) = serde_json::from_value::< + Box, + >(value.clone()) + { + if !_v._unparsed { + return Ok(DeploymentRulesOptions::DeploymentRuleOptionsMonitor(_v)); + } + } + + return Ok(DeploymentRulesOptions::UnparsedObject( + crate::datadog::UnparsedObject { value }, + )); + } +} diff --git a/src/datadogV2/model/model_httpcd_gates_bad_request_response.rs b/src/datadogV2/model/model_httpcd_gates_bad_request_response.rs new file mode 100644 index 000000000..5a1c2a3bf --- /dev/null +++ b/src/datadogV2/model/model_httpcd_gates_bad_request_response.rs @@ -0,0 +1,105 @@ +// 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}; + +/// Bad request. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct HTTPCDGatesBadRequestResponse { + /// Structured errors. + #[serde(rename = "errors")] + pub errors: Option>, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl HTTPCDGatesBadRequestResponse { + pub fn new() -> HTTPCDGatesBadRequestResponse { + HTTPCDGatesBadRequestResponse { + errors: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn errors(mut self, value: Vec) -> Self { + self.errors = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for HTTPCDGatesBadRequestResponse { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for HTTPCDGatesBadRequestResponse { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct HTTPCDGatesBadRequestResponseVisitor; + impl<'a> Visitor<'a> for HTTPCDGatesBadRequestResponseVisitor { + type Value = HTTPCDGatesBadRequestResponse; + + 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 errors: 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() { + "errors" => { + if v.is_null() { + continue; + } + errors = 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 content = HTTPCDGatesBadRequestResponse { + errors, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(HTTPCDGatesBadRequestResponseVisitor) + } +} diff --git a/src/datadogV2/model/model_httpcd_gates_not_found_response.rs b/src/datadogV2/model/model_httpcd_gates_not_found_response.rs new file mode 100644 index 000000000..3a4e7414c --- /dev/null +++ b/src/datadogV2/model/model_httpcd_gates_not_found_response.rs @@ -0,0 +1,105 @@ +// 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}; + +/// Deployment gate not found. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct HTTPCDGatesNotFoundResponse { + /// Structured errors. + #[serde(rename = "errors")] + pub errors: Option>, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl HTTPCDGatesNotFoundResponse { + pub fn new() -> HTTPCDGatesNotFoundResponse { + HTTPCDGatesNotFoundResponse { + errors: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn errors(mut self, value: Vec) -> Self { + self.errors = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for HTTPCDGatesNotFoundResponse { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for HTTPCDGatesNotFoundResponse { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct HTTPCDGatesNotFoundResponseVisitor; + impl<'a> Visitor<'a> for HTTPCDGatesNotFoundResponseVisitor { + type Value = HTTPCDGatesNotFoundResponse; + + 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 errors: 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() { + "errors" => { + if v.is_null() { + continue; + } + errors = 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 content = HTTPCDGatesNotFoundResponse { + errors, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(HTTPCDGatesNotFoundResponseVisitor) + } +} diff --git a/src/datadogV2/model/model_httpcd_rules_not_found_response.rs b/src/datadogV2/model/model_httpcd_rules_not_found_response.rs new file mode 100644 index 000000000..a008a0d45 --- /dev/null +++ b/src/datadogV2/model/model_httpcd_rules_not_found_response.rs @@ -0,0 +1,105 @@ +// 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}; + +/// Deployment rule not found. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct HTTPCDRulesNotFoundResponse { + /// Structured errors. + #[serde(rename = "errors")] + pub errors: Option>, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl HTTPCDRulesNotFoundResponse { + pub fn new() -> HTTPCDRulesNotFoundResponse { + HTTPCDRulesNotFoundResponse { + errors: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn errors(mut self, value: Vec) -> Self { + self.errors = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for HTTPCDRulesNotFoundResponse { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for HTTPCDRulesNotFoundResponse { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct HTTPCDRulesNotFoundResponseVisitor; + impl<'a> Visitor<'a> for HTTPCDRulesNotFoundResponseVisitor { + type Value = HTTPCDRulesNotFoundResponse; + + 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 errors: 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() { + "errors" => { + if v.is_null() { + continue; + } + errors = 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 content = HTTPCDRulesNotFoundResponse { + errors, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(HTTPCDRulesNotFoundResponseVisitor) + } +} diff --git a/src/datadogV2/model/model_update_deployment_gate_params.rs b/src/datadogV2/model/model_update_deployment_gate_params.rs new file mode 100644 index 000000000..cbe2e8bae --- /dev/null +++ b/src/datadogV2/model/model_update_deployment_gate_params.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}; + +/// Parameters for updating a deployment gate. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct UpdateDeploymentGateParams { + /// Parameters for updating a deployment gate. + #[serde(rename = "data")] + pub data: crate::datadogV2::model::UpdateDeploymentGateParamsData, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl UpdateDeploymentGateParams { + pub fn new( + data: crate::datadogV2::model::UpdateDeploymentGateParamsData, + ) -> UpdateDeploymentGateParams { + UpdateDeploymentGateParams { + 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 UpdateDeploymentGateParams { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct UpdateDeploymentGateParamsVisitor; + impl<'a> Visitor<'a> for UpdateDeploymentGateParamsVisitor { + type Value = UpdateDeploymentGateParams; + + 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 = UpdateDeploymentGateParams { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(UpdateDeploymentGateParamsVisitor) + } +} diff --git a/src/datadogV2/model/model_update_deployment_gate_params_data.rs b/src/datadogV2/model/model_update_deployment_gate_params_data.rs new file mode 100644 index 000000000..bc1eb2c9c --- /dev/null +++ b/src/datadogV2/model/model_update_deployment_gate_params_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}; + +/// Parameters for updating a deployment gate. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct UpdateDeploymentGateParamsData { + /// Attributes for updating a deployment gate. + #[serde(rename = "attributes")] + pub attributes: crate::datadogV2::model::UpdateDeploymentGateParamsDataAttributes, + /// Unique identifier of the deployment gate. + #[serde(rename = "id")] + pub id: String, + /// Deployment gate resource type. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::DeploymentGateDataType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl UpdateDeploymentGateParamsData { + pub fn new( + attributes: crate::datadogV2::model::UpdateDeploymentGateParamsDataAttributes, + id: String, + type_: crate::datadogV2::model::DeploymentGateDataType, + ) -> UpdateDeploymentGateParamsData { + UpdateDeploymentGateParamsData { + 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 UpdateDeploymentGateParamsData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct UpdateDeploymentGateParamsDataVisitor; + impl<'a> Visitor<'a> for UpdateDeploymentGateParamsDataVisitor { + type Value = UpdateDeploymentGateParamsData; + + 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::UpdateDeploymentGateParamsDataAttributes, + > = 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::DeploymentGateDataType::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 = UpdateDeploymentGateParamsData { + attributes, + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(UpdateDeploymentGateParamsDataVisitor) + } +} diff --git a/src/datadogV2/model/model_update_deployment_gate_params_data_attributes.rs b/src/datadogV2/model/model_update_deployment_gate_params_data_attributes.rs new file mode 100644 index 000000000..6dff23fad --- /dev/null +++ b/src/datadogV2/model/model_update_deployment_gate_params_data_attributes.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}; + +/// Attributes for updating a deployment gate. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct UpdateDeploymentGateParamsDataAttributes { + /// Whether to run in dry-run mode. + #[serde(rename = "dry_run")] + pub dry_run: bool, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl UpdateDeploymentGateParamsDataAttributes { + pub fn new(dry_run: bool) -> UpdateDeploymentGateParamsDataAttributes { + UpdateDeploymentGateParamsDataAttributes { + dry_run, + 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 UpdateDeploymentGateParamsDataAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct UpdateDeploymentGateParamsDataAttributesVisitor; + impl<'a> Visitor<'a> for UpdateDeploymentGateParamsDataAttributesVisitor { + type Value = UpdateDeploymentGateParamsDataAttributes; + + 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 dry_run: 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() { + "dry_run" => { + dry_run = 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 dry_run = dry_run.ok_or_else(|| M::Error::missing_field("dry_run"))?; + + let content = UpdateDeploymentGateParamsDataAttributes { + dry_run, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(UpdateDeploymentGateParamsDataAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_update_deployment_rule_params.rs b/src/datadogV2/model/model_update_deployment_rule_params.rs new file mode 100644 index 000000000..69605615c --- /dev/null +++ b/src/datadogV2/model/model_update_deployment_rule_params.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}; + +/// Parameters for updating a deployment rule. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct UpdateDeploymentRuleParams { + /// Parameters for updating a deployment rule. + #[serde(rename = "data")] + pub data: crate::datadogV2::model::UpdateDeploymentRuleParamsData, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl UpdateDeploymentRuleParams { + pub fn new( + data: crate::datadogV2::model::UpdateDeploymentRuleParamsData, + ) -> UpdateDeploymentRuleParams { + UpdateDeploymentRuleParams { + 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 UpdateDeploymentRuleParams { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct UpdateDeploymentRuleParamsVisitor; + impl<'a> Visitor<'a> for UpdateDeploymentRuleParamsVisitor { + type Value = UpdateDeploymentRuleParams; + + 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 = UpdateDeploymentRuleParams { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(UpdateDeploymentRuleParamsVisitor) + } +} diff --git a/src/datadogV2/model/model_update_deployment_rule_params_data.rs b/src/datadogV2/model/model_update_deployment_rule_params_data.rs new file mode 100644 index 000000000..463779b66 --- /dev/null +++ b/src/datadogV2/model/model_update_deployment_rule_params_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}; + +/// Parameters for updating a deployment rule. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct UpdateDeploymentRuleParamsData { + /// Parameters for updating a deployment rule. + #[serde(rename = "attributes")] + pub attributes: crate::datadogV2::model::UpdateDeploymentRuleParamsDataAttributes, + /// Deployment rule resource type. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::DeploymentRuleDataType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl UpdateDeploymentRuleParamsData { + pub fn new( + attributes: crate::datadogV2::model::UpdateDeploymentRuleParamsDataAttributes, + type_: crate::datadogV2::model::DeploymentRuleDataType, + ) -> UpdateDeploymentRuleParamsData { + UpdateDeploymentRuleParamsData { + 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 UpdateDeploymentRuleParamsData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct UpdateDeploymentRuleParamsDataVisitor; + impl<'a> Visitor<'a> for UpdateDeploymentRuleParamsDataVisitor { + type Value = UpdateDeploymentRuleParamsData; + + 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::UpdateDeploymentRuleParamsDataAttributes, + > = 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::DeploymentRuleDataType::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 = UpdateDeploymentRuleParamsData { + attributes, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(UpdateDeploymentRuleParamsDataVisitor) + } +} diff --git a/src/datadogV2/model/model_update_deployment_rule_params_data_attributes.rs b/src/datadogV2/model/model_update_deployment_rule_params_data_attributes.rs new file mode 100644 index 000000000..3163282e4 --- /dev/null +++ b/src/datadogV2/model/model_update_deployment_rule_params_data_attributes.rs @@ -0,0 +1,124 @@ +// 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}; + +/// Parameters for updating a deployment rule. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct UpdateDeploymentRuleParamsDataAttributes { + /// Whether to run this rule in dry-run mode. + #[serde(rename = "dry_run")] + pub dry_run: bool, + /// The name of the deployment rule. + #[serde(rename = "name")] + pub name: String, + /// Options for deployment rule response representing either faulty deployment detection or monitor options. + #[serde(rename = "options")] + pub options: crate::datadogV2::model::DeploymentRulesOptions, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl UpdateDeploymentRuleParamsDataAttributes { + pub fn new( + dry_run: bool, + name: String, + options: crate::datadogV2::model::DeploymentRulesOptions, + ) -> UpdateDeploymentRuleParamsDataAttributes { + UpdateDeploymentRuleParamsDataAttributes { + dry_run, + name, + options, + 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 UpdateDeploymentRuleParamsDataAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct UpdateDeploymentRuleParamsDataAttributesVisitor; + impl<'a> Visitor<'a> for UpdateDeploymentRuleParamsDataAttributesVisitor { + type Value = UpdateDeploymentRuleParamsDataAttributes; + + 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 dry_run: Option = None; + let mut name: Option = None; + let mut options: 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() { + "dry_run" => { + dry_run = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "name" => { + name = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "options" => { + options = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _options) = options { + match _options { + crate::datadogV2::model::DeploymentRulesOptions::UnparsedObject(_options) => { + _unparsed = true; + }, + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let dry_run = dry_run.ok_or_else(|| M::Error::missing_field("dry_run"))?; + let name = name.ok_or_else(|| M::Error::missing_field("name"))?; + let options = options.ok_or_else(|| M::Error::missing_field("options"))?; + + let content = UpdateDeploymentRuleParamsDataAttributes { + dry_run, + name, + options, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(UpdateDeploymentRuleParamsDataAttributesVisitor) + } +} diff --git a/tests/scenarios/cassettes/v2/deployment_gates/Create-deployment-gate-returns-Bad-Request-response.frozen b/tests/scenarios/cassettes/v2/deployment_gates/Create-deployment-gate-returns-Bad-Request-response.frozen new file mode 100644 index 000000000..3c155e790 --- /dev/null +++ b/tests/scenarios/cassettes/v2/deployment_gates/Create-deployment-gate-returns-Bad-Request-response.frozen @@ -0,0 +1 @@ +2025-10-28T14:03:25.410Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/deployment_gates/Create-deployment-gate-returns-Bad-Request-response.json b/tests/scenarios/cassettes/v2/deployment_gates/Create-deployment-gate-returns-Bad-Request-response.json new file mode 100644 index 000000000..abce249a7 --- /dev/null +++ b/tests/scenarios/cassettes/v2/deployment_gates/Create-deployment-gate-returns-Bad-Request-response.json @@ -0,0 +1,39 @@ +{ + "http_interactions": [ + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"env\":\"\",\"identifier\":\"my-gate\",\"service\":\"test-service\"},\"type\":\"deployment_gate\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v2/deployment_gates" + }, + "response": { + "body": { + "string": "{\"errors\":[{\"status\":\"400\",\"title\":\"Bad Request\",\"detail\":\"attribute \\\"env\\\" is required\"}]}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 400, + "message": "Bad Request" + } + }, + "recorded_at": "Tue, 28 Oct 2025 14:03:25 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/deployment_gates/Create-deployment-gate-returns-OK-response.frozen b/tests/scenarios/cassettes/v2/deployment_gates/Create-deployment-gate-returns-OK-response.frozen new file mode 100644 index 000000000..89457259c --- /dev/null +++ b/tests/scenarios/cassettes/v2/deployment_gates/Create-deployment-gate-returns-OK-response.frozen @@ -0,0 +1 @@ +2025-10-28T14:03:26.103Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/deployment_gates/Create-deployment-gate-returns-OK-response.json b/tests/scenarios/cassettes/v2/deployment_gates/Create-deployment-gate-returns-OK-response.json new file mode 100644 index 000000000..003147943 --- /dev/null +++ b/tests/scenarios/cassettes/v2/deployment_gates/Create-deployment-gate-returns-OK-response.json @@ -0,0 +1,63 @@ +{ + "http_interactions": [ + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"dry_run\":false,\"env\":\"production\",\"identifier\":\"my-gate-1\",\"service\":\"my-service\"},\"type\":\"deployment_gate\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v2/deployment_gates" + }, + "response": { + "body": { + "string": "{\"data\":{\"id\":\"0cc075c2-fec1-4ed3-9e43-0882646fac07\",\"type\":\"deployment_gate\",\"attributes\":{\"created_at\":\"2025-10-28T14:03:26.337009Z\",\"created_by\":{\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"name\":\"CI Account\",\"handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\"},\"dry_run\":false,\"env\":\"production\",\"identifier\":\"my-gate-1\",\"service\":\"my-service\",\"updated_at\":\"2025-10-28T14:03:26.337009Z\",\"updated_by\":{\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"name\":\"CI Account\",\"handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\"}}}}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 200, + "message": "OK" + } + }, + "recorded_at": "Tue, 28 Oct 2025 14:03:26 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/deployment_gates/0cc075c2-fec1-4ed3-9e43-0882646fac07" + }, + "response": { + "body": { + "string": "", + "encoding": null + }, + "headers": {}, + "status": { + "code": 204, + "message": "No Content" + } + }, + "recorded_at": "Tue, 28 Oct 2025 14:03:26 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/deployment_gates/Create-deployment-rule-returns-Bad-Request-response.frozen b/tests/scenarios/cassettes/v2/deployment_gates/Create-deployment-rule-returns-Bad-Request-response.frozen new file mode 100644 index 000000000..70cc3602d --- /dev/null +++ b/tests/scenarios/cassettes/v2/deployment_gates/Create-deployment-rule-returns-Bad-Request-response.frozen @@ -0,0 +1 @@ +2025-10-28T14:51:12.459Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/deployment_gates/Create-deployment-rule-returns-Bad-Request-response.json b/tests/scenarios/cassettes/v2/deployment_gates/Create-deployment-rule-returns-Bad-Request-response.json new file mode 100644 index 000000000..3aa5ae8fd --- /dev/null +++ b/tests/scenarios/cassettes/v2/deployment_gates/Create-deployment-rule-returns-Bad-Request-response.json @@ -0,0 +1,97 @@ +{ + "http_interactions": [ + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"dry_run\":false,\"env\":\"production\",\"identifier\":\"my-gate\",\"service\":\"my-service\"},\"type\":\"deployment_gate\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v2/deployment_gates" + }, + "response": { + "body": { + "string": "{\"data\":{\"id\":\"c7d0bed9-01dc-45d5-88ad-242123881f81\",\"type\":\"deployment_gate\",\"attributes\":{\"created_at\":\"2025-10-28T14:51:13.006792Z\",\"created_by\":{\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"name\":\"CI Account\",\"handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\"},\"dry_run\":false,\"env\":\"production\",\"identifier\":\"my-gate\",\"service\":\"my-service\",\"updated_at\":\"2025-10-28T14:51:13.006792Z\",\"updated_by\":{\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"name\":\"CI Account\",\"handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\"}}}}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 200, + "message": "OK" + } + }, + "recorded_at": "Tue, 28 Oct 2025 14:51:12 GMT" + }, + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"dry_run\":false,\"name\":\"test\",\"options\":{\"excluded_resources\":[]},\"type\":\"fdd\"},\"type\":\"deployment_rule\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v2/deployment_gates/c7d0bed9-01dc-45d5-88ad-242123881f81/rules" + }, + "response": { + "body": { + "string": "{\"errors\":[{\"status\":\"400\",\"title\":\"Bad Request\",\"detail\":\"attribute \\\"type\\\" must be one of \\\"monitor faulty_deployment_detection\\\"\"}]}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 400, + "message": "Bad Request" + } + }, + "recorded_at": "Tue, 28 Oct 2025 14:51:12 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/deployment_gates/c7d0bed9-01dc-45d5-88ad-242123881f81" + }, + "response": { + "body": { + "string": "", + "encoding": null + }, + "headers": {}, + "status": { + "code": 204, + "message": "No Content" + } + }, + "recorded_at": "Tue, 28 Oct 2025 14:51:12 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/deployment_gates/Create-deployment-rule-returns-OK-response.frozen b/tests/scenarios/cassettes/v2/deployment_gates/Create-deployment-rule-returns-OK-response.frozen new file mode 100644 index 000000000..44db2e7bb --- /dev/null +++ b/tests/scenarios/cassettes/v2/deployment_gates/Create-deployment-rule-returns-OK-response.frozen @@ -0,0 +1 @@ +2025-10-28T14:51:13.363Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/deployment_gates/Create-deployment-rule-returns-OK-response.json b/tests/scenarios/cassettes/v2/deployment_gates/Create-deployment-rule-returns-OK-response.json new file mode 100644 index 000000000..63806fac4 --- /dev/null +++ b/tests/scenarios/cassettes/v2/deployment_gates/Create-deployment-rule-returns-OK-response.json @@ -0,0 +1,121 @@ +{ + "http_interactions": [ + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"dry_run\":false,\"env\":\"production\",\"identifier\":\"my-gate\",\"service\":\"my-service\"},\"type\":\"deployment_gate\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v2/deployment_gates" + }, + "response": { + "body": { + "string": "{\"data\":{\"id\":\"58066a8e-44e7-4119-8ac6-a5ecc3b31c1b\",\"type\":\"deployment_gate\",\"attributes\":{\"created_at\":\"2025-10-28T14:51:13.477518Z\",\"created_by\":{\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"name\":\"CI Account\",\"handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\"},\"dry_run\":false,\"env\":\"production\",\"identifier\":\"my-gate\",\"service\":\"my-service\",\"updated_at\":\"2025-10-28T14:51:13.477518Z\",\"updated_by\":{\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"name\":\"CI Account\",\"handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\"}}}}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 200, + "message": "OK" + } + }, + "recorded_at": "Tue, 28 Oct 2025 14:51:13 GMT" + }, + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"dry_run\":false,\"name\":\"My deployment rule\",\"options\":{\"excluded_resources\":[]},\"type\":\"faulty_deployment_detection\"},\"type\":\"deployment_rule\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v2/deployment_gates/58066a8e-44e7-4119-8ac6-a5ecc3b31c1b/rules" + }, + "response": { + "body": { + "string": "{\"data\":{\"id\":\"8330bf79-6906-4cea-85d5-a4da6767458e\",\"type\":\"deployment_rule\",\"attributes\":{\"created_at\":\"2025-10-28T14:51:13.852895Z\",\"created_by\":{\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"name\":\"CI Account\",\"handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\"},\"dry_run\":false,\"gate_id\":\"58066a8e-44e7-4119-8ac6-a5ecc3b31c1b\",\"name\":\"My deployment rule\",\"options\":{},\"type\":\"faulty_deployment_detection\",\"updated_at\":\"2025-10-28T14:51:13.852895Z\",\"updated_by\":{\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"name\":\"CI Account\",\"handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\"}}}}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 200, + "message": "OK" + } + }, + "recorded_at": "Tue, 28 Oct 2025 14:51:13 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/deployment_gates/58066a8e-44e7-4119-8ac6-a5ecc3b31c1b/rules/8330bf79-6906-4cea-85d5-a4da6767458e" + }, + "response": { + "body": { + "string": "", + "encoding": null + }, + "headers": {}, + "status": { + "code": 204, + "message": "No Content" + } + }, + "recorded_at": "Tue, 28 Oct 2025 14:51:13 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/deployment_gates/58066a8e-44e7-4119-8ac6-a5ecc3b31c1b" + }, + "response": { + "body": { + "string": "", + "encoding": null + }, + "headers": {}, + "status": { + "code": 204, + "message": "No Content" + } + }, + "recorded_at": "Tue, 28 Oct 2025 14:51:13 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/deployment_gates/Delete-deployment-gate-returns-Bad-Request-response.frozen b/tests/scenarios/cassettes/v2/deployment_gates/Delete-deployment-gate-returns-Bad-Request-response.frozen new file mode 100644 index 000000000..a5e028fea --- /dev/null +++ b/tests/scenarios/cassettes/v2/deployment_gates/Delete-deployment-gate-returns-Bad-Request-response.frozen @@ -0,0 +1 @@ +2025-10-28T14:03:29.170Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/deployment_gates/Delete-deployment-gate-returns-Bad-Request-response.json b/tests/scenarios/cassettes/v2/deployment_gates/Delete-deployment-gate-returns-Bad-Request-response.json new file mode 100644 index 000000000..04b5058d4 --- /dev/null +++ b/tests/scenarios/cassettes/v2/deployment_gates/Delete-deployment-gate-returns-Bad-Request-response.json @@ -0,0 +1,33 @@ +{ + "http_interactions": [ + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/deployment_gates/invalid-gate-id" + }, + "response": { + "body": { + "string": "{\"errors\":[{\"status\":\"400\",\"title\":\"Bad Request\",\"detail\":\"attribute \\\"id\\\" Invalid id\"}]}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 400, + "message": "Bad Request" + } + }, + "recorded_at": "Tue, 28 Oct 2025 14:03:29 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/deployment_gates/Delete-deployment-gate-returns-No-Content-response.frozen b/tests/scenarios/cassettes/v2/deployment_gates/Delete-deployment-gate-returns-No-Content-response.frozen new file mode 100644 index 000000000..88c603c5c --- /dev/null +++ b/tests/scenarios/cassettes/v2/deployment_gates/Delete-deployment-gate-returns-No-Content-response.frozen @@ -0,0 +1 @@ +2025-10-28T14:51:14.192Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/deployment_gates/Delete-deployment-gate-returns-No-Content-response.json b/tests/scenarios/cassettes/v2/deployment_gates/Delete-deployment-gate-returns-No-Content-response.json new file mode 100644 index 000000000..4fb6e77c4 --- /dev/null +++ b/tests/scenarios/cassettes/v2/deployment_gates/Delete-deployment-gate-returns-No-Content-response.json @@ -0,0 +1,91 @@ +{ + "http_interactions": [ + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"dry_run\":false,\"env\":\"production\",\"identifier\":\"my-gate\",\"service\":\"my-service\"},\"type\":\"deployment_gate\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v2/deployment_gates" + }, + "response": { + "body": { + "string": "{\"data\":{\"id\":\"dba6d48b-b7ac-4ac8-b2d5-70e45b500eed\",\"type\":\"deployment_gate\",\"attributes\":{\"created_at\":\"2025-10-28T14:51:14.313688Z\",\"created_by\":{\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"name\":\"CI Account\",\"handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\"},\"dry_run\":false,\"env\":\"production\",\"identifier\":\"my-gate\",\"service\":\"my-service\",\"updated_at\":\"2025-10-28T14:51:14.313688Z\",\"updated_by\":{\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"name\":\"CI Account\",\"handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\"}}}}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 200, + "message": "OK" + } + }, + "recorded_at": "Tue, 28 Oct 2025 14:51:14 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/deployment_gates/dba6d48b-b7ac-4ac8-b2d5-70e45b500eed" + }, + "response": { + "body": { + "string": "", + "encoding": null + }, + "headers": {}, + "status": { + "code": 204, + "message": "No Content" + } + }, + "recorded_at": "Tue, 28 Oct 2025 14:51:14 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/deployment_gates/dba6d48b-b7ac-4ac8-b2d5-70e45b500eed" + }, + "response": { + "body": { + "string": "{\"errors\":[{\"status\":\"404\",\"title\":\"Not Found\",\"detail\":\"Gate does not exist\"}]}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 404, + "message": "Not Found" + } + }, + "recorded_at": "Tue, 28 Oct 2025 14:51:14 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/deployment_gates/Delete-deployment-rule-returns-Bad-Request-response.frozen b/tests/scenarios/cassettes/v2/deployment_gates/Delete-deployment-rule-returns-Bad-Request-response.frozen new file mode 100644 index 000000000..8a22d65c1 --- /dev/null +++ b/tests/scenarios/cassettes/v2/deployment_gates/Delete-deployment-rule-returns-Bad-Request-response.frozen @@ -0,0 +1 @@ +2025-10-28T14:03:30.230Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/deployment_gates/Delete-deployment-rule-returns-Bad-Request-response.json b/tests/scenarios/cassettes/v2/deployment_gates/Delete-deployment-rule-returns-Bad-Request-response.json new file mode 100644 index 000000000..e6527d05b --- /dev/null +++ b/tests/scenarios/cassettes/v2/deployment_gates/Delete-deployment-rule-returns-Bad-Request-response.json @@ -0,0 +1,33 @@ +{ + "http_interactions": [ + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/deployment_gates/invalid-gate-id/rules/invalid-rule-id" + }, + "response": { + "body": { + "string": "{\"errors\":[{\"status\":\"400\",\"title\":\"Bad Request\",\"detail\":\"attribute \\\"gate_id\\\" Invalid id\"}]}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 400, + "message": "Bad Request" + } + }, + "recorded_at": "Tue, 28 Oct 2025 14:03:30 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/deployment_gates/Delete-deployment-rule-returns-No-Content-response.frozen b/tests/scenarios/cassettes/v2/deployment_gates/Delete-deployment-rule-returns-No-Content-response.frozen new file mode 100644 index 000000000..6685aa65a --- /dev/null +++ b/tests/scenarios/cassettes/v2/deployment_gates/Delete-deployment-rule-returns-No-Content-response.frozen @@ -0,0 +1 @@ +2025-10-28T14:51:14.630Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/deployment_gates/Delete-deployment-rule-returns-No-Content-response.json b/tests/scenarios/cassettes/v2/deployment_gates/Delete-deployment-rule-returns-No-Content-response.json new file mode 100644 index 000000000..97adc04c9 --- /dev/null +++ b/tests/scenarios/cassettes/v2/deployment_gates/Delete-deployment-rule-returns-No-Content-response.json @@ -0,0 +1,149 @@ +{ + "http_interactions": [ + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"dry_run\":false,\"env\":\"production\",\"identifier\":\"my-gate\",\"service\":\"my-service\"},\"type\":\"deployment_gate\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v2/deployment_gates" + }, + "response": { + "body": { + "string": "{\"data\":{\"id\":\"8e202ae7-a86b-4f4a-a213-585801a42630\",\"type\":\"deployment_gate\",\"attributes\":{\"created_at\":\"2025-10-28T14:51:14.754979Z\",\"created_by\":{\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"name\":\"CI Account\",\"handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\"},\"dry_run\":false,\"env\":\"production\",\"identifier\":\"my-gate\",\"service\":\"my-service\",\"updated_at\":\"2025-10-28T14:51:14.754979Z\",\"updated_by\":{\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"name\":\"CI Account\",\"handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\"}}}}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 200, + "message": "OK" + } + }, + "recorded_at": "Tue, 28 Oct 2025 14:51:14 GMT" + }, + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"dry_run\":false,\"name\":\"My deployment rule\",\"options\":{\"excluded_resources\":[]},\"type\":\"faulty_deployment_detection\"},\"type\":\"deployment_rule\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v2/deployment_gates/8e202ae7-a86b-4f4a-a213-585801a42630/rules" + }, + "response": { + "body": { + "string": "{\"data\":{\"id\":\"31e6717f-2eaa-45e5-9559-a55ca9d45f8d\",\"type\":\"deployment_rule\",\"attributes\":{\"created_at\":\"2025-10-28T14:51:14.911642Z\",\"created_by\":{\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"name\":\"CI Account\",\"handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\"},\"dry_run\":false,\"gate_id\":\"8e202ae7-a86b-4f4a-a213-585801a42630\",\"name\":\"My deployment rule\",\"options\":{},\"type\":\"faulty_deployment_detection\",\"updated_at\":\"2025-10-28T14:51:14.911642Z\",\"updated_by\":{\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"name\":\"CI Account\",\"handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\"}}}}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 200, + "message": "OK" + } + }, + "recorded_at": "Tue, 28 Oct 2025 14:51:14 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/deployment_gates/8e202ae7-a86b-4f4a-a213-585801a42630/rules/31e6717f-2eaa-45e5-9559-a55ca9d45f8d" + }, + "response": { + "body": { + "string": "", + "encoding": null + }, + "headers": {}, + "status": { + "code": 204, + "message": "No Content" + } + }, + "recorded_at": "Tue, 28 Oct 2025 14:51:14 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/deployment_gates/8e202ae7-a86b-4f4a-a213-585801a42630/rules/31e6717f-2eaa-45e5-9559-a55ca9d45f8d" + }, + "response": { + "body": { + "string": "{\"errors\":[{\"status\":\"404\",\"title\":\"Not Found\",\"detail\":\"Rule does not exist\"}]}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 404, + "message": "Not Found" + } + }, + "recorded_at": "Tue, 28 Oct 2025 14:51:14 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/deployment_gates/8e202ae7-a86b-4f4a-a213-585801a42630" + }, + "response": { + "body": { + "string": "", + "encoding": null + }, + "headers": {}, + "status": { + "code": 204, + "message": "No Content" + } + }, + "recorded_at": "Tue, 28 Oct 2025 14:51:14 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/deployment_gates/Get-deployment-gate-returns-Bad-Request-response.frozen b/tests/scenarios/cassettes/v2/deployment_gates/Get-deployment-gate-returns-Bad-Request-response.frozen new file mode 100644 index 000000000..818f6bcc3 --- /dev/null +++ b/tests/scenarios/cassettes/v2/deployment_gates/Get-deployment-gate-returns-Bad-Request-response.frozen @@ -0,0 +1 @@ +2025-10-28T14:03:31.887Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/deployment_gates/Get-deployment-gate-returns-Bad-Request-response.json b/tests/scenarios/cassettes/v2/deployment_gates/Get-deployment-gate-returns-Bad-Request-response.json new file mode 100644 index 000000000..034976c6e --- /dev/null +++ b/tests/scenarios/cassettes/v2/deployment_gates/Get-deployment-gate-returns-Bad-Request-response.json @@ -0,0 +1,33 @@ +{ + "http_interactions": [ + { + "request": { + "body": "", + "headers": { + "Accept": [ + "application/json" + ] + }, + "method": "get", + "uri": "https://api.datadoghq.com/api/v2/deployment_gates/invalid-gate-id" + }, + "response": { + "body": { + "string": "{\"errors\":[{\"status\":\"400\",\"title\":\"Bad Request\",\"detail\":\"attribute \\\"id\\\" Invalid id\"}]}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 400, + "message": "Bad Request" + } + }, + "recorded_at": "Tue, 28 Oct 2025 14:03:31 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/deployment_gates/Get-deployment-gate-returns-OK-response.frozen b/tests/scenarios/cassettes/v2/deployment_gates/Get-deployment-gate-returns-OK-response.frozen new file mode 100644 index 000000000..b38e931fd --- /dev/null +++ b/tests/scenarios/cassettes/v2/deployment_gates/Get-deployment-gate-returns-OK-response.frozen @@ -0,0 +1 @@ +2025-10-28T14:51:15.372Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/deployment_gates/Get-deployment-gate-returns-OK-response.json b/tests/scenarios/cassettes/v2/deployment_gates/Get-deployment-gate-returns-OK-response.json new file mode 100644 index 000000000..00eb491a1 --- /dev/null +++ b/tests/scenarios/cassettes/v2/deployment_gates/Get-deployment-gate-returns-OK-response.json @@ -0,0 +1,91 @@ +{ + "http_interactions": [ + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"dry_run\":false,\"env\":\"production\",\"identifier\":\"my-gate\",\"service\":\"my-service\"},\"type\":\"deployment_gate\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v2/deployment_gates" + }, + "response": { + "body": { + "string": "{\"data\":{\"id\":\"ed4085c5-e8d3-4bf8-89a6-c257164d8952\",\"type\":\"deployment_gate\",\"attributes\":{\"created_at\":\"2025-10-28T14:51:15.478086Z\",\"created_by\":{\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"name\":\"CI Account\",\"handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\"},\"dry_run\":false,\"env\":\"production\",\"identifier\":\"my-gate\",\"service\":\"my-service\",\"updated_at\":\"2025-10-28T14:51:15.478086Z\",\"updated_by\":{\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"name\":\"CI Account\",\"handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\"}}}}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 200, + "message": "OK" + } + }, + "recorded_at": "Tue, 28 Oct 2025 14:51:15 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "application/json" + ] + }, + "method": "get", + "uri": "https://api.datadoghq.com/api/v2/deployment_gates/ed4085c5-e8d3-4bf8-89a6-c257164d8952" + }, + "response": { + "body": { + "string": "{\"data\":{\"id\":\"ed4085c5-e8d3-4bf8-89a6-c257164d8952\",\"type\":\"deployment_gate\",\"attributes\":{\"created_at\":\"2025-10-28T14:51:15.478086Z\",\"created_by\":{\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"name\":\"CI Account\",\"handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\"},\"dry_run\":false,\"env\":\"production\",\"identifier\":\"my-gate\",\"service\":\"my-service\",\"updated_at\":\"2025-10-28T14:51:15.478086Z\",\"updated_by\":{\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"name\":\"CI Account\",\"handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\"}}}}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 200, + "message": "OK" + } + }, + "recorded_at": "Tue, 28 Oct 2025 14:51:15 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/deployment_gates/ed4085c5-e8d3-4bf8-89a6-c257164d8952" + }, + "response": { + "body": { + "string": "", + "encoding": null + }, + "headers": {}, + "status": { + "code": 204, + "message": "No Content" + } + }, + "recorded_at": "Tue, 28 Oct 2025 14:51:15 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/deployment_gates/Get-deployment-rule-returns-Bad-Request-response.frozen b/tests/scenarios/cassettes/v2/deployment_gates/Get-deployment-rule-returns-Bad-Request-response.frozen new file mode 100644 index 000000000..3246cdbd6 --- /dev/null +++ b/tests/scenarios/cassettes/v2/deployment_gates/Get-deployment-rule-returns-Bad-Request-response.frozen @@ -0,0 +1 @@ +2025-10-28T14:51:15.883Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/deployment_gates/Get-deployment-rule-returns-Bad-Request-response.json b/tests/scenarios/cassettes/v2/deployment_gates/Get-deployment-rule-returns-Bad-Request-response.json new file mode 100644 index 000000000..66dde807c --- /dev/null +++ b/tests/scenarios/cassettes/v2/deployment_gates/Get-deployment-rule-returns-Bad-Request-response.json @@ -0,0 +1,149 @@ +{ + "http_interactions": [ + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"dry_run\":false,\"env\":\"production\",\"identifier\":\"my-gate\",\"service\":\"my-service\"},\"type\":\"deployment_gate\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v2/deployment_gates" + }, + "response": { + "body": { + "string": "{\"data\":{\"id\":\"d49e6d82-2dc4-45b6-ab50-4fb09feae18e\",\"type\":\"deployment_gate\",\"attributes\":{\"created_at\":\"2025-10-28T14:51:16.013862Z\",\"created_by\":{\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"name\":\"CI Account\",\"handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\"},\"dry_run\":false,\"env\":\"production\",\"identifier\":\"my-gate\",\"service\":\"my-service\",\"updated_at\":\"2025-10-28T14:51:16.013862Z\",\"updated_by\":{\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"name\":\"CI Account\",\"handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\"}}}}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 200, + "message": "OK" + } + }, + "recorded_at": "Tue, 28 Oct 2025 14:51:15 GMT" + }, + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"dry_run\":false,\"name\":\"My deployment rule\",\"options\":{\"excluded_resources\":[]},\"type\":\"faulty_deployment_detection\"},\"type\":\"deployment_rule\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v2/deployment_gates/d49e6d82-2dc4-45b6-ab50-4fb09feae18e/rules" + }, + "response": { + "body": { + "string": "{\"data\":{\"id\":\"611707d2-276e-4dc5-b754-db8f94eab0b5\",\"type\":\"deployment_rule\",\"attributes\":{\"created_at\":\"2025-10-28T14:51:16.184094Z\",\"created_by\":{\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"name\":\"CI Account\",\"handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\"},\"dry_run\":false,\"gate_id\":\"d49e6d82-2dc4-45b6-ab50-4fb09feae18e\",\"name\":\"My deployment rule\",\"options\":{},\"type\":\"faulty_deployment_detection\",\"updated_at\":\"2025-10-28T14:51:16.184094Z\",\"updated_by\":{\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"name\":\"CI Account\",\"handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\"}}}}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 200, + "message": "OK" + } + }, + "recorded_at": "Tue, 28 Oct 2025 14:51:15 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "application/json" + ] + }, + "method": "get", + "uri": "https://api.datadoghq.com/api/v2/deployment_gates/invalid-gate-id/rules/invalid-rule-id" + }, + "response": { + "body": { + "string": "{\"errors\":[{\"status\":\"400\",\"title\":\"Bad Request\",\"detail\":\"attribute \\\"gate_id\\\" Invalid id\"}]}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 400, + "message": "Bad Request" + } + }, + "recorded_at": "Tue, 28 Oct 2025 14:51:15 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/deployment_gates/d49e6d82-2dc4-45b6-ab50-4fb09feae18e/rules/611707d2-276e-4dc5-b754-db8f94eab0b5" + }, + "response": { + "body": { + "string": "", + "encoding": null + }, + "headers": {}, + "status": { + "code": 204, + "message": "No Content" + } + }, + "recorded_at": "Tue, 28 Oct 2025 14:51:15 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/deployment_gates/d49e6d82-2dc4-45b6-ab50-4fb09feae18e" + }, + "response": { + "body": { + "string": "", + "encoding": null + }, + "headers": {}, + "status": { + "code": 204, + "message": "No Content" + } + }, + "recorded_at": "Tue, 28 Oct 2025 14:51:15 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/deployment_gates/Get-deployment-rule-returns-OK-response.frozen b/tests/scenarios/cassettes/v2/deployment_gates/Get-deployment-rule-returns-OK-response.frozen new file mode 100644 index 000000000..f1e5e9639 --- /dev/null +++ b/tests/scenarios/cassettes/v2/deployment_gates/Get-deployment-rule-returns-OK-response.frozen @@ -0,0 +1 @@ +2025-10-28T14:51:16.642Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/deployment_gates/Get-deployment-rule-returns-OK-response.json b/tests/scenarios/cassettes/v2/deployment_gates/Get-deployment-rule-returns-OK-response.json new file mode 100644 index 000000000..8816efc17 --- /dev/null +++ b/tests/scenarios/cassettes/v2/deployment_gates/Get-deployment-rule-returns-OK-response.json @@ -0,0 +1,149 @@ +{ + "http_interactions": [ + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"dry_run\":false,\"env\":\"production\",\"identifier\":\"my-gate\",\"service\":\"my-service\"},\"type\":\"deployment_gate\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v2/deployment_gates" + }, + "response": { + "body": { + "string": "{\"data\":{\"id\":\"50df9de0-aa0c-4d7c-8fc8-811ee2ab4e56\",\"type\":\"deployment_gate\",\"attributes\":{\"created_at\":\"2025-10-28T14:51:16.752908Z\",\"created_by\":{\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"name\":\"CI Account\",\"handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\"},\"dry_run\":false,\"env\":\"production\",\"identifier\":\"my-gate\",\"service\":\"my-service\",\"updated_at\":\"2025-10-28T14:51:16.752908Z\",\"updated_by\":{\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"name\":\"CI Account\",\"handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\"}}}}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 200, + "message": "OK" + } + }, + "recorded_at": "Tue, 28 Oct 2025 14:51:16 GMT" + }, + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"dry_run\":false,\"name\":\"My deployment rule\",\"options\":{\"excluded_resources\":[]},\"type\":\"faulty_deployment_detection\"},\"type\":\"deployment_rule\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v2/deployment_gates/50df9de0-aa0c-4d7c-8fc8-811ee2ab4e56/rules" + }, + "response": { + "body": { + "string": "{\"data\":{\"id\":\"a38ab685-4ef9-4000-a938-740da6c37296\",\"type\":\"deployment_rule\",\"attributes\":{\"created_at\":\"2025-10-28T14:51:16.947341Z\",\"created_by\":{\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"name\":\"CI Account\",\"handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\"},\"dry_run\":false,\"gate_id\":\"50df9de0-aa0c-4d7c-8fc8-811ee2ab4e56\",\"name\":\"My deployment rule\",\"options\":{},\"type\":\"faulty_deployment_detection\",\"updated_at\":\"2025-10-28T14:51:16.947341Z\",\"updated_by\":{\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"name\":\"CI Account\",\"handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\"}}}}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 200, + "message": "OK" + } + }, + "recorded_at": "Tue, 28 Oct 2025 14:51:16 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "application/json" + ] + }, + "method": "get", + "uri": "https://api.datadoghq.com/api/v2/deployment_gates/50df9de0-aa0c-4d7c-8fc8-811ee2ab4e56/rules/a38ab685-4ef9-4000-a938-740da6c37296" + }, + "response": { + "body": { + "string": "{\"data\":{\"id\":\"a38ab685-4ef9-4000-a938-740da6c37296\",\"type\":\"deployment_rule\",\"attributes\":{\"created_at\":\"2025-10-28T14:51:16.947341Z\",\"created_by\":{\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"name\":\"CI Account\",\"handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\"},\"dry_run\":false,\"gate_id\":\"50df9de0-aa0c-4d7c-8fc8-811ee2ab4e56\",\"name\":\"My deployment rule\",\"options\":{},\"type\":\"faulty_deployment_detection\",\"updated_at\":\"2025-10-28T14:51:16.947341Z\",\"updated_by\":{\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"name\":\"CI Account\",\"handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\"}}}}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 200, + "message": "OK" + } + }, + "recorded_at": "Tue, 28 Oct 2025 14:51:16 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/deployment_gates/50df9de0-aa0c-4d7c-8fc8-811ee2ab4e56/rules/a38ab685-4ef9-4000-a938-740da6c37296" + }, + "response": { + "body": { + "string": "", + "encoding": null + }, + "headers": {}, + "status": { + "code": 204, + "message": "No Content" + } + }, + "recorded_at": "Tue, 28 Oct 2025 14:51:16 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/deployment_gates/50df9de0-aa0c-4d7c-8fc8-811ee2ab4e56" + }, + "response": { + "body": { + "string": "", + "encoding": null + }, + "headers": {}, + "status": { + "code": 204, + "message": "No Content" + } + }, + "recorded_at": "Tue, 28 Oct 2025 14:51:16 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/deployment_gates/Update-deployment-gate-returns-Bad-Request-response.frozen b/tests/scenarios/cassettes/v2/deployment_gates/Update-deployment-gate-returns-Bad-Request-response.frozen new file mode 100644 index 000000000..88eba0b98 --- /dev/null +++ b/tests/scenarios/cassettes/v2/deployment_gates/Update-deployment-gate-returns-Bad-Request-response.frozen @@ -0,0 +1 @@ +2025-10-28T14:03:35.734Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/deployment_gates/Update-deployment-gate-returns-Bad-Request-response.json b/tests/scenarios/cassettes/v2/deployment_gates/Update-deployment-gate-returns-Bad-Request-response.json new file mode 100644 index 000000000..bd87dd989 --- /dev/null +++ b/tests/scenarios/cassettes/v2/deployment_gates/Update-deployment-gate-returns-Bad-Request-response.json @@ -0,0 +1,39 @@ +{ + "http_interactions": [ + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"dry_run\":true},\"id\":\"invalid-gate-id\",\"type\":\"deployment_gate\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "put", + "uri": "https://api.datadoghq.com/api/v2/deployment_gates/invalid-gate-id" + }, + "response": { + "body": { + "string": "{\"errors\":[{\"status\":\"400\",\"title\":\"Bad Request\",\"detail\":\"attribute \\\"id\\\" Invalid id\"}]}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 400, + "message": "Bad Request" + } + }, + "recorded_at": "Tue, 28 Oct 2025 14:03:35 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/deployment_gates/Update-deployment-gate-returns-OK-response.frozen b/tests/scenarios/cassettes/v2/deployment_gates/Update-deployment-gate-returns-OK-response.frozen new file mode 100644 index 000000000..b67d99b53 --- /dev/null +++ b/tests/scenarios/cassettes/v2/deployment_gates/Update-deployment-gate-returns-OK-response.frozen @@ -0,0 +1 @@ +2025-10-28T14:51:17.586Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/deployment_gates/Update-deployment-gate-returns-OK-response.json b/tests/scenarios/cassettes/v2/deployment_gates/Update-deployment-gate-returns-OK-response.json new file mode 100644 index 000000000..a692e03a2 --- /dev/null +++ b/tests/scenarios/cassettes/v2/deployment_gates/Update-deployment-gate-returns-OK-response.json @@ -0,0 +1,97 @@ +{ + "http_interactions": [ + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"dry_run\":false,\"env\":\"production\",\"identifier\":\"my-gate\",\"service\":\"my-service\"},\"type\":\"deployment_gate\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v2/deployment_gates" + }, + "response": { + "body": { + "string": "{\"data\":{\"id\":\"ef672c2e-81fc-4fcc-9690-392a9cf0d70c\",\"type\":\"deployment_gate\",\"attributes\":{\"created_at\":\"2025-10-28T14:51:17.693361Z\",\"created_by\":{\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"name\":\"CI Account\",\"handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\"},\"dry_run\":false,\"env\":\"production\",\"identifier\":\"my-gate\",\"service\":\"my-service\",\"updated_at\":\"2025-10-28T14:51:17.693361Z\",\"updated_by\":{\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"name\":\"CI Account\",\"handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\"}}}}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 200, + "message": "OK" + } + }, + "recorded_at": "Tue, 28 Oct 2025 14:51:17 GMT" + }, + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"dry_run\":false},\"id\":\"12345678-1234-1234-1234-123456789012\",\"type\":\"deployment_gate\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "put", + "uri": "https://api.datadoghq.com/api/v2/deployment_gates/ef672c2e-81fc-4fcc-9690-392a9cf0d70c" + }, + "response": { + "body": { + "string": "{\"data\":{\"id\":\"ef672c2e-81fc-4fcc-9690-392a9cf0d70c\",\"type\":\"deployment_gate\",\"attributes\":{\"created_at\":\"2025-10-28T14:51:17.693361Z\",\"created_by\":{\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"name\":\"CI Account\",\"handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\"},\"dry_run\":false,\"env\":\"production\",\"identifier\":\"my-gate\",\"service\":\"my-service\",\"updated_at\":\"2025-10-28T14:51:17.841019Z\",\"updated_by\":{\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"name\":\"CI Account\",\"handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\"}}}}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 200, + "message": "OK" + } + }, + "recorded_at": "Tue, 28 Oct 2025 14:51:17 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/deployment_gates/ef672c2e-81fc-4fcc-9690-392a9cf0d70c" + }, + "response": { + "body": { + "string": "", + "encoding": null + }, + "headers": {}, + "status": { + "code": 204, + "message": "No Content" + } + }, + "recorded_at": "Tue, 28 Oct 2025 14:51:17 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/deployment_gates/Update-deployment-rule-returns-Bad-Request-response.frozen b/tests/scenarios/cassettes/v2/deployment_gates/Update-deployment-rule-returns-Bad-Request-response.frozen new file mode 100644 index 000000000..1691ea924 --- /dev/null +++ b/tests/scenarios/cassettes/v2/deployment_gates/Update-deployment-rule-returns-Bad-Request-response.frozen @@ -0,0 +1 @@ +2025-10-28T14:51:18.004Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/deployment_gates/Update-deployment-rule-returns-Bad-Request-response.json b/tests/scenarios/cassettes/v2/deployment_gates/Update-deployment-rule-returns-Bad-Request-response.json new file mode 100644 index 000000000..c11e903cf --- /dev/null +++ b/tests/scenarios/cassettes/v2/deployment_gates/Update-deployment-rule-returns-Bad-Request-response.json @@ -0,0 +1,155 @@ +{ + "http_interactions": [ + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"dry_run\":false,\"env\":\"production\",\"identifier\":\"my-gate\",\"service\":\"my-service\"},\"type\":\"deployment_gate\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v2/deployment_gates" + }, + "response": { + "body": { + "string": "{\"data\":{\"id\":\"b2bd3ad3-f414-4f05-9ad6-248ed3f99f4d\",\"type\":\"deployment_gate\",\"attributes\":{\"created_at\":\"2025-10-28T14:51:18.108594Z\",\"created_by\":{\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"name\":\"CI Account\",\"handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\"},\"dry_run\":false,\"env\":\"production\",\"identifier\":\"my-gate\",\"service\":\"my-service\",\"updated_at\":\"2025-10-28T14:51:18.108594Z\",\"updated_by\":{\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"name\":\"CI Account\",\"handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\"}}}}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 200, + "message": "OK" + } + }, + "recorded_at": "Tue, 28 Oct 2025 14:51:18 GMT" + }, + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"dry_run\":false,\"name\":\"My deployment rule\",\"options\":{\"excluded_resources\":[]},\"type\":\"faulty_deployment_detection\"},\"type\":\"deployment_rule\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v2/deployment_gates/b2bd3ad3-f414-4f05-9ad6-248ed3f99f4d/rules" + }, + "response": { + "body": { + "string": "{\"data\":{\"id\":\"189846d6-3c19-46e8-98d1-9d05a2f43361\",\"type\":\"deployment_rule\",\"attributes\":{\"created_at\":\"2025-10-28T14:51:18.251816Z\",\"created_by\":{\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"name\":\"CI Account\",\"handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\"},\"dry_run\":false,\"gate_id\":\"b2bd3ad3-f414-4f05-9ad6-248ed3f99f4d\",\"name\":\"My deployment rule\",\"options\":{},\"type\":\"faulty_deployment_detection\",\"updated_at\":\"2025-10-28T14:51:18.251816Z\",\"updated_by\":{\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"name\":\"CI Account\",\"handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\"}}}}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 200, + "message": "OK" + } + }, + "recorded_at": "Tue, 28 Oct 2025 14:51:18 GMT" + }, + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"dry_run\":false,\"name\":\"Updated deployment rule\",\"options\":{\"excluded_resources\":[]}},\"type\":\"deployment_rule\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "put", + "uri": "https://api.datadoghq.com/api/v2/deployment_gates/invalid-gate-id/rules/invalid-rule-id" + }, + "response": { + "body": { + "string": "{\"errors\":[{\"status\":\"400\",\"title\":\"Bad Request\",\"detail\":\"attribute \\\"gate_id\\\" Invalid id\"}]}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 400, + "message": "Bad Request" + } + }, + "recorded_at": "Tue, 28 Oct 2025 14:51:18 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/deployment_gates/b2bd3ad3-f414-4f05-9ad6-248ed3f99f4d/rules/189846d6-3c19-46e8-98d1-9d05a2f43361" + }, + "response": { + "body": { + "string": "", + "encoding": null + }, + "headers": {}, + "status": { + "code": 204, + "message": "No Content" + } + }, + "recorded_at": "Tue, 28 Oct 2025 14:51:18 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/deployment_gates/b2bd3ad3-f414-4f05-9ad6-248ed3f99f4d" + }, + "response": { + "body": { + "string": "", + "encoding": null + }, + "headers": {}, + "status": { + "code": 204, + "message": "No Content" + } + }, + "recorded_at": "Tue, 28 Oct 2025 14:51:18 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/deployment_gates/Update-deployment-rule-returns-OK-response.frozen b/tests/scenarios/cassettes/v2/deployment_gates/Update-deployment-rule-returns-OK-response.frozen new file mode 100644 index 000000000..7ae0c5541 --- /dev/null +++ b/tests/scenarios/cassettes/v2/deployment_gates/Update-deployment-rule-returns-OK-response.frozen @@ -0,0 +1 @@ +2025-10-28T14:51:18.721Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/deployment_gates/Update-deployment-rule-returns-OK-response.json b/tests/scenarios/cassettes/v2/deployment_gates/Update-deployment-rule-returns-OK-response.json new file mode 100644 index 000000000..c31f2daee --- /dev/null +++ b/tests/scenarios/cassettes/v2/deployment_gates/Update-deployment-rule-returns-OK-response.json @@ -0,0 +1,155 @@ +{ + "http_interactions": [ + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"dry_run\":false,\"env\":\"production\",\"identifier\":\"my-gate\",\"service\":\"my-service\"},\"type\":\"deployment_gate\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v2/deployment_gates" + }, + "response": { + "body": { + "string": "{\"data\":{\"id\":\"301122dd-9022-40f0-886f-f9a6c227dc9a\",\"type\":\"deployment_gate\",\"attributes\":{\"created_at\":\"2025-10-28T14:51:18.845469Z\",\"created_by\":{\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"name\":\"CI Account\",\"handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\"},\"dry_run\":false,\"env\":\"production\",\"identifier\":\"my-gate\",\"service\":\"my-service\",\"updated_at\":\"2025-10-28T14:51:18.845469Z\",\"updated_by\":{\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"name\":\"CI Account\",\"handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\"}}}}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 200, + "message": "OK" + } + }, + "recorded_at": "Tue, 28 Oct 2025 14:51:18 GMT" + }, + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"dry_run\":false,\"name\":\"My deployment rule\",\"options\":{\"excluded_resources\":[]},\"type\":\"faulty_deployment_detection\"},\"type\":\"deployment_rule\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v2/deployment_gates/301122dd-9022-40f0-886f-f9a6c227dc9a/rules" + }, + "response": { + "body": { + "string": "{\"data\":{\"id\":\"483937d1-efc4-4a7c-95a6-89bd6b2e4e75\",\"type\":\"deployment_rule\",\"attributes\":{\"created_at\":\"2025-10-28T14:51:19.007448Z\",\"created_by\":{\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"name\":\"CI Account\",\"handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\"},\"dry_run\":false,\"gate_id\":\"301122dd-9022-40f0-886f-f9a6c227dc9a\",\"name\":\"My deployment rule\",\"options\":{},\"type\":\"faulty_deployment_detection\",\"updated_at\":\"2025-10-28T14:51:19.007448Z\",\"updated_by\":{\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"name\":\"CI Account\",\"handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\"}}}}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 200, + "message": "OK" + } + }, + "recorded_at": "Tue, 28 Oct 2025 14:51:18 GMT" + }, + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"dry_run\":false,\"name\":\"Updated deployment rule\",\"options\":{\"excluded_resources\":[]}},\"type\":\"deployment_rule\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "put", + "uri": "https://api.datadoghq.com/api/v2/deployment_gates/301122dd-9022-40f0-886f-f9a6c227dc9a/rules/483937d1-efc4-4a7c-95a6-89bd6b2e4e75" + }, + "response": { + "body": { + "string": "{\"data\":{\"id\":\"483937d1-efc4-4a7c-95a6-89bd6b2e4e75\",\"type\":\"deployment_rule\",\"attributes\":{\"created_at\":\"2025-10-28T14:51:19.007448Z\",\"created_by\":{\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"name\":\"CI Account\",\"handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\"},\"dry_run\":false,\"gate_id\":\"301122dd-9022-40f0-886f-f9a6c227dc9a\",\"name\":\"Updated deployment rule\",\"options\":{},\"type\":\"faulty_deployment_detection\",\"updated_at\":\"2025-10-28T14:51:19.134366Z\",\"updated_by\":{\"id\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\",\"name\":\"CI Account\",\"handle\":\"9919ec9b-ebc7-49ee-8dc8-03626e717cca\"}}}}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 200, + "message": "OK" + } + }, + "recorded_at": "Tue, 28 Oct 2025 14:51:18 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/deployment_gates/301122dd-9022-40f0-886f-f9a6c227dc9a/rules/483937d1-efc4-4a7c-95a6-89bd6b2e4e75" + }, + "response": { + "body": { + "string": "", + "encoding": null + }, + "headers": {}, + "status": { + "code": 204, + "message": "No Content" + } + }, + "recorded_at": "Tue, 28 Oct 2025 14:51:18 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/deployment_gates/301122dd-9022-40f0-886f-f9a6c227dc9a" + }, + "response": { + "body": { + "string": "", + "encoding": null + }, + "headers": {}, + "status": { + "code": 204, + "message": "No Content" + } + }, + "recorded_at": "Tue, 28 Oct 2025 14:51:18 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/features/v2/deployment_gates.feature b/tests/scenarios/features/v2/deployment_gates.feature new file mode 100644 index 000000000..e4023c565 --- /dev/null +++ b/tests/scenarios/features/v2/deployment_gates.feature @@ -0,0 +1,289 @@ +@endpoint(deployment-gates) @endpoint(deployment-gates-v2) +Feature: Deployment Gates + 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. + + Background: + Given a valid "apiKeyAuth" key in the system + And a valid "appKeyAuth" key in the system + And an instance of "DeploymentGates" API + + @team:DataDog/ci-app-backend + Scenario: Create deployment gate returns "Bad Request" response + Given operation "CreateDeploymentGate" enabled + And new "CreateDeploymentGate" request + And body with value {"data": {"attributes": {"env": "", "service":"test-service", "identifier": "my-gate"}, "type": "deployment_gate"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/ci-app-backend + Scenario: Create deployment gate returns "Bad request." response + Given operation "CreateDeploymentGate" enabled + And new "CreateDeploymentGate" request + And body with value {"data": {"attributes": {"dry_run": false, "env": "production", "identifier": "pre", "service": "my-service"}, "type": "deployment_gate"}} + When the request is sent + Then the response status is 400 Bad request. + + @team:DataDog/ci-app-backend + Scenario: Create deployment gate returns "OK" response + Given operation "CreateDeploymentGate" enabled + And new "CreateDeploymentGate" request + And body with value {"data": {"attributes": {"dry_run": false, "env": "production", "identifier": "my-gate-1", "service": "my-service"}, "type": "deployment_gate"}} + When the request is sent + Then the response status is 200 OK + + @team:DataDog/ci-app-backend + Scenario: Create deployment rule returns "Bad Request" response + Given there is a valid "deployment_gate" in the system + And operation "CreateDeploymentRule" enabled + And new "CreateDeploymentRule" request + And request contains "gate_id" parameter from "deployment_gate.data.id" + And body with value {"data": {"attributes": {"dry_run": false, "name":"test", "options": {"excluded_resources": []}, "type": "fdd"}, "type": "deployment_rule"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/ci-app-backend + Scenario: Create deployment rule returns "Bad request." response + Given operation "CreateDeploymentRule" enabled + And new "CreateDeploymentRule" request + And request contains "gate_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"dry_run": false, "name": "My deployment rule", "options": {"duration": 3600, "excluded_resources": ["resource1", "resource2"]}, "type": "faulty_deployment_detection"}, "type": "deployment_rule"}} + When the request is sent + Then the response status is 400 Bad request. + + @team:DataDog/ci-app-backend + Scenario: Create deployment rule returns "OK" response + Given there is a valid "deployment_gate" in the system + And operation "CreateDeploymentRule" enabled + And new "CreateDeploymentRule" request + And request contains "gate_id" parameter from "deployment_gate.data.id" + And body with value {"data": {"attributes": {"dry_run": false, "name": "My deployment rule", "options": {"excluded_resources": []}, "type": "faulty_deployment_detection"}, "type": "deployment_rule"}} + When the request is sent + Then the response status is 200 OK + + @team:DataDog/ci-app-backend + Scenario: Delete deployment gate returns "Bad Request" response + Given operation "DeleteDeploymentGate" enabled + And new "DeleteDeploymentGate" request + And request contains "id" parameter with value "invalid-gate-id" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/ci-app-backend + Scenario: Delete deployment gate returns "Bad request." response + Given operation "DeleteDeploymentGate" enabled + And new "DeleteDeploymentGate" request + And request contains "id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad request. + + @generated @skip @team:DataDog/ci-app-backend + Scenario: Delete deployment gate returns "Deployment gate not found." response + Given operation "DeleteDeploymentGate" enabled + And new "DeleteDeploymentGate" request + And request contains "id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Deployment gate not found. + + @team:DataDog/ci-app-backend + Scenario: Delete deployment gate returns "No Content" response + Given there is a valid "deployment_gate" in the system + And operation "DeleteDeploymentGate" enabled + And new "DeleteDeploymentGate" request + And request contains "id" parameter from "deployment_gate.data.id" + When the request is sent + Then the response status is 204 No Content + + @team:DataDog/ci-app-backend + Scenario: Delete deployment rule returns "Bad Request" response + Given operation "DeleteDeploymentRule" enabled + And new "DeleteDeploymentRule" request + And request contains "gate_id" parameter with value "invalid-gate-id" + And request contains "id" parameter with value "invalid-rule-id" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/ci-app-backend + Scenario: Delete deployment rule returns "Bad request." response + Given operation "DeleteDeploymentRule" enabled + And new "DeleteDeploymentRule" request + And request contains "gate_id" parameter from "REPLACE.ME" + And request contains "id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad request. + + @generated @skip @team:DataDog/ci-app-backend + Scenario: Delete deployment rule returns "Deployment gate not found." response + Given operation "DeleteDeploymentRule" enabled + And new "DeleteDeploymentRule" request + And request contains "gate_id" parameter from "REPLACE.ME" + And request contains "id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Deployment gate not found. + + @team:DataDog/ci-app-backend + Scenario: Delete deployment rule returns "No Content" response + Given there is a valid "deployment_gate" in the system + And there is a valid "deployment_rule" in the system + And operation "DeleteDeploymentRule" enabled + And new "DeleteDeploymentRule" request + And request contains "gate_id" parameter from "deployment_gate.data.id" + And request contains "id" parameter from "deployment_rule.data.id" + When the request is sent + Then the response status is 204 No Content + + @team:DataDog/ci-app-backend + Scenario: Get deployment gate returns "Bad Request" response + Given operation "GetDeploymentGate" enabled + And new "GetDeploymentGate" request + And request contains "id" parameter with value "invalid-gate-id" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/ci-app-backend + Scenario: Get deployment gate returns "Bad request." response + Given operation "GetDeploymentGate" enabled + And new "GetDeploymentGate" request + And request contains "id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad request. + + @generated @skip @team:DataDog/ci-app-backend + Scenario: Get deployment gate returns "Deployment gate not found." response + Given operation "GetDeploymentGate" enabled + And new "GetDeploymentGate" request + And request contains "id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Deployment gate not found. + + @team:DataDog/ci-app-backend + Scenario: Get deployment gate returns "OK" response + Given there is a valid "deployment_gate" in the system + And operation "GetDeploymentGate" enabled + And new "GetDeploymentGate" request + And request contains "id" parameter from "deployment_gate.data.id" + When the request is sent + Then the response status is 200 OK + + @team:DataDog/ci-app-backend + Scenario: Get deployment rule returns "Bad Request" response + Given there is a valid "deployment_gate" in the system + And there is a valid "deployment_rule" in the system + And operation "GetDeploymentRule" enabled + And new "GetDeploymentRule" request + And request contains "gate_id" parameter with value "invalid-gate-id" + And request contains "id" parameter with value "invalid-rule-id" + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/ci-app-backend + Scenario: Get deployment rule returns "Bad request." response + Given operation "GetDeploymentRule" enabled + And new "GetDeploymentRule" request + And request contains "gate_id" parameter from "REPLACE.ME" + And request contains "id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 400 Bad request. + + @generated @skip @team:DataDog/ci-app-backend + Scenario: Get deployment rule returns "Deployment rule not found." response + Given operation "GetDeploymentRule" enabled + And new "GetDeploymentRule" request + And request contains "gate_id" parameter from "REPLACE.ME" + And request contains "id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Deployment rule not found. + + @team:DataDog/ci-app-backend + Scenario: Get deployment rule returns "OK" response + Given there is a valid "deployment_gate" in the system + And there is a valid "deployment_rule" in the system + And operation "GetDeploymentRule" enabled + And new "GetDeploymentRule" request + And request contains "gate_id" parameter from "deployment_gate.data.id" + And request contains "id" parameter from "deployment_rule.data.id" + When the request is sent + Then the response status is 200 OK + + @team:DataDog/ci-app-backend + Scenario: Update deployment gate returns "Bad Request" response + Given operation "UpdateDeploymentGate" enabled + And new "UpdateDeploymentGate" request + And request contains "id" parameter with value "invalid-gate-id" + And body with value {"data": {"attributes": {"dry_run":true}, "id": "invalid-gate-id", "type": "deployment_gate"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/ci-app-backend + Scenario: Update deployment gate returns "Bad request." response + Given operation "UpdateDeploymentGate" enabled + And new "UpdateDeploymentGate" request + And request contains "id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"dry_run": false}, "id": "12345678-1234-1234-1234-123456789012", "type": "deployment_gate"}} + When the request is sent + Then the response status is 400 Bad request. + + @generated @skip @team:DataDog/ci-app-backend + Scenario: Update deployment gate returns "Deployment gate not found." response + Given operation "UpdateDeploymentGate" enabled + And new "UpdateDeploymentGate" request + And request contains "id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"dry_run": false}, "id": "12345678-1234-1234-1234-123456789012", "type": "deployment_gate"}} + When the request is sent + Then the response status is 404 Deployment gate not found. + + @team:DataDog/ci-app-backend + Scenario: Update deployment gate returns "OK" response + Given there is a valid "deployment_gate" in the system + And operation "UpdateDeploymentGate" enabled + And new "UpdateDeploymentGate" request + And request contains "id" parameter from "deployment_gate.data.id" + And body with value {"data": {"attributes": {"dry_run": false}, "id": "12345678-1234-1234-1234-123456789012", "type": "deployment_gate"}} + When the request is sent + Then the response status is 200 OK + + @team:DataDog/ci-app-backend + Scenario: Update deployment rule returns "Bad Request" response + Given there is a valid "deployment_gate" in the system + And there is a valid "deployment_rule" in the system + And operation "UpdateDeploymentRule" enabled + And new "UpdateDeploymentRule" request + And request contains "gate_id" parameter with value "invalid-gate-id" + And request contains "id" parameter with value "invalid-rule-id" + And body with value {"data": {"attributes": {"dry_run": false, "name": "Updated deployment rule", "options": {"excluded_resources": []}}, "type": "deployment_rule"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/ci-app-backend + Scenario: Update deployment rule returns "Bad request." response + Given operation "UpdateDeploymentRule" enabled + And new "UpdateDeploymentRule" request + And request contains "gate_id" parameter from "REPLACE.ME" + And request contains "id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"dry_run": false, "name": "Updated deployment rule", "options": {"duration": 3600, "excluded_resources": ["resource1", "resource2"]}}, "type": "deployment_rule"}} + When the request is sent + Then the response status is 400 Bad request. + + @generated @skip @team:DataDog/ci-app-backend + Scenario: Update deployment rule returns "Deployment rule not found." response + Given operation "UpdateDeploymentRule" enabled + And new "UpdateDeploymentRule" request + And request contains "gate_id" parameter from "REPLACE.ME" + And request contains "id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"dry_run": false, "name": "Updated deployment rule", "options": {"duration": 3600, "excluded_resources": ["resource1", "resource2"]}}, "type": "deployment_rule"}} + When the request is sent + Then the response status is 404 Deployment rule not found. + + @team:DataDog/ci-app-backend + Scenario: Update deployment rule returns "OK" response + Given there is a valid "deployment_gate" in the system + And there is a valid "deployment_rule" in the system + And operation "UpdateDeploymentRule" enabled + And new "UpdateDeploymentRule" request + And request contains "gate_id" parameter from "deployment_gate.data.id" + And request contains "id" parameter from "deployment_rule.data.id" + And body with value {"data": {"attributes": {"dry_run": false, "name": "Updated deployment rule", "options": {"excluded_resources": []}}, "type": "deployment_rule"}} + When the request is sent + Then the response status is 200 OK diff --git a/tests/scenarios/features/v2/given.json b/tests/scenarios/features/v2/given.json index 7c9df160a..dcd224b3e 100644 --- a/tests/scenarios/features/v2/given.json +++ b/tests/scenarios/features/v2/given.json @@ -320,6 +320,34 @@ "tag": "Data Deletion", "operationId": "CreateDataDeletionRequest" }, + { + "parameters": [ + { + "name": "body", + "value": "{\n \"data\": {\n \"type\": \"deployment_gate\",\n \"attributes\": {\n \"service\": \"my-service\",\n \"env\": \"production\",\n \"identifier\": \"my-gate\",\n \"dry_run\": false\n }\n }\n}" + } + ], + "step": "there is a valid \"deployment_gate\" in the system", + "key": "deployment_gate", + "tag": "Deployment Gates", + "operationId": "CreateDeploymentGate" + }, + { + "parameters": [ + { + "name": "gate_id", + "source": "deployment_gate.data.id" + }, + { + "name": "body", + "value": "{\n \"data\": {\n \"type\": \"deployment_rule\",\n \"attributes\": {\n \"name\": \"My deployment rule\",\n \"type\": \"faulty_deployment_detection\",\n \"options\": {\n \"excluded_resources\": []\n },\n \"dry_run\": false\n }\n }\n}" + } + ], + "step": "there is a valid \"deployment_rule\" in the system", + "key": "deployment_rule", + "tag": "Deployment Gates", + "operationId": "CreateDeploymentRule" + }, { "parameters": [ { diff --git a/tests/scenarios/features/v2/undo.json b/tests/scenarios/features/v2/undo.json index f4a7f9e7f..26f29e81a 100644 --- a/tests/scenarios/features/v2/undo.json +++ b/tests/scenarios/features/v2/undo.json @@ -1235,6 +1235,72 @@ "type": "idempotent" } }, + "CreateDeploymentGate": { + "tag": "Deployment Gates", + "undo": { + "operationId": "DeleteDeploymentGate", + "parameters": [ + { + "name": "id", + "source": "data.id" + } + ], + "type": "unsafe" + } + }, + "CreateDeploymentRule": { + "tag": "Deployment Gates", + "undo": { + "operationId": "DeleteDeploymentRule", + "parameters": [ + { + "name": "gate_id", + "source": "data.attributes.gate_id" + }, + { + "name": "id", + "source": "data.id" + } + ], + "type": "unsafe" + } + }, + "DeleteDeploymentRule": { + "tag": "Deployment Gates", + "undo": { + "type": "idempotent" + } + }, + "GetDeploymentRule": { + "tag": "Deployment Gates", + "undo": { + "type": "safe" + } + }, + "UpdateDeploymentRule": { + "tag": "Deployment Gates", + "undo": { + "type": "idempotent" + } + }, + "DeleteDeploymentGate": { + "tag": "Deployment Gates", + "undo": { + "type": "idempotent" + } + }, + "GetDeploymentGate": { + "tag": "Deployment Gates", + "undo": { + "type": "safe" + } + }, + "UpdateDeploymentGate": { + "tag": "Deployment Gates", + "undo": { + "type": "idempotent" + } + }, "GetDomainAllowlist": { "tag": "Domain Allowlist", "undo": { diff --git a/tests/scenarios/function_mappings.rs b/tests/scenarios/function_mappings.rs index 43cff6b63..7a382868d 100644 --- a/tests/scenarios/function_mappings.rs +++ b/tests/scenarios/function_mappings.rs @@ -84,6 +84,7 @@ pub struct ApiInstances { pub v2_api_dashboard_lists: Option, pub v2_api_datasets: Option, pub v2_api_data_deletion: Option, + pub v2_api_deployment_gates: Option, pub v2_api_domain_allowlist: Option, pub v2_api_dora_metrics: Option, pub v2_api_downtimes: Option, @@ -655,6 +656,14 @@ pub fn initialize_api_instance(world: &mut DatadogWorld, api: String) { ), ); } + "DeploymentGates" => { + world.api_instances.v2_api_deployment_gates = Some( + datadogV2::api_deployment_gates::DeploymentGatesAPI::with_client_and_config( + world.config.clone(), + world.http_client.as_ref().unwrap().clone(), + ), + ); + } "DomainAllowlist" => { world.api_instances.v2_api_domain_allowlist = Some( datadogV2::api_domain_allowlist::DomainAllowlistAPI::with_client_and_config( @@ -2811,6 +2820,36 @@ pub fn collect_function_calls(world: &mut DatadogWorld) { "v2.CancelDataDeletionRequest".into(), test_v2_cancel_data_deletion_request, ); + world.function_mappings.insert( + "v2.CreateDeploymentGate".into(), + test_v2_create_deployment_gate, + ); + world.function_mappings.insert( + "v2.CreateDeploymentRule".into(), + test_v2_create_deployment_rule, + ); + world.function_mappings.insert( + "v2.DeleteDeploymentRule".into(), + test_v2_delete_deployment_rule, + ); + world + .function_mappings + .insert("v2.GetDeploymentRule".into(), test_v2_get_deployment_rule); + world.function_mappings.insert( + "v2.UpdateDeploymentRule".into(), + test_v2_update_deployment_rule, + ); + world.function_mappings.insert( + "v2.DeleteDeploymentGate".into(), + test_v2_delete_deployment_gate, + ); + world + .function_mappings + .insert("v2.GetDeploymentGate".into(), test_v2_get_deployment_gate); + world.function_mappings.insert( + "v2.UpdateDeploymentGate".into(), + test_v2_update_deployment_gate, + ); world .function_mappings .insert("v2.GetDomainAllowlist".into(), test_v2_get_domain_allowlist); @@ -20622,6 +20661,212 @@ fn test_v2_cancel_data_deletion_request( world.response.code = response.status.as_u16(); } +fn test_v2_create_deployment_gate(world: &mut DatadogWorld, _parameters: &HashMap) { + let api = world + .api_instances + .v2_api_deployment_gates + .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_deployment_gate_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_create_deployment_rule(world: &mut DatadogWorld, _parameters: &HashMap) { + let api = world + .api_instances + .v2_api_deployment_gates + .as_ref() + .expect("api instance not found"); + let gate_id = serde_json::from_value(_parameters.get("gate_id").unwrap().clone()).unwrap(); + let body = serde_json::from_value(_parameters.get("body").unwrap().clone()).unwrap(); + let response = match block_on(api.create_deployment_rule_with_http_info(gate_id, 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_deployment_rule(world: &mut DatadogWorld, _parameters: &HashMap) { + let api = world + .api_instances + .v2_api_deployment_gates + .as_ref() + .expect("api instance not found"); + let gate_id = serde_json::from_value(_parameters.get("gate_id").unwrap().clone()).unwrap(); + let id = serde_json::from_value(_parameters.get("id").unwrap().clone()).unwrap(); + let response = match block_on(api.delete_deployment_rule_with_http_info(gate_id, id)) { + 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_deployment_rule(world: &mut DatadogWorld, _parameters: &HashMap) { + let api = world + .api_instances + .v2_api_deployment_gates + .as_ref() + .expect("api instance not found"); + let gate_id = serde_json::from_value(_parameters.get("gate_id").unwrap().clone()).unwrap(); + let id = serde_json::from_value(_parameters.get("id").unwrap().clone()).unwrap(); + let response = match block_on(api.get_deployment_rule_with_http_info(gate_id, id)) { + 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_update_deployment_rule(world: &mut DatadogWorld, _parameters: &HashMap) { + let api = world + .api_instances + .v2_api_deployment_gates + .as_ref() + .expect("api instance not found"); + let gate_id = serde_json::from_value(_parameters.get("gate_id").unwrap().clone()).unwrap(); + let id = serde_json::from_value(_parameters.get("id").unwrap().clone()).unwrap(); + let body = serde_json::from_value(_parameters.get("body").unwrap().clone()).unwrap(); + let response = match block_on(api.update_deployment_rule_with_http_info(gate_id, id, 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_deployment_gate(world: &mut DatadogWorld, _parameters: &HashMap) { + let api = world + .api_instances + .v2_api_deployment_gates + .as_ref() + .expect("api instance not found"); + let id = serde_json::from_value(_parameters.get("id").unwrap().clone()).unwrap(); + let response = match block_on(api.delete_deployment_gate_with_http_info(id)) { + 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_deployment_gate(world: &mut DatadogWorld, _parameters: &HashMap) { + let api = world + .api_instances + .v2_api_deployment_gates + .as_ref() + .expect("api instance not found"); + let id = serde_json::from_value(_parameters.get("id").unwrap().clone()).unwrap(); + let response = match block_on(api.get_deployment_gate_with_http_info(id)) { + 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_update_deployment_gate(world: &mut DatadogWorld, _parameters: &HashMap) { + let api = world + .api_instances + .v2_api_deployment_gates + .as_ref() + .expect("api instance not found"); + let id = serde_json::from_value(_parameters.get("id").unwrap().clone()).unwrap(); + let body = serde_json::from_value(_parameters.get("body").unwrap().clone()).unwrap(); + let response = match block_on(api.update_deployment_gate_with_http_info(id, 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_get_domain_allowlist(world: &mut DatadogWorld, _parameters: &HashMap) { let api = world .api_instances