diff --git a/.apigentools-info b/.apigentools-info index bb4f561fd..76a1c5f11 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.6.6", - "regenerated": "2025-05-20 07:21:25.102606", - "spec_repo_commit": "fec20f97" + "regenerated": "2025-05-21 15:18:56.367835", + "spec_repo_commit": "3fbcf458" }, "v2": { "apigentools_version": "1.6.6", - "regenerated": "2025-05-20 07:21:25.118736", - "spec_repo_commit": "fec20f97" + "regenerated": "2025-05-21 15:18:56.385996", + "spec_repo_commit": "3fbcf458" } } } \ No newline at end of file diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 79fc922a6..49114744e 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -836,6 +836,13 @@ components: required: true schema: type: string + TenancyOCIDPathParameter: + description: Unique tenancy OCID of the OCI integration config. + in: path + name: tenancy_ocid + required: true + schema: + type: string UserID: description: The ID of the user. in: path @@ -3662,6 +3669,23 @@ components: from the other indexes type: string type: object + AuthCredentials: + description: The auth credentials of the user. Consists of a public key fingerprint + and private key. + properties: + fingerprint: + description: The public key fingerprint. + example: c8:e5:54:f2:da:a2:d7:b0:ed:f4:79:47:93:64:12:b1 + type: string + private_key: + description: The `RSA` private key in `PEM` format. + example: '----BEGIN PRIVATE KEY-----MIIEvgIBADANBgkqhkiG9w0BAQEFAA----END + PRIVATE KEY-----' + type: string + required: + - fingerprint + - private_key + type: object AuthNMapping: description: The AuthN Mapping object returned by API. properties: @@ -9627,6 +9651,107 @@ components: type: $ref: '#/components/schemas/RuleType' type: object + CreateTenancyConfig: + description: The definition of `CreateTenancyConfig` object. + example: + data: + attributes: + auth_credentials: + fingerprint: a7:b5:54:f2:da:a2:d7:b0:ed:f4:79:47:93:64:12:b1 + private_key: '-----BEGIN PRIVATE KEY----- + + o9kEwoumo8yHVn5Ztp4F2cxaD6+MzSJ/I6WesPyePUD7sPeorXByg1UNOXyzqDub + + /aU4/sNo2f8epM9l7QGiCtY= + + -----END PRIVATE KEY-----' + config_version: 2 + home_region: us-ashburn-1 + logs_config: + compartment_tag_filters: + - datadog:true + - env:prod + enabled: true + enabled_services: + - oacnativeproduction + metrics_config: + compartment_tag_filters: + - datadog:true + - env:prod + enabled: true + excluded_services: + - oci_compute + resource_collection_enabled: true + user_ocid: ocid1.user.test + id: ocid1.tenancy.dummy_value + type: oci_tenancy + properties: + data: + $ref: '#/components/schemas/CreateTenancyConfigData' + type: object + CreateTenancyConfigData: + description: The definition of `CreateTenancyConfigData` object. + properties: + attributes: + $ref: '#/components/schemas/CreateTenancyConfigDataAttributes' + id: + description: The OCID of the tenancy to be integrated. + example: ocid1.tenancy.test + type: string + type: + $ref: '#/components/schemas/CreateTenancyConfigDataType' + required: + - type + - id + type: object + CreateTenancyConfigDataAttributes: + description: The definition of `CreateTenancyConfigDataAttributes` object. + properties: + auth_credentials: + $ref: '#/components/schemas/AuthCredentials' + config_version: + description: The config version. It is not recommended to add or change + this value, as it is determined internally. + format: int64 + type: integer + dd_compartment_id: + description: The OCID of the compartment containing Datadog managed resources. + type: string + dd_stack_id: + description: The OCID of the resource manager stack for creating Datadog + managed resources. + type: string + home_region: + description: The home region of the tenancy to be integrated. + example: us-ashburn-1 + type: string + logs_config: + $ref: '#/components/schemas/OCILogsConfig' + metrics_config: + $ref: '#/components/schemas/OCIMetricsConfig' + regions_config: + $ref: '#/components/schemas/RegionsConfig' + resource_collection_enabled: + description: Enable or disable resource collection. + type: boolean + user_ocid: + description: The OCID of the user needed to authenticate and collect data. + example: ocid1.user.test + type: string + required: + - auth_credentials + - home_region + - user_ocid + type: object + CreateTenancyConfigDataType: + default: oci_tenancy + description: OCI tenancy resource type. + enum: + - oci_tenancy + example: oci_tenancy + type: string + x-enum-varnames: + - OCI_TENANCY CreateWorkflowRequest: description: A request object for creating a new workflow. example: @@ -23246,6 +23371,43 @@ components: - id - type type: object + OCILogsConfig: + description: The definition of `OCILogsConfig` object. + properties: + compartment_tag_filters: + description: The compartment tag filters to apply to log collection. Each + value represents a Datadog tag in the format key:value. + items: + type: string + type: array + enabled: + description: Enable or disable log collection. Disabled by default. + type: boolean + enabled_services: + description: The list of services to enable for log collection. + items: + type: string + type: array + type: object + OCIMetricsConfig: + description: The definition of `OCIMetricsConfig` object. + properties: + compartment_tag_filters: + description: The compartment tag filters to apply to metric collection. + Each value represents a Datadog tag in the format key:value. + items: + type: string + type: array + enabled: + description: Enable or disable metric collection. Enabled by default for + all services. + type: boolean + excluded_services: + description: The list of services to exclude from metric collection. + items: + type: string + type: array + type: object ObservabilityPipeline: description: Top-level schema representing a pipeline. properties: @@ -28773,6 +28935,25 @@ components: x-enum-varnames: - ANY - ALL + RegionsConfig: + description: The definition of `RegionsConfig` object. + properties: + available: + description: The list of regions currently subscribed to . + items: + type: string + type: array + disabled: + description: The list of disabled regions. + items: + type: string + type: array + enabled: + description: The list of enabled regions. + items: + type: string + type: array + type: object RelationType: description: Supported relation types. enum: @@ -38229,6 +38410,124 @@ components: description: Offset type. type: string type: object + TenancyConfig: + description: The definition of `TenancyConfig` object. + example: + data: + attributes: + cost_collection_enabled: false + home_region: us-ashburn-1 + logs_config: + compartment_tag_filters: + - compartment.test + enabled: true + enabled_services: + - compute + metrics_config: + compartment_tag_filters: + - compartment.test + enabled: true + excluded_services: + - compute + resource_collection_enabled: true + user_ocid: ocid1.user.test + id: ocid1.tenancy.test + type: oci_tenancy + properties: + data: + $ref: '#/components/schemas/TenancyConfigData' + type: object + TenancyConfigData: + description: The definition of `TenancyConfigData` object. + properties: + attributes: + $ref: '#/components/schemas/TenancyConfigDataAttributes' + id: + description: The OCID of the tenancy config. + type: string + type: + $ref: '#/components/schemas/TenancyConfigDataType' + required: + - type + type: object + TenancyConfigDataAttributes: + description: The definition of `TenancyConfigDataAttributes` object. + properties: + config_version: + description: The config version. It is not recommended to add or change + this value, as it is determined internally. + format: int64 + type: integer + cost_collection_enabled: + description: Enable or disable cost collection. + type: boolean + dd_compartment_id: + description: The OCID of the compartment containing Datadog managed resources. + type: string + dd_stack_id: + description: The OCID of the resource manager stack for creating Datadog + managed resources. + type: string + home_region: + description: The home region of the tenancy to be integrated. + type: string + logs_config: + $ref: '#/components/schemas/OCILogsConfig' + metrics_config: + $ref: '#/components/schemas/OCIMetricsConfig' + regions_config: + $ref: '#/components/schemas/RegionsConfig' + resource_collection_enabled: + description: Enable or disable resource collection. + type: boolean + tenancy_name: + description: The attribute's tenancy_name. + type: string + user_ocid: + description: The OCID of the user needed to authenticate and collect data. + type: string + type: object + TenancyConfigDataType: + default: oci_tenancy + description: OCI tenancy resource type. + enum: + - oci_tenancy + example: oci_tenancy + type: string + x-enum-varnames: + - OCI_TENANCY + TenancyConfigList: + description: The definition of `TenancyConfigList` object. + example: + data: + - attributes: + config_version: 2 + home_region: us-ashburn-1 + logs_config: + compartment_tag_filters: + - compartment.test + enabled: true + enabled_services: + - compute + metrics_config: + compartment_tag_filters: + - compartment.test + enabled: true + excluded_services: + - compute + resource_collection_enabled: true + user_ocid: ocid1.user.test + id: ocid1.tenancy.test + type: oci_tenancy + properties: + data: + description: The `TenancyConfigList` data. + items: + $ref: '#/components/schemas/TenancyConfigData' + type: array + required: + - data + type: object TimeAggregation: description: 'Time aggregation period (in seconds) is used to aggregate the results of the notification rule evaluation. @@ -38851,6 +39150,79 @@ components: type: $ref: '#/components/schemas/RuleType' type: object + UpdateTenancyConfig: + description: The definition of `UpdateTenancyConfig` object. + example: + data: + attributes: + home_region: us-ashburn-1 + logs_config: + compartment_tag_filters: + - datadog:true + - env:prod + enabled: true + enabled_services: + - objectstorage + metrics_config: + compartment_tag_filters: + - datadog:true + - env:prod + enabled: true + excluded_services: + - oci_compute + resource_collection_enabled: true + user_ocid: ocid1.user.test + id: ocid1.tenancy.dummy_value + type: oci_tenancy + properties: + data: + $ref: '#/components/schemas/UpdateTenancyConfigData' + type: object + UpdateTenancyConfigData: + description: The definition of `UpdateTenancyConfigData` object. + properties: + attributes: + $ref: '#/components/schemas/UpdateTenancyConfigDataAttributes' + id: + description: The OCID of the tenancy to be integrated. + example: ocid1.tenancy.test + type: string + type: + $ref: '#/components/schemas/UpdateTenancyConfigDataType' + required: + - type + - id + type: object + UpdateTenancyConfigDataAttributes: + description: The definition of `UpdateTenancyConfigDataAttributes` object. + properties: + auth_credentials: + $ref: '#/components/schemas/AuthCredentials' + home_region: + description: The home region of the tenancy to be integrated. + type: string + logs_config: + $ref: '#/components/schemas/OCILogsConfig' + metrics_config: + $ref: '#/components/schemas/OCIMetricsConfig' + regions_config: + $ref: '#/components/schemas/RegionsConfig' + resource_collection_enabled: + description: Enable or disable resource collection. + type: boolean + user_ocid: + description: The OCID of the user needed to authenticate and collect data. + type: string + type: object + UpdateTenancyConfigDataType: + default: oci_tenancy + description: OCI tenancy resource type. + enum: + - oci_tenancy + example: oci_tenancy + type: string + x-enum-varnames: + - OCI_TENANCY UpdateWorkflowRequest: description: A request object for updating an existing workflow. example: @@ -47664,6 +48036,139 @@ paths: tags: - Microsoft Teams Integration x-codegen-request-body-name: body + /api/v2/integration/oci/tenancies: + get: + description: List all tenancy integrations. + operationId: GetTenancyConfigs + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/TenancyConfigList' + description: OK + '403': + $ref: '#/components/responses/ForbiddenResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: Get tenancy configs + tags: + - OCI Integration + x-permission: + operator: AND + permissions: + - oci_configuration_read + post: + description: Create a new tenancy config. + operationId: CreateTenancyConfig + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/CreateTenancyConfig' + required: true + responses: + '201': + content: + application/json: + schema: + $ref: '#/components/schemas/TenancyConfig' + description: Created + '400': + $ref: '#/components/responses/BadRequestResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '409': + $ref: '#/components/responses/ConflictResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: Create tenancy config + tags: + - OCI Integration + x-permission: + operator: AND + permissions: + - oci_configurations_manage + /api/v2/integration/oci/tenancies/{tenancy_ocid}: + delete: + description: Delete an existing tenancy config. + operationId: DeleteTenancyConfig + parameters: + - $ref: '#/components/parameters/TenancyOCIDPathParameter' + responses: + '204': + description: No Content + '403': + $ref: '#/components/responses/ForbiddenResponse' + '404': + $ref: '#/components/responses/NotFoundResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: Delete tenancy config + tags: + - OCI Integration + x-permission: + operator: AND + permissions: + - oci_configurations_manage + get: + description: Get a single tenancy config object. + operationId: GetTenancyConfig + parameters: + - $ref: '#/components/parameters/TenancyOCIDPathParameter' + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/TenancyConfig' + description: OK + '403': + $ref: '#/components/responses/ForbiddenResponse' + '404': + $ref: '#/components/responses/NotFoundResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: Get tenancy config + tags: + - OCI Integration + x-permission: + operator: AND + permissions: + - oci_configuration_read + patch: + description: Update an existing tenancy config. + operationId: UpdateTenancyConfig + parameters: + - $ref: '#/components/parameters/TenancyOCIDPathParameter' + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/UpdateTenancyConfig' + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/TenancyConfig' + description: OK + '400': + $ref: '#/components/responses/BadRequestResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '404': + $ref: '#/components/responses/NotFoundResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: Update tenancy config + tags: + - OCI Integration + x-permission: + operator: AND + permissions: + - oci_configuration_edit /api/v2/integration/opsgenie/services: get: description: Get a list of all services from the Datadog Opsgenie integration. @@ -62035,6 +62540,11 @@ tags: and their attributes. See the [Network Device Monitoring page](https://docs.datadoghq.com/network_monitoring/) for more information. name: Network Device Monitoring +- description: 'Configure your Datadog-OCI integration directly through the Datadog + API. + + For more information, see the [OCI integration page](https://docs.datadoghq.com/integrations/oracle_cloud_infrastructure/).' + name: OCI Integration - description: Observability Pipelines allows you to collect and process logs within your own infrastructure, and then route them to downstream integrations. externalDocs: diff --git a/examples/v2_oci-integration_CreateTenancyConfig.rs b/examples/v2_oci-integration_CreateTenancyConfig.rs new file mode 100644 index 000000000..eeee4956e --- /dev/null +++ b/examples/v2_oci-integration_CreateTenancyConfig.rs @@ -0,0 +1,62 @@ +// Create tenancy config returns "Created" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_oci_integration::OCIIntegrationAPI; +use datadog_api_client::datadogV2::model::AuthCredentials; +use datadog_api_client::datadogV2::model::CreateTenancyConfig; +use datadog_api_client::datadogV2::model::CreateTenancyConfigData; +use datadog_api_client::datadogV2::model::CreateTenancyConfigDataAttributes; +use datadog_api_client::datadogV2::model::CreateTenancyConfigDataType; +use datadog_api_client::datadogV2::model::OCILogsConfig; +use datadog_api_client::datadogV2::model::OCIMetricsConfig; + +#[tokio::main] +async fn main() { + let body = CreateTenancyConfig::new().data( + CreateTenancyConfigData::new( + "ocid1.tenancy.dummy_value".to_string(), + CreateTenancyConfigDataType::OCI_TENANCY, + ) + .attributes( + CreateTenancyConfigDataAttributes::new( + AuthCredentials::new( + "a7:b5:54:f2:da:a2:d7:b0:ed:f4:79:47:93:64:12:b1".to_string(), + r#"-----BEGIN PRIVATE KEY----- +o9kEwoumo8yHVn5Ztp4F2cxaD6+MzSJ/I6WesPyePUD7sPeorXByg1UNOXyzqDub +/aU4/sNo2f8epM9l7QGiCtY= +-----END PRIVATE KEY-----"# + .to_string(), + ), + "us-ashburn-1".to_string(), + "ocid1.user.test".to_string(), + ) + .config_version(2) + .logs_config( + OCILogsConfig::new() + .compartment_tag_filters(vec![ + "datadog:true".to_string(), + "env:prod".to_string(), + ]) + .enabled(true) + .enabled_services(vec!["oacnativeproduction".to_string()]), + ) + .metrics_config( + OCIMetricsConfig::new() + .compartment_tag_filters(vec![ + "datadog:true".to_string(), + "env:prod".to_string(), + ]) + .enabled(true) + .excluded_services(vec!["oci_compute".to_string()]), + ) + .resource_collection_enabled(true), + ), + ); + let configuration = datadog::Configuration::new(); + let api = OCIIntegrationAPI::with_config(configuration); + let resp = api.create_tenancy_config(body).await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_oci-integration_DeleteTenancyConfig.rs b/examples/v2_oci-integration_DeleteTenancyConfig.rs new file mode 100644 index 000000000..b5dfa7b53 --- /dev/null +++ b/examples/v2_oci-integration_DeleteTenancyConfig.rs @@ -0,0 +1,17 @@ +// Delete tenancy config returns "No Content" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_oci_integration::OCIIntegrationAPI; + +#[tokio::main] +async fn main() { + // there is a valid "oci_tenancy" resource in the system + let oci_tenancy_data_id = std::env::var("OCI_TENANCY_DATA_ID").unwrap(); + let configuration = datadog::Configuration::new(); + let api = OCIIntegrationAPI::with_config(configuration); + let resp = api.delete_tenancy_config(oci_tenancy_data_id.clone()).await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_oci-integration_DeleteTenancyConfig_1134763094.rs b/examples/v2_oci-integration_DeleteTenancyConfig_1134763094.rs new file mode 100644 index 000000000..51a98c0f7 --- /dev/null +++ b/examples/v2_oci-integration_DeleteTenancyConfig_1134763094.rs @@ -0,0 +1,17 @@ +// Delete tenancy config for non-existing tenancy returns "No Content" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_oci_integration::OCIIntegrationAPI; + +#[tokio::main] +async fn main() { + let configuration = datadog::Configuration::new(); + let api = OCIIntegrationAPI::with_config(configuration); + let resp = api + .delete_tenancy_config("ocid1.tenancy.fake".to_string()) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_oci-integration_GetTenancyConfig.rs b/examples/v2_oci-integration_GetTenancyConfig.rs new file mode 100644 index 000000000..c44e4fd53 --- /dev/null +++ b/examples/v2_oci-integration_GetTenancyConfig.rs @@ -0,0 +1,17 @@ +// Get tenancy config returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_oci_integration::OCIIntegrationAPI; + +#[tokio::main] +async fn main() { + // there is a valid "oci_tenancy" resource in the system + let oci_tenancy_data_id = std::env::var("OCI_TENANCY_DATA_ID").unwrap(); + let configuration = datadog::Configuration::new(); + let api = OCIIntegrationAPI::with_config(configuration); + let resp = api.get_tenancy_config(oci_tenancy_data_id.clone()).await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_oci-integration_GetTenancyConfigs.rs b/examples/v2_oci-integration_GetTenancyConfigs.rs new file mode 100644 index 000000000..5a1e3716a --- /dev/null +++ b/examples/v2_oci-integration_GetTenancyConfigs.rs @@ -0,0 +1,15 @@ +// Get tenancy configs returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_oci_integration::OCIIntegrationAPI; + +#[tokio::main] +async fn main() { + let configuration = datadog::Configuration::new(); + let api = OCIIntegrationAPI::with_config(configuration); + let resp = api.get_tenancy_configs().await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_oci-integration_UpdateTenancyConfig.rs b/examples/v2_oci-integration_UpdateTenancyConfig.rs new file mode 100644 index 000000000..cd01ae0d0 --- /dev/null +++ b/examples/v2_oci-integration_UpdateTenancyConfig.rs @@ -0,0 +1,45 @@ +// Update tenancy config returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_oci_integration::OCIIntegrationAPI; +use datadog_api_client::datadogV2::model::OCIMetricsConfig; +use datadog_api_client::datadogV2::model::UpdateTenancyConfig; +use datadog_api_client::datadogV2::model::UpdateTenancyConfigData; +use datadog_api_client::datadogV2::model::UpdateTenancyConfigDataAttributes; +use datadog_api_client::datadogV2::model::UpdateTenancyConfigDataType; + +#[tokio::main] +async fn main() { + // there is a valid "oci_tenancy" resource in the system + let oci_tenancy_data_id = std::env::var("OCI_TENANCY_DATA_ID").unwrap(); + let body = UpdateTenancyConfig::new().data( + UpdateTenancyConfigData::new( + oci_tenancy_data_id.clone(), + UpdateTenancyConfigDataType::OCI_TENANCY, + ) + .attributes( + UpdateTenancyConfigDataAttributes::new() + .home_region("us-sanjose-1".to_string()) + .metrics_config( + OCIMetricsConfig::new() + .compartment_tag_filters(vec![ + "datadog:true".to_string(), + "env:prod".to_string(), + ]) + .enabled(false) + .excluded_services(vec![]), + ) + .resource_collection_enabled(false) + .user_ocid("ocid1.user.test_updated".to_string()), + ), + ); + let configuration = datadog::Configuration::new(); + let api = OCIIntegrationAPI::with_config(configuration); + let resp = api + .update_tenancy_config(oci_tenancy_data_id.clone(), body) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/src/datadogV2/api/api_oci_integration.rs b/src/datadogV2/api/api_oci_integration.rs new file mode 100644 index 000000000..b74ba873a --- /dev/null +++ b/src/datadogV2/api/api_oci_integration.rs @@ -0,0 +1,722 @@ +// 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; + +/// CreateTenancyConfigError is a struct for typed errors of method [`OCIIntegrationAPI::create_tenancy_config`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CreateTenancyConfigError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// DeleteTenancyConfigError is a struct for typed errors of method [`OCIIntegrationAPI::delete_tenancy_config`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum DeleteTenancyConfigError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// GetTenancyConfigError is a struct for typed errors of method [`OCIIntegrationAPI::get_tenancy_config`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetTenancyConfigError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// GetTenancyConfigsError is a struct for typed errors of method [`OCIIntegrationAPI::get_tenancy_configs`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetTenancyConfigsError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// UpdateTenancyConfigError is a struct for typed errors of method [`OCIIntegrationAPI::update_tenancy_config`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum UpdateTenancyConfigError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// Configure your Datadog-OCI integration directly through the Datadog API. +/// For more information, see the [OCI integration page](). +#[derive(Debug, Clone)] +pub struct OCIIntegrationAPI { + config: datadog::Configuration, + client: reqwest_middleware::ClientWithMiddleware, +} + +impl Default for OCIIntegrationAPI { + fn default() -> Self { + Self::with_config(datadog::Configuration::default()) + } +} + +impl OCIIntegrationAPI { + 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 } + } + + /// Create a new tenancy config. + pub async fn create_tenancy_config( + &self, + body: crate::datadogV2::model::CreateTenancyConfig, + ) -> Result> + { + match self.create_tenancy_config_with_http_info(body).await { + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(datadog::Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } + Err(err) => Err(err), + } + } + + /// Create a new tenancy config. + pub async fn create_tenancy_config_with_http_info( + &self, + body: crate::datadogV2::model::CreateTenancyConfig, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.create_tenancy_config"; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/integration/oci/tenancies", + local_configuration.get_operation_host(operation_id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::POST, local_uri_str.as_str()); + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Content-Type", HeaderValue::from_static("application/json")); + headers.insert("Accept", HeaderValue::from_static("application/json")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + // build body parameters + let output = Vec::new(); + let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter); + if body.serialize(&mut ser).is_ok() { + if let Some(content_encoding) = headers.get("Content-Encoding") { + match content_encoding.to_str().unwrap_or_default() { + "gzip" => { + let mut enc = GzEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + "deflate" => { + let mut enc = ZlibEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + "zstd1" => { + let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap(); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + _ => { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + } else { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + match serde_json::from_str::(&local_content) { + Ok(e) => { + return Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: Some(e), + }) + } + Err(e) => return Err(datadog::Error::Serde(e)), + }; + } else { + let local_entity: Option = + serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } + + /// Delete an existing tenancy config. + pub async fn delete_tenancy_config( + &self, + tenancy_ocid: String, + ) -> Result<(), datadog::Error> { + match self + .delete_tenancy_config_with_http_info(tenancy_ocid) + .await + { + Ok(_) => Ok(()), + Err(err) => Err(err), + } + } + + /// Delete an existing tenancy config. + pub async fn delete_tenancy_config_with_http_info( + &self, + tenancy_ocid: String, + ) -> Result, datadog::Error> { + let local_configuration = &self.config; + let operation_id = "v2.delete_tenancy_config"; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/integration/oci/tenancies/{tenancy_ocid}", + local_configuration.get_operation_host(operation_id), + tenancy_ocid = datadog::urlencode(tenancy_ocid) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::DELETE, local_uri_str.as_str()); + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Accept", HeaderValue::from_static("*/*")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: None, + }) + } else { + let local_entity: Option = + serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } + + /// Get a single tenancy config object. + pub async fn get_tenancy_config( + &self, + tenancy_ocid: String, + ) -> Result> { + match self.get_tenancy_config_with_http_info(tenancy_ocid).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 single tenancy config object. + pub async fn get_tenancy_config_with_http_info( + &self, + tenancy_ocid: String, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.get_tenancy_config"; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/integration/oci/tenancies/{tenancy_ocid}", + local_configuration.get_operation_host(operation_id), + tenancy_ocid = datadog::urlencode(tenancy_ocid) + ); + 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 tenancy integrations. + pub async fn get_tenancy_configs( + &self, + ) -> Result> + { + match self.get_tenancy_configs_with_http_info().await { + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(datadog::Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } + Err(err) => Err(err), + } + } + + /// List all tenancy integrations. + pub async fn get_tenancy_configs_with_http_info( + &self, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.get_tenancy_configs"; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/integration/oci/tenancies", + local_configuration.get_operation_host(operation_id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::GET, local_uri_str.as_str()); + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Accept", HeaderValue::from_static("application/json")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + match serde_json::from_str::(&local_content) + { + Ok(e) => { + return Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: Some(e), + }) + } + Err(e) => return Err(datadog::Error::Serde(e)), + }; + } else { + let local_entity: Option = + serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } + + /// Update an existing tenancy config. + pub async fn update_tenancy_config( + &self, + tenancy_ocid: String, + body: crate::datadogV2::model::UpdateTenancyConfig, + ) -> Result> + { + match self + .update_tenancy_config_with_http_info(tenancy_ocid, 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), + } + } + + /// Update an existing tenancy config. + pub async fn update_tenancy_config_with_http_info( + &self, + tenancy_ocid: String, + body: crate::datadogV2::model::UpdateTenancyConfig, + ) -> Result< + datadog::ResponseContent, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.update_tenancy_config"; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/integration/oci/tenancies/{tenancy_ocid}", + local_configuration.get_operation_host(operation_id), + tenancy_ocid = datadog::urlencode(tenancy_ocid) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::PATCH, local_uri_str.as_str()); + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Content-Type", HeaderValue::from_static("application/json")); + headers.insert("Accept", HeaderValue::from_static("application/json")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + // build body parameters + let output = Vec::new(); + let mut ser = serde_json::Serializer::with_formatter(output, datadog::DDFormatter); + if body.serialize(&mut ser).is_ok() { + if let Some(content_encoding) = headers.get("Content-Encoding") { + match content_encoding.to_str().unwrap_or_default() { + "gzip" => { + let mut enc = GzEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + "deflate" => { + let mut enc = ZlibEncoder::new(Vec::new(), Compression::default()); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + "zstd1" => { + let mut enc = zstd::stream::Encoder::new(Vec::new(), 0).unwrap(); + let _ = enc.write_all(ser.into_inner().as_slice()); + match enc.finish() { + Ok(buf) => { + local_req_builder = local_req_builder.body(buf); + } + Err(e) => return Err(datadog::Error::Io(e)), + } + } + _ => { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + } else { + local_req_builder = local_req_builder.body(ser.into_inner()); + } + } + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + match serde_json::from_str::(&local_content) { + Ok(e) => { + return Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: Some(e), + }) + } + Err(e) => return Err(datadog::Error::Serde(e)), + }; + } else { + let local_entity: Option = + serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } +} diff --git a/src/datadogV2/api/mod.rs b/src/datadogV2/api/mod.rs index 0be634c4c..6407be4ae 100644 --- a/src/datadogV2/api/mod.rs +++ b/src/datadogV2/api/mod.rs @@ -46,6 +46,7 @@ pub mod api_microsoft_teams_integration; pub mod api_monitors; pub mod api_network_device_monitoring; pub mod api_observability_pipelines; +pub mod api_oci_integration; pub mod api_okta_integration; pub mod api_on_call; pub mod api_on_call_paging; diff --git a/src/datadogV2/mod.rs b/src/datadogV2/mod.rs index 326381dbf..6b48111dc 100644 --- a/src/datadogV2/mod.rs +++ b/src/datadogV2/mod.rs @@ -47,6 +47,7 @@ pub use self::api::api_microsoft_teams_integration; pub use self::api::api_monitors; pub use self::api::api_network_device_monitoring; pub use self::api::api_observability_pipelines; +pub use self::api::api_oci_integration; pub use self::api::api_okta_integration; pub use self::api::api_on_call; pub use self::api::api_on_call_paging; diff --git a/src/datadogV2/model/mod.rs b/src/datadogV2/model/mod.rs index 6413b3c09..5ee769406 100644 --- a/src/datadogV2/model/mod.rs +++ b/src/datadogV2/model/mod.rs @@ -1898,6 +1898,40 @@ pub mod model_microsoft_teams_update_workflows_webhook_handle_request_data; pub use self::model_microsoft_teams_update_workflows_webhook_handle_request_data::MicrosoftTeamsUpdateWorkflowsWebhookHandleRequestData; pub mod model_microsoft_teams_workflows_webhook_handle_attributes; pub use self::model_microsoft_teams_workflows_webhook_handle_attributes::MicrosoftTeamsWorkflowsWebhookHandleAttributes; +pub mod model_tenancy_config_list; +pub use self::model_tenancy_config_list::TenancyConfigList; +pub mod model_tenancy_config_data; +pub use self::model_tenancy_config_data::TenancyConfigData; +pub mod model_tenancy_config_data_attributes; +pub use self::model_tenancy_config_data_attributes::TenancyConfigDataAttributes; +pub mod model_oci_logs_config; +pub use self::model_oci_logs_config::OCILogsConfig; +pub mod model_oci_metrics_config; +pub use self::model_oci_metrics_config::OCIMetricsConfig; +pub mod model_regions_config; +pub use self::model_regions_config::RegionsConfig; +pub mod model_tenancy_config_data_type; +pub use self::model_tenancy_config_data_type::TenancyConfigDataType; +pub mod model_create_tenancy_config; +pub use self::model_create_tenancy_config::CreateTenancyConfig; +pub mod model_create_tenancy_config_data; +pub use self::model_create_tenancy_config_data::CreateTenancyConfigData; +pub mod model_create_tenancy_config_data_attributes; +pub use self::model_create_tenancy_config_data_attributes::CreateTenancyConfigDataAttributes; +pub mod model_auth_credentials; +pub use self::model_auth_credentials::AuthCredentials; +pub mod model_create_tenancy_config_data_type; +pub use self::model_create_tenancy_config_data_type::CreateTenancyConfigDataType; +pub mod model_tenancy_config; +pub use self::model_tenancy_config::TenancyConfig; +pub mod model_update_tenancy_config; +pub use self::model_update_tenancy_config::UpdateTenancyConfig; +pub mod model_update_tenancy_config_data; +pub use self::model_update_tenancy_config_data::UpdateTenancyConfigData; +pub mod model_update_tenancy_config_data_attributes; +pub use self::model_update_tenancy_config_data_attributes::UpdateTenancyConfigDataAttributes; +pub mod model_update_tenancy_config_data_type; +pub use self::model_update_tenancy_config_data_type::UpdateTenancyConfigDataType; pub mod model_opsgenie_services_response; pub use self::model_opsgenie_services_response::OpsgenieServicesResponse; pub mod model_opsgenie_service_response_data; diff --git a/src/datadogV2/model/model_auth_credentials.rs b/src/datadogV2/model/model_auth_credentials.rs new file mode 100644 index 000000000..55028aa5a --- /dev/null +++ b/src/datadogV2/model/model_auth_credentials.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}; + +/// The auth credentials of the user. Consists of a public key fingerprint and private key. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct AuthCredentials { + /// The public key fingerprint. + #[serde(rename = "fingerprint")] + pub fingerprint: String, + /// The `RSA` private key in `PEM` format. + #[serde(rename = "private_key")] + pub private_key: String, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl AuthCredentials { + pub fn new(fingerprint: String, private_key: String) -> AuthCredentials { + AuthCredentials { + fingerprint, + private_key, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for AuthCredentials { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct AuthCredentialsVisitor; + impl<'a> Visitor<'a> for AuthCredentialsVisitor { + type Value = AuthCredentials; + + 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 fingerprint: Option = None; + let mut private_key: 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() { + "fingerprint" => { + fingerprint = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "private_key" => { + private_key = + 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 fingerprint = + fingerprint.ok_or_else(|| M::Error::missing_field("fingerprint"))?; + let private_key = + private_key.ok_or_else(|| M::Error::missing_field("private_key"))?; + + let content = AuthCredentials { + fingerprint, + private_key, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(AuthCredentialsVisitor) + } +} diff --git a/src/datadogV2/model/model_create_tenancy_config.rs b/src/datadogV2/model/model_create_tenancy_config.rs new file mode 100644 index 000000000..6aaaab56b --- /dev/null +++ b/src/datadogV2/model/model_create_tenancy_config.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 definition of `CreateTenancyConfig` object. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct CreateTenancyConfig { + /// The definition of `CreateTenancyConfigData` object. + #[serde(rename = "data")] + pub data: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl CreateTenancyConfig { + pub fn new() -> CreateTenancyConfig { + CreateTenancyConfig { + data: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn data(mut self, value: crate::datadogV2::model::CreateTenancyConfigData) -> 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 CreateTenancyConfig { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for CreateTenancyConfig { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct CreateTenancyConfigVisitor; + impl<'a> Visitor<'a> for CreateTenancyConfigVisitor { + type Value = CreateTenancyConfig; + + 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 = CreateTenancyConfig { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(CreateTenancyConfigVisitor) + } +} diff --git a/src/datadogV2/model/model_create_tenancy_config_data.rs b/src/datadogV2/model/model_create_tenancy_config_data.rs new file mode 100644 index 000000000..2570f6022 --- /dev/null +++ b/src/datadogV2/model/model_create_tenancy_config_data.rs @@ -0,0 +1,135 @@ +// 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 definition of `CreateTenancyConfigData` object. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct CreateTenancyConfigData { + /// The definition of `CreateTenancyConfigDataAttributes` object. + #[serde(rename = "attributes")] + pub attributes: Option, + /// The OCID of the tenancy to be integrated. + #[serde(rename = "id")] + pub id: String, + /// OCI tenancy resource type. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::CreateTenancyConfigDataType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl CreateTenancyConfigData { + pub fn new( + id: String, + type_: crate::datadogV2::model::CreateTenancyConfigDataType, + ) -> CreateTenancyConfigData { + CreateTenancyConfigData { + attributes: None, + id, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn attributes( + mut self, + value: crate::datadogV2::model::CreateTenancyConfigDataAttributes, + ) -> Self { + self.attributes = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for CreateTenancyConfigData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct CreateTenancyConfigDataVisitor; + impl<'a> Visitor<'a> for CreateTenancyConfigDataVisitor { + type Value = CreateTenancyConfigData; + + 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::CreateTenancyConfigDataAttributes, + > = None; + let mut id: Option = None; + let mut type_: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "attributes" => { + if v.is_null() { + continue; + } + attributes = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "id" => { + id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::CreateTenancyConfigDataType::UnparsedObject(_type_) => { + _unparsed = true; + }, + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let id = id.ok_or_else(|| M::Error::missing_field("id"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = CreateTenancyConfigData { + attributes, + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(CreateTenancyConfigDataVisitor) + } +} diff --git a/src/datadogV2/model/model_create_tenancy_config_data_attributes.rs b/src/datadogV2/model/model_create_tenancy_config_data_attributes.rs new file mode 100644 index 000000000..d857e9d82 --- /dev/null +++ b/src/datadogV2/model/model_create_tenancy_config_data_attributes.rs @@ -0,0 +1,246 @@ +// 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 definition of `CreateTenancyConfigDataAttributes` object. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct CreateTenancyConfigDataAttributes { + /// The auth credentials of the user. Consists of a public key fingerprint and private key. + #[serde(rename = "auth_credentials")] + pub auth_credentials: crate::datadogV2::model::AuthCredentials, + /// The config version. It is not recommended to add or change this value, as it is determined internally. + #[serde(rename = "config_version")] + pub config_version: Option, + /// The OCID of the compartment containing Datadog managed resources. + #[serde(rename = "dd_compartment_id")] + pub dd_compartment_id: Option, + /// The OCID of the resource manager stack for creating Datadog managed resources. + #[serde(rename = "dd_stack_id")] + pub dd_stack_id: Option, + /// The home region of the tenancy to be integrated. + #[serde(rename = "home_region")] + pub home_region: String, + /// The definition of `OCILogsConfig` object. + #[serde(rename = "logs_config")] + pub logs_config: Option, + /// The definition of `OCIMetricsConfig` object. + #[serde(rename = "metrics_config")] + pub metrics_config: Option, + /// The definition of `RegionsConfig` object. + #[serde(rename = "regions_config")] + pub regions_config: Option, + /// Enable or disable resource collection. + #[serde(rename = "resource_collection_enabled")] + pub resource_collection_enabled: Option, + /// The OCID of the user needed to authenticate and collect data. + #[serde(rename = "user_ocid")] + pub user_ocid: String, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl CreateTenancyConfigDataAttributes { + pub fn new( + auth_credentials: crate::datadogV2::model::AuthCredentials, + home_region: String, + user_ocid: String, + ) -> CreateTenancyConfigDataAttributes { + CreateTenancyConfigDataAttributes { + auth_credentials, + config_version: None, + dd_compartment_id: None, + dd_stack_id: None, + home_region, + logs_config: None, + metrics_config: None, + regions_config: None, + resource_collection_enabled: None, + user_ocid, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn config_version(mut self, value: i64) -> Self { + self.config_version = Some(value); + self + } + + pub fn dd_compartment_id(mut self, value: String) -> Self { + self.dd_compartment_id = Some(value); + self + } + + pub fn dd_stack_id(mut self, value: String) -> Self { + self.dd_stack_id = Some(value); + self + } + + pub fn logs_config(mut self, value: crate::datadogV2::model::OCILogsConfig) -> Self { + self.logs_config = Some(value); + self + } + + pub fn metrics_config(mut self, value: crate::datadogV2::model::OCIMetricsConfig) -> Self { + self.metrics_config = Some(value); + self + } + + pub fn regions_config(mut self, value: crate::datadogV2::model::RegionsConfig) -> Self { + self.regions_config = Some(value); + self + } + + pub fn resource_collection_enabled(mut self, value: bool) -> Self { + self.resource_collection_enabled = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for CreateTenancyConfigDataAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct CreateTenancyConfigDataAttributesVisitor; + impl<'a> Visitor<'a> for CreateTenancyConfigDataAttributesVisitor { + type Value = CreateTenancyConfigDataAttributes; + + 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 auth_credentials: Option = None; + let mut config_version: Option = None; + let mut dd_compartment_id: Option = None; + let mut dd_stack_id: Option = None; + let mut home_region: Option = None; + let mut logs_config: Option = None; + let mut metrics_config: Option = None; + let mut regions_config: Option = None; + let mut resource_collection_enabled: Option = None; + let mut user_ocid: 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() { + "auth_credentials" => { + auth_credentials = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "config_version" => { + if v.is_null() { + continue; + } + config_version = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "dd_compartment_id" => { + if v.is_null() { + continue; + } + dd_compartment_id = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "dd_stack_id" => { + if v.is_null() { + continue; + } + dd_stack_id = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "home_region" => { + home_region = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "logs_config" => { + if v.is_null() { + continue; + } + logs_config = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "metrics_config" => { + if v.is_null() { + continue; + } + metrics_config = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "regions_config" => { + if v.is_null() { + continue; + } + regions_config = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "resource_collection_enabled" => { + if v.is_null() { + continue; + } + resource_collection_enabled = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "user_ocid" => { + user_ocid = 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 auth_credentials = + auth_credentials.ok_or_else(|| M::Error::missing_field("auth_credentials"))?; + let home_region = + home_region.ok_or_else(|| M::Error::missing_field("home_region"))?; + let user_ocid = user_ocid.ok_or_else(|| M::Error::missing_field("user_ocid"))?; + + let content = CreateTenancyConfigDataAttributes { + auth_credentials, + config_version, + dd_compartment_id, + dd_stack_id, + home_region, + logs_config, + metrics_config, + regions_config, + resource_collection_enabled, + user_ocid, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(CreateTenancyConfigDataAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_create_tenancy_config_data_type.rs b/src/datadogV2/model/model_create_tenancy_config_data_type.rs new file mode 100644 index 000000000..6f90dcaa4 --- /dev/null +++ b/src/datadogV2/model/model_create_tenancy_config_data_type.rs @@ -0,0 +1,48 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +use serde::{Deserialize, Deserializer, Serialize, Serializer}; + +#[non_exhaustive] +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum CreateTenancyConfigDataType { + OCI_TENANCY, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for CreateTenancyConfigDataType { + fn to_string(&self) -> String { + match self { + Self::OCI_TENANCY => String::from("oci_tenancy"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for CreateTenancyConfigDataType { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match self { + Self::UnparsedObject(v) => v.serialize(serializer), + _ => serializer.serialize_str(self.to_string().as_str()), + } + } +} + +impl<'de> Deserialize<'de> for CreateTenancyConfigDataType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "oci_tenancy" => Self::OCI_TENANCY, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_oci_logs_config.rs b/src/datadogV2/model/model_oci_logs_config.rs new file mode 100644 index 000000000..d9bd59a11 --- /dev/null +++ b/src/datadogV2/model/model_oci_logs_config.rs @@ -0,0 +1,141 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The definition of `OCILogsConfig` object. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct OCILogsConfig { + /// The compartment tag filters to apply to log collection. Each value represents a Datadog tag in the format key:value. + #[serde(rename = "compartment_tag_filters")] + pub compartment_tag_filters: Option>, + /// Enable or disable log collection. Disabled by default. + #[serde(rename = "enabled")] + pub enabled: Option, + /// The list of services to enable for log collection. + #[serde(rename = "enabled_services")] + pub enabled_services: Option>, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl OCILogsConfig { + pub fn new() -> OCILogsConfig { + OCILogsConfig { + compartment_tag_filters: None, + enabled: None, + enabled_services: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn compartment_tag_filters(mut self, value: Vec) -> Self { + self.compartment_tag_filters = Some(value); + self + } + + pub fn enabled(mut self, value: bool) -> Self { + self.enabled = Some(value); + self + } + + pub fn enabled_services(mut self, value: Vec) -> Self { + self.enabled_services = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for OCILogsConfig { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for OCILogsConfig { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct OCILogsConfigVisitor; + impl<'a> Visitor<'a> for OCILogsConfigVisitor { + type Value = OCILogsConfig; + + 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 compartment_tag_filters: Option> = None; + let mut enabled: Option = None; + let mut enabled_services: 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() { + "compartment_tag_filters" => { + if v.is_null() { + continue; + } + compartment_tag_filters = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "enabled" => { + if v.is_null() { + continue; + } + enabled = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "enabled_services" => { + if v.is_null() { + continue; + } + enabled_services = + 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 = OCILogsConfig { + compartment_tag_filters, + enabled, + enabled_services, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(OCILogsConfigVisitor) + } +} diff --git a/src/datadogV2/model/model_oci_metrics_config.rs b/src/datadogV2/model/model_oci_metrics_config.rs new file mode 100644 index 000000000..9ec191941 --- /dev/null +++ b/src/datadogV2/model/model_oci_metrics_config.rs @@ -0,0 +1,141 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The definition of `OCIMetricsConfig` object. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct OCIMetricsConfig { + /// The compartment tag filters to apply to metric collection. Each value represents a Datadog tag in the format key:value. + #[serde(rename = "compartment_tag_filters")] + pub compartment_tag_filters: Option>, + /// Enable or disable metric collection. Enabled by default for all services. + #[serde(rename = "enabled")] + pub enabled: Option, + /// The list of services to exclude from metric collection. + #[serde(rename = "excluded_services")] + pub excluded_services: Option>, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl OCIMetricsConfig { + pub fn new() -> OCIMetricsConfig { + OCIMetricsConfig { + compartment_tag_filters: None, + enabled: None, + excluded_services: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn compartment_tag_filters(mut self, value: Vec) -> Self { + self.compartment_tag_filters = Some(value); + self + } + + pub fn enabled(mut self, value: bool) -> Self { + self.enabled = Some(value); + self + } + + pub fn excluded_services(mut self, value: Vec) -> Self { + self.excluded_services = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for OCIMetricsConfig { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for OCIMetricsConfig { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct OCIMetricsConfigVisitor; + impl<'a> Visitor<'a> for OCIMetricsConfigVisitor { + type Value = OCIMetricsConfig; + + 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 compartment_tag_filters: Option> = None; + let mut enabled: Option = None; + let mut excluded_services: 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() { + "compartment_tag_filters" => { + if v.is_null() { + continue; + } + compartment_tag_filters = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "enabled" => { + if v.is_null() { + continue; + } + enabled = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "excluded_services" => { + if v.is_null() { + continue; + } + excluded_services = + 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 = OCIMetricsConfig { + compartment_tag_filters, + enabled, + excluded_services, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(OCIMetricsConfigVisitor) + } +} diff --git a/src/datadogV2/model/model_regions_config.rs b/src/datadogV2/model/model_regions_config.rs new file mode 100644 index 000000000..d7b6f4e4b --- /dev/null +++ b/src/datadogV2/model/model_regions_config.rs @@ -0,0 +1,139 @@ +// 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 definition of `RegionsConfig` object. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct RegionsConfig { + /// The list of regions currently subscribed to . + #[serde(rename = "available")] + pub available: Option>, + /// The list of disabled regions. + #[serde(rename = "disabled")] + pub disabled: Option>, + /// The list of enabled regions. + #[serde(rename = "enabled")] + pub enabled: Option>, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl RegionsConfig { + pub fn new() -> RegionsConfig { + RegionsConfig { + available: None, + disabled: None, + enabled: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn available(mut self, value: Vec) -> Self { + self.available = Some(value); + self + } + + pub fn disabled(mut self, value: Vec) -> Self { + self.disabled = Some(value); + self + } + + pub fn enabled(mut self, value: Vec) -> Self { + self.enabled = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for RegionsConfig { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for RegionsConfig { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct RegionsConfigVisitor; + impl<'a> Visitor<'a> for RegionsConfigVisitor { + type Value = RegionsConfig; + + 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 available: Option> = None; + let mut disabled: Option> = None; + let mut enabled: 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() { + "available" => { + if v.is_null() { + continue; + } + available = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "disabled" => { + if v.is_null() { + continue; + } + disabled = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "enabled" => { + if v.is_null() { + continue; + } + enabled = 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 = RegionsConfig { + available, + disabled, + enabled, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(RegionsConfigVisitor) + } +} diff --git a/src/datadogV2/model/model_tenancy_config.rs b/src/datadogV2/model/model_tenancy_config.rs new file mode 100644 index 000000000..f8b774496 --- /dev/null +++ b/src/datadogV2/model/model_tenancy_config.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 definition of `TenancyConfig` object. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct TenancyConfig { + /// The definition of `TenancyConfigData` object. + #[serde(rename = "data")] + pub data: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl TenancyConfig { + pub fn new() -> TenancyConfig { + TenancyConfig { + data: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn data(mut self, value: crate::datadogV2::model::TenancyConfigData) -> 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 TenancyConfig { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for TenancyConfig { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct TenancyConfigVisitor; + impl<'a> Visitor<'a> for TenancyConfigVisitor { + type Value = TenancyConfig; + + 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 = TenancyConfig { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(TenancyConfigVisitor) + } +} diff --git a/src/datadogV2/model/model_tenancy_config_data.rs b/src/datadogV2/model/model_tenancy_config_data.rs new file mode 100644 index 000000000..9e12bef8f --- /dev/null +++ b/src/datadogV2/model/model_tenancy_config_data.rs @@ -0,0 +1,138 @@ +// 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 definition of `TenancyConfigData` object. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct TenancyConfigData { + /// The definition of `TenancyConfigDataAttributes` object. + #[serde(rename = "attributes")] + pub attributes: Option, + /// The OCID of the tenancy config. + #[serde(rename = "id")] + pub id: Option, + /// OCI tenancy resource type. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::TenancyConfigDataType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl TenancyConfigData { + pub fn new(type_: crate::datadogV2::model::TenancyConfigDataType) -> TenancyConfigData { + TenancyConfigData { + attributes: None, + id: None, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn attributes( + mut self, + value: crate::datadogV2::model::TenancyConfigDataAttributes, + ) -> Self { + self.attributes = Some(value); + self + } + + 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<'de> Deserialize<'de> for TenancyConfigData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct TenancyConfigDataVisitor; + impl<'a> Visitor<'a> for TenancyConfigDataVisitor { + type Value = TenancyConfigData; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut attributes: Option = + None; + let mut id: Option = None; + let mut type_: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "attributes" => { + if v.is_null() { + continue; + } + attributes = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "id" => { + if v.is_null() { + continue; + } + id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::TenancyConfigDataType::UnparsedObject(_type_) => { + _unparsed = true; + }, + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = TenancyConfigData { + attributes, + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(TenancyConfigDataVisitor) + } +} diff --git a/src/datadogV2/model/model_tenancy_config_data_attributes.rs b/src/datadogV2/model/model_tenancy_config_data_attributes.rs new file mode 100644 index 000000000..6ca74ed42 --- /dev/null +++ b/src/datadogV2/model/model_tenancy_config_data_attributes.rs @@ -0,0 +1,285 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The definition of `TenancyConfigDataAttributes` object. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct TenancyConfigDataAttributes { + /// The config version. It is not recommended to add or change this value, as it is determined internally. + #[serde(rename = "config_version")] + pub config_version: Option, + /// Enable or disable cost collection. + #[serde(rename = "cost_collection_enabled")] + pub cost_collection_enabled: Option, + /// The OCID of the compartment containing Datadog managed resources. + #[serde(rename = "dd_compartment_id")] + pub dd_compartment_id: Option, + /// The OCID of the resource manager stack for creating Datadog managed resources. + #[serde(rename = "dd_stack_id")] + pub dd_stack_id: Option, + /// The home region of the tenancy to be integrated. + #[serde(rename = "home_region")] + pub home_region: Option, + /// The definition of `OCILogsConfig` object. + #[serde(rename = "logs_config")] + pub logs_config: Option, + /// The definition of `OCIMetricsConfig` object. + #[serde(rename = "metrics_config")] + pub metrics_config: Option, + /// The definition of `RegionsConfig` object. + #[serde(rename = "regions_config")] + pub regions_config: Option, + /// Enable or disable resource collection. + #[serde(rename = "resource_collection_enabled")] + pub resource_collection_enabled: Option, + /// The attribute's tenancy_name. + #[serde(rename = "tenancy_name")] + pub tenancy_name: Option, + /// The OCID of the user needed to authenticate and collect data. + #[serde(rename = "user_ocid")] + pub user_ocid: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl TenancyConfigDataAttributes { + pub fn new() -> TenancyConfigDataAttributes { + TenancyConfigDataAttributes { + config_version: None, + cost_collection_enabled: None, + dd_compartment_id: None, + dd_stack_id: None, + home_region: None, + logs_config: None, + metrics_config: None, + regions_config: None, + resource_collection_enabled: None, + tenancy_name: None, + user_ocid: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn config_version(mut self, value: i64) -> Self { + self.config_version = Some(value); + self + } + + pub fn cost_collection_enabled(mut self, value: bool) -> Self { + self.cost_collection_enabled = Some(value); + self + } + + pub fn dd_compartment_id(mut self, value: String) -> Self { + self.dd_compartment_id = Some(value); + self + } + + pub fn dd_stack_id(mut self, value: String) -> Self { + self.dd_stack_id = Some(value); + self + } + + pub fn home_region(mut self, value: String) -> Self { + self.home_region = Some(value); + self + } + + pub fn logs_config(mut self, value: crate::datadogV2::model::OCILogsConfig) -> Self { + self.logs_config = Some(value); + self + } + + pub fn metrics_config(mut self, value: crate::datadogV2::model::OCIMetricsConfig) -> Self { + self.metrics_config = Some(value); + self + } + + pub fn regions_config(mut self, value: crate::datadogV2::model::RegionsConfig) -> Self { + self.regions_config = Some(value); + self + } + + pub fn resource_collection_enabled(mut self, value: bool) -> Self { + self.resource_collection_enabled = Some(value); + self + } + + pub fn tenancy_name(mut self, value: String) -> Self { + self.tenancy_name = Some(value); + self + } + + pub fn user_ocid(mut self, value: String) -> Self { + self.user_ocid = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for TenancyConfigDataAttributes { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for TenancyConfigDataAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct TenancyConfigDataAttributesVisitor; + impl<'a> Visitor<'a> for TenancyConfigDataAttributesVisitor { + type Value = TenancyConfigDataAttributes; + + 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 config_version: Option = None; + let mut cost_collection_enabled: Option = None; + let mut dd_compartment_id: Option = None; + let mut dd_stack_id: Option = None; + let mut home_region: Option = None; + let mut logs_config: Option = None; + let mut metrics_config: Option = None; + let mut regions_config: Option = None; + let mut resource_collection_enabled: Option = None; + let mut tenancy_name: Option = None; + let mut user_ocid: 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() { + "config_version" => { + if v.is_null() { + continue; + } + config_version = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "cost_collection_enabled" => { + if v.is_null() { + continue; + } + cost_collection_enabled = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "dd_compartment_id" => { + if v.is_null() { + continue; + } + dd_compartment_id = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "dd_stack_id" => { + if v.is_null() { + continue; + } + dd_stack_id = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "home_region" => { + if v.is_null() { + continue; + } + home_region = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "logs_config" => { + if v.is_null() { + continue; + } + logs_config = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "metrics_config" => { + if v.is_null() { + continue; + } + metrics_config = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "regions_config" => { + if v.is_null() { + continue; + } + regions_config = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "resource_collection_enabled" => { + if v.is_null() { + continue; + } + resource_collection_enabled = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "tenancy_name" => { + if v.is_null() { + continue; + } + tenancy_name = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "user_ocid" => { + if v.is_null() { + continue; + } + user_ocid = 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 = TenancyConfigDataAttributes { + config_version, + cost_collection_enabled, + dd_compartment_id, + dd_stack_id, + home_region, + logs_config, + metrics_config, + regions_config, + resource_collection_enabled, + tenancy_name, + user_ocid, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(TenancyConfigDataAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_tenancy_config_data_type.rs b/src/datadogV2/model/model_tenancy_config_data_type.rs new file mode 100644 index 000000000..65f781ce3 --- /dev/null +++ b/src/datadogV2/model/model_tenancy_config_data_type.rs @@ -0,0 +1,48 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +use serde::{Deserialize, Deserializer, Serialize, Serializer}; + +#[non_exhaustive] +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum TenancyConfigDataType { + OCI_TENANCY, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for TenancyConfigDataType { + fn to_string(&self) -> String { + match self { + Self::OCI_TENANCY => String::from("oci_tenancy"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for TenancyConfigDataType { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match self { + Self::UnparsedObject(v) => v.serialize(serializer), + _ => serializer.serialize_str(self.to_string().as_str()), + } + } +} + +impl<'de> Deserialize<'de> for TenancyConfigDataType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "oci_tenancy" => Self::OCI_TENANCY, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_tenancy_config_list.rs b/src/datadogV2/model/model_tenancy_config_list.rs new file mode 100644 index 000000000..0ced3fc9e --- /dev/null +++ b/src/datadogV2/model/model_tenancy_config_list.rs @@ -0,0 +1,92 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The definition of `TenancyConfigList` object. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct TenancyConfigList { + /// The `TenancyConfigList` data. + #[serde(rename = "data")] + pub data: Vec, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl TenancyConfigList { + pub fn new(data: Vec) -> TenancyConfigList { + TenancyConfigList { + data, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for TenancyConfigList { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct TenancyConfigListVisitor; + impl<'a> Visitor<'a> for TenancyConfigListVisitor { + type Value = TenancyConfigList; + + fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result { + f.write_str("a mapping") + } + + fn visit_map(self, mut map: M) -> Result + where + M: MapAccess<'a>, + { + let mut data: Option> = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "data" => { + data = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let data = data.ok_or_else(|| M::Error::missing_field("data"))?; + + let content = TenancyConfigList { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(TenancyConfigListVisitor) + } +} diff --git a/src/datadogV2/model/model_update_tenancy_config.rs b/src/datadogV2/model/model_update_tenancy_config.rs new file mode 100644 index 000000000..6d4f6dea3 --- /dev/null +++ b/src/datadogV2/model/model_update_tenancy_config.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 definition of `UpdateTenancyConfig` object. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct UpdateTenancyConfig { + /// The definition of `UpdateTenancyConfigData` object. + #[serde(rename = "data")] + pub data: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl UpdateTenancyConfig { + pub fn new() -> UpdateTenancyConfig { + UpdateTenancyConfig { + data: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn data(mut self, value: crate::datadogV2::model::UpdateTenancyConfigData) -> 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 UpdateTenancyConfig { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for UpdateTenancyConfig { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct UpdateTenancyConfigVisitor; + impl<'a> Visitor<'a> for UpdateTenancyConfigVisitor { + type Value = UpdateTenancyConfig; + + 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 = UpdateTenancyConfig { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(UpdateTenancyConfigVisitor) + } +} diff --git a/src/datadogV2/model/model_update_tenancy_config_data.rs b/src/datadogV2/model/model_update_tenancy_config_data.rs new file mode 100644 index 000000000..6a73db9eb --- /dev/null +++ b/src/datadogV2/model/model_update_tenancy_config_data.rs @@ -0,0 +1,135 @@ +// 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 definition of `UpdateTenancyConfigData` object. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct UpdateTenancyConfigData { + /// The definition of `UpdateTenancyConfigDataAttributes` object. + #[serde(rename = "attributes")] + pub attributes: Option, + /// The OCID of the tenancy to be integrated. + #[serde(rename = "id")] + pub id: String, + /// OCI tenancy resource type. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::UpdateTenancyConfigDataType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl UpdateTenancyConfigData { + pub fn new( + id: String, + type_: crate::datadogV2::model::UpdateTenancyConfigDataType, + ) -> UpdateTenancyConfigData { + UpdateTenancyConfigData { + attributes: None, + id, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn attributes( + mut self, + value: crate::datadogV2::model::UpdateTenancyConfigDataAttributes, + ) -> Self { + self.attributes = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for UpdateTenancyConfigData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct UpdateTenancyConfigDataVisitor; + impl<'a> Visitor<'a> for UpdateTenancyConfigDataVisitor { + type Value = UpdateTenancyConfigData; + + 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::UpdateTenancyConfigDataAttributes, + > = None; + let mut id: Option = None; + let mut type_: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "attributes" => { + if v.is_null() { + continue; + } + attributes = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "id" => { + id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::UpdateTenancyConfigDataType::UnparsedObject(_type_) => { + _unparsed = true; + }, + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let id = id.ok_or_else(|| M::Error::missing_field("id"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = UpdateTenancyConfigData { + attributes, + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(UpdateTenancyConfigDataVisitor) + } +} diff --git a/src/datadogV2/model/model_update_tenancy_config_data_attributes.rs b/src/datadogV2/model/model_update_tenancy_config_data_attributes.rs new file mode 100644 index 000000000..35724df5f --- /dev/null +++ b/src/datadogV2/model/model_update_tenancy_config_data_attributes.rs @@ -0,0 +1,213 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The definition of `UpdateTenancyConfigDataAttributes` object. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct UpdateTenancyConfigDataAttributes { + /// The auth credentials of the user. Consists of a public key fingerprint and private key. + #[serde(rename = "auth_credentials")] + pub auth_credentials: Option, + /// The home region of the tenancy to be integrated. + #[serde(rename = "home_region")] + pub home_region: Option, + /// The definition of `OCILogsConfig` object. + #[serde(rename = "logs_config")] + pub logs_config: Option, + /// The definition of `OCIMetricsConfig` object. + #[serde(rename = "metrics_config")] + pub metrics_config: Option, + /// The definition of `RegionsConfig` object. + #[serde(rename = "regions_config")] + pub regions_config: Option, + /// Enable or disable resource collection. + #[serde(rename = "resource_collection_enabled")] + pub resource_collection_enabled: Option, + /// The OCID of the user needed to authenticate and collect data. + #[serde(rename = "user_ocid")] + pub user_ocid: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl UpdateTenancyConfigDataAttributes { + pub fn new() -> UpdateTenancyConfigDataAttributes { + UpdateTenancyConfigDataAttributes { + auth_credentials: None, + home_region: None, + logs_config: None, + metrics_config: None, + regions_config: None, + resource_collection_enabled: None, + user_ocid: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn auth_credentials(mut self, value: crate::datadogV2::model::AuthCredentials) -> Self { + self.auth_credentials = Some(value); + self + } + + pub fn home_region(mut self, value: String) -> Self { + self.home_region = Some(value); + self + } + + pub fn logs_config(mut self, value: crate::datadogV2::model::OCILogsConfig) -> Self { + self.logs_config = Some(value); + self + } + + pub fn metrics_config(mut self, value: crate::datadogV2::model::OCIMetricsConfig) -> Self { + self.metrics_config = Some(value); + self + } + + pub fn regions_config(mut self, value: crate::datadogV2::model::RegionsConfig) -> Self { + self.regions_config = Some(value); + self + } + + pub fn resource_collection_enabled(mut self, value: bool) -> Self { + self.resource_collection_enabled = Some(value); + self + } + + pub fn user_ocid(mut self, value: String) -> Self { + self.user_ocid = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for UpdateTenancyConfigDataAttributes { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for UpdateTenancyConfigDataAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct UpdateTenancyConfigDataAttributesVisitor; + impl<'a> Visitor<'a> for UpdateTenancyConfigDataAttributesVisitor { + type Value = UpdateTenancyConfigDataAttributes; + + 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 auth_credentials: Option = None; + let mut home_region: Option = None; + let mut logs_config: Option = None; + let mut metrics_config: Option = None; + let mut regions_config: Option = None; + let mut resource_collection_enabled: Option = None; + let mut user_ocid: 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() { + "auth_credentials" => { + if v.is_null() { + continue; + } + auth_credentials = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "home_region" => { + if v.is_null() { + continue; + } + home_region = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "logs_config" => { + if v.is_null() { + continue; + } + logs_config = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "metrics_config" => { + if v.is_null() { + continue; + } + metrics_config = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "regions_config" => { + if v.is_null() { + continue; + } + regions_config = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "resource_collection_enabled" => { + if v.is_null() { + continue; + } + resource_collection_enabled = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "user_ocid" => { + if v.is_null() { + continue; + } + user_ocid = 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 = UpdateTenancyConfigDataAttributes { + auth_credentials, + home_region, + logs_config, + metrics_config, + regions_config, + resource_collection_enabled, + user_ocid, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(UpdateTenancyConfigDataAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_update_tenancy_config_data_type.rs b/src/datadogV2/model/model_update_tenancy_config_data_type.rs new file mode 100644 index 000000000..e94e58c19 --- /dev/null +++ b/src/datadogV2/model/model_update_tenancy_config_data_type.rs @@ -0,0 +1,48 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +use serde::{Deserialize, Deserializer, Serialize, Serializer}; + +#[non_exhaustive] +#[derive(Clone, Debug, Eq, PartialEq)] +pub enum UpdateTenancyConfigDataType { + OCI_TENANCY, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for UpdateTenancyConfigDataType { + fn to_string(&self) -> String { + match self { + Self::OCI_TENANCY => String::from("oci_tenancy"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for UpdateTenancyConfigDataType { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + match self { + Self::UnparsedObject(v) => v.serialize(serializer), + _ => serializer.serialize_str(self.to_string().as_str()), + } + } +} + +impl<'de> Deserialize<'de> for UpdateTenancyConfigDataType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "oci_tenancy" => Self::OCI_TENANCY, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/tests/scenarios/cassettes/v2/oci_integration/Create-tenancy-config-returns-Bad-Request-response.frozen b/tests/scenarios/cassettes/v2/oci_integration/Create-tenancy-config-returns-Bad-Request-response.frozen new file mode 100644 index 000000000..28c6be745 --- /dev/null +++ b/tests/scenarios/cassettes/v2/oci_integration/Create-tenancy-config-returns-Bad-Request-response.frozen @@ -0,0 +1 @@ +2025-05-08T15:48:41.992Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/oci_integration/Create-tenancy-config-returns-Bad-Request-response.json b/tests/scenarios/cassettes/v2/oci_integration/Create-tenancy-config-returns-Bad-Request-response.json new file mode 100644 index 000000000..6b4f248d0 --- /dev/null +++ b/tests/scenarios/cassettes/v2/oci_integration/Create-tenancy-config-returns-Bad-Request-response.json @@ -0,0 +1,39 @@ +{ + "http_interactions": [ + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"auth_credentials\":{\"fingerprint\":\"a7:b5:54:f2:da:a2:d7:b0:ed:f4:79:47:93:64:12:b1\",\"private_key\":\"-----BEGIN PRIVATE KEY-----\\nMIIEv\\n-----END PRIVATE KEY-----\\n\"},\"config_version\":2,\"home_region\":\"us-ashburn-1\",\"logs_config\":{\"compartment_tag_filters\":[\"datadog:true\",\"env:prod\"],\"enabled\":true,\"enabled_services\":[\"oacnativeproduction\"]},\"metrics_config\":{\"compartment_tag_filters\":[\"datadog:true\",\"env:prod\"],\"enabled\":true,\"excluded_services\":[\"oci_compute\"]},\"resource_collection_enabled\":true,\"user_ocid\":\"ocid1.user.test\"},\"id\":\"ocid1.tenancy.dummy_value\",\"type\":\"oci_tenancy\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v2/integration/oci/tenancies" + }, + "response": { + "body": { + "string": "{\"errors\":[{\"status\":\"400\",\"title\":\"Bad Request\",\"detail\":\"invalid private key\"}]}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 400, + "message": "Bad Request" + } + }, + "recorded_at": "Thu, 08 May 2025 15:48:41 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/oci_integration/Delete-tenancy-config-returns-No-Content-response.frozen b/tests/scenarios/cassettes/v2/oci_integration/Delete-tenancy-config-returns-No-Content-response.frozen new file mode 100644 index 000000000..60d7de843 --- /dev/null +++ b/tests/scenarios/cassettes/v2/oci_integration/Delete-tenancy-config-returns-No-Content-response.frozen @@ -0,0 +1 @@ +2025-05-07T20:00:06.021Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/oci_integration/Delete-tenancy-config-returns-No-Content-response.json b/tests/scenarios/cassettes/v2/oci_integration/Delete-tenancy-config-returns-No-Content-response.json new file mode 100644 index 000000000..9f39eac26 --- /dev/null +++ b/tests/scenarios/cassettes/v2/oci_integration/Delete-tenancy-config-returns-No-Content-response.json @@ -0,0 +1,91 @@ +{ + "http_interactions": [ + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"auth_credentials\":{\"fingerprint\":\"c8:e5:54:f2:da:a2:d7:b0:ed:f4:79:47:93:64:12:b1\",\"private_key\":\"-----BEGIN PRIVATE KEY-----\\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCmMo2jwJXWTt0y\\nk+X6biZycflZSwOAP/iNeAZPTWwhYxj9pxDvd5OfiIe+o/7eupk/3q+fRsSaztPn\\nJwI/JnbQz5IT5miLi/apIozg870FFxjrgRxSGjo7BNH0dLKITc5nLDLBnOEzxR2Y\\nk9+0dFaiNlcodFULlg75trqbILRSc6jn9Tp9G8C5e9cj+LYQuUu2JwIqhCJqcNcU\\nt+lRL5odBJhZ85KlugKyUg6LN3VQIdOpTtPBMXYA1oBgDCbe5Rw5yzgnd0KtSFf3\\nGOmLfR95gQshLfbGavLOTh9ioaOj/2hT9HrsEe1VWgX3m1WibqKiPc4OA4BGGToN\\n9tzN/t89AgMBAAECggEAVFKD4JherXwX6Ih3f6cRZLGFBJP1s8VBM225LdUnTo07\\n6b4w7n6p7KBV1xjXwGPGS0yNqG88YxsbEkWNc0Ltt6YJBIW7d0nNHSVFewDPX1zH\\nrP01xEZAUx9v8uqehl+LoHchTXBuJlkVWgt0zdbU+bo+YG0dlSJOeM4IQZrHQqlQ\\ne4PNk73rot9NSqiKQFXUroaoVPTkUHb3idpLX60K3MgIBoAm4DpJ6cMItb4hyHv5\\npNZhHQbr9Eciz2tj+OhQTYKCrAd0gJgl0tC+6L3kzkmiYE3ceGphqWfI9bX52Y96\\nwpgAtYi6o8wTykgRLabLc6vSQ9RegWEh7P8iSAvAlQKBgQDX5wJhYeWDdG4uPqLC\\nX3EtnR3y5zYgOd7cVtMr1DIvXa4I8PSIOC4Wnb/5A1S03dJ2e8GJ/qSbl5R2fsDr\\nXhjIm/KeBPI9p2dVZM8fPoWppR3SgDaHY5qxAED111DnEZuTMl5BO87QZXurTSiF\\nfbGsWaVqdVieRAQ3b5DEkC9TSwKBgQDFEFgui7iyPhQaQafsjnVbWyrWF821xjTG\\nb6Bo4FO97c9pw/tbkpfM+dcOU4SsZL8HjwGBUhUsDsVOX7m/sWRjZqNM5t/VR+52\\n9ygIPEjNyh0b3aARgn8AQ8n+RZvl1Z2A32KCO3MFzhpVKnv2sdSc1TNHQkuJH/rq\\neUAm3El6lwKBgQCK8w+jIOAXRB2NAZ66PbaXRqD5rTg2cUguwmpRsNVDiqTw+DJI\\nYO+4enoMhspDROeofWlHqGzD/j/8KwN59ys4ILV6YXCNoWltmd17HD/luHCDAyUU\\n6VOrSqCEF7jnnXtktmvWy+kEUevPiW7kyspIQ8GjzDXmVZvpGZIwDyOGFQKBgGtS\\nl3PiDFimjnQuRbIDc86pPA8VL6dLpvpbWNVFNtY9abSEU6RvldTATGs0+RCaXZ9U\\nNtGjTnyMHtCsOZE4nx+zikQbiNOzNR/9QwQZMN1Csc+3R7HBjEEsqhmc92aYjArf\\nndqnXeFPee/gD1svRkeTpTWt2U146UJBfrqrRilJAoGAQp7FtEtps5I9xK92AVpD\\nHj2p1JNKzLCRtWQ8j4jthKqR0iTQ9SwQyjiAvcKc7HdMaG11gmr5XbmKAzelVC+f\\no9kEwoumo8yHVn5Ztp4F2cxaD6+MzSJ/I6WesPyePUD7sPeorXByg1UNOXyzqDub\\n/aU4/sNo2f8epM9l7QGiCtY=\\n-----END PRIVATE KEY-----\\n\"},\"config_version\":2,\"home_region\":\"us-ashburn-1\",\"logs_config\":{\"compartment_tag_filters\":[\"datadog:true\",\"env:prod\"],\"enabled\":true,\"enabled_services\":[\"oci_compute\"]},\"metrics_config\":{\"compartment_tag_filters\":[\"datadog:true\",\"env:prod\"],\"enabled\":true,\"excluded_services\":[\"oacnativeproduction\"]},\"resource_collection_enabled\":true,\"user_ocid\":\"ocid1.user.test\"},\"id\":\"ocid1.tenancy.test\",\"type\":\"oci_tenancy\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v2/integration/oci/tenancies" + }, + "response": { + "body": { + "string": "{\"data\":{\"id\":\"ocid1.tenancy.test\",\"type\":\"oci_tenancy\",\"attributes\":{\"home_region\":\"us-ashburn-1\",\"user_ocid\":\"ocid1.user.test\"}}}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 201, + "message": "Created" + } + }, + "recorded_at": "Wed, 07 May 2025 20:00:06 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/integration/oci/tenancies/ocid1.tenancy.test" + }, + "response": { + "body": { + "string": "", + "encoding": null + }, + "headers": {}, + "status": { + "code": 204, + "message": "No Content" + } + }, + "recorded_at": "Wed, 07 May 2025 20:00:06 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/integration/oci/tenancies/ocid1.tenancy.test" + }, + "response": { + "body": { + "string": "{\"errors\":[{\"status\":\"404\",\"title\":\"Not Found\",\"detail\":\"tenancy not found\"}]}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 404, + "message": "Not Found" + } + }, + "recorded_at": "Wed, 07 May 2025 20:00:06 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/oci_integration/Get-tenancy-config-returns-Not-Found-response.frozen b/tests/scenarios/cassettes/v2/oci_integration/Get-tenancy-config-returns-Not-Found-response.frozen new file mode 100644 index 000000000..5ff2a7bec --- /dev/null +++ b/tests/scenarios/cassettes/v2/oci_integration/Get-tenancy-config-returns-Not-Found-response.frozen @@ -0,0 +1 @@ +2025-05-07T20:00:07.060Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/oci_integration/Get-tenancy-config-returns-Not-Found-response.json b/tests/scenarios/cassettes/v2/oci_integration/Get-tenancy-config-returns-Not-Found-response.json new file mode 100644 index 000000000..185d4dc93 --- /dev/null +++ b/tests/scenarios/cassettes/v2/oci_integration/Get-tenancy-config-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/integration/oci/tenancies/ocid1.tenancy.fake" + }, + "response": { + "body": { + "string": "{\"errors\":[{\"status\":\"404\",\"title\":\"Not Found\",\"detail\":\"tenancy not found\"}]}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 404, + "message": "Not Found" + } + }, + "recorded_at": "Wed, 07 May 2025 20:00:07 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/oci_integration/Get-tenancy-config-returns-OK-response.frozen b/tests/scenarios/cassettes/v2/oci_integration/Get-tenancy-config-returns-OK-response.frozen new file mode 100644 index 000000000..5d4e974e1 --- /dev/null +++ b/tests/scenarios/cassettes/v2/oci_integration/Get-tenancy-config-returns-OK-response.frozen @@ -0,0 +1 @@ +2025-05-07T20:00:07.257Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/oci_integration/Get-tenancy-config-returns-OK-response.json b/tests/scenarios/cassettes/v2/oci_integration/Get-tenancy-config-returns-OK-response.json new file mode 100644 index 000000000..a536ec366 --- /dev/null +++ b/tests/scenarios/cassettes/v2/oci_integration/Get-tenancy-config-returns-OK-response.json @@ -0,0 +1,91 @@ +{ + "http_interactions": [ + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"auth_credentials\":{\"fingerprint\":\"c8:e5:54:f2:da:a2:d7:b0:ed:f4:79:47:93:64:12:b1\",\"private_key\":\"-----BEGIN PRIVATE KEY-----\\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCmMo2jwJXWTt0y\\nk+X6biZycflZSwOAP/iNeAZPTWwhYxj9pxDvd5OfiIe+o/7eupk/3q+fRsSaztPn\\nJwI/JnbQz5IT5miLi/apIozg870FFxjrgRxSGjo7BNH0dLKITc5nLDLBnOEzxR2Y\\nk9+0dFaiNlcodFULlg75trqbILRSc6jn9Tp9G8C5e9cj+LYQuUu2JwIqhCJqcNcU\\nt+lRL5odBJhZ85KlugKyUg6LN3VQIdOpTtPBMXYA1oBgDCbe5Rw5yzgnd0KtSFf3\\nGOmLfR95gQshLfbGavLOTh9ioaOj/2hT9HrsEe1VWgX3m1WibqKiPc4OA4BGGToN\\n9tzN/t89AgMBAAECggEAVFKD4JherXwX6Ih3f6cRZLGFBJP1s8VBM225LdUnTo07\\n6b4w7n6p7KBV1xjXwGPGS0yNqG88YxsbEkWNc0Ltt6YJBIW7d0nNHSVFewDPX1zH\\nrP01xEZAUx9v8uqehl+LoHchTXBuJlkVWgt0zdbU+bo+YG0dlSJOeM4IQZrHQqlQ\\ne4PNk73rot9NSqiKQFXUroaoVPTkUHb3idpLX60K3MgIBoAm4DpJ6cMItb4hyHv5\\npNZhHQbr9Eciz2tj+OhQTYKCrAd0gJgl0tC+6L3kzkmiYE3ceGphqWfI9bX52Y96\\nwpgAtYi6o8wTykgRLabLc6vSQ9RegWEh7P8iSAvAlQKBgQDX5wJhYeWDdG4uPqLC\\nX3EtnR3y5zYgOd7cVtMr1DIvXa4I8PSIOC4Wnb/5A1S03dJ2e8GJ/qSbl5R2fsDr\\nXhjIm/KeBPI9p2dVZM8fPoWppR3SgDaHY5qxAED111DnEZuTMl5BO87QZXurTSiF\\nfbGsWaVqdVieRAQ3b5DEkC9TSwKBgQDFEFgui7iyPhQaQafsjnVbWyrWF821xjTG\\nb6Bo4FO97c9pw/tbkpfM+dcOU4SsZL8HjwGBUhUsDsVOX7m/sWRjZqNM5t/VR+52\\n9ygIPEjNyh0b3aARgn8AQ8n+RZvl1Z2A32KCO3MFzhpVKnv2sdSc1TNHQkuJH/rq\\neUAm3El6lwKBgQCK8w+jIOAXRB2NAZ66PbaXRqD5rTg2cUguwmpRsNVDiqTw+DJI\\nYO+4enoMhspDROeofWlHqGzD/j/8KwN59ys4ILV6YXCNoWltmd17HD/luHCDAyUU\\n6VOrSqCEF7jnnXtktmvWy+kEUevPiW7kyspIQ8GjzDXmVZvpGZIwDyOGFQKBgGtS\\nl3PiDFimjnQuRbIDc86pPA8VL6dLpvpbWNVFNtY9abSEU6RvldTATGs0+RCaXZ9U\\nNtGjTnyMHtCsOZE4nx+zikQbiNOzNR/9QwQZMN1Csc+3R7HBjEEsqhmc92aYjArf\\nndqnXeFPee/gD1svRkeTpTWt2U146UJBfrqrRilJAoGAQp7FtEtps5I9xK92AVpD\\nHj2p1JNKzLCRtWQ8j4jthKqR0iTQ9SwQyjiAvcKc7HdMaG11gmr5XbmKAzelVC+f\\no9kEwoumo8yHVn5Ztp4F2cxaD6+MzSJ/I6WesPyePUD7sPeorXByg1UNOXyzqDub\\n/aU4/sNo2f8epM9l7QGiCtY=\\n-----END PRIVATE KEY-----\\n\"},\"config_version\":2,\"home_region\":\"us-ashburn-1\",\"logs_config\":{\"compartment_tag_filters\":[\"datadog:true\",\"env:prod\"],\"enabled\":true,\"enabled_services\":[\"oci_compute\"]},\"metrics_config\":{\"compartment_tag_filters\":[\"datadog:true\",\"env:prod\"],\"enabled\":true,\"excluded_services\":[\"oacnativeproduction\"]},\"resource_collection_enabled\":true,\"user_ocid\":\"ocid1.user.test\"},\"id\":\"ocid1.tenancy.test\",\"type\":\"oci_tenancy\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v2/integration/oci/tenancies" + }, + "response": { + "body": { + "string": "{\"data\":{\"id\":\"ocid1.tenancy.test\",\"type\":\"oci_tenancy\",\"attributes\":{\"home_region\":\"us-ashburn-1\",\"user_ocid\":\"ocid1.user.test\"}}}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 201, + "message": "Created" + } + }, + "recorded_at": "Wed, 07 May 2025 20:00:07 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "application/json" + ] + }, + "method": "get", + "uri": "https://api.datadoghq.com/api/v2/integration/oci/tenancies/ocid1.tenancy.test" + }, + "response": { + "body": { + "string": "{\"data\":{\"id\":\"ocid1.tenancy.test\",\"type\":\"oci_tenancy\",\"attributes\":{\"config_version\":2,\"cost_collection_enabled\":false,\"home_region\":\"us-ashburn-1\",\"logs_config\":{\"enabled\":true,\"compartment_tag_filters\":[\"datadog:true\",\"env:prod\"],\"enabled_services\":[\"oci_compute\"]},\"metrics_config\":{\"enabled\":true,\"compartment_tag_filters\":[\"datadog:true\",\"env:prod\"],\"excluded_services\":[\"oacnativeproduction\"]},\"resource_collection_enabled\":true,\"user_ocid\":\"ocid1.user.test\"}}}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 200, + "message": "OK" + } + }, + "recorded_at": "Wed, 07 May 2025 20:00:07 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/integration/oci/tenancies/ocid1.tenancy.test" + }, + "response": { + "body": { + "string": "", + "encoding": null + }, + "headers": {}, + "status": { + "code": 204, + "message": "No Content" + } + }, + "recorded_at": "Wed, 07 May 2025 20:00:07 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/oci_integration/Get-tenancy-configs-returns-OK-response.frozen b/tests/scenarios/cassettes/v2/oci_integration/Get-tenancy-configs-returns-OK-response.frozen new file mode 100644 index 000000000..ad760cc0c --- /dev/null +++ b/tests/scenarios/cassettes/v2/oci_integration/Get-tenancy-configs-returns-OK-response.frozen @@ -0,0 +1 @@ +2025-05-07T20:00:07.843Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/oci_integration/Get-tenancy-configs-returns-OK-response.json b/tests/scenarios/cassettes/v2/oci_integration/Get-tenancy-configs-returns-OK-response.json new file mode 100644 index 000000000..279eccbd3 --- /dev/null +++ b/tests/scenarios/cassettes/v2/oci_integration/Get-tenancy-configs-returns-OK-response.json @@ -0,0 +1,91 @@ +{ + "http_interactions": [ + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"auth_credentials\":{\"fingerprint\":\"c8:e5:54:f2:da:a2:d7:b0:ed:f4:79:47:93:64:12:b1\",\"private_key\":\"-----BEGIN PRIVATE KEY-----\\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCmMo2jwJXWTt0y\\nk+X6biZycflZSwOAP/iNeAZPTWwhYxj9pxDvd5OfiIe+o/7eupk/3q+fRsSaztPn\\nJwI/JnbQz5IT5miLi/apIozg870FFxjrgRxSGjo7BNH0dLKITc5nLDLBnOEzxR2Y\\nk9+0dFaiNlcodFULlg75trqbILRSc6jn9Tp9G8C5e9cj+LYQuUu2JwIqhCJqcNcU\\nt+lRL5odBJhZ85KlugKyUg6LN3VQIdOpTtPBMXYA1oBgDCbe5Rw5yzgnd0KtSFf3\\nGOmLfR95gQshLfbGavLOTh9ioaOj/2hT9HrsEe1VWgX3m1WibqKiPc4OA4BGGToN\\n9tzN/t89AgMBAAECggEAVFKD4JherXwX6Ih3f6cRZLGFBJP1s8VBM225LdUnTo07\\n6b4w7n6p7KBV1xjXwGPGS0yNqG88YxsbEkWNc0Ltt6YJBIW7d0nNHSVFewDPX1zH\\nrP01xEZAUx9v8uqehl+LoHchTXBuJlkVWgt0zdbU+bo+YG0dlSJOeM4IQZrHQqlQ\\ne4PNk73rot9NSqiKQFXUroaoVPTkUHb3idpLX60K3MgIBoAm4DpJ6cMItb4hyHv5\\npNZhHQbr9Eciz2tj+OhQTYKCrAd0gJgl0tC+6L3kzkmiYE3ceGphqWfI9bX52Y96\\nwpgAtYi6o8wTykgRLabLc6vSQ9RegWEh7P8iSAvAlQKBgQDX5wJhYeWDdG4uPqLC\\nX3EtnR3y5zYgOd7cVtMr1DIvXa4I8PSIOC4Wnb/5A1S03dJ2e8GJ/qSbl5R2fsDr\\nXhjIm/KeBPI9p2dVZM8fPoWppR3SgDaHY5qxAED111DnEZuTMl5BO87QZXurTSiF\\nfbGsWaVqdVieRAQ3b5DEkC9TSwKBgQDFEFgui7iyPhQaQafsjnVbWyrWF821xjTG\\nb6Bo4FO97c9pw/tbkpfM+dcOU4SsZL8HjwGBUhUsDsVOX7m/sWRjZqNM5t/VR+52\\n9ygIPEjNyh0b3aARgn8AQ8n+RZvl1Z2A32KCO3MFzhpVKnv2sdSc1TNHQkuJH/rq\\neUAm3El6lwKBgQCK8w+jIOAXRB2NAZ66PbaXRqD5rTg2cUguwmpRsNVDiqTw+DJI\\nYO+4enoMhspDROeofWlHqGzD/j/8KwN59ys4ILV6YXCNoWltmd17HD/luHCDAyUU\\n6VOrSqCEF7jnnXtktmvWy+kEUevPiW7kyspIQ8GjzDXmVZvpGZIwDyOGFQKBgGtS\\nl3PiDFimjnQuRbIDc86pPA8VL6dLpvpbWNVFNtY9abSEU6RvldTATGs0+RCaXZ9U\\nNtGjTnyMHtCsOZE4nx+zikQbiNOzNR/9QwQZMN1Csc+3R7HBjEEsqhmc92aYjArf\\nndqnXeFPee/gD1svRkeTpTWt2U146UJBfrqrRilJAoGAQp7FtEtps5I9xK92AVpD\\nHj2p1JNKzLCRtWQ8j4jthKqR0iTQ9SwQyjiAvcKc7HdMaG11gmr5XbmKAzelVC+f\\no9kEwoumo8yHVn5Ztp4F2cxaD6+MzSJ/I6WesPyePUD7sPeorXByg1UNOXyzqDub\\n/aU4/sNo2f8epM9l7QGiCtY=\\n-----END PRIVATE KEY-----\\n\"},\"config_version\":2,\"home_region\":\"us-ashburn-1\",\"logs_config\":{\"compartment_tag_filters\":[\"datadog:true\",\"env:prod\"],\"enabled\":true,\"enabled_services\":[\"oci_compute\"]},\"metrics_config\":{\"compartment_tag_filters\":[\"datadog:true\",\"env:prod\"],\"enabled\":true,\"excluded_services\":[\"oacnativeproduction\"]},\"resource_collection_enabled\":true,\"user_ocid\":\"ocid1.user.test\"},\"id\":\"ocid1.tenancy.test\",\"type\":\"oci_tenancy\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v2/integration/oci/tenancies" + }, + "response": { + "body": { + "string": "{\"data\":{\"id\":\"ocid1.tenancy.test\",\"type\":\"oci_tenancy\",\"attributes\":{\"home_region\":\"us-ashburn-1\",\"user_ocid\":\"ocid1.user.test\"}}}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 201, + "message": "Created" + } + }, + "recorded_at": "Wed, 07 May 2025 20:00:07 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "application/json" + ] + }, + "method": "get", + "uri": "https://api.datadoghq.com/api/v2/integration/oci/tenancies" + }, + "response": { + "body": { + "string": "{\"data\":[{\"id\":\"ocid1.tenancy.test\",\"type\":\"oci_tenancy\",\"attributes\":{\"config_version\":2,\"cost_collection_enabled\":false,\"home_region\":\"us-ashburn-1\",\"logs_config\":{\"enabled\":true,\"compartment_tag_filters\":[\"datadog:true\",\"env:prod\"],\"enabled_services\":[\"oci_compute\"]},\"metrics_config\":{\"enabled\":true,\"compartment_tag_filters\":[\"datadog:true\",\"env:prod\"],\"excluded_services\":[\"oacnativeproduction\"]},\"resource_collection_enabled\":true,\"user_ocid\":\"ocid1.user.test\"}}]}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 200, + "message": "OK" + } + }, + "recorded_at": "Wed, 07 May 2025 20:00:07 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/integration/oci/tenancies/ocid1.tenancy.test" + }, + "response": { + "body": { + "string": "", + "encoding": null + }, + "headers": {}, + "status": { + "code": 204, + "message": "No Content" + } + }, + "recorded_at": "Wed, 07 May 2025 20:00:07 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/oci_integration/Update-tenancy-config-returns-Bad-Request-response.frozen b/tests/scenarios/cassettes/v2/oci_integration/Update-tenancy-config-returns-Bad-Request-response.frozen new file mode 100644 index 000000000..36a8dba63 --- /dev/null +++ b/tests/scenarios/cassettes/v2/oci_integration/Update-tenancy-config-returns-Bad-Request-response.frozen @@ -0,0 +1 @@ +2025-05-07T20:00:08.400Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/oci_integration/Update-tenancy-config-returns-Bad-Request-response.json b/tests/scenarios/cassettes/v2/oci_integration/Update-tenancy-config-returns-Bad-Request-response.json new file mode 100644 index 000000000..359fe7f0e --- /dev/null +++ b/tests/scenarios/cassettes/v2/oci_integration/Update-tenancy-config-returns-Bad-Request-response.json @@ -0,0 +1,97 @@ +{ + "http_interactions": [ + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"auth_credentials\":{\"fingerprint\":\"c8:e5:54:f2:da:a2:d7:b0:ed:f4:79:47:93:64:12:b1\",\"private_key\":\"-----BEGIN PRIVATE KEY-----\\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCmMo2jwJXWTt0y\\nk+X6biZycflZSwOAP/iNeAZPTWwhYxj9pxDvd5OfiIe+o/7eupk/3q+fRsSaztPn\\nJwI/JnbQz5IT5miLi/apIozg870FFxjrgRxSGjo7BNH0dLKITc5nLDLBnOEzxR2Y\\nk9+0dFaiNlcodFULlg75trqbILRSc6jn9Tp9G8C5e9cj+LYQuUu2JwIqhCJqcNcU\\nt+lRL5odBJhZ85KlugKyUg6LN3VQIdOpTtPBMXYA1oBgDCbe5Rw5yzgnd0KtSFf3\\nGOmLfR95gQshLfbGavLOTh9ioaOj/2hT9HrsEe1VWgX3m1WibqKiPc4OA4BGGToN\\n9tzN/t89AgMBAAECggEAVFKD4JherXwX6Ih3f6cRZLGFBJP1s8VBM225LdUnTo07\\n6b4w7n6p7KBV1xjXwGPGS0yNqG88YxsbEkWNc0Ltt6YJBIW7d0nNHSVFewDPX1zH\\nrP01xEZAUx9v8uqehl+LoHchTXBuJlkVWgt0zdbU+bo+YG0dlSJOeM4IQZrHQqlQ\\ne4PNk73rot9NSqiKQFXUroaoVPTkUHb3idpLX60K3MgIBoAm4DpJ6cMItb4hyHv5\\npNZhHQbr9Eciz2tj+OhQTYKCrAd0gJgl0tC+6L3kzkmiYE3ceGphqWfI9bX52Y96\\nwpgAtYi6o8wTykgRLabLc6vSQ9RegWEh7P8iSAvAlQKBgQDX5wJhYeWDdG4uPqLC\\nX3EtnR3y5zYgOd7cVtMr1DIvXa4I8PSIOC4Wnb/5A1S03dJ2e8GJ/qSbl5R2fsDr\\nXhjIm/KeBPI9p2dVZM8fPoWppR3SgDaHY5qxAED111DnEZuTMl5BO87QZXurTSiF\\nfbGsWaVqdVieRAQ3b5DEkC9TSwKBgQDFEFgui7iyPhQaQafsjnVbWyrWF821xjTG\\nb6Bo4FO97c9pw/tbkpfM+dcOU4SsZL8HjwGBUhUsDsVOX7m/sWRjZqNM5t/VR+52\\n9ygIPEjNyh0b3aARgn8AQ8n+RZvl1Z2A32KCO3MFzhpVKnv2sdSc1TNHQkuJH/rq\\neUAm3El6lwKBgQCK8w+jIOAXRB2NAZ66PbaXRqD5rTg2cUguwmpRsNVDiqTw+DJI\\nYO+4enoMhspDROeofWlHqGzD/j/8KwN59ys4ILV6YXCNoWltmd17HD/luHCDAyUU\\n6VOrSqCEF7jnnXtktmvWy+kEUevPiW7kyspIQ8GjzDXmVZvpGZIwDyOGFQKBgGtS\\nl3PiDFimjnQuRbIDc86pPA8VL6dLpvpbWNVFNtY9abSEU6RvldTATGs0+RCaXZ9U\\nNtGjTnyMHtCsOZE4nx+zikQbiNOzNR/9QwQZMN1Csc+3R7HBjEEsqhmc92aYjArf\\nndqnXeFPee/gD1svRkeTpTWt2U146UJBfrqrRilJAoGAQp7FtEtps5I9xK92AVpD\\nHj2p1JNKzLCRtWQ8j4jthKqR0iTQ9SwQyjiAvcKc7HdMaG11gmr5XbmKAzelVC+f\\no9kEwoumo8yHVn5Ztp4F2cxaD6+MzSJ/I6WesPyePUD7sPeorXByg1UNOXyzqDub\\n/aU4/sNo2f8epM9l7QGiCtY=\\n-----END PRIVATE KEY-----\\n\"},\"config_version\":2,\"home_region\":\"us-ashburn-1\",\"logs_config\":{\"compartment_tag_filters\":[\"datadog:true\",\"env:prod\"],\"enabled\":true,\"enabled_services\":[\"oci_compute\"]},\"metrics_config\":{\"compartment_tag_filters\":[\"datadog:true\",\"env:prod\"],\"enabled\":true,\"excluded_services\":[\"oacnativeproduction\"]},\"resource_collection_enabled\":true,\"user_ocid\":\"ocid1.user.test\"},\"id\":\"ocid1.tenancy.test\",\"type\":\"oci_tenancy\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v2/integration/oci/tenancies" + }, + "response": { + "body": { + "string": "{\"data\":{\"id\":\"ocid1.tenancy.test\",\"type\":\"oci_tenancy\",\"attributes\":{\"home_region\":\"us-ashburn-1\",\"user_ocid\":\"ocid1.user.test\"}}}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 201, + "message": "Created" + } + }, + "recorded_at": "Wed, 07 May 2025 20:00:08 GMT" + }, + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"home_region\":\"us-ashburn-1\",\"logs_config\":{\"compartment_tag_filters\":[\"datadog:true\",\"env:prod\"],\"enabled\":true,\"enabled_services\":[\"objectstorage\"]},\"metrics_config\":{\"compartment_tag_filters\":[\"datadog:true\",\"env:prod\"],\"enabled\":true,\"excluded_services\":[\"oci_compute\"]},\"resource_collection_enabled\":true,\"user_ocid\":\"user.test\"},\"id\":\"ocid1.tenancy.dummy_value\",\"type\":\"oci_tenancy\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "patch", + "uri": "https://api.datadoghq.com/api/v2/integration/oci/tenancies/ocid1.tenancy.test" + }, + "response": { + "body": { + "string": "{\"errors\":[{\"status\":\"400\",\"title\":\"Bad Request\",\"detail\":\"attribute \\\"user_ocid\\\" failed startswith validation\"}]}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 400, + "message": "Bad Request" + } + }, + "recorded_at": "Wed, 07 May 2025 20:00:08 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/integration/oci/tenancies/ocid1.tenancy.test" + }, + "response": { + "body": { + "string": "", + "encoding": null + }, + "headers": {}, + "status": { + "code": 204, + "message": "No Content" + } + }, + "recorded_at": "Wed, 07 May 2025 20:00:08 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/oci_integration/Update-tenancy-config-returns-Not-Found-response.frozen b/tests/scenarios/cassettes/v2/oci_integration/Update-tenancy-config-returns-Not-Found-response.frozen new file mode 100644 index 000000000..329e73041 --- /dev/null +++ b/tests/scenarios/cassettes/v2/oci_integration/Update-tenancy-config-returns-Not-Found-response.frozen @@ -0,0 +1 @@ +2025-05-07T20:00:09.002Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/oci_integration/Update-tenancy-config-returns-Not-Found-response.json b/tests/scenarios/cassettes/v2/oci_integration/Update-tenancy-config-returns-Not-Found-response.json new file mode 100644 index 000000000..831867923 --- /dev/null +++ b/tests/scenarios/cassettes/v2/oci_integration/Update-tenancy-config-returns-Not-Found-response.json @@ -0,0 +1,39 @@ +{ + "http_interactions": [ + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"home_region\":\"us-ashburn-1\",\"logs_config\":{\"compartment_tag_filters\":[\"datadog:true\",\"env:prod\"],\"enabled\":true,\"enabled_services\":[\"objectstorage\"]},\"metrics_config\":{\"compartment_tag_filters\":[\"datadog:true\",\"env:prod\"],\"enabled\":true,\"excluded_services\":[\"oci_compute\"]},\"resource_collection_enabled\":true,\"user_ocid\":\"ocid1.user.test\"},\"id\":\"ocid1.tenancy.fake\",\"type\":\"oci_tenancy\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "patch", + "uri": "https://api.datadoghq.com/api/v2/integration/oci/tenancies/ocid1.tenancy.fake" + }, + "response": { + "body": { + "string": "{\"errors\":[{\"status\":\"404\",\"title\":\"Not Found\",\"detail\":\"tenancy not found\"}]}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 404, + "message": "Not Found" + } + }, + "recorded_at": "Wed, 07 May 2025 20:00:09 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/oci_integration/Update-tenancy-config-returns-OK-response.frozen b/tests/scenarios/cassettes/v2/oci_integration/Update-tenancy-config-returns-OK-response.frozen new file mode 100644 index 000000000..5f8f6ecb8 --- /dev/null +++ b/tests/scenarios/cassettes/v2/oci_integration/Update-tenancy-config-returns-OK-response.frozen @@ -0,0 +1 @@ +2025-05-07T20:23:20.166Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/v2/oci_integration/Update-tenancy-config-returns-OK-response.json b/tests/scenarios/cassettes/v2/oci_integration/Update-tenancy-config-returns-OK-response.json new file mode 100644 index 000000000..4dcc3995d --- /dev/null +++ b/tests/scenarios/cassettes/v2/oci_integration/Update-tenancy-config-returns-OK-response.json @@ -0,0 +1,97 @@ +{ + "http_interactions": [ + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"auth_credentials\":{\"fingerprint\":\"c8:e5:54:f2:da:a2:d7:b0:ed:f4:79:47:93:64:12:b1\",\"private_key\":\"-----BEGIN PRIVATE KEY-----\\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCmMo2jwJXWTt0y\\nk+X6biZycflZSwOAP/iNeAZPTWwhYxj9pxDvd5OfiIe+o/7eupk/3q+fRsSaztPn\\nJwI/JnbQz5IT5miLi/apIozg870FFxjrgRxSGjo7BNH0dLKITc5nLDLBnOEzxR2Y\\nk9+0dFaiNlcodFULlg75trqbILRSc6jn9Tp9G8C5e9cj+LYQuUu2JwIqhCJqcNcU\\nt+lRL5odBJhZ85KlugKyUg6LN3VQIdOpTtPBMXYA1oBgDCbe5Rw5yzgnd0KtSFf3\\nGOmLfR95gQshLfbGavLOTh9ioaOj/2hT9HrsEe1VWgX3m1WibqKiPc4OA4BGGToN\\n9tzN/t89AgMBAAECggEAVFKD4JherXwX6Ih3f6cRZLGFBJP1s8VBM225LdUnTo07\\n6b4w7n6p7KBV1xjXwGPGS0yNqG88YxsbEkWNc0Ltt6YJBIW7d0nNHSVFewDPX1zH\\nrP01xEZAUx9v8uqehl+LoHchTXBuJlkVWgt0zdbU+bo+YG0dlSJOeM4IQZrHQqlQ\\ne4PNk73rot9NSqiKQFXUroaoVPTkUHb3idpLX60K3MgIBoAm4DpJ6cMItb4hyHv5\\npNZhHQbr9Eciz2tj+OhQTYKCrAd0gJgl0tC+6L3kzkmiYE3ceGphqWfI9bX52Y96\\nwpgAtYi6o8wTykgRLabLc6vSQ9RegWEh7P8iSAvAlQKBgQDX5wJhYeWDdG4uPqLC\\nX3EtnR3y5zYgOd7cVtMr1DIvXa4I8PSIOC4Wnb/5A1S03dJ2e8GJ/qSbl5R2fsDr\\nXhjIm/KeBPI9p2dVZM8fPoWppR3SgDaHY5qxAED111DnEZuTMl5BO87QZXurTSiF\\nfbGsWaVqdVieRAQ3b5DEkC9TSwKBgQDFEFgui7iyPhQaQafsjnVbWyrWF821xjTG\\nb6Bo4FO97c9pw/tbkpfM+dcOU4SsZL8HjwGBUhUsDsVOX7m/sWRjZqNM5t/VR+52\\n9ygIPEjNyh0b3aARgn8AQ8n+RZvl1Z2A32KCO3MFzhpVKnv2sdSc1TNHQkuJH/rq\\neUAm3El6lwKBgQCK8w+jIOAXRB2NAZ66PbaXRqD5rTg2cUguwmpRsNVDiqTw+DJI\\nYO+4enoMhspDROeofWlHqGzD/j/8KwN59ys4ILV6YXCNoWltmd17HD/luHCDAyUU\\n6VOrSqCEF7jnnXtktmvWy+kEUevPiW7kyspIQ8GjzDXmVZvpGZIwDyOGFQKBgGtS\\nl3PiDFimjnQuRbIDc86pPA8VL6dLpvpbWNVFNtY9abSEU6RvldTATGs0+RCaXZ9U\\nNtGjTnyMHtCsOZE4nx+zikQbiNOzNR/9QwQZMN1Csc+3R7HBjEEsqhmc92aYjArf\\nndqnXeFPee/gD1svRkeTpTWt2U146UJBfrqrRilJAoGAQp7FtEtps5I9xK92AVpD\\nHj2p1JNKzLCRtWQ8j4jthKqR0iTQ9SwQyjiAvcKc7HdMaG11gmr5XbmKAzelVC+f\\no9kEwoumo8yHVn5Ztp4F2cxaD6+MzSJ/I6WesPyePUD7sPeorXByg1UNOXyzqDub\\n/aU4/sNo2f8epM9l7QGiCtY=\\n-----END PRIVATE KEY-----\\n\"},\"config_version\":2,\"home_region\":\"us-ashburn-1\",\"logs_config\":{\"compartment_tag_filters\":[\"datadog:true\",\"env:prod\"],\"enabled\":true,\"enabled_services\":[\"oci_compute\"]},\"metrics_config\":{\"compartment_tag_filters\":[\"datadog:true\",\"env:prod\"],\"enabled\":true,\"excluded_services\":[\"oacnativeproduction\"]},\"resource_collection_enabled\":true,\"user_ocid\":\"ocid1.user.test\"},\"id\":\"ocid1.tenancy.test\",\"type\":\"oci_tenancy\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "post", + "uri": "https://api.datadoghq.com/api/v2/integration/oci/tenancies" + }, + "response": { + "body": { + "string": "{\"data\":{\"id\":\"ocid1.tenancy.test\",\"type\":\"oci_tenancy\",\"attributes\":{\"home_region\":\"us-ashburn-1\",\"user_ocid\":\"ocid1.user.test\"}}}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 201, + "message": "Created" + } + }, + "recorded_at": "Wed, 07 May 2025 20:23:20 GMT" + }, + { + "request": { + "body": { + "string": "{\"data\":{\"attributes\":{\"home_region\":\"us-sanjose-1\",\"metrics_config\":{\"compartment_tag_filters\":[\"datadog:true\",\"env:prod\"],\"enabled\":false,\"excluded_services\":[]},\"resource_collection_enabled\":false,\"user_ocid\":\"ocid1.user.test_updated\"},\"id\":\"ocid1.tenancy.test\",\"type\":\"oci_tenancy\"}}", + "encoding": null + }, + "headers": { + "Accept": [ + "application/json" + ], + "Content-Type": [ + "application/json" + ] + }, + "method": "patch", + "uri": "https://api.datadoghq.com/api/v2/integration/oci/tenancies/ocid1.tenancy.test" + }, + "response": { + "body": { + "string": "{\"data\":{\"id\":\"ocid1.tenancy.test\",\"type\":\"oci_tenancy\",\"attributes\":{\"home_region\":\"us-sanjose-1\",\"user_ocid\":\"ocid1.user.test_updated\"}}}", + "encoding": null + }, + "headers": { + "Content-Type": [ + "application/vnd.api+json" + ] + }, + "status": { + "code": 200, + "message": "OK" + } + }, + "recorded_at": "Wed, 07 May 2025 20:23:20 GMT" + }, + { + "request": { + "body": "", + "headers": { + "Accept": [ + "*/*" + ] + }, + "method": "delete", + "uri": "https://api.datadoghq.com/api/v2/integration/oci/tenancies/ocid1.tenancy.test" + }, + "response": { + "body": { + "string": "", + "encoding": null + }, + "headers": {}, + "status": { + "code": 204, + "message": "No Content" + } + }, + "recorded_at": "Wed, 07 May 2025 20:23:20 GMT" + } + ], + "recorded_with": "VCR 6.0.0" +} \ No newline at end of file diff --git a/tests/scenarios/features/v2/given.json b/tests/scenarios/features/v2/given.json index 696fef088..7b381db87 100644 --- a/tests/scenarios/features/v2/given.json +++ b/tests/scenarios/features/v2/given.json @@ -312,6 +312,18 @@ "tag": "Microsoft Teams Integration", "operationId": "CreateWorkflowsWebhookHandle" }, + { + "parameters": [ + { + "name": "body", + "value": "{\n \"data\": {\n \"attributes\": {\n \"auth_credentials\": {\n \"fingerprint\": \"c8:e5:54:f2:da:a2:d7:b0:ed:f4:79:47:93:64:12:b1\",\n \"private_key\": \"-----BEGIN PRIVATE KEY-----\\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCmMo2jwJXWTt0y\\nk+X6biZycflZSwOAP/iNeAZPTWwhYxj9pxDvd5OfiIe+o/7eupk/3q+fRsSaztPn\\nJwI/JnbQz5IT5miLi/apIozg870FFxjrgRxSGjo7BNH0dLKITc5nLDLBnOEzxR2Y\\nk9+0dFaiNlcodFULlg75trqbILRSc6jn9Tp9G8C5e9cj+LYQuUu2JwIqhCJqcNcU\\nt+lRL5odBJhZ85KlugKyUg6LN3VQIdOpTtPBMXYA1oBgDCbe5Rw5yzgnd0KtSFf3\\nGOmLfR95gQshLfbGavLOTh9ioaOj/2hT9HrsEe1VWgX3m1WibqKiPc4OA4BGGToN\\n9tzN/t89AgMBAAECggEAVFKD4JherXwX6Ih3f6cRZLGFBJP1s8VBM225LdUnTo07\\n6b4w7n6p7KBV1xjXwGPGS0yNqG88YxsbEkWNc0Ltt6YJBIW7d0nNHSVFewDPX1zH\\nrP01xEZAUx9v8uqehl+LoHchTXBuJlkVWgt0zdbU+bo+YG0dlSJOeM4IQZrHQqlQ\\ne4PNk73rot9NSqiKQFXUroaoVPTkUHb3idpLX60K3MgIBoAm4DpJ6cMItb4hyHv5\\npNZhHQbr9Eciz2tj+OhQTYKCrAd0gJgl0tC+6L3kzkmiYE3ceGphqWfI9bX52Y96\\nwpgAtYi6o8wTykgRLabLc6vSQ9RegWEh7P8iSAvAlQKBgQDX5wJhYeWDdG4uPqLC\\nX3EtnR3y5zYgOd7cVtMr1DIvXa4I8PSIOC4Wnb/5A1S03dJ2e8GJ/qSbl5R2fsDr\\nXhjIm/KeBPI9p2dVZM8fPoWppR3SgDaHY5qxAED111DnEZuTMl5BO87QZXurTSiF\\nfbGsWaVqdVieRAQ3b5DEkC9TSwKBgQDFEFgui7iyPhQaQafsjnVbWyrWF821xjTG\\nb6Bo4FO97c9pw/tbkpfM+dcOU4SsZL8HjwGBUhUsDsVOX7m/sWRjZqNM5t/VR+52\\n9ygIPEjNyh0b3aARgn8AQ8n+RZvl1Z2A32KCO3MFzhpVKnv2sdSc1TNHQkuJH/rq\\neUAm3El6lwKBgQCK8w+jIOAXRB2NAZ66PbaXRqD5rTg2cUguwmpRsNVDiqTw+DJI\\nYO+4enoMhspDROeofWlHqGzD/j/8KwN59ys4ILV6YXCNoWltmd17HD/luHCDAyUU\\n6VOrSqCEF7jnnXtktmvWy+kEUevPiW7kyspIQ8GjzDXmVZvpGZIwDyOGFQKBgGtS\\nl3PiDFimjnQuRbIDc86pPA8VL6dLpvpbWNVFNtY9abSEU6RvldTATGs0+RCaXZ9U\\nNtGjTnyMHtCsOZE4nx+zikQbiNOzNR/9QwQZMN1Csc+3R7HBjEEsqhmc92aYjArf\\nndqnXeFPee/gD1svRkeTpTWt2U146UJBfrqrRilJAoGAQp7FtEtps5I9xK92AVpD\\nHj2p1JNKzLCRtWQ8j4jthKqR0iTQ9SwQyjiAvcKc7HdMaG11gmr5XbmKAzelVC+f\\no9kEwoumo8yHVn5Ztp4F2cxaD6+MzSJ/I6WesPyePUD7sPeorXByg1UNOXyzqDub\\n/aU4/sNo2f8epM9l7QGiCtY=\\n-----END PRIVATE KEY-----\\n\"\n },\n \"config_version\": 2,\n \"home_region\": \"us-ashburn-1\",\n \"logs_config\": {\n \"compartment_tag_filters\": [\n \"datadog:true\",\n \"env:prod\"\n ],\n \"enabled\": true,\n \"enabled_services\": [\"oci_compute\"]\n },\n \"metrics_config\": {\n \"compartment_tag_filters\": [\n \"datadog:true\",\n \"env:prod\"\n ],\n \"enabled\": true,\n \"excluded_services\": [\"oacnativeproduction\"]\n },\n \"resource_collection_enabled\": true,\n \"user_ocid\": \"ocid1.user.test\"\n },\n \"id\": \"ocid1.tenancy.test\",\n \"type\": \"oci_tenancy\"\n }\n}\n" + } + ], + "step": "there is a valid \"oci_tenancy\" resource in the system", + "key": "oci_tenancy", + "tag": "OCI Integration", + "operationId": "CreateTenancyConfig" + }, { "parameters": [ { diff --git a/tests/scenarios/features/v2/oci_integration.feature b/tests/scenarios/features/v2/oci_integration.feature new file mode 100644 index 000000000..d3c1beffb --- /dev/null +++ b/tests/scenarios/features/v2/oci_integration.feature @@ -0,0 +1,106 @@ +@endpoint(oci-integration) @endpoint(oci-integration-v2) +Feature: OCI Integration + Configure your Datadog-OCI integration directly through the Datadog API. + For more information, see the [OCI integration page](https://docs.datadogh + q.com/integrations/oracle_cloud_infrastructure/). + + Background: + Given a valid "apiKeyAuth" key in the system + And a valid "appKeyAuth" key in the system + And an instance of "OCIIntegration" API + + @team:DataDog/emerging-cloud-integrations + Scenario: Create tenancy config returns "Bad Request" response + Given new "CreateTenancyConfig" request + And body with value {"data": {"attributes": {"auth_credentials": {"fingerprint": "a7:b5:54:f2:da:a2:d7:b0:ed:f4:79:47:93:64:12:b1", "private_key": "-----BEGIN PRIVATE KEY-----\nMIIEv\n-----END PRIVATE KEY-----\n"}, "config_version": 2, "home_region": "us-ashburn-1", "logs_config": {"compartment_tag_filters": ["datadog:true", "env:prod"], "enabled": true, "enabled_services": ["oacnativeproduction"]}, "metrics_config": {"compartment_tag_filters": ["datadog:true", "env:prod"], "enabled": true, "excluded_services": ["oci_compute"]}, "resource_collection_enabled": true, "user_ocid": "ocid1.user.test"}, "id": "ocid1.tenancy.dummy_value", "type": "oci_tenancy"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/emerging-cloud-integrations + Scenario: Create tenancy config returns "Conflict" response + Given new "CreateTenancyConfig" request + And body with value {"data": {"attributes": {"auth_credentials": {"fingerprint": "a7:b5:54:f2:da:a2:d7:b0:ed:f4:79:47:93:64:12:b1", "private_key": "-----BEGIN PRIVATE KEY-----\no9kEwoumo8yHVn5Ztp4F2cxaD6+MzSJ/I6WesPyePUD7sPeorXByg1UNOXyzqDub\n/aU4/sNo2f8epM9l7QGiCtY=\n-----END PRIVATE KEY-----"}, "config_version": 2, "home_region": "us-ashburn-1", "logs_config": {"compartment_tag_filters": ["datadog:true", "env:prod"], "enabled": true, "enabled_services": ["oacnativeproduction"]}, "metrics_config": {"compartment_tag_filters": ["datadog:true", "env:prod"], "enabled": true, "excluded_services": ["oci_compute"]}, "resource_collection_enabled": true, "user_ocid": "ocid1.user.test"}, "id": "ocid1.tenancy.dummy_value", "type": "oci_tenancy"}} + When the request is sent + Then the response status is 409 Conflict + + @generated @skip @team:DataDog/emerging-cloud-integrations + Scenario: Create tenancy config returns "Created" response + Given new "CreateTenancyConfig" request + And body with value {"data": {"attributes": {"auth_credentials": {"fingerprint": "a7:b5:54:f2:da:a2:d7:b0:ed:f4:79:47:93:64:12:b1", "private_key": "-----BEGIN PRIVATE KEY-----\no9kEwoumo8yHVn5Ztp4F2cxaD6+MzSJ/I6WesPyePUD7sPeorXByg1UNOXyzqDub\n/aU4/sNo2f8epM9l7QGiCtY=\n-----END PRIVATE KEY-----"}, "config_version": 2, "home_region": "us-ashburn-1", "logs_config": {"compartment_tag_filters": ["datadog:true", "env:prod"], "enabled": true, "enabled_services": ["oacnativeproduction"]}, "metrics_config": {"compartment_tag_filters": ["datadog:true", "env:prod"], "enabled": true, "excluded_services": ["oci_compute"]}, "resource_collection_enabled": true, "user_ocid": "ocid1.user.test"}, "id": "ocid1.tenancy.dummy_value", "type": "oci_tenancy"}} + When the request is sent + Then the response status is 201 Created + + @skip @team:DataDog/emerging-cloud-integrations + Scenario: Delete tenancy config for non-existing tenancy returns "No Content" response + Given new "DeleteTenancyConfig" request + And request contains "tenancy_ocid" parameter with value "ocid1.tenancy.fake" + When the request is sent + Then the response status is 204 No Content + + @team:DataDog/emerging-cloud-integrations + Scenario: Delete tenancy config returns "No Content" response + Given there is a valid "oci_tenancy" resource in the system + And new "DeleteTenancyConfig" request + And request contains "tenancy_ocid" parameter from "oci_tenancy.data.id" + When the request is sent + Then the response status is 204 No Content + + @generated @skip @team:DataDog/emerging-cloud-integrations + Scenario: Delete tenancy config returns "Not Found" response + Given new "DeleteTenancyConfig" request + And request contains "tenancy_ocid" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @team:DataDog/emerging-cloud-integrations + Scenario: Get tenancy config returns "Not Found" response + Given new "GetTenancyConfig" request + And request contains "tenancy_ocid" parameter with value "ocid1.tenancy.fake" + When the request is sent + Then the response status is 404 Not Found + + @team:DataDog/emerging-cloud-integrations + Scenario: Get tenancy config returns "OK" response + Given there is a valid "oci_tenancy" resource in the system + And new "GetTenancyConfig" request + And request contains "tenancy_ocid" parameter from "oci_tenancy.data.id" + When the request is sent + Then the response status is 200 OK + And the response "data.id" is equal to "{{oci_tenancy.data.id}}" + + @team:DataDog/emerging-cloud-integrations + Scenario: Get tenancy configs returns "OK" response + Given there is a valid "oci_tenancy" resource in the system + And new "GetTenancyConfigs" request + When the request is sent + Then the response status is 200 OK + And the response "data[0].id" is equal to "{{oci_tenancy.data.id}}" + + @team:DataDog/emerging-cloud-integrations + Scenario: Update tenancy config returns "Bad Request" response + Given there is a valid "oci_tenancy" resource in the system + And new "UpdateTenancyConfig" request + And request contains "tenancy_ocid" parameter from "oci_tenancy.data.id" + And body with value {"data": {"attributes": {"home_region": "us-ashburn-1", "logs_config": {"compartment_tag_filters": ["datadog:true", "env:prod"], "enabled": true, "enabled_services": ["objectstorage"]}, "metrics_config": {"compartment_tag_filters": ["datadog:true", "env:prod"], "enabled": true, "excluded_services": ["oci_compute"]}, "resource_collection_enabled": true, "user_ocid": "user.test"}, "id": "ocid1.tenancy.dummy_value", "type": "oci_tenancy"}} + When the request is sent + Then the response status is 400 Bad Request + + @team:DataDog/emerging-cloud-integrations + Scenario: Update tenancy config returns "Not Found" response + Given new "UpdateTenancyConfig" request + And request contains "tenancy_ocid" parameter with value "ocid1.tenancy.fake" + And body with value {"data": {"attributes": {"home_region": "us-ashburn-1", "logs_config": {"compartment_tag_filters": ["datadog:true", "env:prod"], "enabled": true, "enabled_services": ["objectstorage"]}, "metrics_config": {"compartment_tag_filters": ["datadog:true", "env:prod"], "enabled": true, "excluded_services": ["oci_compute"]}, "resource_collection_enabled": true, "user_ocid": "ocid1.user.test"}, "id": "ocid1.tenancy.fake", "type": "oci_tenancy"}} + When the request is sent + Then the response status is 404 Not Found + + @team:DataDog/emerging-cloud-integrations + Scenario: Update tenancy config returns "OK" response + Given there is a valid "oci_tenancy" resource in the system + And new "UpdateTenancyConfig" request + And request contains "tenancy_ocid" parameter from "oci_tenancy.data.id" + And body with value {"data": {"attributes": {"home_region": "us-sanjose-1", "metrics_config": {"compartment_tag_filters": ["datadog:true", "env:prod"], "enabled": false, "excluded_services": []}, "resource_collection_enabled": false, "user_ocid": "ocid1.user.test_updated"}, "id": "{{oci_tenancy.data.id}}", "type": "oci_tenancy"}} + When the request is sent + Then the response status is 200 OK + And the response "data.id" is equal to "{{oci_tenancy.data.id}}" + And the response "data.attributes.user_ocid" is equal to "{{oci_tenancy.data.attributes.user_ocid}}_updated" + And the response "data.attributes.home_region" is equal to "us-sanjose-1" diff --git a/tests/scenarios/features/v2/undo.json b/tests/scenarios/features/v2/undo.json index 6f0ee3848..4616e6f62 100644 --- a/tests/scenarios/features/v2/undo.json +++ b/tests/scenarios/features/v2/undo.json @@ -1234,6 +1234,43 @@ "type": "idempotent" } }, + "GetTenancyConfigs": { + "tag": "OCI Integration", + "undo": { + "type": "safe" + } + }, + "CreateTenancyConfig": { + "tag": "OCI Integration", + "undo": { + "operationId": "DeleteTenancyConfig", + "parameters": [ + { + "name": "tenancy_ocid", + "source": "data.id" + } + ], + "type": "unsafe" + } + }, + "DeleteTenancyConfig": { + "tag": "OCI Integration", + "undo": { + "type": "idempotent" + } + }, + "GetTenancyConfig": { + "tag": "OCI Integration", + "undo": { + "type": "safe" + } + }, + "UpdateTenancyConfig": { + "tag": "OCI Integration", + "undo": { + "type": "idempotent" + } + }, "ListOpsgenieServices": { "tag": "Opsgenie Integration", "undo": { diff --git a/tests/scenarios/function_mappings.rs b/tests/scenarios/function_mappings.rs index 8fa946fce..9a7c1a1ff 100644 --- a/tests/scenarios/function_mappings.rs +++ b/tests/scenarios/function_mappings.rs @@ -88,6 +88,7 @@ pub struct ApiInstances { pub v2_api_gcp_integration: Option, pub v2_api_microsoft_teams_integration: Option, + pub v2_api_oci_integration: Option, pub v2_api_opsgenie_integration: Option, pub v2_api_cloudflare_integration: @@ -634,6 +635,14 @@ pub fn initialize_api_instance(world: &mut DatadogWorld, api: String) { world.http_client.as_ref().unwrap().clone() )); } + "OCIIntegration" => { + world.api_instances.v2_api_oci_integration = Some( + datadogV2::api_oci_integration::OCIIntegrationAPI::with_client_and_config( + world.config.clone(), + world.http_client.as_ref().unwrap().clone(), + ), + ); + } "OpsgenieIntegration" => { world.api_instances.v2_api_opsgenie_integration = Some( datadogV2::api_opsgenie_integration::OpsgenieIntegrationAPI::with_client_and_config( @@ -2628,6 +2637,24 @@ pub fn collect_function_calls(world: &mut DatadogWorld) { "v2.UpdateWorkflowsWebhookHandle".into(), test_v2_update_workflows_webhook_handle, ); + world + .function_mappings + .insert("v2.GetTenancyConfigs".into(), test_v2_get_tenancy_configs); + world.function_mappings.insert( + "v2.CreateTenancyConfig".into(), + test_v2_create_tenancy_config, + ); + world.function_mappings.insert( + "v2.DeleteTenancyConfig".into(), + test_v2_delete_tenancy_config, + ); + world + .function_mappings + .insert("v2.GetTenancyConfig".into(), test_v2_get_tenancy_config); + world.function_mappings.insert( + "v2.UpdateTenancyConfig".into(), + test_v2_update_tenancy_config, + ); world.function_mappings.insert( "v2.ListOpsgenieServices".into(), test_v2_list_opsgenie_services, @@ -19368,6 +19395,134 @@ fn test_v2_update_workflows_webhook_handle( world.response.code = response.status.as_u16(); } +fn test_v2_get_tenancy_configs(world: &mut DatadogWorld, _parameters: &HashMap) { + let api = world + .api_instances + .v2_api_oci_integration + .as_ref() + .expect("api instance not found"); + let response = match block_on(api.get_tenancy_configs_with_http_info()) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + +fn test_v2_create_tenancy_config(world: &mut DatadogWorld, _parameters: &HashMap) { + let api = world + .api_instances + .v2_api_oci_integration + .as_ref() + .expect("api instance not found"); + let body = serde_json::from_value(_parameters.get("body").unwrap().clone()).unwrap(); + let response = match block_on(api.create_tenancy_config_with_http_info(body)) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + +fn test_v2_delete_tenancy_config(world: &mut DatadogWorld, _parameters: &HashMap) { + let api = world + .api_instances + .v2_api_oci_integration + .as_ref() + .expect("api instance not found"); + let tenancy_ocid = + serde_json::from_value(_parameters.get("tenancy_ocid").unwrap().clone()).unwrap(); + let response = match block_on(api.delete_tenancy_config_with_http_info(tenancy_ocid)) { + 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_tenancy_config(world: &mut DatadogWorld, _parameters: &HashMap) { + let api = world + .api_instances + .v2_api_oci_integration + .as_ref() + .expect("api instance not found"); + let tenancy_ocid = + serde_json::from_value(_parameters.get("tenancy_ocid").unwrap().clone()).unwrap(); + let response = match block_on(api.get_tenancy_config_with_http_info(tenancy_ocid)) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + +fn test_v2_update_tenancy_config(world: &mut DatadogWorld, _parameters: &HashMap) { + let api = world + .api_instances + .v2_api_oci_integration + .as_ref() + .expect("api instance not found"); + let tenancy_ocid = + serde_json::from_value(_parameters.get("tenancy_ocid").unwrap().clone()).unwrap(); + let body = serde_json::from_value(_parameters.get("body").unwrap().clone()).unwrap(); + let response = match block_on(api.update_tenancy_config_with_http_info(tenancy_ocid, 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_list_opsgenie_services(world: &mut DatadogWorld, _parameters: &HashMap) { let api = world .api_instances