From ab8e53639a687ed7aacd43ec7148a036e3176a74 Mon Sep 17 00:00:00 2001 From: "ci.datadog-api-spec" Date: Tue, 30 Jul 2024 19:30:12 +0000 Subject: [PATCH] Regenerate client from commit edbd396a of spec repo --- .apigentools-info | 8 +- .generator/schemas/v2/openapi.yaml | 222 ++++++ ...kflow-automation_CancelWorkflowInstance.rs | 20 + ...kflow-automation_CreateWorkflowInstance.rs | 25 + ...workflow-automation_GetWorkflowInstance.rs | 20 + ...rkflow-automation_ListWorkflowInstances.rs | 21 + src/datadogV2/api/api_workflow_automation.rs | 649 ++++++++++++++++++ src/datadogV2/api/mod.rs | 1 + src/datadogV2/mod.rs | 1 + src/datadogV2/model/mod.rs | 26 + .../model_workflow_instance_create_meta.rs | 83 +++ .../model_workflow_instance_create_request.rs | 82 +++ ...model_workflow_instance_create_response.rs | 109 +++ ..._workflow_instance_create_response_data.rs | 105 +++ .../model_workflow_instance_list_item.rs | 105 +++ .../model_workflow_list_instances_response.rs | 126 ++++ ...l_workflow_list_instances_response_meta.rs | 110 +++ ...kflow_list_instances_response_meta_page.rs | 106 +++ ...odel_worklflow_cancel_instance_response.rs | 86 +++ ...worklflow_cancel_instance_response_data.rs | 82 +++ .../model_worklflow_get_instance_response.rs | 109 +++ ...el_worklflow_get_instance_response_data.rs | 110 +++ ...w_get_instance_response_data_attributes.rs | 105 +++ ...stance-returns-Bad-Request-response.frozen | 1 + ...instance-returns-Bad-Request-response.json | 33 + ...instance-returns-Not-Found-response.frozen | 1 + ...w-instance-returns-Not-Found-response.json | 33 + ...rkflow-instance-returns-OK-response.frozen | 1 + ...workflow-instance-returns-OK-response.json | 33 + ...rkflow-returns-Bad-Request-response.frozen | 1 + ...workflow-returns-Bad-Request-response.json | 39 ++ ...a-workflow-returns-Created-response.frozen | 1 + ...e-a-workflow-returns-Created-response.json | 39 ++ ...stance-returns-Bad-Request-response.frozen | 1 + ...instance-returns-Bad-Request-response.json | 33 + ...instance-returns-Not-Found-response.frozen | 1 + ...w-instance-returns-Not-Found-response.json | 33 + ...rkflow-instance-returns-OK-response.frozen | 1 + ...workflow-instance-returns-OK-response.json | 33 + ...tances-returns-Bad-Request-response.frozen | 1 + ...nstances-returns-Bad-Request-response.json | 33 + ...kflow-instances-returns-OK-response.frozen | 1 + ...orkflow-instances-returns-OK-response.json | 33 + tests/scenarios/features/v2/undo.json | 24 + .../features/v2/workflow_automation.feature | 87 +++ tests/scenarios/function_mappings.rs | 153 +++++ 46 files changed, 2923 insertions(+), 4 deletions(-) create mode 100644 examples/v2_workflow-automation_CancelWorkflowInstance.rs create mode 100644 examples/v2_workflow-automation_CreateWorkflowInstance.rs create mode 100644 examples/v2_workflow-automation_GetWorkflowInstance.rs create mode 100644 examples/v2_workflow-automation_ListWorkflowInstances.rs create mode 100644 src/datadogV2/api/api_workflow_automation.rs create mode 100644 src/datadogV2/model/model_workflow_instance_create_meta.rs create mode 100644 src/datadogV2/model/model_workflow_instance_create_request.rs create mode 100644 src/datadogV2/model/model_workflow_instance_create_response.rs create mode 100644 src/datadogV2/model/model_workflow_instance_create_response_data.rs create mode 100644 src/datadogV2/model/model_workflow_instance_list_item.rs create mode 100644 src/datadogV2/model/model_workflow_list_instances_response.rs create mode 100644 src/datadogV2/model/model_workflow_list_instances_response_meta.rs create mode 100644 src/datadogV2/model/model_workflow_list_instances_response_meta_page.rs create mode 100644 src/datadogV2/model/model_worklflow_cancel_instance_response.rs create mode 100644 src/datadogV2/model/model_worklflow_cancel_instance_response_data.rs create mode 100644 src/datadogV2/model/model_worklflow_get_instance_response.rs create mode 100644 src/datadogV2/model/model_worklflow_get_instance_response_data.rs create mode 100644 src/datadogV2/model/model_worklflow_get_instance_response_data_attributes.rs create mode 100644 tests/scenarios/cassettes/v2/workflow_automation/Cancel-a-workflow-instance-returns-Bad-Request-response.frozen create mode 100644 tests/scenarios/cassettes/v2/workflow_automation/Cancel-a-workflow-instance-returns-Bad-Request-response.json create mode 100644 tests/scenarios/cassettes/v2/workflow_automation/Cancel-a-workflow-instance-returns-Not-Found-response.frozen create mode 100644 tests/scenarios/cassettes/v2/workflow_automation/Cancel-a-workflow-instance-returns-Not-Found-response.json create mode 100644 tests/scenarios/cassettes/v2/workflow_automation/Cancel-a-workflow-instance-returns-OK-response.frozen create mode 100644 tests/scenarios/cassettes/v2/workflow_automation/Cancel-a-workflow-instance-returns-OK-response.json create mode 100644 tests/scenarios/cassettes/v2/workflow_automation/Execute-a-workflow-returns-Bad-Request-response.frozen create mode 100644 tests/scenarios/cassettes/v2/workflow_automation/Execute-a-workflow-returns-Bad-Request-response.json create mode 100644 tests/scenarios/cassettes/v2/workflow_automation/Execute-a-workflow-returns-Created-response.frozen create mode 100644 tests/scenarios/cassettes/v2/workflow_automation/Execute-a-workflow-returns-Created-response.json create mode 100644 tests/scenarios/cassettes/v2/workflow_automation/Get-a-workflow-instance-returns-Bad-Request-response.frozen create mode 100644 tests/scenarios/cassettes/v2/workflow_automation/Get-a-workflow-instance-returns-Bad-Request-response.json create mode 100644 tests/scenarios/cassettes/v2/workflow_automation/Get-a-workflow-instance-returns-Not-Found-response.frozen create mode 100644 tests/scenarios/cassettes/v2/workflow_automation/Get-a-workflow-instance-returns-Not-Found-response.json create mode 100644 tests/scenarios/cassettes/v2/workflow_automation/Get-a-workflow-instance-returns-OK-response.frozen create mode 100644 tests/scenarios/cassettes/v2/workflow_automation/Get-a-workflow-instance-returns-OK-response.json create mode 100644 tests/scenarios/cassettes/v2/workflow_automation/List-workflow-instances-returns-Bad-Request-response.frozen create mode 100644 tests/scenarios/cassettes/v2/workflow_automation/List-workflow-instances-returns-Bad-Request-response.json create mode 100644 tests/scenarios/cassettes/v2/workflow_automation/List-workflow-instances-returns-OK-response.frozen create mode 100644 tests/scenarios/cassettes/v2/workflow_automation/List-workflow-instances-returns-OK-response.json create mode 100644 tests/scenarios/features/v2/workflow_automation.feature diff --git a/.apigentools-info b/.apigentools-info index ddb356871..faeb814b5 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.6.6", - "regenerated": "2024-07-30 17:01:08.846214", - "spec_repo_commit": "4380003d" + "regenerated": "2024-07-30 19:24:54.991074", + "spec_repo_commit": "edbd396a" }, "v2": { "apigentools_version": "1.6.6", - "regenerated": "2024-07-30 17:01:08.864677", - "spec_repo_commit": "4380003d" + "regenerated": "2024-07-30 19:24:55.009349", + "spec_repo_commit": "edbd396a" } } } \ No newline at end of file diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index d5bfe90d9..8f7bfc316 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -358,6 +358,13 @@ components: required: true schema: type: string + InstanceId: + description: The ID of the workflow instance. + in: path + name: instance_id + required: true + schema: + type: string MetricID: description: The name of the log-based metric. in: path @@ -543,6 +550,13 @@ components: schema: example: 00000000-0000-9999-0000-000000000000 type: string + WorkflowId: + description: The ID of the workflow. + in: path + name: workflow_id + required: true + schema: + type: string requestBodies: {} responses: BadRequestResponse: @@ -23831,6 +23845,107 @@ components: - PAST_SIX_MONTHS - PAST_ONE_YEAR - ALERT + WorkflowInstanceCreateMeta: + description: Additional information for creating a workflow instance. + properties: + payload: + additionalProperties: {} + description: The input parameters to the workflow. + type: object + type: object + WorkflowInstanceCreateRequest: + description: Request used to create a workflow instance. + properties: + meta: + $ref: '#/components/schemas/WorkflowInstanceCreateMeta' + type: object + WorkflowInstanceCreateResponse: + additionalProperties: {} + description: Response returned upon successful workflow instance creation. + properties: + data: + $ref: '#/components/schemas/WorkflowInstanceCreateResponseData' + type: object + WorkflowInstanceCreateResponseData: + additionalProperties: {} + description: Data about the created workflow instance. + properties: + id: + description: The ID of the workflow execution. It can be used to fetch the + execution status. + type: string + type: object + WorkflowInstanceListItem: + additionalProperties: {} + description: An item in the workflow instances list. + properties: + id: + description: The ID of the workflow instance + type: string + type: object + WorkflowListInstancesResponse: + additionalProperties: {} + description: Response returned when listing workflow instances. + properties: + data: + description: A list of workflow instances. + items: + $ref: '#/components/schemas/WorkflowInstanceListItem' + type: array + meta: + $ref: '#/components/schemas/WorkflowListInstancesResponseMeta' + type: object + WorkflowListInstancesResponseMeta: + additionalProperties: {} + description: Metadata about the instances list + properties: + page: + $ref: '#/components/schemas/WorkflowListInstancesResponseMetaPage' + type: object + WorkflowListInstancesResponseMetaPage: + additionalProperties: {} + description: Page information for the list instances response. + properties: + totalCount: + description: The total count of items. + format: int64 + type: integer + type: object + WorklflowCancelInstanceResponse: + description: Information about the canceled instance. + properties: + data: + $ref: '#/components/schemas/WorklflowCancelInstanceResponseData' + type: object + WorklflowCancelInstanceResponseData: + description: Data about the canceled instance. + properties: + id: + description: The id of the canceled instance + type: string + type: object + WorklflowGetInstanceResponse: + additionalProperties: {} + description: The state of the given workflow instance. + properties: + data: + $ref: '#/components/schemas/WorklflowGetInstanceResponseData' + type: object + WorklflowGetInstanceResponseData: + additionalProperties: {} + description: The data of the instance response. + properties: + attributes: + $ref: '#/components/schemas/WorklflowGetInstanceResponseDataAttributes' + type: object + WorklflowGetInstanceResponseDataAttributes: + additionalProperties: {} + description: The attributes of the instance response data. + properties: + id: + description: The id of the instance. + type: string + type: object securitySchemes: AuthZ: description: This API uses OAuth 2 with the implicit grant flow. @@ -37850,6 +37965,108 @@ paths: summary: Get user memberships tags: - Teams + /api/v2/workflows/{workflow_id}/instances: + get: + description: List all instances of a given workflow. + operationId: ListWorkflowInstances + parameters: + - $ref: '#/components/parameters/WorkflowId' + - $ref: '#/components/parameters/PageSize' + - $ref: '#/components/parameters/PageNumber' + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/WorkflowListInstancesResponse' + description: OK + '400': + $ref: '#/components/responses/BadRequestResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: List workflow instances + tags: + - Workflow Automation + post: + description: Execute the given workflow + operationId: CreateWorkflowInstance + parameters: + - $ref: '#/components/parameters/WorkflowId' + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/WorkflowInstanceCreateRequest' + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/WorkflowInstanceCreateResponse' + description: Created + '400': + $ref: '#/components/responses/BadRequestResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: Execute a workflow + tags: + - Workflow Automation + x-codegen-request-body-name: body + /api/v2/workflows/{workflow_id}/instances/{instance_id}: + get: + description: Get a specific execution of a given workflow. + operationId: GetWorkflowInstance + parameters: + - $ref: '#/components/parameters/WorkflowId' + - $ref: '#/components/parameters/InstanceId' + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/WorklflowGetInstanceResponse' + description: OK + '400': + $ref: '#/components/responses/BadRequestResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '404': + $ref: '#/components/responses/NotFoundResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: Get a workflow instance + tags: + - Workflow Automation + /api/v2/workflows/{workflow_id}/instances/{instance_id}/cancel: + put: + description: Cancels a specific execution of a given workflow. + operationId: CancelWorkflowInstance + parameters: + - $ref: '#/components/parameters/WorkflowId' + - $ref: '#/components/parameters/InstanceId' + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/WorklflowCancelInstanceResponse' + description: OK + '400': + $ref: '#/components/responses/BadRequestResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '404': + $ref: '#/components/responses/NotFoundResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: Cancel a workflow instance + tags: + - Workflow Automation security: - apiKeyAuth: [] appKeyAuth: [] @@ -38221,4 +38438,9 @@ tags: externalDocs: url: https://docs.datadoghq.com/account_management/users name: Users +- description: Automate your teams operational processes with Datadog Workflow Automation. + externalDocs: + description: Find out more at + url: https://docs.datadoghq.com/service_management/workflows/ + name: Workflow Automation x-group-parameters: true diff --git a/examples/v2_workflow-automation_CancelWorkflowInstance.rs b/examples/v2_workflow-automation_CancelWorkflowInstance.rs new file mode 100644 index 000000000..5ed82eafc --- /dev/null +++ b/examples/v2_workflow-automation_CancelWorkflowInstance.rs @@ -0,0 +1,20 @@ +// Cancel a workflow instance returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_workflow_automation::WorkflowAutomationAPI; + +#[tokio::main] +async fn main() { + let configuration = datadog::Configuration::new(); + let api = WorkflowAutomationAPI::with_config(configuration); + let resp = api + .cancel_workflow_instance( + "ccf73164-1998-4785-a7a3-8d06c7e5f558".to_string(), + "305a472b-71ab-4ce8-8f8d-75db635627b5".to_string(), + ) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_workflow-automation_CreateWorkflowInstance.rs b/examples/v2_workflow-automation_CreateWorkflowInstance.rs new file mode 100644 index 000000000..f9e252885 --- /dev/null +++ b/examples/v2_workflow-automation_CreateWorkflowInstance.rs @@ -0,0 +1,25 @@ +// Execute a workflow returns "Created" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_workflow_automation::WorkflowAutomationAPI; +use datadog_api_client::datadogV2::model::WorkflowInstanceCreateMeta; +use datadog_api_client::datadogV2::model::WorkflowInstanceCreateRequest; +use serde_json::Value; +use std::collections::BTreeMap; + +#[tokio::main] +async fn main() { + let body = + WorkflowInstanceCreateRequest::new().meta(WorkflowInstanceCreateMeta::new().payload( + BTreeMap::from([("input".to_string(), Value::from("value"))]), + )); + let configuration = datadog::Configuration::new(); + let api = WorkflowAutomationAPI::with_config(configuration); + let resp = api + .create_workflow_instance("ccf73164-1998-4785-a7a3-8d06c7e5f558".to_string(), body) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_workflow-automation_GetWorkflowInstance.rs b/examples/v2_workflow-automation_GetWorkflowInstance.rs new file mode 100644 index 000000000..b92b46779 --- /dev/null +++ b/examples/v2_workflow-automation_GetWorkflowInstance.rs @@ -0,0 +1,20 @@ +// Get a workflow instance returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_workflow_automation::WorkflowAutomationAPI; + +#[tokio::main] +async fn main() { + let configuration = datadog::Configuration::new(); + let api = WorkflowAutomationAPI::with_config(configuration); + let resp = api + .get_workflow_instance( + "ccf73164-1998-4785-a7a3-8d06c7e5f558".to_string(), + "305a472b-71ab-4ce8-8f8d-75db635627b5".to_string(), + ) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_workflow-automation_ListWorkflowInstances.rs b/examples/v2_workflow-automation_ListWorkflowInstances.rs new file mode 100644 index 000000000..54dff8928 --- /dev/null +++ b/examples/v2_workflow-automation_ListWorkflowInstances.rs @@ -0,0 +1,21 @@ +// List workflow instances returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_workflow_automation::ListWorkflowInstancesOptionalParams; +use datadog_api_client::datadogV2::api_workflow_automation::WorkflowAutomationAPI; + +#[tokio::main] +async fn main() { + let configuration = datadog::Configuration::new(); + let api = WorkflowAutomationAPI::with_config(configuration); + let resp = api + .list_workflow_instances( + "ccf73164-1998-4785-a7a3-8d06c7e5f558".to_string(), + ListWorkflowInstancesOptionalParams::default(), + ) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/src/datadogV2/api/api_workflow_automation.rs b/src/datadogV2/api/api_workflow_automation.rs new file mode 100644 index 000000000..f72decee6 --- /dev/null +++ b/src/datadogV2/api/api_workflow_automation.rs @@ -0,0 +1,649 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use crate::datadog; +use flate2::{ + write::{GzEncoder, ZlibEncoder}, + Compression, +}; +use reqwest::header::{HeaderMap, HeaderValue}; +use serde::{Deserialize, Serialize}; +use std::io::Write; + +/// ListWorkflowInstancesOptionalParams is a struct for passing parameters to the method [`WorkflowAutomationAPI::list_workflow_instances`] +#[non_exhaustive] +#[derive(Clone, Default, Debug)] +pub struct ListWorkflowInstancesOptionalParams { + /// Size for a given page. The maximum allowed value is 100. + pub page_size: Option, + /// Specific page number to return. + pub page_number: Option, +} + +impl ListWorkflowInstancesOptionalParams { + /// Size for a given page. The maximum allowed value is 100. + pub fn page_size(mut self, value: i64) -> Self { + self.page_size = Some(value); + self + } + /// Specific page number to return. + pub fn page_number(mut self, value: i64) -> Self { + self.page_number = Some(value); + self + } +} + +/// CancelWorkflowInstanceError is a struct for typed errors of method [`WorkflowAutomationAPI::cancel_workflow_instance`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CancelWorkflowInstanceError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// CreateWorkflowInstanceError is a struct for typed errors of method [`WorkflowAutomationAPI::create_workflow_instance`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CreateWorkflowInstanceError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// GetWorkflowInstanceError is a struct for typed errors of method [`WorkflowAutomationAPI::get_workflow_instance`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetWorkflowInstanceError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// ListWorkflowInstancesError is a struct for typed errors of method [`WorkflowAutomationAPI::list_workflow_instances`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ListWorkflowInstancesError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// Automate your teams operational processes with Datadog Workflow Automation. +#[derive(Debug, Clone)] +pub struct WorkflowAutomationAPI { + config: datadog::Configuration, + client: reqwest_middleware::ClientWithMiddleware, +} + +impl Default for WorkflowAutomationAPI { + fn default() -> Self { + Self::with_config(datadog::Configuration::default()) + } +} + +impl WorkflowAutomationAPI { + 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 } + } + + /// Cancels a specific execution of a given workflow. + pub async fn cancel_workflow_instance( + &self, + workflow_id: String, + instance_id: String, + ) -> Result< + crate::datadogV2::model::WorklflowCancelInstanceResponse, + datadog::Error, + > { + match self + .cancel_workflow_instance_with_http_info(workflow_id, instance_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), + } + } + + /// Cancels a specific execution of a given workflow. + pub async fn cancel_workflow_instance_with_http_info( + &self, + workflow_id: String, + instance_id: String, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.cancel_workflow_instance"; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/workflows/{workflow_id}/instances/{instance_id}/cancel", + local_configuration.get_operation_host(operation_id), + workflow_id = datadog::urlencode(workflow_id), + instance_id = datadog::urlencode(instance_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("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)) + } + } + + /// Execute the given workflow + pub async fn create_workflow_instance( + &self, + workflow_id: String, + body: crate::datadogV2::model::WorkflowInstanceCreateRequest, + ) -> Result< + crate::datadogV2::model::WorkflowInstanceCreateResponse, + datadog::Error, + > { + match self + .create_workflow_instance_with_http_info(workflow_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), + } + } + + /// Execute the given workflow + pub async fn create_workflow_instance_with_http_info( + &self, + workflow_id: String, + body: crate::datadogV2::model::WorkflowInstanceCreateRequest, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.create_workflow_instance"; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/workflows/{workflow_id}/instances", + local_configuration.get_operation_host(operation_id), + workflow_id = datadog::urlencode(workflow_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)) + } + } + + /// Get a specific execution of a given workflow. + pub async fn get_workflow_instance( + &self, + workflow_id: String, + instance_id: String, + ) -> Result< + crate::datadogV2::model::WorklflowGetInstanceResponse, + datadog::Error, + > { + match self + .get_workflow_instance_with_http_info(workflow_id, instance_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), + } + } + + /// Get a specific execution of a given workflow. + pub async fn get_workflow_instance_with_http_info( + &self, + workflow_id: String, + instance_id: String, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.get_workflow_instance"; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/workflows/{workflow_id}/instances/{instance_id}", + local_configuration.get_operation_host(operation_id), + workflow_id = datadog::urlencode(workflow_id), + instance_id = datadog::urlencode(instance_id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::GET, local_uri_str.as_str()); + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Accept", HeaderValue::from_static("application/json")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + match serde_json::from_str::( + &local_content, + ) { + Ok(e) => { + return Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: Some(e), + }) + } + Err(e) => return Err(datadog::Error::Serde(e)), + }; + } else { + let local_entity: Option = + serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } + + /// List all instances of a given workflow. + pub async fn list_workflow_instances( + &self, + workflow_id: String, + params: ListWorkflowInstancesOptionalParams, + ) -> Result< + crate::datadogV2::model::WorkflowListInstancesResponse, + datadog::Error, + > { + match self + .list_workflow_instances_with_http_info(workflow_id, params) + .await + { + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(datadog::Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } + Err(err) => Err(err), + } + } + + /// List all instances of a given workflow. + pub async fn list_workflow_instances_with_http_info( + &self, + workflow_id: String, + params: ListWorkflowInstancesOptionalParams, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.list_workflow_instances"; + + // unbox and build optional parameters + let page_size = params.page_size; + let page_number = params.page_number; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/workflows/{workflow_id}/instances", + local_configuration.get_operation_host(operation_id), + workflow_id = datadog::urlencode(workflow_id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::GET, local_uri_str.as_str()); + + if let Some(ref local_query_param) = page_size { + local_req_builder = + local_req_builder.query(&[("page[size]", &local_query_param.to_string())]); + }; + if let Some(ref local_query_param) = page_number { + local_req_builder = + local_req_builder.query(&[("page[number]", &local_query_param.to_string())]); + }; + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Accept", HeaderValue::from_static("application/json")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + match serde_json::from_str::( + &local_content, + ) { + Ok(e) => { + return Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: Some(e), + }) + } + Err(e) => return Err(datadog::Error::Serde(e)), + }; + } else { + let local_entity: Option = + serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } +} diff --git a/src/datadogV2/api/mod.rs b/src/datadogV2/api/mod.rs index 5c194587c..ecb2843f3 100644 --- a/src/datadogV2/api/mod.rs +++ b/src/datadogV2/api/mod.rs @@ -53,3 +53,4 @@ pub mod api_synthetics; pub mod api_teams; pub mod api_usage_metering; pub mod api_users; +pub mod api_workflow_automation; diff --git a/src/datadogV2/mod.rs b/src/datadogV2/mod.rs index f876017a3..303855eed 100644 --- a/src/datadogV2/mod.rs +++ b/src/datadogV2/mod.rs @@ -54,4 +54,5 @@ pub use self::api::api_synthetics; pub use self::api::api_teams; pub use self::api::api_usage_metering; pub use self::api::api_users; +pub use self::api::api_workflow_automation; pub mod model; diff --git a/src/datadogV2/model/mod.rs b/src/datadogV2/model/mod.rs index 41f483a99..8540e20ca 100644 --- a/src/datadogV2/model/mod.rs +++ b/src/datadogV2/model/mod.rs @@ -3020,3 +3020,29 @@ pub mod model_user_update_data; pub use self::model_user_update_data::UserUpdateData; pub mod model_user_update_attributes; pub use self::model_user_update_attributes::UserUpdateAttributes; +pub mod model_workflow_list_instances_response; +pub use self::model_workflow_list_instances_response::WorkflowListInstancesResponse; +pub mod model_workflow_instance_list_item; +pub use self::model_workflow_instance_list_item::WorkflowInstanceListItem; +pub mod model_workflow_list_instances_response_meta; +pub use self::model_workflow_list_instances_response_meta::WorkflowListInstancesResponseMeta; +pub mod model_workflow_list_instances_response_meta_page; +pub use self::model_workflow_list_instances_response_meta_page::WorkflowListInstancesResponseMetaPage; +pub mod model_workflow_instance_create_request; +pub use self::model_workflow_instance_create_request::WorkflowInstanceCreateRequest; +pub mod model_workflow_instance_create_meta; +pub use self::model_workflow_instance_create_meta::WorkflowInstanceCreateMeta; +pub mod model_workflow_instance_create_response; +pub use self::model_workflow_instance_create_response::WorkflowInstanceCreateResponse; +pub mod model_workflow_instance_create_response_data; +pub use self::model_workflow_instance_create_response_data::WorkflowInstanceCreateResponseData; +pub mod model_worklflow_get_instance_response; +pub use self::model_worklflow_get_instance_response::WorklflowGetInstanceResponse; +pub mod model_worklflow_get_instance_response_data; +pub use self::model_worklflow_get_instance_response_data::WorklflowGetInstanceResponseData; +pub mod model_worklflow_get_instance_response_data_attributes; +pub use self::model_worklflow_get_instance_response_data_attributes::WorklflowGetInstanceResponseDataAttributes; +pub mod model_worklflow_cancel_instance_response; +pub use self::model_worklflow_cancel_instance_response::WorklflowCancelInstanceResponse; +pub mod model_worklflow_cancel_instance_response_data; +pub use self::model_worklflow_cancel_instance_response_data::WorklflowCancelInstanceResponseData; diff --git a/src/datadogV2/model/model_workflow_instance_create_meta.rs b/src/datadogV2/model/model_workflow_instance_create_meta.rs new file mode 100644 index 000000000..9b6ea335e --- /dev/null +++ b/src/datadogV2/model/model_workflow_instance_create_meta.rs @@ -0,0 +1,83 @@ +// 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}; + +/// Additional information for creating a workflow instance. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct WorkflowInstanceCreateMeta { + /// The input parameters to the workflow. + #[serde(rename = "payload")] + pub payload: Option>, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl WorkflowInstanceCreateMeta { + pub fn new() -> WorkflowInstanceCreateMeta { + WorkflowInstanceCreateMeta { + payload: None, + _unparsed: false, + } + } + + pub fn payload(mut self, value: std::collections::BTreeMap) -> Self { + self.payload = Some(value); + self + } +} + +impl Default for WorkflowInstanceCreateMeta { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for WorkflowInstanceCreateMeta { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct WorkflowInstanceCreateMetaVisitor; + impl<'a> Visitor<'a> for WorkflowInstanceCreateMetaVisitor { + type Value = WorkflowInstanceCreateMeta; + + 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 payload: Option> = + None; + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "payload" => { + if v.is_null() { + continue; + } + payload = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => {} + } + } + + let content = WorkflowInstanceCreateMeta { payload, _unparsed }; + + Ok(content) + } + } + + deserializer.deserialize_any(WorkflowInstanceCreateMetaVisitor) + } +} diff --git a/src/datadogV2/model/model_workflow_instance_create_request.rs b/src/datadogV2/model/model_workflow_instance_create_request.rs new file mode 100644 index 000000000..42e0fed81 --- /dev/null +++ b/src/datadogV2/model/model_workflow_instance_create_request.rs @@ -0,0 +1,82 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Request used to create a workflow instance. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct WorkflowInstanceCreateRequest { + /// Additional information for creating a workflow instance. + #[serde(rename = "meta")] + pub meta: Option, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl WorkflowInstanceCreateRequest { + pub fn new() -> WorkflowInstanceCreateRequest { + WorkflowInstanceCreateRequest { + meta: None, + _unparsed: false, + } + } + + pub fn meta(mut self, value: crate::datadogV2::model::WorkflowInstanceCreateMeta) -> Self { + self.meta = Some(value); + self + } +} + +impl Default for WorkflowInstanceCreateRequest { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for WorkflowInstanceCreateRequest { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct WorkflowInstanceCreateRequestVisitor; + impl<'a> Visitor<'a> for WorkflowInstanceCreateRequestVisitor { + type Value = WorkflowInstanceCreateRequest; + + 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 meta: Option = None; + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "meta" => { + if v.is_null() { + continue; + } + meta = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => {} + } + } + + let content = WorkflowInstanceCreateRequest { meta, _unparsed }; + + Ok(content) + } + } + + deserializer.deserialize_any(WorkflowInstanceCreateRequestVisitor) + } +} diff --git a/src/datadogV2/model/model_workflow_instance_create_response.rs b/src/datadogV2/model/model_workflow_instance_create_response.rs new file mode 100644 index 000000000..390b1c26d --- /dev/null +++ b/src/datadogV2/model/model_workflow_instance_create_response.rs @@ -0,0 +1,109 @@ +// 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 returned upon successful workflow instance creation. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct WorkflowInstanceCreateResponse { + /// Data about the created workflow instance. + #[serde(rename = "data")] + pub data: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl WorkflowInstanceCreateResponse { + pub fn new() -> WorkflowInstanceCreateResponse { + WorkflowInstanceCreateResponse { + data: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn data( + mut self, + value: crate::datadogV2::model::WorkflowInstanceCreateResponseData, + ) -> 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 WorkflowInstanceCreateResponse { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for WorkflowInstanceCreateResponse { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct WorkflowInstanceCreateResponseVisitor; + impl<'a> Visitor<'a> for WorkflowInstanceCreateResponseVisitor { + type Value = WorkflowInstanceCreateResponse; + + 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 = WorkflowInstanceCreateResponse { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(WorkflowInstanceCreateResponseVisitor) + } +} diff --git a/src/datadogV2/model/model_workflow_instance_create_response_data.rs b/src/datadogV2/model/model_workflow_instance_create_response_data.rs new file mode 100644 index 000000000..5ff7708e8 --- /dev/null +++ b/src/datadogV2/model/model_workflow_instance_create_response_data.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}; + +/// Data about the created workflow instance. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct WorkflowInstanceCreateResponseData { + /// The ID of the workflow execution. It can be used to fetch the execution status. + #[serde(rename = "id")] + pub id: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl WorkflowInstanceCreateResponseData { + pub fn new() -> WorkflowInstanceCreateResponseData { + WorkflowInstanceCreateResponseData { + id: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn id(mut self, value: String) -> Self { + self.id = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for WorkflowInstanceCreateResponseData { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for WorkflowInstanceCreateResponseData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct WorkflowInstanceCreateResponseDataVisitor; + impl<'a> Visitor<'a> for WorkflowInstanceCreateResponseDataVisitor { + type Value = WorkflowInstanceCreateResponseData; + + 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 id: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "id" => { + if v.is_null() { + continue; + } + id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = WorkflowInstanceCreateResponseData { + id, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(WorkflowInstanceCreateResponseDataVisitor) + } +} diff --git a/src/datadogV2/model/model_workflow_instance_list_item.rs b/src/datadogV2/model/model_workflow_instance_list_item.rs new file mode 100644 index 000000000..adebc5135 --- /dev/null +++ b/src/datadogV2/model/model_workflow_instance_list_item.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}; + +/// An item in the workflow instances list. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct WorkflowInstanceListItem { + /// The ID of the workflow instance + #[serde(rename = "id")] + pub id: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl WorkflowInstanceListItem { + pub fn new() -> WorkflowInstanceListItem { + WorkflowInstanceListItem { + id: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn id(mut self, value: String) -> Self { + self.id = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for WorkflowInstanceListItem { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for WorkflowInstanceListItem { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct WorkflowInstanceListItemVisitor; + impl<'a> Visitor<'a> for WorkflowInstanceListItemVisitor { + type Value = WorkflowInstanceListItem; + + 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 id: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "id" => { + if v.is_null() { + continue; + } + id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = WorkflowInstanceListItem { + id, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(WorkflowInstanceListItemVisitor) + } +} diff --git a/src/datadogV2/model/model_workflow_list_instances_response.rs b/src/datadogV2/model/model_workflow_list_instances_response.rs new file mode 100644 index 000000000..b5fdc97e6 --- /dev/null +++ b/src/datadogV2/model/model_workflow_list_instances_response.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}; + +/// Response returned when listing workflow instances. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct WorkflowListInstancesResponse { + /// A list of workflow instances. + #[serde(rename = "data")] + pub data: Option>, + /// Metadata about the instances list + #[serde(rename = "meta")] + pub meta: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl WorkflowListInstancesResponse { + pub fn new() -> WorkflowListInstancesResponse { + WorkflowListInstancesResponse { + data: None, + meta: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn data(mut self, value: Vec) -> Self { + self.data = Some(value); + self + } + + pub fn meta( + mut self, + value: crate::datadogV2::model::WorkflowListInstancesResponseMeta, + ) -> Self { + self.meta = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for WorkflowListInstancesResponse { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for WorkflowListInstancesResponse { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct WorkflowListInstancesResponseVisitor; + impl<'a> Visitor<'a> for WorkflowListInstancesResponseVisitor { + type Value = WorkflowListInstancesResponse; + + 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 meta: 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)?); + } + "meta" => { + if v.is_null() { + continue; + } + meta = 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 = WorkflowListInstancesResponse { + data, + meta, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(WorkflowListInstancesResponseVisitor) + } +} diff --git a/src/datadogV2/model/model_workflow_list_instances_response_meta.rs b/src/datadogV2/model/model_workflow_list_instances_response_meta.rs new file mode 100644 index 000000000..451a21cd7 --- /dev/null +++ b/src/datadogV2/model/model_workflow_list_instances_response_meta.rs @@ -0,0 +1,110 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Metadata about the instances list +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct WorkflowListInstancesResponseMeta { + /// Page information for the list instances response. + #[serde(rename = "page")] + pub page: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl WorkflowListInstancesResponseMeta { + pub fn new() -> WorkflowListInstancesResponseMeta { + WorkflowListInstancesResponseMeta { + page: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn page( + mut self, + value: crate::datadogV2::model::WorkflowListInstancesResponseMetaPage, + ) -> Self { + self.page = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for WorkflowListInstancesResponseMeta { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for WorkflowListInstancesResponseMeta { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct WorkflowListInstancesResponseMetaVisitor; + impl<'a> Visitor<'a> for WorkflowListInstancesResponseMetaVisitor { + type Value = WorkflowListInstancesResponseMeta; + + 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 page: Option< + crate::datadogV2::model::WorkflowListInstancesResponseMetaPage, + > = 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() { + "page" => { + if v.is_null() { + continue; + } + page = 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 = WorkflowListInstancesResponseMeta { + page, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(WorkflowListInstancesResponseMetaVisitor) + } +} diff --git a/src/datadogV2/model/model_workflow_list_instances_response_meta_page.rs b/src/datadogV2/model/model_workflow_list_instances_response_meta_page.rs new file mode 100644 index 000000000..0f031ed25 --- /dev/null +++ b/src/datadogV2/model/model_workflow_list_instances_response_meta_page.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}; + +/// Page information for the list instances response. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct WorkflowListInstancesResponseMetaPage { + /// The total count of items. + #[serde(rename = "totalCount")] + pub total_count: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl WorkflowListInstancesResponseMetaPage { + pub fn new() -> WorkflowListInstancesResponseMetaPage { + WorkflowListInstancesResponseMetaPage { + total_count: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn total_count(mut self, value: i64) -> Self { + self.total_count = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for WorkflowListInstancesResponseMetaPage { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for WorkflowListInstancesResponseMetaPage { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct WorkflowListInstancesResponseMetaPageVisitor; + impl<'a> Visitor<'a> for WorkflowListInstancesResponseMetaPageVisitor { + type Value = WorkflowListInstancesResponseMetaPage; + + 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 total_count: 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() { + "totalCount" => { + if v.is_null() { + continue; + } + total_count = + 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 = WorkflowListInstancesResponseMetaPage { + total_count, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(WorkflowListInstancesResponseMetaPageVisitor) + } +} diff --git a/src/datadogV2/model/model_worklflow_cancel_instance_response.rs b/src/datadogV2/model/model_worklflow_cancel_instance_response.rs new file mode 100644 index 000000000..0c7118a85 --- /dev/null +++ b/src/datadogV2/model/model_worklflow_cancel_instance_response.rs @@ -0,0 +1,86 @@ +// 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 canceled instance. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct WorklflowCancelInstanceResponse { + /// Data about the canceled instance. + #[serde(rename = "data")] + pub data: Option, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl WorklflowCancelInstanceResponse { + pub fn new() -> WorklflowCancelInstanceResponse { + WorklflowCancelInstanceResponse { + data: None, + _unparsed: false, + } + } + + pub fn data( + mut self, + value: crate::datadogV2::model::WorklflowCancelInstanceResponseData, + ) -> Self { + self.data = Some(value); + self + } +} + +impl Default for WorklflowCancelInstanceResponse { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for WorklflowCancelInstanceResponse { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct WorklflowCancelInstanceResponseVisitor; + impl<'a> Visitor<'a> for WorklflowCancelInstanceResponseVisitor { + type Value = WorklflowCancelInstanceResponse; + + 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 _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)?); + } + &_ => {} + } + } + + let content = WorklflowCancelInstanceResponse { data, _unparsed }; + + Ok(content) + } + } + + deserializer.deserialize_any(WorklflowCancelInstanceResponseVisitor) + } +} diff --git a/src/datadogV2/model/model_worklflow_cancel_instance_response_data.rs b/src/datadogV2/model/model_worklflow_cancel_instance_response_data.rs new file mode 100644 index 000000000..f3fd33867 --- /dev/null +++ b/src/datadogV2/model/model_worklflow_cancel_instance_response_data.rs @@ -0,0 +1,82 @@ +// 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 about the canceled instance. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct WorklflowCancelInstanceResponseData { + /// The id of the canceled instance + #[serde(rename = "id")] + pub id: Option, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl WorklflowCancelInstanceResponseData { + pub fn new() -> WorklflowCancelInstanceResponseData { + WorklflowCancelInstanceResponseData { + id: None, + _unparsed: false, + } + } + + pub fn id(mut self, value: String) -> Self { + self.id = Some(value); + self + } +} + +impl Default for WorklflowCancelInstanceResponseData { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for WorklflowCancelInstanceResponseData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct WorklflowCancelInstanceResponseDataVisitor; + impl<'a> Visitor<'a> for WorklflowCancelInstanceResponseDataVisitor { + type Value = WorklflowCancelInstanceResponseData; + + 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 id: Option = None; + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "id" => { + if v.is_null() { + continue; + } + id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => {} + } + } + + let content = WorklflowCancelInstanceResponseData { id, _unparsed }; + + Ok(content) + } + } + + deserializer.deserialize_any(WorklflowCancelInstanceResponseDataVisitor) + } +} diff --git a/src/datadogV2/model/model_worklflow_get_instance_response.rs b/src/datadogV2/model/model_worklflow_get_instance_response.rs new file mode 100644 index 000000000..99d943f82 --- /dev/null +++ b/src/datadogV2/model/model_worklflow_get_instance_response.rs @@ -0,0 +1,109 @@ +// 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}; + +/// The state of the given workflow instance. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct WorklflowGetInstanceResponse { + /// The data of the instance response. + #[serde(rename = "data")] + pub data: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl WorklflowGetInstanceResponse { + pub fn new() -> WorklflowGetInstanceResponse { + WorklflowGetInstanceResponse { + data: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn data( + mut self, + value: crate::datadogV2::model::WorklflowGetInstanceResponseData, + ) -> 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 WorklflowGetInstanceResponse { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for WorklflowGetInstanceResponse { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct WorklflowGetInstanceResponseVisitor; + impl<'a> Visitor<'a> for WorklflowGetInstanceResponseVisitor { + type Value = WorklflowGetInstanceResponse; + + 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 = WorklflowGetInstanceResponse { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(WorklflowGetInstanceResponseVisitor) + } +} diff --git a/src/datadogV2/model/model_worklflow_get_instance_response_data.rs b/src/datadogV2/model/model_worklflow_get_instance_response_data.rs new file mode 100644 index 000000000..b34e8428b --- /dev/null +++ b/src/datadogV2/model/model_worklflow_get_instance_response_data.rs @@ -0,0 +1,110 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The data of the instance response. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct WorklflowGetInstanceResponseData { + /// The attributes of the instance response data. + #[serde(rename = "attributes")] + pub attributes: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl WorklflowGetInstanceResponseData { + pub fn new() -> WorklflowGetInstanceResponseData { + WorklflowGetInstanceResponseData { + attributes: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn attributes( + mut self, + value: crate::datadogV2::model::WorklflowGetInstanceResponseDataAttributes, + ) -> Self { + self.attributes = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for WorklflowGetInstanceResponseData { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for WorklflowGetInstanceResponseData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct WorklflowGetInstanceResponseDataVisitor; + impl<'a> Visitor<'a> for WorklflowGetInstanceResponseDataVisitor { + type Value = WorklflowGetInstanceResponseData; + + 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::WorklflowGetInstanceResponseDataAttributes, + > = 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" => { + if v.is_null() { + continue; + } + attributes = 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 = WorklflowGetInstanceResponseData { + attributes, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(WorklflowGetInstanceResponseDataVisitor) + } +} diff --git a/src/datadogV2/model/model_worklflow_get_instance_response_data_attributes.rs b/src/datadogV2/model/model_worklflow_get_instance_response_data_attributes.rs new file mode 100644 index 000000000..5f3c89348 --- /dev/null +++ b/src/datadogV2/model/model_worklflow_get_instance_response_data_attributes.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}; + +/// The attributes of the instance response data. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct WorklflowGetInstanceResponseDataAttributes { + /// The id of the instance. + #[serde(rename = "id")] + pub id: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl WorklflowGetInstanceResponseDataAttributes { + pub fn new() -> WorklflowGetInstanceResponseDataAttributes { + WorklflowGetInstanceResponseDataAttributes { + id: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn id(mut self, value: String) -> Self { + self.id = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for WorklflowGetInstanceResponseDataAttributes { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for WorklflowGetInstanceResponseDataAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct WorklflowGetInstanceResponseDataAttributesVisitor; + impl<'a> Visitor<'a> for WorklflowGetInstanceResponseDataAttributesVisitor { + type Value = WorklflowGetInstanceResponseDataAttributes; + + 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 id: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "id" => { + if v.is_null() { + continue; + } + id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = WorklflowGetInstanceResponseDataAttributes { + id, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(WorklflowGetInstanceResponseDataAttributesVisitor) + } +} diff --git a/tests/scenarios/cassettes/v2/workflow_automation/Cancel-a-workflow-instance-returns-Bad-Request-response.frozen b/tests/scenarios/cassettes/v2/workflow_automation/Cancel-a-workflow-instance-returns-Bad-Request-response.frozen new file mode 100644 index 000000000..3b73466a4 --- /dev/null +++ b/tests/scenarios/cassettes/v2/workflow_automation/Cancel-a-workflow-instance-returns-Bad-Request-response.frozen @@ -0,0 +1 @@ +2024-07-24T18:39:57.489Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/workflow_automation/Cancel-a-workflow-instance-returns-Bad-Request-response.json b/tests/scenarios/cassettes/v2/workflow_automation/Cancel-a-workflow-instance-returns-Bad-Request-response.json new file mode 100644 index 000000000..0d2afe508 --- /dev/null +++ b/tests/scenarios/cassettes/v2/workflow_automation/Cancel-a-workflow-instance-returns-Bad-Request-response.json @@ -0,0 +1,33 @@ +{ + "http_interactions": [ + { + "request": { + "body": "", + "headers": { + "Accept": [ + "application/json" + ] + }, + "method": "put", + "uri": "https://api.datadoghq.com/api/v2/workflows/malformed/instances/malformed/cancel" + }, + "response": { + "body": { + "string": "{\"errors\":[{\"code\":\"INVALID_FIELD_VALUE\",\"detail\":\"value is invalid for field workflow_id\"}]}\n", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "status": { + "code": 400, + "message": "Bad Request" + } + }, + "recorded_at": "Wed, 24 Jul 2024 18:39:57 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/workflow_automation/Cancel-a-workflow-instance-returns-Not-Found-response.frozen b/tests/scenarios/cassettes/v2/workflow_automation/Cancel-a-workflow-instance-returns-Not-Found-response.frozen new file mode 100644 index 000000000..674a620d5 --- /dev/null +++ b/tests/scenarios/cassettes/v2/workflow_automation/Cancel-a-workflow-instance-returns-Not-Found-response.frozen @@ -0,0 +1 @@ +2024-07-24T18:39:57.698Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/workflow_automation/Cancel-a-workflow-instance-returns-Not-Found-response.json b/tests/scenarios/cassettes/v2/workflow_automation/Cancel-a-workflow-instance-returns-Not-Found-response.json new file mode 100644 index 000000000..26516fd9d --- /dev/null +++ b/tests/scenarios/cassettes/v2/workflow_automation/Cancel-a-workflow-instance-returns-Not-Found-response.json @@ -0,0 +1,33 @@ +{ + "http_interactions": [ + { + "request": { + "body": "", + "headers": { + "Accept": [ + "application/json" + ] + }, + "method": "put", + "uri": "https://api.datadoghq.com/api/v2/workflows/0233a3b7-b7ba-425e-a8cc-375ca2020b5b/instances/e0c64dc8-f946-4ae8-8d79-54569031ce67/cancel" + }, + "response": { + "body": { + "string": "{\"errors\":[{\"code\":\"INSTANCE_NOT_FOUND\",\"detail\":\"instance e0c64dc8-f946-4ae8-8d79-54569031ce67 not found\"}]}\n", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "status": { + "code": 404, + "message": "Not Found" + } + }, + "recorded_at": "Wed, 24 Jul 2024 18:39:57 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/workflow_automation/Cancel-a-workflow-instance-returns-OK-response.frozen b/tests/scenarios/cassettes/v2/workflow_automation/Cancel-a-workflow-instance-returns-OK-response.frozen new file mode 100644 index 000000000..a62f2698f --- /dev/null +++ b/tests/scenarios/cassettes/v2/workflow_automation/Cancel-a-workflow-instance-returns-OK-response.frozen @@ -0,0 +1 @@ +2024-07-24T18:39:57.827Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/workflow_automation/Cancel-a-workflow-instance-returns-OK-response.json b/tests/scenarios/cassettes/v2/workflow_automation/Cancel-a-workflow-instance-returns-OK-response.json new file mode 100644 index 000000000..aebda0cba --- /dev/null +++ b/tests/scenarios/cassettes/v2/workflow_automation/Cancel-a-workflow-instance-returns-OK-response.json @@ -0,0 +1,33 @@ +{ + "http_interactions": [ + { + "request": { + "body": "", + "headers": { + "Accept": [ + "application/json" + ] + }, + "method": "put", + "uri": "https://api.datadoghq.com/api/v2/workflows/ccf73164-1998-4785-a7a3-8d06c7e5f558/instances/305a472b-71ab-4ce8-8f8d-75db635627b5/cancel" + }, + "response": { + "body": { + "string": "{}\n", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "status": { + "code": 200, + "message": "OK" + } + }, + "recorded_at": "Wed, 24 Jul 2024 18:39:57 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/workflow_automation/Execute-a-workflow-returns-Bad-Request-response.frozen b/tests/scenarios/cassettes/v2/workflow_automation/Execute-a-workflow-returns-Bad-Request-response.frozen new file mode 100644 index 000000000..f6b8453bd --- /dev/null +++ b/tests/scenarios/cassettes/v2/workflow_automation/Execute-a-workflow-returns-Bad-Request-response.frozen @@ -0,0 +1 @@ +2024-07-24T18:39:57.981Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/workflow_automation/Execute-a-workflow-returns-Bad-Request-response.json b/tests/scenarios/cassettes/v2/workflow_automation/Execute-a-workflow-returns-Bad-Request-response.json new file mode 100644 index 000000000..f7c458a03 --- /dev/null +++ b/tests/scenarios/cassettes/v2/workflow_automation/Execute-a-workflow-returns-Bad-Request-response.json @@ -0,0 +1,39 @@ +{ + "http_interactions": [ + { + "request": { + "body": { + "string": "{\"meta\":{\"payload\":{\"input\":\"value\"}}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v2/workflows/malformed/instances" + }, + "response": { + "body": { + "string": "{\"errors\":[{\"code\":\"INVALID_FIELD_VALUE\",\"detail\":\"value is invalid for field workflow_id\"}]}\n", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "status": { + "code": 400, + "message": "Bad Request" + } + }, + "recorded_at": "Wed, 24 Jul 2024 18:39:57 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/workflow_automation/Execute-a-workflow-returns-Created-response.frozen b/tests/scenarios/cassettes/v2/workflow_automation/Execute-a-workflow-returns-Created-response.frozen new file mode 100644 index 000000000..becb79803 --- /dev/null +++ b/tests/scenarios/cassettes/v2/workflow_automation/Execute-a-workflow-returns-Created-response.frozen @@ -0,0 +1 @@ +2024-07-24T18:39:58.210Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/workflow_automation/Execute-a-workflow-returns-Created-response.json b/tests/scenarios/cassettes/v2/workflow_automation/Execute-a-workflow-returns-Created-response.json new file mode 100644 index 000000000..c387c4a2d --- /dev/null +++ b/tests/scenarios/cassettes/v2/workflow_automation/Execute-a-workflow-returns-Created-response.json @@ -0,0 +1,39 @@ +{ + "http_interactions": [ + { + "request": { + "body": { + "string": "{\"meta\":{\"payload\":{\"input\":\"value\"}}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v2/workflows/ccf73164-1998-4785-a7a3-8d06c7e5f558/instances" + }, + "response": { + "body": { + "string": "{\"data\":{\"attributes\":{},\"id\":\"111e18d6-3f19-4ada-91d3-ab1e1546b8b4\",\"type\":\"instances\"},\"meta\":{\"workflowId\":\"ccf73164-1998-4785-a7a3-8d06c7e5f558\"}}\n", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "status": { + "code": 200, + "message": "OK" + } + }, + "recorded_at": "Wed, 24 Jul 2024 18:39:58 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/workflow_automation/Get-a-workflow-instance-returns-Bad-Request-response.frozen b/tests/scenarios/cassettes/v2/workflow_automation/Get-a-workflow-instance-returns-Bad-Request-response.frozen new file mode 100644 index 000000000..873df33c0 --- /dev/null +++ b/tests/scenarios/cassettes/v2/workflow_automation/Get-a-workflow-instance-returns-Bad-Request-response.frozen @@ -0,0 +1 @@ +2024-07-24T18:39:58.459Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/workflow_automation/Get-a-workflow-instance-returns-Bad-Request-response.json b/tests/scenarios/cassettes/v2/workflow_automation/Get-a-workflow-instance-returns-Bad-Request-response.json new file mode 100644 index 000000000..be7d8965c --- /dev/null +++ b/tests/scenarios/cassettes/v2/workflow_automation/Get-a-workflow-instance-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/workflows/malformed/instances/malformed" + }, + "response": { + "body": { + "string": "{\"errors\":[{\"code\":\"INVALID_FIELD_VALUE\",\"detail\":\"value is invalid for field workflow_id\"}]}\n", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "status": { + "code": 400, + "message": "Bad Request" + } + }, + "recorded_at": "Wed, 24 Jul 2024 18:39:58 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/workflow_automation/Get-a-workflow-instance-returns-Not-Found-response.frozen b/tests/scenarios/cassettes/v2/workflow_automation/Get-a-workflow-instance-returns-Not-Found-response.frozen new file mode 100644 index 000000000..72f845efc --- /dev/null +++ b/tests/scenarios/cassettes/v2/workflow_automation/Get-a-workflow-instance-returns-Not-Found-response.frozen @@ -0,0 +1 @@ +2024-07-24T18:39:58.587Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/workflow_automation/Get-a-workflow-instance-returns-Not-Found-response.json b/tests/scenarios/cassettes/v2/workflow_automation/Get-a-workflow-instance-returns-Not-Found-response.json new file mode 100644 index 000000000..4a75e1ba8 --- /dev/null +++ b/tests/scenarios/cassettes/v2/workflow_automation/Get-a-workflow-instance-returns-Not-Found-response.json @@ -0,0 +1,33 @@ +{ + "http_interactions": [ + { + "request": { + "body": "", + "headers": { + "Accept": [ + "application/json" + ] + }, + "method": "get", + "uri": "https://api.datadoghq.com/api/v2/workflows/0233a3b7-b7ba-425e-a8cc-375ca2020b5b/instances/e0c64dc8-f946-4ae8-8d79-54569031ce67" + }, + "response": { + "body": { + "string": "{\"errors\":[{\"code\":\"WORKFLOW_NOT_FOUND\",\"detail\":\"workflow not found\"}]}\n", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "status": { + "code": 404, + "message": "Not Found" + } + }, + "recorded_at": "Wed, 24 Jul 2024 18:39:58 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/workflow_automation/Get-a-workflow-instance-returns-OK-response.frozen b/tests/scenarios/cassettes/v2/workflow_automation/Get-a-workflow-instance-returns-OK-response.frozen new file mode 100644 index 000000000..95289c982 --- /dev/null +++ b/tests/scenarios/cassettes/v2/workflow_automation/Get-a-workflow-instance-returns-OK-response.frozen @@ -0,0 +1 @@ +2024-07-24T18:39:58.724Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/workflow_automation/Get-a-workflow-instance-returns-OK-response.json b/tests/scenarios/cassettes/v2/workflow_automation/Get-a-workflow-instance-returns-OK-response.json new file mode 100644 index 000000000..beb3d54a3 --- /dev/null +++ b/tests/scenarios/cassettes/v2/workflow_automation/Get-a-workflow-instance-returns-OK-response.json @@ -0,0 +1,33 @@ +{ + "http_interactions": [ + { + "request": { + "body": "", + "headers": { + "Accept": [ + "application/json" + ] + }, + "method": "get", + "uri": "https://api.datadoghq.com/api/v2/workflows/ccf73164-1998-4785-a7a3-8d06c7e5f558/instances/305a472b-71ab-4ce8-8f8d-75db635627b5" + }, + "response": { + "body": { + "string": "{\"data\":{\"attributes\":{\"endTimestamp\":\"2024-07-24T18:39:58.219283Z\",\"instanceStatus\":{\"detailsKind\":\"CANCELED\",\"displayName\":\"Canceled\"},\"outputs\":{},\"source\":{\"manual\":{\"actingUser\":{\"userEmail\":\"max.gale@datadoghq.com\",\"userName\":\"Max Gale\",\"userUuid\":\"e39535f4-306b-11ee-9383-6ac9a4415a29\"}}},\"sourceForTemplating\":{\"initiator\":{\"email\":\"max.gale@datadoghq.com\",\"id\":\"e39535f4-306b-11ee-9383-6ac9a4415a29\",\"name\":\"Max Gale\"},\"name\":\"Max Jul 24 2024 02:38\",\"type\":\"manual\",\"url\":\"https://app.datadoghq.com/workflow/ccf73164-1998-4785-a7a3-8d06c7e5f558?instance=305a472b-71ab-4ce8-8f8d-75db635627b5\"},\"startTimestamp\":\"2024-07-24T18:38:31.326418Z\",\"stepStateAssociations\":[{\"stepName\":\"Sleep\",\"stepState\":\"CANCELED\"}],\"trigger\":{}},\"id\":\"305a472b-71ab-4ce8-8f8d-75db635627b5\",\"relationships\":{\"specVersion\":{\"data\":{\"id\":\"37d9abeb-2ac1-4185-91f8-86d92d5cbf7f\",\"type\":\"spec_versions\"}},\"workflow\":{\"data\":{\"id\":\"ccf73164-1998-4785-a7a3-8d06c7e5f558\",\"type\":\"workflows\"}}},\"type\":\"instances\"},\"included\":[{\"attributes\":{\"createdAt\":\"2024-07-24T18:38:29.839739Z\",\"spec\":{\"steps\":[{\"actionId\":\"com.datadoghq.core.sleep\",\"display\":{\"bounds\":{\"y\":186}},\"name\":\"Sleep\",\"parameters\":[{\"name\":\"durationSeconds\",\"value\":300}]}],\"triggers\":[{\"apiTrigger\":{},\"startStepNames\":[\"Sleep\"]}]},\"workflowId\":\"ccf73164-1998-4785-a7a3-8d06c7e5f558\"},\"id\":\"37d9abeb-2ac1-4185-91f8-86d92d5cbf7f\",\"type\":\"spec_versions\"},{\"attributes\":{\"createdAt\":\"2024-07-24T18:38:05.701669Z\",\"creationSource\":\"workflows_ui\",\"name\":\"Max Jul 24 2024 02:38\",\"specVersionId\":\"3d660f9c-7dfe-4fbd-bea5-f61eccea0600\",\"updatedAt\":\"2024-07-24T18:38:59.939929Z\"},\"id\":\"ccf73164-1998-4785-a7a3-8d06c7e5f558\",\"type\":\"workflows\"}],\"meta\":{\"outputsTooBig\":false,\"sourceTooBig\":false,\"triggerTooBig\":false}}\n", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "status": { + "code": 200, + "message": "OK" + } + }, + "recorded_at": "Wed, 24 Jul 2024 18:39:58 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/workflow_automation/List-workflow-instances-returns-Bad-Request-response.frozen b/tests/scenarios/cassettes/v2/workflow_automation/List-workflow-instances-returns-Bad-Request-response.frozen new file mode 100644 index 000000000..f07d03b73 --- /dev/null +++ b/tests/scenarios/cassettes/v2/workflow_automation/List-workflow-instances-returns-Bad-Request-response.frozen @@ -0,0 +1 @@ +2024-07-24T18:39:58.870Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/workflow_automation/List-workflow-instances-returns-Bad-Request-response.json b/tests/scenarios/cassettes/v2/workflow_automation/List-workflow-instances-returns-Bad-Request-response.json new file mode 100644 index 000000000..05e635227 --- /dev/null +++ b/tests/scenarios/cassettes/v2/workflow_automation/List-workflow-instances-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/workflows/malformed/instances" + }, + "response": { + "body": { + "string": "{\"errors\":[{\"code\":\"INVALID_FIELD_VALUE\",\"detail\":\"value is invalid for field workflow_id\"}]}\n", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "status": { + "code": 400, + "message": "Bad Request" + } + }, + "recorded_at": "Wed, 24 Jul 2024 18:39:58 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/workflow_automation/List-workflow-instances-returns-OK-response.frozen b/tests/scenarios/cassettes/v2/workflow_automation/List-workflow-instances-returns-OK-response.frozen new file mode 100644 index 000000000..27666a9e4 --- /dev/null +++ b/tests/scenarios/cassettes/v2/workflow_automation/List-workflow-instances-returns-OK-response.frozen @@ -0,0 +1 @@ +2024-07-24T18:39:59.003Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/workflow_automation/List-workflow-instances-returns-OK-response.json b/tests/scenarios/cassettes/v2/workflow_automation/List-workflow-instances-returns-OK-response.json new file mode 100644 index 000000000..4c4275bed --- /dev/null +++ b/tests/scenarios/cassettes/v2/workflow_automation/List-workflow-instances-returns-OK-response.json @@ -0,0 +1,33 @@ +{ + "http_interactions": [ + { + "request": { + "body": "", + "headers": { + "Accept": [ + "application/json" + ] + }, + "method": "get", + "uri": "https://api.datadoghq.com/api/v2/workflows/ccf73164-1998-4785-a7a3-8d06c7e5f558/instances" + }, + "response": { + "body": { + "string": "{\"data\":[{\"attributes\":{\"instanceStatus\":{\"detailsKind\":\"IN_PROGRESS\",\"displayName\":\"Running\"},\"source\":{\"api\":{\"actingUser\":{\"userEmail\":\"max.gale@datadoghq.com\",\"userName\":\"Max Gale\",\"userUuid\":\"e39535f4-306b-11ee-9383-6ac9a4415a29\"}}},\"startTimestamp\":\"2024-07-24T18:39:58.396793Z\"},\"id\":\"111e18d6-3f19-4ada-91d3-ab1e1546b8b4\",\"type\":\"instances\"},{\"attributes\":{\"endTimestamp\":\"2024-07-24T18:39:58.219283Z\",\"instanceStatus\":{\"detailsKind\":\"CANCELED\",\"displayName\":\"Canceled\"},\"source\":{\"manual\":{\"actingUser\":{\"userEmail\":\"max.gale@datadoghq.com\",\"userName\":\"Max Gale\",\"userUuid\":\"e39535f4-306b-11ee-9383-6ac9a4415a29\"}}},\"startTimestamp\":\"2024-07-24T18:38:31.326418Z\"},\"id\":\"305a472b-71ab-4ce8-8f8d-75db635627b5\",\"type\":\"instances\"}],\"meta\":{\"canceledCount\":1,\"failedCount\":0,\"page\":{\"totalCount\":2,\"totalFilteredCount\":2},\"succeededCount\":0}}\n", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "status": { + "code": 200, + "message": "OK" + } + }, + "recorded_at": "Wed, 24 Jul 2024 18:39:59 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/features/v2/undo.json b/tests/scenarios/features/v2/undo.json index c97bab6f7..a1effb52e 100644 --- a/tests/scenarios/features/v2/undo.json +++ b/tests/scenarios/features/v2/undo.json @@ -2430,5 +2430,29 @@ "undo": { "type": "safe" } + }, + "ListWorkflowInstances": { + "tag": "Workflow Automation", + "undo": { + "type": "safe" + } + }, + "CreateWorkflowInstance": { + "tag": "Workflow Automation", + "undo": { + "type": "safe" + } + }, + "GetWorkflowInstance": { + "tag": "Workflow Automation", + "undo": { + "type": "safe" + } + }, + "CancelWorkflowInstance": { + "tag": "Workflow Automation", + "undo": { + "type": "safe" + } } } diff --git a/tests/scenarios/features/v2/workflow_automation.feature b/tests/scenarios/features/v2/workflow_automation.feature new file mode 100644 index 000000000..fe979f72d --- /dev/null +++ b/tests/scenarios/features/v2/workflow_automation.feature @@ -0,0 +1,87 @@ +@endpoint(workflow-automation) @endpoint(workflow-automation-v2) +Feature: Workflow Automation + Automate your teams operational processes with Datadog Workflow + Automation. + + Background: + Given a valid "apiKeyAuth" key in the system + And a valid "appKeyAuth" key in the system + And an instance of "WorkflowAutomation" API + + @replay-only @team:DataDog/workflow-automation-dev + Scenario: Cancel a workflow instance returns "Bad Request" response + Given new "CancelWorkflowInstance" request + And request contains "workflow_id" parameter with value "malformed" + And request contains "instance_id" parameter with value "malformed" + When the request is sent + Then the response status is 400 Bad Request + + @replay-only @team:DataDog/workflow-automation-dev + Scenario: Cancel a workflow instance returns "Not Found" response + Given new "CancelWorkflowInstance" request + And request contains "workflow_id" parameter with value "0233a3b7-b7ba-425e-a8cc-375ca2020b5b" + And request contains "instance_id" parameter with value "e0c64dc8-f946-4ae8-8d79-54569031ce67" + When the request is sent + Then the response status is 404 Not Found + + @replay-only @team:DataDog/workflow-automation-dev + Scenario: Cancel a workflow instance returns "OK" response + Given new "CancelWorkflowInstance" request + And request contains "workflow_id" parameter with value "ccf73164-1998-4785-a7a3-8d06c7e5f558" + And request contains "instance_id" parameter with value "305a472b-71ab-4ce8-8f8d-75db635627b5" + When the request is sent + Then the response status is 200 OK + + @replay-only @team:DataDog/workflow-automation-dev + Scenario: Execute a workflow returns "Bad Request" response + Given new "CreateWorkflowInstance" request + And request contains "workflow_id" parameter with value "malformed" + And body with value { "meta": { "payload": { "input": "value" } } } + When the request is sent + Then the response status is 400 Bad Request + + @replay-only @team:DataDog/workflow-automation-dev + Scenario: Execute a workflow returns "Created" response + Given new "CreateWorkflowInstance" request + And request contains "workflow_id" parameter with value "ccf73164-1998-4785-a7a3-8d06c7e5f558" + And body with value { "meta": { "payload": { "input": "value" } } } + When the request is sent + Then the response status is 200 Created + + @replay-only @team:DataDog/workflow-automation-dev + Scenario: Get a workflow instance returns "Bad Request" response + Given new "GetWorkflowInstance" request + And request contains "workflow_id" parameter with value "malformed" + And request contains "instance_id" parameter with value "malformed" + When the request is sent + Then the response status is 400 Bad Request + + @replay-only @team:DataDog/workflow-automation-dev + Scenario: Get a workflow instance returns "Not Found" response + Given new "GetWorkflowInstance" request + And request contains "workflow_id" parameter with value "0233a3b7-b7ba-425e-a8cc-375ca2020b5b" + And request contains "instance_id" parameter with value "e0c64dc8-f946-4ae8-8d79-54569031ce67" + When the request is sent + Then the response status is 404 Not Found + + @replay-only @team:DataDog/workflow-automation-dev + Scenario: Get a workflow instance returns "OK" response + Given new "GetWorkflowInstance" request + And request contains "workflow_id" parameter with value "ccf73164-1998-4785-a7a3-8d06c7e5f558" + And request contains "instance_id" parameter with value "305a472b-71ab-4ce8-8f8d-75db635627b5" + When the request is sent + Then the response status is 200 OK + + @replay-only @team:DataDog/workflow-automation-dev + Scenario: List workflow instances returns "Bad Request" response + Given new "ListWorkflowInstances" request + And request contains "workflow_id" parameter with value "malformed" + When the request is sent + Then the response status is 400 Bad Request + + @replay-only @team:DataDog/workflow-automation-dev + Scenario: List workflow instances returns "OK" response + Given new "ListWorkflowInstances" request + And request contains "workflow_id" parameter with value "ccf73164-1998-4785-a7a3-8d06c7e5f558" + When the request is sent + Then the response status is 200 OK diff --git a/tests/scenarios/function_mappings.rs b/tests/scenarios/function_mappings.rs index 7d7344be9..3f7804e75 100644 --- a/tests/scenarios/function_mappings.rs +++ b/tests/scenarios/function_mappings.rs @@ -112,6 +112,8 @@ pub struct ApiInstances { pub v2_api_teams: Option, pub v2_api_incident_teams: Option, pub v2_api_users: Option, + pub v2_api_workflow_automation: + Option, } pub fn initialize_api_instance(world: &mut DatadogWorld, api: String) { @@ -707,6 +709,14 @@ pub fn initialize_api_instance(world: &mut DatadogWorld, api: String) { ), ); } + "WorkflowAutomation" => { + world.api_instances.v2_api_workflow_automation = Some( + datadogV2::api_workflow_automation::WorkflowAutomationAPI::with_client_and_config( + world.config.clone(), + world.http_client.as_ref().unwrap().clone(), + ), + ); + } _ => panic!("{api} API instance not found"), } } @@ -2891,6 +2901,22 @@ pub fn collect_function_calls(world: &mut DatadogWorld) { "v2.ListUserPermissions".into(), test_v2_list_user_permissions, ); + world.function_mappings.insert( + "v2.ListWorkflowInstances".into(), + test_v2_list_workflow_instances, + ); + world.function_mappings.insert( + "v2.CreateWorkflowInstance".into(), + test_v2_create_workflow_instance, + ); + world.function_mappings.insert( + "v2.GetWorkflowInstance".into(), + test_v2_get_workflow_instance, + ); + world.function_mappings.insert( + "v2.CancelWorkflowInstance".into(), + test_v2_cancel_workflow_instance, + ); } fn test_v1_get_ip_ranges(world: &mut DatadogWorld, _parameters: &HashMap) { @@ -22255,3 +22281,130 @@ fn test_v2_list_user_permissions(world: &mut DatadogWorld, _parameters: &HashMap world.response.object = serde_json::to_value(response.entity).unwrap(); world.response.code = response.status.as_u16(); } + +fn test_v2_list_workflow_instances(world: &mut DatadogWorld, _parameters: &HashMap) { + let api = world + .api_instances + .v2_api_workflow_automation + .as_ref() + .expect("api instance not found"); + let workflow_id = + serde_json::from_value(_parameters.get("workflow_id").unwrap().clone()).unwrap(); + let page_size = _parameters + .get("page[size]") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let page_number = _parameters + .get("page[number]") + .and_then(|param| Some(serde_json::from_value(param.clone()).unwrap())); + let mut params = + datadogV2::api_workflow_automation::ListWorkflowInstancesOptionalParams::default(); + params.page_size = page_size; + params.page_number = page_number; + let response = match block_on(api.list_workflow_instances_with_http_info(workflow_id, params)) { + 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_workflow_instance( + world: &mut DatadogWorld, + _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_workflow_automation + .as_ref() + .expect("api instance not found"); + let workflow_id = + serde_json::from_value(_parameters.get("workflow_id").unwrap().clone()).unwrap(); + let body = serde_json::from_value(_parameters.get("body").unwrap().clone()).unwrap(); + let response = match block_on(api.create_workflow_instance_with_http_info(workflow_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_workflow_instance(world: &mut DatadogWorld, _parameters: &HashMap) { + let api = world + .api_instances + .v2_api_workflow_automation + .as_ref() + .expect("api instance not found"); + let workflow_id = + serde_json::from_value(_parameters.get("workflow_id").unwrap().clone()).unwrap(); + let instance_id = + serde_json::from_value(_parameters.get("instance_id").unwrap().clone()).unwrap(); + let response = + match block_on(api.get_workflow_instance_with_http_info(workflow_id, instance_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_cancel_workflow_instance( + world: &mut DatadogWorld, + _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_workflow_automation + .as_ref() + .expect("api instance not found"); + let workflow_id = + serde_json::from_value(_parameters.get("workflow_id").unwrap().clone()).unwrap(); + let instance_id = + serde_json::from_value(_parameters.get("instance_id").unwrap().clone()).unwrap(); + let response = + match block_on(api.cancel_workflow_instance_with_http_info(workflow_id, instance_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(); +}