From f1f43376ad9c82844b041e583b034e433669b562 Mon Sep 17 00:00:00 2001 From: "ci.datadog-api-spec" Date: Thu, 17 Oct 2024 13:05:51 +0000 Subject: [PATCH] Regenerate client from commit 97c53c7d of spec repo --- .apigentools-info | 8 +- .generator/schemas/v2/openapi.yaml | 450 +++++++++++ ...reateApplicationSecurityExclusionFilter.rs | 35 + ...eleteApplicationSecurityExclusionFilter.rs | 17 + ..._GetApplicationSecurityExclusionFilters.rs | 17 + ...ListApplicationSecurityExclusionFilters.rs | 15 + ...pdateApplicationSecurityExclusionFilter.rs | 41 + ..._application_security_exclusion_filters.rs | 763 ++++++++++++++++++ src/datadogV2/api/mod.rs | 1 + src/datadogV2/mod.rs | 1 + src/datadogV2/model/mod.rs | 36 + ...on_security_exclusion_filter_attributes.rs | 242 ++++++ ...rity_exclusion_filter_create_attributes.rs | 198 +++++ ...n_security_exclusion_filter_create_data.rs | 117 +++ ...ecurity_exclusion_filter_create_request.rs | 96 +++ ...lication_security_exclusion_filter_data.rs | 157 ++++ ...curity_exclusion_filter_list_attributes.rs | 242 ++++++ ...security_exclusion_filter_list_response.rs | 110 +++ ...rity_exclusion_filter_list_rules_target.rs | 111 +++ ...exclusion_filter_list_rules_target_tags.rs | 122 +++ ...tion_security_exclusion_filter_metadata.rs | 158 ++++ ...tion_security_exclusion_filter_response.rs | 110 +++ ..._security_exclusion_filter_rules_target.rs | 105 +++ ...ication_security_exclusion_filter_scope.rs | 122 +++ ...lication_security_exclusion_filter_type.rs | 48 ++ ...rity_exclusion_filter_update_attributes.rs | 198 +++++ ...n_security_exclusion_filter_update_data.rs | 134 +++ ...ecurity_exclusion_filter_update_request.rs | 96 +++ ...ion_security_exclusion_list_filter_data.rs | 158 ++++ ...ication_security_exclusion_filters.feature | 89 ++ tests/scenarios/features/v2/given.json | 12 + tests/scenarios/features/v2/undo.json | 37 + tests/scenarios/function_mappings.rs | 239 +++++- 33 files changed, 4240 insertions(+), 45 deletions(-) create mode 100644 examples/v2_application-security-exclusion-filters_CreateApplicationSecurityExclusionFilter.rs create mode 100644 examples/v2_application-security-exclusion-filters_DeleteApplicationSecurityExclusionFilter.rs create mode 100644 examples/v2_application-security-exclusion-filters_GetApplicationSecurityExclusionFilters.rs create mode 100644 examples/v2_application-security-exclusion-filters_ListApplicationSecurityExclusionFilters.rs create mode 100644 examples/v2_application-security-exclusion-filters_UpdateApplicationSecurityExclusionFilter.rs create mode 100644 src/datadogV2/api/api_application_security_exclusion_filters.rs create mode 100644 src/datadogV2/model/model_application_security_exclusion_filter_attributes.rs create mode 100644 src/datadogV2/model/model_application_security_exclusion_filter_create_attributes.rs create mode 100644 src/datadogV2/model/model_application_security_exclusion_filter_create_data.rs create mode 100644 src/datadogV2/model/model_application_security_exclusion_filter_create_request.rs create mode 100644 src/datadogV2/model/model_application_security_exclusion_filter_data.rs create mode 100644 src/datadogV2/model/model_application_security_exclusion_filter_list_attributes.rs create mode 100644 src/datadogV2/model/model_application_security_exclusion_filter_list_response.rs create mode 100644 src/datadogV2/model/model_application_security_exclusion_filter_list_rules_target.rs create mode 100644 src/datadogV2/model/model_application_security_exclusion_filter_list_rules_target_tags.rs create mode 100644 src/datadogV2/model/model_application_security_exclusion_filter_metadata.rs create mode 100644 src/datadogV2/model/model_application_security_exclusion_filter_response.rs create mode 100644 src/datadogV2/model/model_application_security_exclusion_filter_rules_target.rs create mode 100644 src/datadogV2/model/model_application_security_exclusion_filter_scope.rs create mode 100644 src/datadogV2/model/model_application_security_exclusion_filter_type.rs create mode 100644 src/datadogV2/model/model_application_security_exclusion_filter_update_attributes.rs create mode 100644 src/datadogV2/model/model_application_security_exclusion_filter_update_data.rs create mode 100644 src/datadogV2/model/model_application_security_exclusion_filter_update_request.rs create mode 100644 src/datadogV2/model/model_application_security_exclusion_list_filter_data.rs create mode 100644 tests/scenarios/features/v2/application_security_exclusion_filters.feature diff --git a/.apigentools-info b/.apigentools-info index 79742d6b7..748b8cd43 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.6.6", - "regenerated": "2024-10-10 19:45:59.732627", - "spec_repo_commit": "049920eb" + "regenerated": "2024-10-17 13:00:24.788844", + "spec_repo_commit": "97c53c7d" }, "v2": { "apigentools_version": "1.6.6", - "regenerated": "2024-10-10 19:45:59.753615", - "spec_repo_commit": "049920eb" + "regenerated": "2024-10-17 13:00:24.807766", + "spec_repo_commit": "97c53c7d" } } } \ No newline at end of file diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index c592c7ff2..a765d8767 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -137,6 +137,14 @@ components: required: false schema: $ref: '#/components/schemas/ApplicationKeysSort' + ApplicationSecurityExclusionFilterID: + description: The ID of the exclusion filter. + example: 3b5-v82-ns6 + in: path + name: exclusion_filter_id + required: true + schema: + type: string ArchiveID: description: The ID of the archive. in: path @@ -1204,6 +1212,326 @@ components: type: string x-enum-varnames: - APPLICATION_KEYS + ApplicationSecurityExclusionFilterAttributes: + description: The attributes of the Application Security exclusion filter. + properties: + description: + description: A description for the exclusion filter. + example: Test exclude path + type: string + enabled: + description: Indicates whether the exclusion filter is enabled. + example: false + type: boolean + ip_list: + description: The IPs list for the exclusion filter. + items: + example: 127.0.0.1 + type: string + type: array + metadata: + $ref: '#/components/schemas/ApplicationSecurityExclusionFilterMetadata' + parameters: + description: A list of parameters for the exclusion filter. + items: + example: list.search.query + type: string + type: array + path_glob: + description: The path glob for the exclusion filter. + example: /lfi_include/* + type: string + rules_target: + description: A list of rules targeted by the exclusion filter. + items: + $ref: '#/components/schemas/ApplicationSecurityExclusionFilterRulesTarget' + type: array + scope: + description: The scope of the exclusion filter. + items: + $ref: '#/components/schemas/ApplicationSecurityExclusionFilterScope' + type: array + type: object + ApplicationSecurityExclusionFilterCreateAttributes: + description: Create a new Application Security exclusion filter. + properties: + description: + description: A description for the exclusion filter. + example: Test exclude path + type: string + enabled: + description: Indicates whether the exclusion filter is enabled. + example: false + type: boolean + ip_list: + description: The IPs list for the exclusion filter. + items: + example: 127.0.0.1 + type: string + type: array + parameters: + description: A list of parameters for the exclusion filter. + items: + example: list.search.query + type: string + type: array + path_glob: + description: The path glob for the exclusion filter. + example: /lfi_include/* + type: string + rules_target: + description: A list of rules targeted by the exclusion filter. + items: + $ref: '#/components/schemas/ApplicationSecurityExclusionFilterRulesTarget' + type: array + scope: + description: The scope of the exclusion filter. + items: + $ref: '#/components/schemas/ApplicationSecurityExclusionFilterScope' + type: array + required: + - description + - enabled + - path_glob + ApplicationSecurityExclusionFilterCreateData: + description: Object for a single exclusion filter. + properties: + attributes: + $ref: '#/components/schemas/ApplicationSecurityExclusionFilterCreateAttributes' + type: + $ref: '#/components/schemas/ApplicationSecurityExclusionFilterType' + required: + - attributes + - type + type: object + ApplicationSecurityExclusionFilterCreateRequest: + description: Request object that includes the exclusion filter to create. + properties: + data: + $ref: '#/components/schemas/ApplicationSecurityExclusionFilterCreateData' + required: + - data + type: object + ApplicationSecurityExclusionFilterData: + description: Object for a single Exclusion filter. + properties: + attributes: + $ref: '#/components/schemas/ApplicationSecurityExclusionFilterAttributes' + id: + description: The ID of the Exclusion filter. + example: 3dd-0uc-h1s + type: string + type: + $ref: '#/components/schemas/ApplicationSecurityExclusionFilterType' + type: object + ApplicationSecurityExclusionFilterID: + description: The ID of the exclusion filter. + example: 3dd-0uc-h1s + type: string + ApplicationSecurityExclusionFilterListAttributes: + description: The attributes of the Application Security exclusion filter. + properties: + description: + description: A description for the exclusion filter. + example: Test exclude path + type: string + enabled: + description: Indicates whether the exclusion filter is enabled. + example: false + type: boolean + ip_list: + description: The IPs list for the exclusion filter. + items: + example: 127.0.0.1 + type: string + type: array + metadata: + $ref: '#/components/schemas/ApplicationSecurityExclusionFilterMetadata' + parameters: + description: A list of parameters for the exclusion filter. + items: + example: list.search.query + type: string + type: array + path_glob: + description: The path glob for the exclusion filter. + example: /lfi_include/* + type: string + rules_target: + description: A list of rules targeted by the exclusion filter. + items: + $ref: '#/components/schemas/ApplicationSecurityExclusionFilterListRulesTarget' + type: array + scope: + description: The scope of the exclusion filter. + items: + $ref: '#/components/schemas/ApplicationSecurityExclusionFilterScope' + type: array + type: object + ApplicationSecurityExclusionFilterListResponse: + description: Response object that includes a list of exclusion filters. + properties: + data: + description: The Application Security exclusion filter response data. + items: + $ref: '#/components/schemas/ApplicationSecurityExclusionListFilterData' + type: array + type: object + ApplicationSecurityExclusionFilterListRulesTarget: + description: A rule targeted by the exclusion filter. + properties: + tags: + $ref: '#/components/schemas/ApplicationSecurityExclusionFilterListRulesTargetTags' + type: object + ApplicationSecurityExclusionFilterListRulesTargetTags: + description: Tags identifying the category and type of the targeted rule. + properties: + category: + description: The category of the rule. + example: attack_attempt + type: string + type: + description: The type of the rule. + example: lfi + type: string + type: object + ApplicationSecurityExclusionFilterMetadata: + description: Metadata about the exclusion filter. + properties: + added_at: + description: The timestamp when the exclusion filter was added. + example: '2023-05-04T15:26:41Z' + format: date-time + type: string + added_by: + description: The email address of the user who added the exclusion filter. + example: xxxx@xxxx.com + type: string + modified_at: + description: The timestamp when the exclusion filter was last modified. + example: '2023-05-30T15:45:51Z' + format: date-time + type: string + modified_by: + description: The email address of the user who last modified the exclusion + filter. + example: xxx@xxx.com + type: string + type: object + ApplicationSecurityExclusionFilterResponse: + description: Response object that includes a list of exclusion filters. + properties: + data: + description: The Application Security exclusion filter data. + items: + $ref: '#/components/schemas/ApplicationSecurityExclusionFilterData' + type: array + type: object + ApplicationSecurityExclusionFilterRulesTarget: + description: A rule targeted by the exclusion filter. + properties: + rule_id: + description: The ID of the targeted rule. + example: dog-913-009 + type: string + type: object + ApplicationSecurityExclusionFilterScope: + description: The scope of the exclusion filter. + properties: + env: + description: The environment scope for the exclusion filter. + example: dd-appsec-php-support + type: string + service: + description: The service scope for the exclusion filter. + example: anil-php-weblog + type: string + type: object + ApplicationSecurityExclusionFilterType: + default: exclusion_filter + description: The type of the resource. The value should always be `exclusion_filter`. + enum: + - exclusion_filter + example: exclusion_filter + type: string + x-enum-varnames: + - EXCLUSION_FILTER + ApplicationSecurityExclusionFilterUpdateAttributes: + description: Update an existing Application Security Exclusion filter. + properties: + description: + description: The description of the Exclusion filter. + example: My Exclusion filter + type: string + enabled: + description: Whether the Exclusion filter is enabled. + example: true + type: boolean + ip_list: + description: The IPs list for the exclusion filter. + items: + example: 127.0.0.1 + type: string + type: array + parameters: + description: A list of parameters for the exclusion filter. + items: + example: list.search.query + type: string + type: array + path_glob: + description: The path glob for the exclusion filter. + example: /lfi_include/* + type: string + rules_target: + description: A list of rules targeted by the exclusion filter. + items: + $ref: '#/components/schemas/ApplicationSecurityExclusionFilterRulesTarget' + type: array + scope: + description: The scope of the exclusion filter. + items: + $ref: '#/components/schemas/ApplicationSecurityExclusionFilterScope' + type: array + required: + - description + - enabled + - path_glob + type: object + ApplicationSecurityExclusionFilterUpdateData: + description: Object for a single Exclusion filter. + properties: + attributes: + $ref: '#/components/schemas/ApplicationSecurityExclusionFilterUpdateAttributes' + id: + $ref: '#/components/schemas/ApplicationSecurityExclusionFilterID' + type: + $ref: '#/components/schemas/ApplicationSecurityExclusionFilterType' + required: + - attributes + - type + type: object + ApplicationSecurityExclusionFilterUpdateRequest: + description: Request object that includes the Exclusion filter with the attributes + to update. + properties: + data: + $ref: '#/components/schemas/ApplicationSecurityExclusionFilterUpdateData' + required: + - data + type: object + ApplicationSecurityExclusionListFilterData: + description: Object for a single Exclusion filter. + properties: + attributes: + $ref: '#/components/schemas/ApplicationSecurityExclusionFilterListAttributes' + id: + description: The ID of the Exclusion filter. + example: 3dd-0uc-h1s + type: string + type: + $ref: '#/components/schemas/ApplicationSecurityExclusionFilterType' + type: object AuditLogsEvent: description: Object description of an Audit Logs event after it is processed and stored by Datadog. @@ -34924,6 +35252,125 @@ paths: We are gradually onboarding support for more sources. If you have any feedback, contact [Datadog Support](https://docs.datadoghq.com/help/).' + /api/v2/remote_config/products/asm/waf/exclusion_filters: + get: + description: Retrieve a list of Application Security exclusion filters. + operationId: ListApplicationSecurityExclusionFilters + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/ApplicationSecurityExclusionFilterListResponse' + description: OK + '403': + $ref: '#/components/responses/NotAuthorizedResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: List all ASM Exclusion Filters + tags: + - Application Security Exclusion Filters + post: + description: Create a new exclusion filter with the given parameters. + operationId: CreateApplicationSecurityExclusionFilter + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ApplicationSecurityExclusionFilterCreateRequest' + description: The definition of the new Exclusion filter. + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/ApplicationSecurityExclusionFilterResponse' + description: OK + '400': + $ref: '#/components/responses/BadRequestResponse' + '403': + $ref: '#/components/responses/NotAuthorizedResponse' + '409': + $ref: '#/components/responses/ConflictResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: Create an ASM Exclusion filter + tags: + - Application Security Exclusion Filters + x-codegen-request-body-name: body + /api/v2/remote_config/products/asm/waf/exclusion_filters/{exclusion_filter_id}: + delete: + description: Delete a specific Application Security Exclusion filter. + operationId: DeleteApplicationSecurityExclusionFilter + parameters: + - $ref: '#/components/parameters/ApplicationSecurityExclusionFilterID' + responses: + '204': + description: OK + '403': + $ref: '#/components/responses/NotAuthorizedResponse' + '404': + $ref: '#/components/responses/NotFoundResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: Delete an ASM Exclusion Filter + tags: + - Application Security Exclusion Filters + get: + description: Retrieve a specific Application Security exclusion filter by ID. + operationId: GetApplicationSecurityExclusionFilters + parameters: + - $ref: '#/components/parameters/ApplicationSecurityExclusionFilterID' + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/ApplicationSecurityExclusionFilterResponse' + description: OK + '403': + $ref: '#/components/responses/NotAuthorizedResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: Get a specific ASM Exclusion Filter + tags: + - Application Security Exclusion Filters + patch: + description: 'Update a specific Exclusion filter. + + Returns the Exclusion filter object when the request is successful.' + operationId: UpdateApplicationSecurityExclusionFilter + parameters: + - $ref: '#/components/parameters/ApplicationSecurityExclusionFilterID' + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ApplicationSecurityExclusionFilterUpdateRequest' + description: New definition of the Exclusion filter. + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/ApplicationSecurityExclusionFilterResponse' + description: OK + '400': + $ref: '#/components/responses/BadRequestResponse' + '403': + $ref: '#/components/responses/NotAuthorizedResponse' + '404': + $ref: '#/components/responses/NotFoundResponse' + '409': + $ref: '#/components/responses/ConcurrentModificationResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: Update an ASM Exclusion filter + tags: + - Application Security Exclusion Filters + x-codegen-request-body-name: body /api/v2/remote_config/products/cws/agent_rules: get: description: Get the list of Cloud Security Management Threats Agent rules. @@ -41311,6 +41758,9 @@ tags: description: Find out more at url: https://docs.datadoghq.com/tracing/trace_pipeline/trace_retention/ name: APM Retention Filters +- description: Exclusion filters in Application Security libraries are used to circumvent + false positives in protection. + name: Application Security Exclusion Filters - description: Search your Audit Logs events over HTTP. name: Audit - description: '[The AuthN Mappings API](https://docs.datadoghq.com/account_management/authn_mapping/?tab=example) diff --git a/examples/v2_application-security-exclusion-filters_CreateApplicationSecurityExclusionFilter.rs b/examples/v2_application-security-exclusion-filters_CreateApplicationSecurityExclusionFilter.rs new file mode 100644 index 000000000..d48cdb768 --- /dev/null +++ b/examples/v2_application-security-exclusion-filters_CreateApplicationSecurityExclusionFilter.rs @@ -0,0 +1,35 @@ +// Create an ASM Exclusion filter returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_application_security_exclusion_filters::ApplicationSecurityExclusionFiltersAPI; +use datadog_api_client::datadogV2::model::ApplicationSecurityExclusionFilterCreateAttributes; +use datadog_api_client::datadogV2::model::ApplicationSecurityExclusionFilterCreateData; +use datadog_api_client::datadogV2::model::ApplicationSecurityExclusionFilterCreateRequest; +use datadog_api_client::datadogV2::model::ApplicationSecurityExclusionFilterRulesTarget; +use datadog_api_client::datadogV2::model::ApplicationSecurityExclusionFilterScope; +use datadog_api_client::datadogV2::model::ApplicationSecurityExclusionFilterType; + +#[tokio::main] +async fn main() { + let body = ApplicationSecurityExclusionFilterCreateRequest::new( + ApplicationSecurityExclusionFilterCreateData::new( + ApplicationSecurityExclusionFilterCreateAttributes::new( + "my description".to_string(), + true, + "*".to_string(), + ) + .rules_target(vec![ApplicationSecurityExclusionFilterRulesTarget::new()]) + .scope(vec![ApplicationSecurityExclusionFilterScope::new() + .env("staging".to_string()) + .service("container-resolver".to_string())]), + ApplicationSecurityExclusionFilterType::EXCLUSION_FILTER, + ), + ); + let configuration = datadog::Configuration::new(); + let api = ApplicationSecurityExclusionFiltersAPI::with_config(configuration); + let resp = api.create_application_security_exclusion_filter(body).await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_application-security-exclusion-filters_DeleteApplicationSecurityExclusionFilter.rs b/examples/v2_application-security-exclusion-filters_DeleteApplicationSecurityExclusionFilter.rs new file mode 100644 index 000000000..72443525f --- /dev/null +++ b/examples/v2_application-security-exclusion-filters_DeleteApplicationSecurityExclusionFilter.rs @@ -0,0 +1,17 @@ +// Delete an ASM Exclusion Filter returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_application_security_exclusion_filters::ApplicationSecurityExclusionFiltersAPI; + +#[tokio::main] +async fn main() { + let configuration = datadog::Configuration::new(); + let api = ApplicationSecurityExclusionFiltersAPI::with_config(configuration); + let resp = api + .delete_application_security_exclusion_filter("exclusion_filter_id".to_string()) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_application-security-exclusion-filters_GetApplicationSecurityExclusionFilters.rs b/examples/v2_application-security-exclusion-filters_GetApplicationSecurityExclusionFilters.rs new file mode 100644 index 000000000..8e34ebcbf --- /dev/null +++ b/examples/v2_application-security-exclusion-filters_GetApplicationSecurityExclusionFilters.rs @@ -0,0 +1,17 @@ +// Get a specific ASM Exclusion Filter returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_application_security_exclusion_filters::ApplicationSecurityExclusionFiltersAPI; + +#[tokio::main] +async fn main() { + let configuration = datadog::Configuration::new(); + let api = ApplicationSecurityExclusionFiltersAPI::with_config(configuration); + let resp = api + .get_application_security_exclusion_filters("exclusion_filter_id".to_string()) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_application-security-exclusion-filters_ListApplicationSecurityExclusionFilters.rs b/examples/v2_application-security-exclusion-filters_ListApplicationSecurityExclusionFilters.rs new file mode 100644 index 000000000..8d11b670f --- /dev/null +++ b/examples/v2_application-security-exclusion-filters_ListApplicationSecurityExclusionFilters.rs @@ -0,0 +1,15 @@ +// List all ASM Exclusion Filters returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_application_security_exclusion_filters::ApplicationSecurityExclusionFiltersAPI; + +#[tokio::main] +async fn main() { + let configuration = datadog::Configuration::new(); + let api = ApplicationSecurityExclusionFiltersAPI::with_config(configuration); + let resp = api.list_application_security_exclusion_filters().await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/examples/v2_application-security-exclusion-filters_UpdateApplicationSecurityExclusionFilter.rs b/examples/v2_application-security-exclusion-filters_UpdateApplicationSecurityExclusionFilter.rs new file mode 100644 index 000000000..ac5d72e86 --- /dev/null +++ b/examples/v2_application-security-exclusion-filters_UpdateApplicationSecurityExclusionFilter.rs @@ -0,0 +1,41 @@ +// Update an ASM Exclusion filter returns "OK" response +use datadog_api_client::datadog; +use datadog_api_client::datadogV2::api_application_security_exclusion_filters::ApplicationSecurityExclusionFiltersAPI; +use datadog_api_client::datadogV2::model::ApplicationSecurityExclusionFilterRulesTarget; +use datadog_api_client::datadogV2::model::ApplicationSecurityExclusionFilterScope; +use datadog_api_client::datadogV2::model::ApplicationSecurityExclusionFilterType; +use datadog_api_client::datadogV2::model::ApplicationSecurityExclusionFilterUpdateAttributes; +use datadog_api_client::datadogV2::model::ApplicationSecurityExclusionFilterUpdateData; +use datadog_api_client::datadogV2::model::ApplicationSecurityExclusionFilterUpdateRequest; + +#[tokio::main] +async fn main() { + let body = ApplicationSecurityExclusionFilterUpdateRequest::new( + ApplicationSecurityExclusionFilterUpdateData::new( + ApplicationSecurityExclusionFilterUpdateAttributes::new( + "My Exclusion filter".to_string(), + true, + "/lfi_include/*".to_string(), + ) + .ip_list(vec!["127.0.0.1".to_string()]) + .parameters(vec!["list.search.query".to_string()]) + .rules_target(vec![ApplicationSecurityExclusionFilterRulesTarget::new() + .rule_id("dog-913-009".to_string())]) + .scope(vec![ApplicationSecurityExclusionFilterScope::new() + .env("dd-appsec-php-support".to_string()) + .service("anil-php-weblog".to_string())]), + ApplicationSecurityExclusionFilterType::EXCLUSION_FILTER, + ) + .id("3dd-0uc-h1s".to_string()), + ); + let configuration = datadog::Configuration::new(); + let api = ApplicationSecurityExclusionFiltersAPI::with_config(configuration); + let resp = api + .update_application_security_exclusion_filter("exclusion_filter_id".to_string(), body) + .await; + if let Ok(value) = resp { + println!("{:#?}", value); + } else { + println!("{:#?}", resp.unwrap_err()); + } +} diff --git a/src/datadogV2/api/api_application_security_exclusion_filters.rs b/src/datadogV2/api/api_application_security_exclusion_filters.rs new file mode 100644 index 000000000..e23006f11 --- /dev/null +++ b/src/datadogV2/api/api_application_security_exclusion_filters.rs @@ -0,0 +1,763 @@ +// 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; + +/// CreateApplicationSecurityExclusionFilterError is a struct for typed errors of method [`ApplicationSecurityExclusionFiltersAPI::create_application_security_exclusion_filter`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum CreateApplicationSecurityExclusionFilterError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// DeleteApplicationSecurityExclusionFilterError is a struct for typed errors of method [`ApplicationSecurityExclusionFiltersAPI::delete_application_security_exclusion_filter`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum DeleteApplicationSecurityExclusionFilterError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// GetApplicationSecurityExclusionFiltersError is a struct for typed errors of method [`ApplicationSecurityExclusionFiltersAPI::get_application_security_exclusion_filters`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum GetApplicationSecurityExclusionFiltersError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// ListApplicationSecurityExclusionFiltersError is a struct for typed errors of method [`ApplicationSecurityExclusionFiltersAPI::list_application_security_exclusion_filters`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ListApplicationSecurityExclusionFiltersError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// UpdateApplicationSecurityExclusionFilterError is a struct for typed errors of method [`ApplicationSecurityExclusionFiltersAPI::update_application_security_exclusion_filter`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum UpdateApplicationSecurityExclusionFilterError { + APIErrorResponse(crate::datadogV2::model::APIErrorResponse), + UnknownValue(serde_json::Value), +} + +/// Exclusion filters in Application Security libraries are used to circumvent false positives in protection. +#[derive(Debug, Clone)] +pub struct ApplicationSecurityExclusionFiltersAPI { + config: datadog::Configuration, + client: reqwest_middleware::ClientWithMiddleware, +} + +impl Default for ApplicationSecurityExclusionFiltersAPI { + fn default() -> Self { + Self::with_config(datadog::Configuration::default()) + } +} + +impl ApplicationSecurityExclusionFiltersAPI { + 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 exclusion filter with the given parameters. + pub async fn create_application_security_exclusion_filter( + &self, + body: crate::datadogV2::model::ApplicationSecurityExclusionFilterCreateRequest, + ) -> Result< + crate::datadogV2::model::ApplicationSecurityExclusionFilterResponse, + datadog::Error, + > { + match self + .create_application_security_exclusion_filter_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 exclusion filter with the given parameters. + pub async fn create_application_security_exclusion_filter_with_http_info( + &self, + body: crate::datadogV2::model::ApplicationSecurityExclusionFilterCreateRequest, + ) -> Result< + datadog::ResponseContent< + crate::datadogV2::model::ApplicationSecurityExclusionFilterResponse, + >, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.create_application_security_exclusion_filter"; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/remote_config/products/asm/waf/exclusion_filters", + 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::< + crate::datadogV2::model::ApplicationSecurityExclusionFilterResponse, + >(&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 a specific Application Security Exclusion filter. + pub async fn delete_application_security_exclusion_filter( + &self, + exclusion_filter_id: String, + ) -> Result<(), datadog::Error> { + match self + .delete_application_security_exclusion_filter_with_http_info(exclusion_filter_id) + .await + { + Ok(_) => Ok(()), + Err(err) => Err(err), + } + } + + /// Delete a specific Application Security Exclusion filter. + pub async fn delete_application_security_exclusion_filter_with_http_info( + &self, + exclusion_filter_id: String, + ) -> Result< + datadog::ResponseContent<()>, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.delete_application_security_exclusion_filter"; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/remote_config/products/asm/waf/exclusion_filters/{exclusion_filter_id}", + local_configuration.get_operation_host(operation_id), + exclusion_filter_id = datadog::urlencode(exclusion_filter_id) + ); + let mut local_req_builder = + local_client.request(reqwest::Method::DELETE, local_uri_str.as_str()); + + // build headers + let mut headers = HeaderMap::new(); + headers.insert("Accept", HeaderValue::from_static("*/*")); + + // build user agent + match HeaderValue::from_str(local_configuration.user_agent.as_str()) { + Ok(user_agent) => headers.insert(reqwest::header::USER_AGENT, user_agent), + Err(e) => { + log::warn!("Failed to parse user agent header: {e}, falling back to default"); + headers.insert( + reqwest::header::USER_AGENT, + HeaderValue::from_static(datadog::DEFAULT_USER_AGENT.as_str()), + ) + } + }; + + // build auth + if let Some(local_key) = local_configuration.auth_keys.get("apiKeyAuth") { + headers.insert( + "DD-API-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-API-KEY header"), + ); + }; + if let Some(local_key) = local_configuration.auth_keys.get("appKeyAuth") { + headers.insert( + "DD-APPLICATION-KEY", + HeaderValue::from_str(local_key.key.as_str()) + .expect("failed to parse DD-APPLICATION-KEY header"), + ); + }; + + local_req_builder = local_req_builder.headers(headers); + let local_req = local_req_builder.build()?; + log::debug!("request content: {:?}", local_req.body()); + let local_resp = local_client.execute(local_req).await?; + + let local_status = local_resp.status(); + let local_content = local_resp.text().await?; + log::debug!("response content: {}", local_content); + + if !local_status.is_client_error() && !local_status.is_server_error() { + Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: None, + }) + } else { + let local_entity: Option = + serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } + + /// Retrieve a specific Application Security exclusion filter by ID. + pub async fn get_application_security_exclusion_filters( + &self, + exclusion_filter_id: String, + ) -> Result< + crate::datadogV2::model::ApplicationSecurityExclusionFilterResponse, + datadog::Error, + > { + match self + .get_application_security_exclusion_filters_with_http_info(exclusion_filter_id) + .await + { + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(datadog::Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } + Err(err) => Err(err), + } + } + + /// Retrieve a specific Application Security exclusion filter by ID. + pub async fn get_application_security_exclusion_filters_with_http_info( + &self, + exclusion_filter_id: String, + ) -> Result< + datadog::ResponseContent< + crate::datadogV2::model::ApplicationSecurityExclusionFilterResponse, + >, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.get_application_security_exclusion_filters"; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/remote_config/products/asm/waf/exclusion_filters/{exclusion_filter_id}", + local_configuration.get_operation_host(operation_id), + exclusion_filter_id = datadog::urlencode(exclusion_filter_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::< + crate::datadogV2::model::ApplicationSecurityExclusionFilterResponse, + >(&local_content) + { + Ok(e) => { + return Ok(datadog::ResponseContent { + status: local_status, + content: local_content, + entity: Some(e), + }) + } + Err(e) => return Err(datadog::Error::Serde(e)), + }; + } else { + let local_entity: Option = + serde_json::from_str(&local_content).ok(); + let local_error = datadog::ResponseContent { + status: local_status, + content: local_content, + entity: local_entity, + }; + Err(datadog::Error::ResponseError(local_error)) + } + } + + /// Retrieve a list of Application Security exclusion filters. + pub async fn list_application_security_exclusion_filters( + &self, + ) -> Result< + crate::datadogV2::model::ApplicationSecurityExclusionFilterListResponse, + datadog::Error, + > { + match self + .list_application_security_exclusion_filters_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), + } + } + + /// Retrieve a list of Application Security exclusion filters. + pub async fn list_application_security_exclusion_filters_with_http_info( + &self, + ) -> Result< + datadog::ResponseContent< + crate::datadogV2::model::ApplicationSecurityExclusionFilterListResponse, + >, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.list_application_security_exclusion_filters"; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/remote_config/products/asm/waf/exclusion_filters", + 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::< + crate::datadogV2::model::ApplicationSecurityExclusionFilterListResponse, + >(&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 a specific Exclusion filter. + /// Returns the Exclusion filter object when the request is successful. + pub async fn update_application_security_exclusion_filter( + &self, + exclusion_filter_id: String, + body: crate::datadogV2::model::ApplicationSecurityExclusionFilterUpdateRequest, + ) -> Result< + crate::datadogV2::model::ApplicationSecurityExclusionFilterResponse, + datadog::Error, + > { + match self + .update_application_security_exclusion_filter_with_http_info(exclusion_filter_id, body) + .await + { + Ok(response_content) => { + if let Some(e) = response_content.entity { + Ok(e) + } else { + Err(datadog::Error::Serde(serde::de::Error::custom( + "response content was None", + ))) + } + } + Err(err) => Err(err), + } + } + + /// Update a specific Exclusion filter. + /// Returns the Exclusion filter object when the request is successful. + pub async fn update_application_security_exclusion_filter_with_http_info( + &self, + exclusion_filter_id: String, + body: crate::datadogV2::model::ApplicationSecurityExclusionFilterUpdateRequest, + ) -> Result< + datadog::ResponseContent< + crate::datadogV2::model::ApplicationSecurityExclusionFilterResponse, + >, + datadog::Error, + > { + let local_configuration = &self.config; + let operation_id = "v2.update_application_security_exclusion_filter"; + + let local_client = &self.client; + + let local_uri_str = format!( + "{}/api/v2/remote_config/products/asm/waf/exclusion_filters/{exclusion_filter_id}", + local_configuration.get_operation_host(operation_id), + exclusion_filter_id = datadog::urlencode(exclusion_filter_id) + ); + 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::< + crate::datadogV2::model::ApplicationSecurityExclusionFilterResponse, + >(&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 a565b682c..a3e34c8e7 100644 --- a/src/datadogV2/api/mod.rs +++ b/src/datadogV2/api/mod.rs @@ -4,6 +4,7 @@ pub mod api_api_management; pub mod api_apm_retention_filters; +pub mod api_application_security_exclusion_filters; pub mod api_audit; pub mod api_authn_mappings; pub mod api_case_management; diff --git a/src/datadogV2/mod.rs b/src/datadogV2/mod.rs index cf52d2407..22b1db532 100644 --- a/src/datadogV2/mod.rs +++ b/src/datadogV2/mod.rs @@ -5,6 +5,7 @@ pub mod api; pub use self::api::api_api_management; pub use self::api::api_apm_retention_filters; +pub use self::api::api_application_security_exclusion_filters; pub use self::api::api_audit; pub use self::api::api_authn_mappings; pub use self::api::api_case_management; diff --git a/src/datadogV2/model/mod.rs b/src/datadogV2/model/mod.rs index daa37d736..6bb75bbd5 100644 --- a/src/datadogV2/model/mod.rs +++ b/src/datadogV2/model/mod.rs @@ -2132,6 +2132,42 @@ pub mod model_timeseries_response_series; pub use self::model_timeseries_response_series::TimeseriesResponseSeries; pub mod model_timeseries_formula_response_type; pub use self::model_timeseries_formula_response_type::TimeseriesFormulaResponseType; +pub mod model_application_security_exclusion_filter_list_response; +pub use self::model_application_security_exclusion_filter_list_response::ApplicationSecurityExclusionFilterListResponse; +pub mod model_application_security_exclusion_list_filter_data; +pub use self::model_application_security_exclusion_list_filter_data::ApplicationSecurityExclusionListFilterData; +pub mod model_application_security_exclusion_filter_list_attributes; +pub use self::model_application_security_exclusion_filter_list_attributes::ApplicationSecurityExclusionFilterListAttributes; +pub mod model_application_security_exclusion_filter_metadata; +pub use self::model_application_security_exclusion_filter_metadata::ApplicationSecurityExclusionFilterMetadata; +pub mod model_application_security_exclusion_filter_list_rules_target; +pub use self::model_application_security_exclusion_filter_list_rules_target::ApplicationSecurityExclusionFilterListRulesTarget; +pub mod model_application_security_exclusion_filter_list_rules_target_tags; +pub use self::model_application_security_exclusion_filter_list_rules_target_tags::ApplicationSecurityExclusionFilterListRulesTargetTags; +pub mod model_application_security_exclusion_filter_scope; +pub use self::model_application_security_exclusion_filter_scope::ApplicationSecurityExclusionFilterScope; +pub mod model_application_security_exclusion_filter_type; +pub use self::model_application_security_exclusion_filter_type::ApplicationSecurityExclusionFilterType; +pub mod model_application_security_exclusion_filter_create_request; +pub use self::model_application_security_exclusion_filter_create_request::ApplicationSecurityExclusionFilterCreateRequest; +pub mod model_application_security_exclusion_filter_create_data; +pub use self::model_application_security_exclusion_filter_create_data::ApplicationSecurityExclusionFilterCreateData; +pub mod model_application_security_exclusion_filter_create_attributes; +pub use self::model_application_security_exclusion_filter_create_attributes::ApplicationSecurityExclusionFilterCreateAttributes; +pub mod model_application_security_exclusion_filter_rules_target; +pub use self::model_application_security_exclusion_filter_rules_target::ApplicationSecurityExclusionFilterRulesTarget; +pub mod model_application_security_exclusion_filter_response; +pub use self::model_application_security_exclusion_filter_response::ApplicationSecurityExclusionFilterResponse; +pub mod model_application_security_exclusion_filter_data; +pub use self::model_application_security_exclusion_filter_data::ApplicationSecurityExclusionFilterData; +pub mod model_application_security_exclusion_filter_attributes; +pub use self::model_application_security_exclusion_filter_attributes::ApplicationSecurityExclusionFilterAttributes; +pub mod model_application_security_exclusion_filter_update_request; +pub use self::model_application_security_exclusion_filter_update_request::ApplicationSecurityExclusionFilterUpdateRequest; +pub mod model_application_security_exclusion_filter_update_data; +pub use self::model_application_security_exclusion_filter_update_data::ApplicationSecurityExclusionFilterUpdateData; +pub mod model_application_security_exclusion_filter_update_attributes; +pub use self::model_application_security_exclusion_filter_update_attributes::ApplicationSecurityExclusionFilterUpdateAttributes; pub mod model_cloud_workload_security_agent_rules_list_response; pub use self::model_cloud_workload_security_agent_rules_list_response::CloudWorkloadSecurityAgentRulesListResponse; pub mod model_cloud_workload_security_agent_rule_data; diff --git a/src/datadogV2/model/model_application_security_exclusion_filter_attributes.rs b/src/datadogV2/model/model_application_security_exclusion_filter_attributes.rs new file mode 100644 index 000000000..091b5e178 --- /dev/null +++ b/src/datadogV2/model/model_application_security_exclusion_filter_attributes.rs @@ -0,0 +1,242 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The attributes of the Application Security exclusion filter. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct ApplicationSecurityExclusionFilterAttributes { + /// A description for the exclusion filter. + #[serde(rename = "description")] + pub description: Option, + /// Indicates whether the exclusion filter is enabled. + #[serde(rename = "enabled")] + pub enabled: Option, + /// The IPs list for the exclusion filter. + #[serde(rename = "ip_list")] + pub ip_list: Option>, + /// Metadata about the exclusion filter. + #[serde(rename = "metadata")] + pub metadata: Option, + /// A list of parameters for the exclusion filter. + #[serde(rename = "parameters")] + pub parameters: Option>, + /// The path glob for the exclusion filter. + #[serde(rename = "path_glob")] + pub path_glob: Option, + /// A list of rules targeted by the exclusion filter. + #[serde(rename = "rules_target")] + pub rules_target: + Option>, + /// The scope of the exclusion filter. + #[serde(rename = "scope")] + pub scope: Option>, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl ApplicationSecurityExclusionFilterAttributes { + pub fn new() -> ApplicationSecurityExclusionFilterAttributes { + ApplicationSecurityExclusionFilterAttributes { + description: None, + enabled: None, + ip_list: None, + metadata: None, + parameters: None, + path_glob: None, + rules_target: None, + scope: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn description(mut self, value: String) -> Self { + self.description = Some(value); + self + } + + pub fn enabled(mut self, value: bool) -> Self { + self.enabled = Some(value); + self + } + + pub fn ip_list(mut self, value: Vec) -> Self { + self.ip_list = Some(value); + self + } + + pub fn metadata( + mut self, + value: crate::datadogV2::model::ApplicationSecurityExclusionFilterMetadata, + ) -> Self { + self.metadata = Some(value); + self + } + + pub fn parameters(mut self, value: Vec) -> Self { + self.parameters = Some(value); + self + } + + pub fn path_glob(mut self, value: String) -> Self { + self.path_glob = Some(value); + self + } + + pub fn rules_target( + mut self, + value: Vec, + ) -> Self { + self.rules_target = Some(value); + self + } + + pub fn scope( + mut self, + value: Vec, + ) -> Self { + self.scope = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for ApplicationSecurityExclusionFilterAttributes { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for ApplicationSecurityExclusionFilterAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct ApplicationSecurityExclusionFilterAttributesVisitor; + impl<'a> Visitor<'a> for ApplicationSecurityExclusionFilterAttributesVisitor { + type Value = ApplicationSecurityExclusionFilterAttributes; + + 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 description: Option = None; + let mut enabled: Option = None; + let mut ip_list: Option> = None; + let mut metadata: Option< + crate::datadogV2::model::ApplicationSecurityExclusionFilterMetadata, + > = None; + let mut parameters: Option> = None; + let mut path_glob: Option = None; + let mut rules_target: Option< + Vec, + > = None; + let mut scope: Option< + Vec, + > = 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() { + "description" => { + if v.is_null() { + continue; + } + description = + 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)?); + } + "ip_list" => { + if v.is_null() { + continue; + } + ip_list = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "metadata" => { + if v.is_null() { + continue; + } + metadata = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "parameters" => { + if v.is_null() { + continue; + } + parameters = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "path_glob" => { + if v.is_null() { + continue; + } + path_glob = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "rules_target" => { + if v.is_null() { + continue; + } + rules_target = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "scope" => { + if v.is_null() { + continue; + } + scope = 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 = ApplicationSecurityExclusionFilterAttributes { + description, + enabled, + ip_list, + metadata, + parameters, + path_glob, + rules_target, + scope, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(ApplicationSecurityExclusionFilterAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_application_security_exclusion_filter_create_attributes.rs b/src/datadogV2/model/model_application_security_exclusion_filter_create_attributes.rs new file mode 100644 index 000000000..f73ce224f --- /dev/null +++ b/src/datadogV2/model/model_application_security_exclusion_filter_create_attributes.rs @@ -0,0 +1,198 @@ +// 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}; + +/// Create a new Application Security exclusion filter. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct ApplicationSecurityExclusionFilterCreateAttributes { + /// A description for the exclusion filter. + #[serde(rename = "description")] + pub description: String, + /// Indicates whether the exclusion filter is enabled. + #[serde(rename = "enabled")] + pub enabled: bool, + /// The IPs list for the exclusion filter. + #[serde(rename = "ip_list")] + pub ip_list: Option>, + /// A list of parameters for the exclusion filter. + #[serde(rename = "parameters")] + pub parameters: Option>, + /// The path glob for the exclusion filter. + #[serde(rename = "path_glob")] + pub path_glob: String, + /// A list of rules targeted by the exclusion filter. + #[serde(rename = "rules_target")] + pub rules_target: + Option>, + /// The scope of the exclusion filter. + #[serde(rename = "scope")] + pub scope: Option>, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl ApplicationSecurityExclusionFilterCreateAttributes { + pub fn new( + description: String, + enabled: bool, + path_glob: String, + ) -> ApplicationSecurityExclusionFilterCreateAttributes { + ApplicationSecurityExclusionFilterCreateAttributes { + description, + enabled, + ip_list: None, + parameters: None, + path_glob, + rules_target: None, + scope: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn ip_list(mut self, value: Vec) -> Self { + self.ip_list = Some(value); + self + } + + pub fn parameters(mut self, value: Vec) -> Self { + self.parameters = Some(value); + self + } + + pub fn rules_target( + mut self, + value: Vec, + ) -> Self { + self.rules_target = Some(value); + self + } + + pub fn scope( + mut self, + value: Vec, + ) -> Self { + self.scope = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for ApplicationSecurityExclusionFilterCreateAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct ApplicationSecurityExclusionFilterCreateAttributesVisitor; + impl<'a> Visitor<'a> for ApplicationSecurityExclusionFilterCreateAttributesVisitor { + type Value = ApplicationSecurityExclusionFilterCreateAttributes; + + 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 description: Option = None; + let mut enabled: Option = None; + let mut ip_list: Option> = None; + let mut parameters: Option> = None; + let mut path_glob: Option = None; + let mut rules_target: Option< + Vec, + > = None; + let mut scope: Option< + Vec, + > = 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() { + "description" => { + description = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "enabled" => { + enabled = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "ip_list" => { + if v.is_null() { + continue; + } + ip_list = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "parameters" => { + if v.is_null() { + continue; + } + parameters = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "path_glob" => { + path_glob = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "rules_target" => { + if v.is_null() { + continue; + } + rules_target = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "scope" => { + if v.is_null() { + continue; + } + scope = 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 description = + description.ok_or_else(|| M::Error::missing_field("description"))?; + let enabled = enabled.ok_or_else(|| M::Error::missing_field("enabled"))?; + let path_glob = path_glob.ok_or_else(|| M::Error::missing_field("path_glob"))?; + + let content = ApplicationSecurityExclusionFilterCreateAttributes { + description, + enabled, + ip_list, + parameters, + path_glob, + rules_target, + scope, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(ApplicationSecurityExclusionFilterCreateAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_application_security_exclusion_filter_create_data.rs b/src/datadogV2/model/model_application_security_exclusion_filter_create_data.rs new file mode 100644 index 000000000..b31afbab2 --- /dev/null +++ b/src/datadogV2/model/model_application_security_exclusion_filter_create_data.rs @@ -0,0 +1,117 @@ +// 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}; + +/// Object for a single exclusion filter. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct ApplicationSecurityExclusionFilterCreateData { + /// Create a new Application Security exclusion filter. + #[serde(rename = "attributes")] + pub attributes: crate::datadogV2::model::ApplicationSecurityExclusionFilterCreateAttributes, + /// The type of the resource. The value should always be `exclusion_filter`. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::ApplicationSecurityExclusionFilterType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl ApplicationSecurityExclusionFilterCreateData { + pub fn new( + attributes: crate::datadogV2::model::ApplicationSecurityExclusionFilterCreateAttributes, + type_: crate::datadogV2::model::ApplicationSecurityExclusionFilterType, + ) -> ApplicationSecurityExclusionFilterCreateData { + ApplicationSecurityExclusionFilterCreateData { + attributes, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for ApplicationSecurityExclusionFilterCreateData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct ApplicationSecurityExclusionFilterCreateDataVisitor; + impl<'a> Visitor<'a> for ApplicationSecurityExclusionFilterCreateDataVisitor { + type Value = ApplicationSecurityExclusionFilterCreateData; + + 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::ApplicationSecurityExclusionFilterCreateAttributes, + > = None; + let mut type_: Option< + crate::datadogV2::model::ApplicationSecurityExclusionFilterType, + > = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "attributes" => { + attributes = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::ApplicationSecurityExclusionFilterType::UnparsedObject(_type_) => { + _unparsed = true; + }, + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let attributes = attributes.ok_or_else(|| M::Error::missing_field("attributes"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = ApplicationSecurityExclusionFilterCreateData { + attributes, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(ApplicationSecurityExclusionFilterCreateDataVisitor) + } +} diff --git a/src/datadogV2/model/model_application_security_exclusion_filter_create_request.rs b/src/datadogV2/model/model_application_security_exclusion_filter_create_request.rs new file mode 100644 index 000000000..4cbf46ca7 --- /dev/null +++ b/src/datadogV2/model/model_application_security_exclusion_filter_create_request.rs @@ -0,0 +1,96 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Request object that includes the exclusion filter to create. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct ApplicationSecurityExclusionFilterCreateRequest { + /// Object for a single exclusion filter. + #[serde(rename = "data")] + pub data: crate::datadogV2::model::ApplicationSecurityExclusionFilterCreateData, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl ApplicationSecurityExclusionFilterCreateRequest { + pub fn new( + data: crate::datadogV2::model::ApplicationSecurityExclusionFilterCreateData, + ) -> ApplicationSecurityExclusionFilterCreateRequest { + ApplicationSecurityExclusionFilterCreateRequest { + 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 ApplicationSecurityExclusionFilterCreateRequest { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct ApplicationSecurityExclusionFilterCreateRequestVisitor; + impl<'a> Visitor<'a> for ApplicationSecurityExclusionFilterCreateRequestVisitor { + type Value = ApplicationSecurityExclusionFilterCreateRequest; + + 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< + crate::datadogV2::model::ApplicationSecurityExclusionFilterCreateData, + > = 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 = ApplicationSecurityExclusionFilterCreateRequest { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(ApplicationSecurityExclusionFilterCreateRequestVisitor) + } +} diff --git a/src/datadogV2/model/model_application_security_exclusion_filter_data.rs b/src/datadogV2/model/model_application_security_exclusion_filter_data.rs new file mode 100644 index 000000000..1805a2b35 --- /dev/null +++ b/src/datadogV2/model/model_application_security_exclusion_filter_data.rs @@ -0,0 +1,157 @@ +// 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}; + +/// Object for a single Exclusion filter. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct ApplicationSecurityExclusionFilterData { + /// The attributes of the Application Security exclusion filter. + #[serde(rename = "attributes")] + pub attributes: Option, + /// The ID of the Exclusion filter. + #[serde(rename = "id")] + pub id: Option, + /// The type of the resource. The value should always be `exclusion_filter`. + #[serde(rename = "type")] + pub type_: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl ApplicationSecurityExclusionFilterData { + pub fn new() -> ApplicationSecurityExclusionFilterData { + ApplicationSecurityExclusionFilterData { + attributes: None, + id: None, + type_: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn attributes( + mut self, + value: crate::datadogV2::model::ApplicationSecurityExclusionFilterAttributes, + ) -> Self { + self.attributes = Some(value); + self + } + + pub fn id(mut self, value: String) -> Self { + self.id = Some(value); + self + } + + pub fn type_( + mut self, + value: crate::datadogV2::model::ApplicationSecurityExclusionFilterType, + ) -> Self { + self.type_ = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for ApplicationSecurityExclusionFilterData { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for ApplicationSecurityExclusionFilterData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct ApplicationSecurityExclusionFilterDataVisitor; + impl<'a> Visitor<'a> for ApplicationSecurityExclusionFilterDataVisitor { + type Value = ApplicationSecurityExclusionFilterData; + + 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::ApplicationSecurityExclusionFilterAttributes, + > = None; + let mut id: Option = None; + let mut type_: Option< + crate::datadogV2::model::ApplicationSecurityExclusionFilterType, + > = 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" => { + if v.is_null() { + continue; + } + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::ApplicationSecurityExclusionFilterType::UnparsedObject(_type_) => { + _unparsed = true; + }, + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = ApplicationSecurityExclusionFilterData { + attributes, + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(ApplicationSecurityExclusionFilterDataVisitor) + } +} diff --git a/src/datadogV2/model/model_application_security_exclusion_filter_list_attributes.rs b/src/datadogV2/model/model_application_security_exclusion_filter_list_attributes.rs new file mode 100644 index 000000000..60dd4fa4c --- /dev/null +++ b/src/datadogV2/model/model_application_security_exclusion_filter_list_attributes.rs @@ -0,0 +1,242 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// The attributes of the Application Security exclusion filter. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct ApplicationSecurityExclusionFilterListAttributes { + /// A description for the exclusion filter. + #[serde(rename = "description")] + pub description: Option, + /// Indicates whether the exclusion filter is enabled. + #[serde(rename = "enabled")] + pub enabled: Option, + /// The IPs list for the exclusion filter. + #[serde(rename = "ip_list")] + pub ip_list: Option>, + /// Metadata about the exclusion filter. + #[serde(rename = "metadata")] + pub metadata: Option, + /// A list of parameters for the exclusion filter. + #[serde(rename = "parameters")] + pub parameters: Option>, + /// The path glob for the exclusion filter. + #[serde(rename = "path_glob")] + pub path_glob: Option, + /// A list of rules targeted by the exclusion filter. + #[serde(rename = "rules_target")] + pub rules_target: + Option>, + /// The scope of the exclusion filter. + #[serde(rename = "scope")] + pub scope: Option>, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl ApplicationSecurityExclusionFilterListAttributes { + pub fn new() -> ApplicationSecurityExclusionFilterListAttributes { + ApplicationSecurityExclusionFilterListAttributes { + description: None, + enabled: None, + ip_list: None, + metadata: None, + parameters: None, + path_glob: None, + rules_target: None, + scope: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn description(mut self, value: String) -> Self { + self.description = Some(value); + self + } + + pub fn enabled(mut self, value: bool) -> Self { + self.enabled = Some(value); + self + } + + pub fn ip_list(mut self, value: Vec) -> Self { + self.ip_list = Some(value); + self + } + + pub fn metadata( + mut self, + value: crate::datadogV2::model::ApplicationSecurityExclusionFilterMetadata, + ) -> Self { + self.metadata = Some(value); + self + } + + pub fn parameters(mut self, value: Vec) -> Self { + self.parameters = Some(value); + self + } + + pub fn path_glob(mut self, value: String) -> Self { + self.path_glob = Some(value); + self + } + + pub fn rules_target( + mut self, + value: Vec, + ) -> Self { + self.rules_target = Some(value); + self + } + + pub fn scope( + mut self, + value: Vec, + ) -> Self { + self.scope = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for ApplicationSecurityExclusionFilterListAttributes { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for ApplicationSecurityExclusionFilterListAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct ApplicationSecurityExclusionFilterListAttributesVisitor; + impl<'a> Visitor<'a> for ApplicationSecurityExclusionFilterListAttributesVisitor { + type Value = ApplicationSecurityExclusionFilterListAttributes; + + 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 description: Option = None; + let mut enabled: Option = None; + let mut ip_list: Option> = None; + let mut metadata: Option< + crate::datadogV2::model::ApplicationSecurityExclusionFilterMetadata, + > = None; + let mut parameters: Option> = None; + let mut path_glob: Option = None; + let mut rules_target: Option< + Vec, + > = None; + let mut scope: Option< + Vec, + > = 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() { + "description" => { + if v.is_null() { + continue; + } + description = + 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)?); + } + "ip_list" => { + if v.is_null() { + continue; + } + ip_list = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "metadata" => { + if v.is_null() { + continue; + } + metadata = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "parameters" => { + if v.is_null() { + continue; + } + parameters = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "path_glob" => { + if v.is_null() { + continue; + } + path_glob = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "rules_target" => { + if v.is_null() { + continue; + } + rules_target = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "scope" => { + if v.is_null() { + continue; + } + scope = 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 = ApplicationSecurityExclusionFilterListAttributes { + description, + enabled, + ip_list, + metadata, + parameters, + path_glob, + rules_target, + scope, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(ApplicationSecurityExclusionFilterListAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_application_security_exclusion_filter_list_response.rs b/src/datadogV2/model/model_application_security_exclusion_filter_list_response.rs new file mode 100644 index 000000000..9627a4955 --- /dev/null +++ b/src/datadogV2/model/model_application_security_exclusion_filter_list_response.rs @@ -0,0 +1,110 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Response object that includes a list of exclusion filters. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct ApplicationSecurityExclusionFilterListResponse { + /// The Application Security exclusion filter response data. + #[serde(rename = "data")] + pub data: Option>, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl ApplicationSecurityExclusionFilterListResponse { + pub fn new() -> ApplicationSecurityExclusionFilterListResponse { + ApplicationSecurityExclusionFilterListResponse { + data: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn data( + mut self, + value: Vec, + ) -> 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 ApplicationSecurityExclusionFilterListResponse { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for ApplicationSecurityExclusionFilterListResponse { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct ApplicationSecurityExclusionFilterListResponseVisitor; + impl<'a> Visitor<'a> for ApplicationSecurityExclusionFilterListResponseVisitor { + type Value = ApplicationSecurityExclusionFilterListResponse; + + 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< + Vec, + > = 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 = ApplicationSecurityExclusionFilterListResponse { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(ApplicationSecurityExclusionFilterListResponseVisitor) + } +} diff --git a/src/datadogV2/model/model_application_security_exclusion_filter_list_rules_target.rs b/src/datadogV2/model/model_application_security_exclusion_filter_list_rules_target.rs new file mode 100644 index 000000000..ec464c22e --- /dev/null +++ b/src/datadogV2/model/model_application_security_exclusion_filter_list_rules_target.rs @@ -0,0 +1,111 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// A rule targeted by the exclusion filter. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct ApplicationSecurityExclusionFilterListRulesTarget { + /// Tags identifying the category and type of the targeted rule. + #[serde(rename = "tags")] + pub tags: + Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl ApplicationSecurityExclusionFilterListRulesTarget { + pub fn new() -> ApplicationSecurityExclusionFilterListRulesTarget { + ApplicationSecurityExclusionFilterListRulesTarget { + tags: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn tags( + mut self, + value: crate::datadogV2::model::ApplicationSecurityExclusionFilterListRulesTargetTags, + ) -> Self { + self.tags = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for ApplicationSecurityExclusionFilterListRulesTarget { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for ApplicationSecurityExclusionFilterListRulesTarget { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct ApplicationSecurityExclusionFilterListRulesTargetVisitor; + impl<'a> Visitor<'a> for ApplicationSecurityExclusionFilterListRulesTargetVisitor { + type Value = ApplicationSecurityExclusionFilterListRulesTarget; + + 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 tags: Option< + crate::datadogV2::model::ApplicationSecurityExclusionFilterListRulesTargetTags, + > = 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() { + "tags" => { + if v.is_null() { + continue; + } + tags = 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 = ApplicationSecurityExclusionFilterListRulesTarget { + tags, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(ApplicationSecurityExclusionFilterListRulesTargetVisitor) + } +} diff --git a/src/datadogV2/model/model_application_security_exclusion_filter_list_rules_target_tags.rs b/src/datadogV2/model/model_application_security_exclusion_filter_list_rules_target_tags.rs new file mode 100644 index 000000000..5dba9f79d --- /dev/null +++ b/src/datadogV2/model/model_application_security_exclusion_filter_list_rules_target_tags.rs @@ -0,0 +1,122 @@ +// 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}; + +/// Tags identifying the category and type of the targeted rule. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct ApplicationSecurityExclusionFilterListRulesTargetTags { + /// The category of the rule. + #[serde(rename = "category")] + pub category: Option, + /// The type of the rule. + #[serde(rename = "type")] + pub type_: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl ApplicationSecurityExclusionFilterListRulesTargetTags { + pub fn new() -> ApplicationSecurityExclusionFilterListRulesTargetTags { + ApplicationSecurityExclusionFilterListRulesTargetTags { + category: None, + type_: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn category(mut self, value: String) -> Self { + self.category = Some(value); + self + } + + pub fn type_(mut self, value: String) -> Self { + self.type_ = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for ApplicationSecurityExclusionFilterListRulesTargetTags { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for ApplicationSecurityExclusionFilterListRulesTargetTags { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct ApplicationSecurityExclusionFilterListRulesTargetTagsVisitor; + impl<'a> Visitor<'a> for ApplicationSecurityExclusionFilterListRulesTargetTagsVisitor { + type Value = ApplicationSecurityExclusionFilterListRulesTargetTags; + + 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 category: 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() { + "category" => { + if v.is_null() { + continue; + } + category = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "type" => { + if v.is_null() { + continue; + } + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = ApplicationSecurityExclusionFilterListRulesTargetTags { + category, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(ApplicationSecurityExclusionFilterListRulesTargetTagsVisitor) + } +} diff --git a/src/datadogV2/model/model_application_security_exclusion_filter_metadata.rs b/src/datadogV2/model/model_application_security_exclusion_filter_metadata.rs new file mode 100644 index 000000000..8e9567601 --- /dev/null +++ b/src/datadogV2/model/model_application_security_exclusion_filter_metadata.rs @@ -0,0 +1,158 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Metadata about the exclusion filter. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct ApplicationSecurityExclusionFilterMetadata { + /// The timestamp when the exclusion filter was added. + #[serde(rename = "added_at")] + pub added_at: Option>, + /// The email address of the user who added the exclusion filter. + #[serde(rename = "added_by")] + pub added_by: Option, + /// The timestamp when the exclusion filter was last modified. + #[serde(rename = "modified_at")] + pub modified_at: Option>, + /// The email address of the user who last modified the exclusion filter. + #[serde(rename = "modified_by")] + pub modified_by: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl ApplicationSecurityExclusionFilterMetadata { + pub fn new() -> ApplicationSecurityExclusionFilterMetadata { + ApplicationSecurityExclusionFilterMetadata { + added_at: None, + added_by: None, + modified_at: None, + modified_by: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn added_at(mut self, value: chrono::DateTime) -> Self { + self.added_at = Some(value); + self + } + + pub fn added_by(mut self, value: String) -> Self { + self.added_by = Some(value); + self + } + + pub fn modified_at(mut self, value: chrono::DateTime) -> Self { + self.modified_at = Some(value); + self + } + + pub fn modified_by(mut self, value: String) -> Self { + self.modified_by = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for ApplicationSecurityExclusionFilterMetadata { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for ApplicationSecurityExclusionFilterMetadata { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct ApplicationSecurityExclusionFilterMetadataVisitor; + impl<'a> Visitor<'a> for ApplicationSecurityExclusionFilterMetadataVisitor { + type Value = ApplicationSecurityExclusionFilterMetadata; + + 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 added_at: Option> = None; + let mut added_by: Option = None; + let mut modified_at: Option> = None; + let mut modified_by: 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() { + "added_at" => { + if v.is_null() { + continue; + } + added_at = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "added_by" => { + if v.is_null() { + continue; + } + added_by = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "modified_at" => { + if v.is_null() { + continue; + } + modified_at = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "modified_by" => { + if v.is_null() { + continue; + } + modified_by = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = ApplicationSecurityExclusionFilterMetadata { + added_at, + added_by, + modified_at, + modified_by, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(ApplicationSecurityExclusionFilterMetadataVisitor) + } +} diff --git a/src/datadogV2/model/model_application_security_exclusion_filter_response.rs b/src/datadogV2/model/model_application_security_exclusion_filter_response.rs new file mode 100644 index 000000000..39bf1b5b0 --- /dev/null +++ b/src/datadogV2/model/model_application_security_exclusion_filter_response.rs @@ -0,0 +1,110 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Response object that includes a list of exclusion filters. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct ApplicationSecurityExclusionFilterResponse { + /// The Application Security exclusion filter data. + #[serde(rename = "data")] + pub data: Option>, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl ApplicationSecurityExclusionFilterResponse { + pub fn new() -> ApplicationSecurityExclusionFilterResponse { + ApplicationSecurityExclusionFilterResponse { + data: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn data( + mut self, + value: Vec, + ) -> 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 ApplicationSecurityExclusionFilterResponse { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for ApplicationSecurityExclusionFilterResponse { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct ApplicationSecurityExclusionFilterResponseVisitor; + impl<'a> Visitor<'a> for ApplicationSecurityExclusionFilterResponseVisitor { + type Value = ApplicationSecurityExclusionFilterResponse; + + 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< + Vec, + > = 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 = ApplicationSecurityExclusionFilterResponse { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(ApplicationSecurityExclusionFilterResponseVisitor) + } +} diff --git a/src/datadogV2/model/model_application_security_exclusion_filter_rules_target.rs b/src/datadogV2/model/model_application_security_exclusion_filter_rules_target.rs new file mode 100644 index 000000000..79ffe6902 --- /dev/null +++ b/src/datadogV2/model/model_application_security_exclusion_filter_rules_target.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}; + +/// A rule targeted by the exclusion filter. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct ApplicationSecurityExclusionFilterRulesTarget { + /// The ID of the targeted rule. + #[serde(rename = "rule_id")] + pub rule_id: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl ApplicationSecurityExclusionFilterRulesTarget { + pub fn new() -> ApplicationSecurityExclusionFilterRulesTarget { + ApplicationSecurityExclusionFilterRulesTarget { + rule_id: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn rule_id(mut self, value: String) -> Self { + self.rule_id = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for ApplicationSecurityExclusionFilterRulesTarget { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for ApplicationSecurityExclusionFilterRulesTarget { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct ApplicationSecurityExclusionFilterRulesTargetVisitor; + impl<'a> Visitor<'a> for ApplicationSecurityExclusionFilterRulesTargetVisitor { + type Value = ApplicationSecurityExclusionFilterRulesTarget; + + 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 rule_id: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "rule_id" => { + if v.is_null() { + continue; + } + rule_id = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = ApplicationSecurityExclusionFilterRulesTarget { + rule_id, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(ApplicationSecurityExclusionFilterRulesTargetVisitor) + } +} diff --git a/src/datadogV2/model/model_application_security_exclusion_filter_scope.rs b/src/datadogV2/model/model_application_security_exclusion_filter_scope.rs new file mode 100644 index 000000000..f46e598df --- /dev/null +++ b/src/datadogV2/model/model_application_security_exclusion_filter_scope.rs @@ -0,0 +1,122 @@ +// 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 scope of the exclusion filter. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct ApplicationSecurityExclusionFilterScope { + /// The environment scope for the exclusion filter. + #[serde(rename = "env")] + pub env: Option, + /// The service scope for the exclusion filter. + #[serde(rename = "service")] + pub service: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl ApplicationSecurityExclusionFilterScope { + pub fn new() -> ApplicationSecurityExclusionFilterScope { + ApplicationSecurityExclusionFilterScope { + env: None, + service: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn env(mut self, value: String) -> Self { + self.env = Some(value); + self + } + + pub fn service(mut self, value: String) -> Self { + self.service = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for ApplicationSecurityExclusionFilterScope { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for ApplicationSecurityExclusionFilterScope { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct ApplicationSecurityExclusionFilterScopeVisitor; + impl<'a> Visitor<'a> for ApplicationSecurityExclusionFilterScopeVisitor { + type Value = ApplicationSecurityExclusionFilterScope; + + 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 env: Option = None; + let mut service: Option = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "env" => { + if v.is_null() { + continue; + } + env = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "service" => { + if v.is_null() { + continue; + } + service = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = ApplicationSecurityExclusionFilterScope { + env, + service, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(ApplicationSecurityExclusionFilterScopeVisitor) + } +} diff --git a/src/datadogV2/model/model_application_security_exclusion_filter_type.rs b/src/datadogV2/model/model_application_security_exclusion_filter_type.rs new file mode 100644 index 000000000..f9b17687f --- /dev/null +++ b/src/datadogV2/model/model_application_security_exclusion_filter_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 ApplicationSecurityExclusionFilterType { + EXCLUSION_FILTER, + UnparsedObject(crate::datadog::UnparsedObject), +} + +impl ToString for ApplicationSecurityExclusionFilterType { + fn to_string(&self) -> String { + match self { + Self::EXCLUSION_FILTER => String::from("exclusion_filter"), + Self::UnparsedObject(v) => v.value.to_string(), + } + } +} + +impl Serialize for ApplicationSecurityExclusionFilterType { + 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 ApplicationSecurityExclusionFilterType { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let s: String = String::deserialize(deserializer)?; + Ok(match s.as_str() { + "exclusion_filter" => Self::EXCLUSION_FILTER, + _ => Self::UnparsedObject(crate::datadog::UnparsedObject { + value: serde_json::Value::String(s.into()), + }), + }) + } +} diff --git a/src/datadogV2/model/model_application_security_exclusion_filter_update_attributes.rs b/src/datadogV2/model/model_application_security_exclusion_filter_update_attributes.rs new file mode 100644 index 000000000..aeceb35e0 --- /dev/null +++ b/src/datadogV2/model/model_application_security_exclusion_filter_update_attributes.rs @@ -0,0 +1,198 @@ +// 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}; + +/// Update an existing Application Security Exclusion filter. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct ApplicationSecurityExclusionFilterUpdateAttributes { + /// The description of the Exclusion filter. + #[serde(rename = "description")] + pub description: String, + /// Whether the Exclusion filter is enabled. + #[serde(rename = "enabled")] + pub enabled: bool, + /// The IPs list for the exclusion filter. + #[serde(rename = "ip_list")] + pub ip_list: Option>, + /// A list of parameters for the exclusion filter. + #[serde(rename = "parameters")] + pub parameters: Option>, + /// The path glob for the exclusion filter. + #[serde(rename = "path_glob")] + pub path_glob: String, + /// A list of rules targeted by the exclusion filter. + #[serde(rename = "rules_target")] + pub rules_target: + Option>, + /// The scope of the exclusion filter. + #[serde(rename = "scope")] + pub scope: Option>, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl ApplicationSecurityExclusionFilterUpdateAttributes { + pub fn new( + description: String, + enabled: bool, + path_glob: String, + ) -> ApplicationSecurityExclusionFilterUpdateAttributes { + ApplicationSecurityExclusionFilterUpdateAttributes { + description, + enabled, + ip_list: None, + parameters: None, + path_glob, + rules_target: None, + scope: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn ip_list(mut self, value: Vec) -> Self { + self.ip_list = Some(value); + self + } + + pub fn parameters(mut self, value: Vec) -> Self { + self.parameters = Some(value); + self + } + + pub fn rules_target( + mut self, + value: Vec, + ) -> Self { + self.rules_target = Some(value); + self + } + + pub fn scope( + mut self, + value: Vec, + ) -> Self { + self.scope = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for ApplicationSecurityExclusionFilterUpdateAttributes { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct ApplicationSecurityExclusionFilterUpdateAttributesVisitor; + impl<'a> Visitor<'a> for ApplicationSecurityExclusionFilterUpdateAttributesVisitor { + type Value = ApplicationSecurityExclusionFilterUpdateAttributes; + + 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 description: Option = None; + let mut enabled: Option = None; + let mut ip_list: Option> = None; + let mut parameters: Option> = None; + let mut path_glob: Option = None; + let mut rules_target: Option< + Vec, + > = None; + let mut scope: Option< + Vec, + > = 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() { + "description" => { + description = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "enabled" => { + enabled = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "ip_list" => { + if v.is_null() { + continue; + } + ip_list = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "parameters" => { + if v.is_null() { + continue; + } + parameters = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "path_glob" => { + path_glob = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "rules_target" => { + if v.is_null() { + continue; + } + rules_target = + Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "scope" => { + if v.is_null() { + continue; + } + scope = 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 description = + description.ok_or_else(|| M::Error::missing_field("description"))?; + let enabled = enabled.ok_or_else(|| M::Error::missing_field("enabled"))?; + let path_glob = path_glob.ok_or_else(|| M::Error::missing_field("path_glob"))?; + + let content = ApplicationSecurityExclusionFilterUpdateAttributes { + description, + enabled, + ip_list, + parameters, + path_glob, + rules_target, + scope, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(ApplicationSecurityExclusionFilterUpdateAttributesVisitor) + } +} diff --git a/src/datadogV2/model/model_application_security_exclusion_filter_update_data.rs b/src/datadogV2/model/model_application_security_exclusion_filter_update_data.rs new file mode 100644 index 000000000..5a86c4374 --- /dev/null +++ b/src/datadogV2/model/model_application_security_exclusion_filter_update_data.rs @@ -0,0 +1,134 @@ +// 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}; + +/// Object for a single Exclusion filter. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct ApplicationSecurityExclusionFilterUpdateData { + /// Update an existing Application Security Exclusion filter. + #[serde(rename = "attributes")] + pub attributes: crate::datadogV2::model::ApplicationSecurityExclusionFilterUpdateAttributes, + /// The ID of the exclusion filter. + #[serde(rename = "id")] + pub id: Option, + /// The type of the resource. The value should always be `exclusion_filter`. + #[serde(rename = "type")] + pub type_: crate::datadogV2::model::ApplicationSecurityExclusionFilterType, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl ApplicationSecurityExclusionFilterUpdateData { + pub fn new( + attributes: crate::datadogV2::model::ApplicationSecurityExclusionFilterUpdateAttributes, + type_: crate::datadogV2::model::ApplicationSecurityExclusionFilterType, + ) -> ApplicationSecurityExclusionFilterUpdateData { + ApplicationSecurityExclusionFilterUpdateData { + attributes, + id: None, + type_, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn id(mut self, value: String) -> Self { + self.id = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl<'de> Deserialize<'de> for ApplicationSecurityExclusionFilterUpdateData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct ApplicationSecurityExclusionFilterUpdateDataVisitor; + impl<'a> Visitor<'a> for ApplicationSecurityExclusionFilterUpdateDataVisitor { + type Value = ApplicationSecurityExclusionFilterUpdateData; + + 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::ApplicationSecurityExclusionFilterUpdateAttributes, + > = None; + let mut id: Option = None; + let mut type_: Option< + crate::datadogV2::model::ApplicationSecurityExclusionFilterType, + > = None; + let mut additional_properties: std::collections::BTreeMap< + String, + serde_json::Value, + > = std::collections::BTreeMap::new(); + let mut _unparsed = false; + + while let Some((k, v)) = map.next_entry::()? { + match k.as_str() { + "attributes" => { + attributes = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + } + "id" => { + 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::ApplicationSecurityExclusionFilterType::UnparsedObject(_type_) => { + _unparsed = true; + }, + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + let attributes = attributes.ok_or_else(|| M::Error::missing_field("attributes"))?; + let type_ = type_.ok_or_else(|| M::Error::missing_field("type_"))?; + + let content = ApplicationSecurityExclusionFilterUpdateData { + attributes, + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(ApplicationSecurityExclusionFilterUpdateDataVisitor) + } +} diff --git a/src/datadogV2/model/model_application_security_exclusion_filter_update_request.rs b/src/datadogV2/model/model_application_security_exclusion_filter_update_request.rs new file mode 100644 index 000000000..574126987 --- /dev/null +++ b/src/datadogV2/model/model_application_security_exclusion_filter_update_request.rs @@ -0,0 +1,96 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. +use serde::de::{Error, MapAccess, Visitor}; +use serde::{Deserialize, Deserializer, Serialize}; +use serde_with::skip_serializing_none; +use std::fmt::{self, Formatter}; + +/// Request object that includes the Exclusion filter with the attributes to update. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct ApplicationSecurityExclusionFilterUpdateRequest { + /// Object for a single Exclusion filter. + #[serde(rename = "data")] + pub data: crate::datadogV2::model::ApplicationSecurityExclusionFilterUpdateData, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl ApplicationSecurityExclusionFilterUpdateRequest { + pub fn new( + data: crate::datadogV2::model::ApplicationSecurityExclusionFilterUpdateData, + ) -> ApplicationSecurityExclusionFilterUpdateRequest { + ApplicationSecurityExclusionFilterUpdateRequest { + 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 ApplicationSecurityExclusionFilterUpdateRequest { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct ApplicationSecurityExclusionFilterUpdateRequestVisitor; + impl<'a> Visitor<'a> for ApplicationSecurityExclusionFilterUpdateRequestVisitor { + type Value = ApplicationSecurityExclusionFilterUpdateRequest; + + 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< + crate::datadogV2::model::ApplicationSecurityExclusionFilterUpdateData, + > = 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 = ApplicationSecurityExclusionFilterUpdateRequest { + data, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(ApplicationSecurityExclusionFilterUpdateRequestVisitor) + } +} diff --git a/src/datadogV2/model/model_application_security_exclusion_list_filter_data.rs b/src/datadogV2/model/model_application_security_exclusion_list_filter_data.rs new file mode 100644 index 000000000..80d15117c --- /dev/null +++ b/src/datadogV2/model/model_application_security_exclusion_list_filter_data.rs @@ -0,0 +1,158 @@ +// 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}; + +/// Object for a single Exclusion filter. +#[non_exhaustive] +#[skip_serializing_none] +#[derive(Clone, Debug, PartialEq, Serialize)] +pub struct ApplicationSecurityExclusionListFilterData { + /// The attributes of the Application Security exclusion filter. + #[serde(rename = "attributes")] + pub attributes: + Option, + /// The ID of the Exclusion filter. + #[serde(rename = "id")] + pub id: Option, + /// The type of the resource. The value should always be `exclusion_filter`. + #[serde(rename = "type")] + pub type_: Option, + #[serde(flatten)] + pub additional_properties: std::collections::BTreeMap, + #[serde(skip)] + #[serde(default)] + pub(crate) _unparsed: bool, +} + +impl ApplicationSecurityExclusionListFilterData { + pub fn new() -> ApplicationSecurityExclusionListFilterData { + ApplicationSecurityExclusionListFilterData { + attributes: None, + id: None, + type_: None, + additional_properties: std::collections::BTreeMap::new(), + _unparsed: false, + } + } + + pub fn attributes( + mut self, + value: crate::datadogV2::model::ApplicationSecurityExclusionFilterListAttributes, + ) -> Self { + self.attributes = Some(value); + self + } + + pub fn id(mut self, value: String) -> Self { + self.id = Some(value); + self + } + + pub fn type_( + mut self, + value: crate::datadogV2::model::ApplicationSecurityExclusionFilterType, + ) -> Self { + self.type_ = Some(value); + self + } + + pub fn additional_properties( + mut self, + value: std::collections::BTreeMap, + ) -> Self { + self.additional_properties = value; + self + } +} + +impl Default for ApplicationSecurityExclusionListFilterData { + fn default() -> Self { + Self::new() + } +} + +impl<'de> Deserialize<'de> for ApplicationSecurityExclusionListFilterData { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + struct ApplicationSecurityExclusionListFilterDataVisitor; + impl<'a> Visitor<'a> for ApplicationSecurityExclusionListFilterDataVisitor { + type Value = ApplicationSecurityExclusionListFilterData; + + 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::ApplicationSecurityExclusionFilterListAttributes, + > = None; + let mut id: Option = None; + let mut type_: Option< + crate::datadogV2::model::ApplicationSecurityExclusionFilterType, + > = 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" => { + if v.is_null() { + continue; + } + type_ = Some(serde_json::from_value(v).map_err(M::Error::custom)?); + if let Some(ref _type_) = type_ { + match _type_ { + crate::datadogV2::model::ApplicationSecurityExclusionFilterType::UnparsedObject(_type_) => { + _unparsed = true; + }, + _ => {} + } + } + } + &_ => { + if let Ok(value) = serde_json::from_value(v.clone()) { + additional_properties.insert(k, value); + } + } + } + } + + let content = ApplicationSecurityExclusionListFilterData { + attributes, + id, + type_, + additional_properties, + _unparsed, + }; + + Ok(content) + } + } + + deserializer.deserialize_any(ApplicationSecurityExclusionListFilterDataVisitor) + } +} diff --git a/tests/scenarios/features/v2/application_security_exclusion_filters.feature b/tests/scenarios/features/v2/application_security_exclusion_filters.feature new file mode 100644 index 000000000..0d1e7bc6e --- /dev/null +++ b/tests/scenarios/features/v2/application_security_exclusion_filters.feature @@ -0,0 +1,89 @@ +@endpoint(application-security-exclusion-filters) @endpoint(application-security-exclusion-filters-v2) +Feature: Application Security Exclusion Filters + Exclusion filters in Application Security libraries are used to circumvent + false positives in protection. + + Background: + Given a valid "apiKeyAuth" key in the system + And a valid "appKeyAuth" key in the system + And an instance of "ApplicationSecurityExclusionFilters" API + + @generated @skip @team:DataDog/asm-respond-backend + Scenario: Create an ASM Exclusion filter returns "Bad Request" response + Given new "CreateApplicationSecurityExclusionFilter" request + And body with value {"data": {"type": "exclusion_filter"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/asm-respond-backend + Scenario: Create an ASM Exclusion filter returns "Conflict" response + Given new "CreateApplicationSecurityExclusionFilter" request + And body with value {"data": {"type": "exclusion_filter"}} + When the request is sent + Then the response status is 409 Conflict + + @skip @team:DataDog/asm-respond-backend + Scenario: Create an ASM Exclusion filter returns "OK" response + Given new "CreateApplicationSecurityExclusionFilter" request + And body with value {"data": {"type": "exclusion_filter","attributes":{"description":"my description","enabled":true,"path_glob":"*","rules_target":[{"tags":{"category":"attack_attempt","type":"sql_injection"}}],"scope":[{"env":"staging","service":"container-resolver"}]}}} + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:DataDog/asm-respond-backend + Scenario: Delete an ASM Exclusion Filter returns "Not Found" response + Given new "DeleteApplicationSecurityExclusionFilter" request + And request contains "exclusion_filter_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/asm-respond-backend + Scenario: Delete an ASM Exclusion Filter returns "OK" response + Given new "DeleteApplicationSecurityExclusionFilter" request + And request contains "exclusion_filter_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 204 OK + + @generated @skip @team:DataDog/asm-respond-backend + Scenario: Get a specific ASM Exclusion Filter returns "OK" response + Given new "GetApplicationSecurityExclusionFilters" request + And request contains "exclusion_filter_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:DataDog/asm-respond-backend + Scenario: List all ASM Exclusion Filters returns "OK" response + Given new "ListApplicationSecurityExclusionFilters" request + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:DataDog/asm-respond-backend + Scenario: Update an ASM Exclusion filter returns "Bad Request" response + Given new "UpdateApplicationSecurityExclusionFilter" request + And request contains "exclusion_filter_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"description": "My Exclusion filter", "enabled": true, "ip_list": ["127.0.0.1"], "parameters": ["list.search.query"], "path_glob": "/lfi_include/*", "rules_target": [{"rule_id": "dog-913-009"}], "scope": [{"env": "dd-appsec-php-support", "service": "anil-php-weblog"}]}, "id": "3dd-0uc-h1s", "type": "exclusion_filter"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/asm-respond-backend + Scenario: Update an ASM Exclusion filter returns "Concurrent Modification" response + Given new "UpdateApplicationSecurityExclusionFilter" request + And request contains "exclusion_filter_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"description": "My Exclusion filter", "enabled": true, "ip_list": ["127.0.0.1"], "parameters": ["list.search.query"], "path_glob": "/lfi_include/*", "rules_target": [{"rule_id": "dog-913-009"}], "scope": [{"env": "dd-appsec-php-support", "service": "anil-php-weblog"}]}, "id": "3dd-0uc-h1s", "type": "exclusion_filter"}} + When the request is sent + Then the response status is 409 Concurrent Modification + + @generated @skip @team:DataDog/asm-respond-backend + Scenario: Update an ASM Exclusion filter returns "Not Found" response + Given new "UpdateApplicationSecurityExclusionFilter" request + And request contains "exclusion_filter_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"description": "My Exclusion filter", "enabled": true, "ip_list": ["127.0.0.1"], "parameters": ["list.search.query"], "path_glob": "/lfi_include/*", "rules_target": [{"rule_id": "dog-913-009"}], "scope": [{"env": "dd-appsec-php-support", "service": "anil-php-weblog"}]}, "id": "3dd-0uc-h1s", "type": "exclusion_filter"}} + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/asm-respond-backend + Scenario: Update an ASM Exclusion filter returns "OK" response + Given new "UpdateApplicationSecurityExclusionFilter" request + And request contains "exclusion_filter_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"description": "My Exclusion filter", "enabled": true, "ip_list": ["127.0.0.1"], "parameters": ["list.search.query"], "path_glob": "/lfi_include/*", "rules_target": [{"rule_id": "dog-913-009"}], "scope": [{"env": "dd-appsec-php-support", "service": "anil-php-weblog"}]}, "id": "3dd-0uc-h1s", "type": "exclusion_filter"}} + When the request is sent + Then the response status is 200 OK diff --git a/tests/scenarios/features/v2/given.json b/tests/scenarios/features/v2/given.json index efc7bed91..5f48cef94 100644 --- a/tests/scenarios/features/v2/given.json +++ b/tests/scenarios/features/v2/given.json @@ -391,6 +391,18 @@ "tag": "Powerpack", "operationId": "CreatePowerpack" }, + { + "parameters": [ + { + "name": "body", + "value": "{\n \"data\": {\n \"type\": \"exclusion_filter\",\n \"attributes\": {\n \"description\": \"My Exclusion Filter\",\n \"enabled\": true,\n \"path_glob\": \"*\",\n \"parameters\": [\n \"list.search.query\"\n ],\n \"rules_target\": [\n {\n \"tags\": {\n \"category\":\"attack_attempt\",\n \"type\":\"xss\"\n }\n }\n ],\n \"scope\": [\n {\n \"env\": \"staging\",\n \"service\": \"event-query\"\n }\n ]\n }\n }\n}" + } + ], + "step": "there is a valid \"exclusion_filter\" in the system", + "key": "exclusion_filter", + "tag": "Application Security Exclusion Filters", + "operationId": "CreateApplicationSecurityExclusionFilter" + }, { "parameters": [ { diff --git a/tests/scenarios/features/v2/undo.json b/tests/scenarios/features/v2/undo.json index 62da7c99e..69f656fc9 100644 --- a/tests/scenarios/features/v2/undo.json +++ b/tests/scenarios/features/v2/undo.json @@ -1516,6 +1516,43 @@ "type": "idempotent" } }, + "ListApplicationSecurityExclusionFilters": { + "tag": "Application Security Exclusion Filters", + "undo": { + "type": "safe" + } + }, + "CreateApplicationSecurityExclusionFilter": { + "tag": "Application Security Exclusion Filters", + "undo": { + "operationId": "DeleteApplicationSecurityExclusionFilter", + "parameters": [ + { + "name": "exclusion_filter_id", + "source": "data.id" + } + ], + "type": "unsafe" + } + }, + "DeleteApplicationSecurityExclusionFilter": { + "tag": "Application Security Exclusion Filters", + "undo": { + "type": "idempotent" + } + }, + "GetApplicationSecurityExclusionFilters": { + "tag": "Application Security Exclusion Filters", + "undo": { + "type": "safe" + } + }, + "UpdateApplicationSecurityExclusionFilter": { + "tag": "Application Security Exclusion Filters", + "undo": { + "type": "idempotent" + } + }, "ListCSMThreatsAgentRules": { "tag": "CSM Threats", "undo": { diff --git a/tests/scenarios/function_mappings.rs b/tests/scenarios/function_mappings.rs index ca405dc21..a3b7f3399 100644 --- a/tests/scenarios/function_mappings.rs +++ b/tests/scenarios/function_mappings.rs @@ -23,28 +23,21 @@ pub struct ApiInstances { pub v1_api_snapshots: Option, pub v1_api_hosts: Option, pub v1_api_aws_integration: Option, - pub v1_api_aws_logs_integration: - Option, + pub v1_api_aws_logs_integration: Option, pub v1_api_azure_integration: Option, pub v1_api_gcp_integration: Option, - pub v1_api_pager_duty_integration: - Option, + pub v1_api_pager_duty_integration: Option, pub v1_api_slack_integration: Option, - pub v1_api_webhooks_integration: - Option, + pub v1_api_webhooks_integration: Option, pub v1_api_logs: Option, pub v1_api_logs_indexes: Option, pub v1_api_logs_pipelines: Option, pub v1_api_monitors: Option, pub v1_api_notebooks: Option, pub v1_api_organizations: Option, - pub v1_api_security_monitoring: - Option, - pub v1_api_service_level_objectives: - Option, - pub v1_api_service_level_objective_corrections: Option< - datadogV1::api_service_level_objective_corrections::ServiceLevelObjectiveCorrectionsAPI, - >, + pub v1_api_security_monitoring: Option, + pub v1_api_service_level_objectives: Option, + pub v1_api_service_level_objective_corrections: Option, pub v1_api_synthetics: Option, pub v1_api_tags: Option, pub v1_api_users: Option, @@ -52,20 +45,16 @@ pub struct ApiInstances { pub v2_api_key_management: Option, pub v2_api_api_management: Option, pub v2_api_spans_metrics: Option, - pub v2_api_apm_retention_filters: - Option, + pub v2_api_apm_retention_filters: Option, pub v2_api_audit: Option, pub v2_api_authn_mappings: Option, pub v2_api_case_management: Option, pub v2_api_software_catalog: Option, - pub v2_api_ci_visibility_pipelines: - Option, - pub v2_api_ci_visibility_tests: - Option, + pub v2_api_ci_visibility_pipelines: Option, + pub v2_api_ci_visibility_tests: Option, pub v2_api_container_images: Option, pub v2_api_containers: Option, - pub v2_api_cloud_cost_management: - Option, + pub v2_api_cloud_cost_management: Option, pub v2_api_usage_metering: Option, pub v2_api_dashboard_lists: Option, pub v2_api_dora_metrics: Option, @@ -73,50 +62,41 @@ pub struct ApiInstances { pub v2_api_events: Option, pub v2_api_incidents: Option, pub v2_api_gcp_integration: Option, - pub v2_api_microsoft_teams_integration: - Option, - pub v2_api_opsgenie_integration: - Option, - pub v2_api_cloudflare_integration: - Option, + pub v2_api_microsoft_teams_integration: Option, + pub v2_api_opsgenie_integration: Option, + pub v2_api_cloudflare_integration: Option, pub v2_api_confluent_cloud: Option, pub v2_api_fastly_integration: Option, pub v2_api_okta_integration: Option, pub v2_api_ip_allowlist: Option, pub v2_api_logs: Option, pub v2_api_logs_archives: Option, - pub v2_api_logs_custom_destinations: - Option, + pub v2_api_logs_custom_destinations: Option, pub v2_api_logs_metrics: Option, pub v2_api_metrics: Option, pub v2_api_monitors: Option, - pub v2_api_network_device_monitoring: - Option, + pub v2_api_network_device_monitoring: Option, pub v2_api_organizations: Option, pub v2_api_roles: Option, - pub v2_api_security_monitoring: - Option, + pub v2_api_security_monitoring: Option, pub v2_api_powerpack: Option, pub v2_api_processes: Option, + pub v2_api_application_security_exclusion_filters: Option, pub v2_api_csm_threats: Option, - pub v2_api_restriction_policies: - Option, + pub v2_api_restriction_policies: Option, pub v2_api_rum: Option, pub v2_api_service_scorecards: Option, - pub v2_api_sensitive_data_scanner: - Option, + pub v2_api_sensitive_data_scanner: Option, pub v2_api_service_accounts: Option, pub v2_api_incident_services: Option, pub v2_api_service_definition: Option, - pub v2_api_service_level_objectives: - Option, + pub v2_api_service_level_objectives: Option, pub v2_api_spans: Option, pub v2_api_synthetics: Option, pub v2_api_teams: Option, pub v2_api_incident_teams: Option, pub v2_api_users: Option, - pub v2_api_workflow_automation: - Option, + pub v2_api_workflow_automation: Option, } pub fn initialize_api_instance(world: &mut DatadogWorld, api: String) { @@ -643,6 +623,12 @@ pub fn initialize_api_instance(world: &mut DatadogWorld, api: String) { ), ); } + "ApplicationSecurityExclusionFilters" => { + world.api_instances.v2_api_application_security_exclusion_filters = Some(datadogV2::api_application_security_exclusion_filters::ApplicationSecurityExclusionFiltersAPI::with_client_and_config( + world.config.clone(), + world.http_client.as_ref().unwrap().clone() + )); + } "CSMThreats" => { world.api_instances.v2_api_csm_threats = Some( datadogV2::api_csm_threats::CSMThreatsAPI::with_client_and_config( @@ -2612,6 +2598,26 @@ pub fn collect_function_calls(world: &mut DatadogWorld) { "v2.ListProcessesWithPagination".into(), test_v2_list_processes_with_pagination, ); + world.function_mappings.insert( + "v2.ListApplicationSecurityExclusionFilters".into(), + test_v2_list_application_security_exclusion_filters, + ); + world.function_mappings.insert( + "v2.CreateApplicationSecurityExclusionFilter".into(), + test_v2_create_application_security_exclusion_filter, + ); + world.function_mappings.insert( + "v2.DeleteApplicationSecurityExclusionFilter".into(), + test_v2_delete_application_security_exclusion_filter, + ); + world.function_mappings.insert( + "v2.GetApplicationSecurityExclusionFilters".into(), + test_v2_get_application_security_exclusion_filters, + ); + world.function_mappings.insert( + "v2.UpdateApplicationSecurityExclusionFilter".into(), + test_v2_update_application_security_exclusion_filter, + ); world.function_mappings.insert( "v2.ListCSMThreatsAgentRules".into(), test_v2_list_csm_threats_agent_rules, @@ -19607,6 +19613,157 @@ fn test_v2_list_processes_with_pagination( world.response.code = 200; } +fn test_v2_list_application_security_exclusion_filters( + world: &mut DatadogWorld, + _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_application_security_exclusion_filters + .as_ref() + .expect("api instance not found"); + let response = match block_on(api.list_application_security_exclusion_filters_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_application_security_exclusion_filter( + world: &mut DatadogWorld, + _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_application_security_exclusion_filters + .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_application_security_exclusion_filter_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_application_security_exclusion_filter( + world: &mut DatadogWorld, + _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_application_security_exclusion_filters + .as_ref() + .expect("api instance not found"); + let exclusion_filter_id = + serde_json::from_value(_parameters.get("exclusion_filter_id").unwrap().clone()).unwrap(); + let response = match block_on( + api.delete_application_security_exclusion_filter_with_http_info(exclusion_filter_id), + ) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + +fn test_v2_get_application_security_exclusion_filters( + world: &mut DatadogWorld, + _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_application_security_exclusion_filters + .as_ref() + .expect("api instance not found"); + let exclusion_filter_id = + serde_json::from_value(_parameters.get("exclusion_filter_id").unwrap().clone()).unwrap(); + let response = match block_on( + api.get_application_security_exclusion_filters_with_http_info(exclusion_filter_id), + ) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + +fn test_v2_update_application_security_exclusion_filter( + world: &mut DatadogWorld, + _parameters: &HashMap, +) { + let api = world + .api_instances + .v2_api_application_security_exclusion_filters + .as_ref() + .expect("api instance not found"); + let exclusion_filter_id = + serde_json::from_value(_parameters.get("exclusion_filter_id").unwrap().clone()).unwrap(); + let body = serde_json::from_value(_parameters.get("body").unwrap().clone()).unwrap(); + let response = match block_on( + api.update_application_security_exclusion_filter_with_http_info(exclusion_filter_id, body), + ) { + Ok(response) => response, + Err(error) => { + return match error { + Error::ResponseError(e) => { + world.response.code = e.status.as_u16(); + if let Some(entity) = e.entity { + world.response.object = serde_json::to_value(entity).unwrap(); + } + } + _ => panic!("error parsing response: {error}"), + }; + } + }; + world.response.object = serde_json::to_value(response.entity).unwrap(); + world.response.code = response.status.as_u16(); +} + fn test_v2_list_csm_threats_agent_rules( world: &mut DatadogWorld, _parameters: &HashMap,