diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index a0d181216789..ce659f72c1bf 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -155,6 +155,14 @@ components: required: false schema: $ref: '#/components/schemas/ApplicationKeysSort' + ApplicationSecurityPolicyIDParam: + description: The ID of the policy. + example: recommended + in: path + name: policy_id + required: true + schema: + type: string ApplicationSecurityWafCustomRuleIDParam: description: The ID of the custom rule. example: 3b5-v82-ns6 @@ -3159,6 +3167,292 @@ components: type: string x-enum-varnames: - APPLICATION_KEYS + ApplicationSecurityPolicyAttributes: + description: A WAF policy. + properties: + description: + description: Description of the WAF policy. + example: Policy applied to internal web applications. + type: string + isDefault: + description: Make this policy the default policy. The default policy is + applied to every services not specifically added to another policy. + example: false + type: boolean + name: + description: The Name of the WAF policy. + example: Internal Network Policy + type: string + protectionPresets: + description: Presets enabled on this policy. + items: + example: attack-tools + type: string + type: array + rules: + description: Rule overrides applied by the policy. + items: + $ref: '#/components/schemas/ApplicationSecurityPolicyRuleOverride' + type: array + scope: + description: The scope of the WAF policy. + items: + $ref: '#/components/schemas/ApplicationSecurityPolicyScope' + type: array + version: + default: 0 + description: Version of the WAF ruleset maintained by Datadog used by this + policy. 0 is the default value. + example: 0 + format: int64 + type: integer + required: + - name + - description + type: object + ApplicationSecurityPolicyCreateAttributes: + description: Create a new WAF policy. + properties: + basedOn: + description: When creating a new policy, clone the policy indicated by this + identifier. + example: recommended + type: string + description: + description: Description of the WAF policy. + example: Policy applied to internal web applications. + type: string + isDefault: + description: Make this policy the default policy. The default policy is + applied to every services not specifically added to another policy. + example: false + type: boolean + name: + description: The Name of the WAF policy. + example: Internal Network Policy + type: string + protectionPresets: + description: Presets enabled on this policy. + items: + example: attack-tools + type: string + type: array + rules: + description: Rule overrides applied by the policy. + items: + $ref: '#/components/schemas/ApplicationSecurityPolicyRuleOverride' + type: array + scope: + description: The scope of the WAF policy. + items: + $ref: '#/components/schemas/ApplicationSecurityPolicyScope' + type: array + version: + default: 0 + description: Version of the WAF ruleset maintained by Datadog used by this + policy. 0 is the default value. + example: 0 + format: int64 + type: integer + required: + - name + - description + - basedOn + type: object + ApplicationSecurityPolicyCreateData: + description: Object for a single WAF policy. + properties: + attributes: + $ref: '#/components/schemas/ApplicationSecurityPolicyCreateAttributes' + type: + $ref: '#/components/schemas/ApplicationSecurityPolicyType' + required: + - attributes + - type + type: object + ApplicationSecurityPolicyCreateRequest: + description: Request object that includes the policy to create. + properties: + data: + $ref: '#/components/schemas/ApplicationSecurityPolicyCreateData' + required: + - data + type: object + ApplicationSecurityPolicyData: + description: Object for a single WAF policy. + properties: + attributes: + $ref: '#/components/schemas/ApplicationSecurityPolicyAttributes' + id: + description: The ID of the policy. + example: 2857c47d-1e3a-4300-8b2f-dc24089c084b + readOnly: true + type: string + metadata: + $ref: '#/components/schemas/ApplicationSecurityPolicyMetadata' + type: + $ref: '#/components/schemas/ApplicationSecurityPolicyType' + type: object + ApplicationSecurityPolicyListResponse: + description: Response object that includes a list of WAF policies. + properties: + data: + description: The WAF policy data. + items: + $ref: '#/components/schemas/ApplicationSecurityPolicyData' + type: array + type: object + ApplicationSecurityPolicyMetadata: + description: Metadata associated with the WAF policy. + properties: + added_at: + description: The date and time the WAF policy was created. + example: '2021-01-01T00:00:00Z' + format: date-time + type: string + added_by: + description: The handle of the user who created the WAF policy. + example: john.doe@datadoghq.com + type: string + added_by_name: + description: The name of the user who created the WAF policy. + example: John Doe + type: string + modified_at: + description: The date and time the WAF policy was last updated. + example: '2021-01-01T00:00:00Z' + format: date-time + type: string + modified_by: + description: The handle of the user who last updated the WAF policy. + example: john.doe@datadoghq.com + type: string + modified_by_name: + description: The name of the user who last updated the WAF policy. + example: John Doe + type: string + readOnly: true + type: object + ApplicationSecurityPolicyResponse: + description: Response object that includes a single WAF policy. + properties: + data: + $ref: '#/components/schemas/ApplicationSecurityPolicyData' + type: object + ApplicationSecurityPolicyRuleOverride: + description: Override WAF rule parameters for services in a policy. + properties: + blocking: + description: When blocking is enabled, the rule will block the traffic matched + by this rule. + example: false + type: boolean + enabled: + description: When false, this rule will not match any traffic. + example: true + type: boolean + id: + description: Override the parameters for this WAF rule identifier. + example: rasp-001-002 + type: string + required: + - id + - enabled + - blocking + type: object + ApplicationSecurityPolicyScope: + description: The scope of the WAF policy. + properties: + env: + description: The environment scope for the WAF policy. + example: prod + type: string + service: + description: The service scope for the WAF policy. + example: billing-service + type: string + required: + - service + - env + type: object + ApplicationSecurityPolicyType: + default: policy + description: The type of the resource. The value should always be `policy`. + enum: + - policy + example: policy + type: string + x-enum-varnames: + - POLICY + ApplicationSecurityPolicyUpdateAttributes: + description: Update a WAF policy. + properties: + description: + description: Description of the WAF policy. + example: Policy applied to internal web applications. + type: string + isDefault: + description: Make this policy the default policy. The default policy is + applied to every services not specifically added to another policy. + example: false + type: boolean + name: + description: The Name of the WAF policy. + example: Internal Network Policy + type: string + protectionPresets: + description: Presets enabled on this policy. + example: + - attack-tools + items: + example: attack-tools + type: string + type: array + rules: + description: Rule overrides applied by the policy. + items: + $ref: '#/components/schemas/ApplicationSecurityPolicyRuleOverride' + type: array + scope: + description: The scope of the WAF policy. + items: + $ref: '#/components/schemas/ApplicationSecurityPolicyScope' + type: array + version: + default: 0 + description: Version of the WAF ruleset maintained by Datadog used by this + policy. 0 is the default value. + example: 0 + format: int64 + type: integer + required: + - name + - description + - version + - isDefault + - rules + - protectionPresets + - scope + type: object + ApplicationSecurityPolicyUpdateData: + description: Object for a single WAF policy. + properties: + attributes: + $ref: '#/components/schemas/ApplicationSecurityPolicyUpdateAttributes' + type: + $ref: '#/components/schemas/ApplicationSecurityPolicyType' + required: + - attributes + - type + type: object + ApplicationSecurityPolicyUpdateRequest: + description: Request object that includes the policy to update. + properties: + data: + $ref: '#/components/schemas/ApplicationSecurityPolicyUpdateData' + required: + - data + type: object ApplicationSecurityWafCustomRuleAction: description: The definition of `ApplicationSecurityWafCustomRuleAction` object. properties: @@ -67009,6 +67303,130 @@ paths: permissions: - appsec_protect_write x-terraform-resource: appsec_waf_exclusion_filter + /api/v2/remote_config/products/asm/waf/policies: + get: + description: Retrieve a list of WAF policies. + operationId: ListApplicationSecurityWAFPolicies + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/ApplicationSecurityPolicyListResponse' + description: OK + '403': + $ref: '#/components/responses/NotAuthorizedResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: List all WAF policies + tags: + - Application Security + post: + description: Create a new WAF policy. + operationId: CreateApplicationSecurityWafPolicy + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ApplicationSecurityPolicyCreateRequest' + description: The new WAF policy. + required: true + responses: + '201': + content: + application/json: + schema: + $ref: '#/components/schemas/ApplicationSecurityPolicyResponse' + description: Created + '400': + $ref: '#/components/responses/BadRequestResponse' + '403': + $ref: '#/components/responses/NotAuthorizedResponse' + '409': + $ref: '#/components/responses/ConcurrentModificationResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: Create a WAF Policy + tags: + - Application Security + x-codegen-request-body-name: body + /api/v2/remote_config/products/asm/waf/policies/{policy_id}: + delete: + description: Delete a specific WAF policy. + operationId: DeleteApplicationSecurityWafPolicy + parameters: + - $ref: '#/components/parameters/ApplicationSecurityPolicyIDParam' + responses: + '204': + description: No Content + '403': + $ref: '#/components/responses/NotAuthorizedResponse' + '404': + $ref: '#/components/responses/NotFoundResponse' + '409': + $ref: '#/components/responses/ConcurrentModificationResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: Delete a WAF Policy + tags: + - Application Security + x-terraform-resource: appsec_waf_policy + get: + description: Retrieve a WAF policy by ID. + operationId: GetApplicationSecurityWafPolicy + parameters: + - $ref: '#/components/parameters/ApplicationSecurityPolicyIDParam' + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/ApplicationSecurityPolicyResponse' + description: OK + '403': + $ref: '#/components/responses/NotAuthorizedResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: Get a WAF Policy + tags: + - Application Security + x-terraform-resource: appsec_waf_policy + put: + description: 'Update a specific WAF policy. + + Returns the Policy object when the request is successful.' + operationId: UpdateApplicationSecurityWafPolicy + parameters: + - $ref: '#/components/parameters/ApplicationSecurityPolicyIDParam' + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ApplicationSecurityPolicyUpdateRequest' + description: New WAF Policy. + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/ApplicationSecurityPolicyResponse' + 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 a WAF Policy + tags: + - Application Security + x-codegen-request-body-name: body + x-terraform-resource: appsec_waf_policy /api/v2/remote_config/products/cws/agent_rules: get: description: 'Get the list of Workload Protection agent rules. diff --git a/examples/v2/application-security/CreateApplicationSecurityWafPolicy.rb b/examples/v2/application-security/CreateApplicationSecurityWafPolicy.rb new file mode 100644 index 000000000000..16936b128631 --- /dev/null +++ b/examples/v2/application-security/CreateApplicationSecurityWafPolicy.rb @@ -0,0 +1,34 @@ +# Create a WAF Policy returns "Created" response + +require "datadog_api_client" +api_instance = DatadogAPIClient::V2::ApplicationSecurityAPI.new + +body = DatadogAPIClient::V2::ApplicationSecurityPolicyCreateRequest.new({ + data: DatadogAPIClient::V2::ApplicationSecurityPolicyCreateData.new({ + attributes: DatadogAPIClient::V2::ApplicationSecurityPolicyCreateAttributes.new({ + based_on: "recommended", + description: "Policy applied to internal web applications.", + is_default: false, + name: "Internal Network Policy", + protection_presets: [ + "attack-tools", + ], + rules: [ + DatadogAPIClient::V2::ApplicationSecurityPolicyRuleOverride.new({ + blocking: false, + enabled: true, + id: "rasp-001-002", + }), + ], + scope: [ + DatadogAPIClient::V2::ApplicationSecurityPolicyScope.new({ + env: "prod", + service: "billing-service", + }), + ], + version: 0, + }), + type: DatadogAPIClient::V2::ApplicationSecurityPolicyType::POLICY, + }), +}) +p api_instance.create_application_security_waf_policy(body) diff --git a/examples/v2/application-security/DeleteApplicationSecurityWafPolicy.rb b/examples/v2/application-security/DeleteApplicationSecurityWafPolicy.rb new file mode 100644 index 000000000000..51f98cf0cc62 --- /dev/null +++ b/examples/v2/application-security/DeleteApplicationSecurityWafPolicy.rb @@ -0,0 +1,5 @@ +# Delete a WAF Policy returns "No Content" response + +require "datadog_api_client" +api_instance = DatadogAPIClient::V2::ApplicationSecurityAPI.new +api_instance.delete_application_security_waf_policy("policy_id") diff --git a/examples/v2/application-security/GetApplicationSecurityWafPolicy.rb b/examples/v2/application-security/GetApplicationSecurityWafPolicy.rb new file mode 100644 index 000000000000..27eeaa82f26d --- /dev/null +++ b/examples/v2/application-security/GetApplicationSecurityWafPolicy.rb @@ -0,0 +1,5 @@ +# Get a WAF Policy returns "OK" response + +require "datadog_api_client" +api_instance = DatadogAPIClient::V2::ApplicationSecurityAPI.new +p api_instance.get_application_security_waf_policy("policy_id") diff --git a/examples/v2/application-security/ListApplicationSecurityWAFPolicies.rb b/examples/v2/application-security/ListApplicationSecurityWAFPolicies.rb new file mode 100644 index 000000000000..ceca5b01b3e1 --- /dev/null +++ b/examples/v2/application-security/ListApplicationSecurityWAFPolicies.rb @@ -0,0 +1,5 @@ +# List all WAF policies returns "OK" response + +require "datadog_api_client" +api_instance = DatadogAPIClient::V2::ApplicationSecurityAPI.new +p api_instance.list_application_security_waf_policies() diff --git a/examples/v2/application-security/UpdateApplicationSecurityWafPolicy.rb b/examples/v2/application-security/UpdateApplicationSecurityWafPolicy.rb new file mode 100644 index 000000000000..6891f43cd11f --- /dev/null +++ b/examples/v2/application-security/UpdateApplicationSecurityWafPolicy.rb @@ -0,0 +1,33 @@ +# Update a WAF Policy returns "OK" response + +require "datadog_api_client" +api_instance = DatadogAPIClient::V2::ApplicationSecurityAPI.new + +body = DatadogAPIClient::V2::ApplicationSecurityPolicyUpdateRequest.new({ + data: DatadogAPIClient::V2::ApplicationSecurityPolicyUpdateData.new({ + attributes: DatadogAPIClient::V2::ApplicationSecurityPolicyUpdateAttributes.new({ + description: "Policy applied to internal web applications.", + is_default: false, + name: "Internal Network Policy", + protection_presets: [ + "attack-tools", + ], + rules: [ + DatadogAPIClient::V2::ApplicationSecurityPolicyRuleOverride.new({ + blocking: false, + enabled: true, + id: "rasp-001-002", + }), + ], + scope: [ + DatadogAPIClient::V2::ApplicationSecurityPolicyScope.new({ + env: "prod", + service: "billing-service", + }), + ], + version: 0, + }), + type: DatadogAPIClient::V2::ApplicationSecurityPolicyType::POLICY, + }), +}) +p api_instance.update_application_security_waf_policy("policy_id", body) diff --git a/features/scenarios_model_mapping.rb b/features/scenarios_model_mapping.rb index 5cbf5c8ea60e..c0cf8d950312 100644 --- a/features/scenarios_model_mapping.rb +++ b/features/scenarios_model_mapping.rb @@ -2581,6 +2581,19 @@ "exclusion_filter_id" => "String", "body" => "ApplicationSecurityWafExclusionFilterUpdateRequest", }, + "v2.CreateApplicationSecurityWafPolicy" => { + "body" => "ApplicationSecurityPolicyCreateRequest", + }, + "v2.DeleteApplicationSecurityWafPolicy" => { + "policy_id" => "String", + }, + "v2.GetApplicationSecurityWafPolicy" => { + "policy_id" => "String", + }, + "v2.UpdateApplicationSecurityWafPolicy" => { + "policy_id" => "String", + "body" => "ApplicationSecurityPolicyUpdateRequest", + }, "v2.ListCSMThreatsAgentRules" => { "policy_id" => "String", }, diff --git a/features/v2/application_security.feature b/features/v2/application_security.feature index f10a470ff2e0..fa4288ef7caf 100644 --- a/features/v2/application_security.feature +++ b/features/v2/application_security.feature @@ -13,6 +13,27 @@ Feature: Application Security And a valid "appKeyAuth" key in the system And an instance of "ApplicationSecurity" API + @generated @skip @team:DataDog/asm-backend + Scenario: Create a WAF Policy returns "Bad Request" response + Given new "CreateApplicationSecurityWafPolicy" request + And body with value {"data": {"attributes": {"basedOn": "recommended", "description": "Policy applied to internal web applications.", "isDefault": false, "name": "Internal Network Policy", "protectionPresets": ["attack-tools"], "rules": [{"blocking": false, "enabled": true, "id": "rasp-001-002"}], "scope": [{"env": "prod", "service": "billing-service"}], "version": 0}, "type": "policy"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/asm-backend + Scenario: Create a WAF Policy returns "Concurrent Modification" response + Given new "CreateApplicationSecurityWafPolicy" request + And body with value {"data": {"attributes": {"basedOn": "recommended", "description": "Policy applied to internal web applications.", "isDefault": false, "name": "Internal Network Policy", "protectionPresets": ["attack-tools"], "rules": [{"blocking": false, "enabled": true, "id": "rasp-001-002"}], "scope": [{"env": "prod", "service": "billing-service"}], "version": 0}, "type": "policy"}} + When the request is sent + Then the response status is 409 Concurrent Modification + + @generated @skip @team:DataDog/asm-backend + Scenario: Create a WAF Policy returns "Created" response + Given new "CreateApplicationSecurityWafPolicy" request + And body with value {"data": {"attributes": {"basedOn": "recommended", "description": "Policy applied to internal web applications.", "isDefault": false, "name": "Internal Network Policy", "protectionPresets": ["attack-tools"], "rules": [{"blocking": false, "enabled": true, "id": "rasp-001-002"}], "scope": [{"env": "prod", "service": "billing-service"}], "version": 0}, "type": "policy"}} + When the request is sent + Then the response status is 201 Created + @generated @skip @team:DataDog/asm-backend Scenario: Create a WAF custom rule returns "Bad Request" response Given new "CreateApplicationSecurityWafCustomRule" request @@ -84,6 +105,27 @@ Feature: Application Security When the request is sent Then the response status is 404 Not Found + @generated @skip @team:DataDog/asm-backend + Scenario: Delete a WAF Policy returns "Concurrent Modification" response + Given new "DeleteApplicationSecurityWafPolicy" request + And request contains "policy_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 409 Concurrent Modification + + @generated @skip @team:DataDog/asm-backend + Scenario: Delete a WAF Policy returns "No Content" response + Given new "DeleteApplicationSecurityWafPolicy" request + And request contains "policy_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 204 No Content + + @generated @skip @team:DataDog/asm-backend + Scenario: Delete a WAF Policy returns "Not Found" response + Given new "DeleteApplicationSecurityWafPolicy" request + And request contains "policy_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + @generated @skip @team:DataDog/asm-backend Scenario: Delete a WAF exclusion filter returns "Concurrent Modification" response Given new "DeleteApplicationSecurityWafExclusionFilter" request @@ -106,6 +148,13 @@ Feature: Application Security When the request is sent Then the response status is 204 OK + @generated @skip @team:DataDog/asm-backend + Scenario: Get a WAF Policy returns "OK" response + Given new "GetApplicationSecurityWafPolicy" request + And request contains "policy_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK + @generated @skip @team:DataDog/asm-backend Scenario: Get a WAF custom rule returns "OK" response Given new "GetApplicationSecurityWafCustomRule" request @@ -140,6 +189,12 @@ Feature: Application Security When the request is sent Then the response status is 200 OK + @generated @skip @team:DataDog/asm-backend + Scenario: List all WAF policies returns "OK" response + Given new "ListApplicationSecurityWAFPolicies" request + When the request is sent + Then the response status is 200 OK + @team:DataDog/asm-backend Scenario: Update a WAF Custom Rule returns "Bad Request" response Given there is a valid "custom_rule" in the system @@ -174,6 +229,38 @@ Feature: Application Security When the request is sent Then the response status is 200 OK + @generated @skip @team:DataDog/asm-backend + Scenario: Update a WAF Policy returns "Bad Request" response + Given new "UpdateApplicationSecurityWafPolicy" request + And request contains "policy_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"description": "Policy applied to internal web applications.", "isDefault": false, "name": "Internal Network Policy", "protectionPresets": ["attack-tools"], "rules": [{"blocking": false, "enabled": true, "id": "rasp-001-002"}], "scope": [{"env": "prod", "service": "billing-service"}], "version": 0}, "type": "policy"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/asm-backend + Scenario: Update a WAF Policy returns "Concurrent Modification" response + Given new "UpdateApplicationSecurityWafPolicy" request + And request contains "policy_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"description": "Policy applied to internal web applications.", "isDefault": false, "name": "Internal Network Policy", "protectionPresets": ["attack-tools"], "rules": [{"blocking": false, "enabled": true, "id": "rasp-001-002"}], "scope": [{"env": "prod", "service": "billing-service"}], "version": 0}, "type": "policy"}} + When the request is sent + Then the response status is 409 Concurrent Modification + + @generated @skip @team:DataDog/asm-backend + Scenario: Update a WAF Policy returns "Not Found" response + Given new "UpdateApplicationSecurityWafPolicy" request + And request contains "policy_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"description": "Policy applied to internal web applications.", "isDefault": false, "name": "Internal Network Policy", "protectionPresets": ["attack-tools"], "rules": [{"blocking": false, "enabled": true, "id": "rasp-001-002"}], "scope": [{"env": "prod", "service": "billing-service"}], "version": 0}, "type": "policy"}} + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/asm-backend + Scenario: Update a WAF Policy returns "OK" response + Given new "UpdateApplicationSecurityWafPolicy" request + And request contains "policy_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"description": "Policy applied to internal web applications.", "isDefault": false, "name": "Internal Network Policy", "protectionPresets": ["attack-tools"], "rules": [{"blocking": false, "enabled": true, "id": "rasp-001-002"}], "scope": [{"env": "prod", "service": "billing-service"}], "version": 0}, "type": "policy"}} + When the request is sent + Then the response status is 200 OK + @team:DataDog/asm-backend Scenario: Update a WAF exclusion filter returns "Bad Request" response Given there is a valid "custom_rule" in the system diff --git a/features/v2/given.json b/features/v2/given.json index 06f7f855c1a1..24cd82910f04 100644 --- a/features/v2/given.json +++ b/features/v2/given.json @@ -693,6 +693,18 @@ "tag": "Application Security", "operationId": "CreateApplicationSecurityWafExclusionFilter" }, + { + "parameters": [ + { + "name": "body", + "value": "{\n \"data\": {\n \"type\": \"policy\",\n \"attributes\": {\n \"name\": \"Test policy\",\n \"description\": \"This is a test policy.\",\n \"basedOn\": \"recommended\"\n }\n }\n}" + } + ], + "step": "there is a valid \"policy\" in the system", + "key": "policy", + "tag": "Application Security", + "operationId": "CreateApplicationSecurityWafPolicy" + }, { "parameters": [ { diff --git a/features/v2/undo.json b/features/v2/undo.json index c4c269d3cab9..01cf520a88c7 100644 --- a/features/v2/undo.json +++ b/features/v2/undo.json @@ -2715,6 +2715,43 @@ "type": "idempotent" } }, + "ListApplicationSecurityWAFPolicies": { + "tag": "Application Security", + "undo": { + "type": "safe" + } + }, + "CreateApplicationSecurityWafPolicy": { + "tag": "Application Security", + "undo": { + "operationId": "DeleteApplicationSecurityWafPolicy", + "parameters": [ + { + "name": "policy_id", + "source": "data.id" + } + ], + "type": "unsafe" + } + }, + "DeleteApplicationSecurityWafPolicy": { + "tag": "Application Security", + "undo": { + "type": "idempotent" + } + }, + "GetApplicationSecurityWafPolicy": { + "tag": "Application Security", + "undo": { + "type": "safe" + } + }, + "UpdateApplicationSecurityWafPolicy": { + "tag": "Application Security", + "undo": { + "type": "idempotent" + } + }, "ListCSMThreatsAgentRules": { "tag": "CSM Threats", "undo": { diff --git a/lib/datadog_api_client/inflector.rb b/lib/datadog_api_client/inflector.rb index 5f593e64148e..cb3eeabba278 100644 --- a/lib/datadog_api_client/inflector.rb +++ b/lib/datadog_api_client/inflector.rb @@ -1034,6 +1034,20 @@ def overrides "v2.application_key_update_attributes" => "ApplicationKeyUpdateAttributes", "v2.application_key_update_data" => "ApplicationKeyUpdateData", "v2.application_key_update_request" => "ApplicationKeyUpdateRequest", + "v2.application_security_policy_attributes" => "ApplicationSecurityPolicyAttributes", + "v2.application_security_policy_create_attributes" => "ApplicationSecurityPolicyCreateAttributes", + "v2.application_security_policy_create_data" => "ApplicationSecurityPolicyCreateData", + "v2.application_security_policy_create_request" => "ApplicationSecurityPolicyCreateRequest", + "v2.application_security_policy_data" => "ApplicationSecurityPolicyData", + "v2.application_security_policy_list_response" => "ApplicationSecurityPolicyListResponse", + "v2.application_security_policy_metadata" => "ApplicationSecurityPolicyMetadata", + "v2.application_security_policy_response" => "ApplicationSecurityPolicyResponse", + "v2.application_security_policy_rule_override" => "ApplicationSecurityPolicyRuleOverride", + "v2.application_security_policy_scope" => "ApplicationSecurityPolicyScope", + "v2.application_security_policy_type" => "ApplicationSecurityPolicyType", + "v2.application_security_policy_update_attributes" => "ApplicationSecurityPolicyUpdateAttributes", + "v2.application_security_policy_update_data" => "ApplicationSecurityPolicyUpdateData", + "v2.application_security_policy_update_request" => "ApplicationSecurityPolicyUpdateRequest", "v2.application_security_waf_custom_rule_action" => "ApplicationSecurityWafCustomRuleAction", "v2.application_security_waf_custom_rule_action_action" => "ApplicationSecurityWafCustomRuleActionAction", "v2.application_security_waf_custom_rule_action_parameters" => "ApplicationSecurityWafCustomRuleActionParameters", diff --git a/lib/datadog_api_client/v2/api/application_security_api.rb b/lib/datadog_api_client/v2/api/application_security_api.rb index 386170e4f96f..c8fe925f622e 100644 --- a/lib/datadog_api_client/v2/api/application_security_api.rb +++ b/lib/datadog_api_client/v2/api/application_security_api.rb @@ -160,6 +160,73 @@ def create_application_security_waf_exclusion_filter_with_http_info(body, opts = return data, status_code, headers end + # Create a WAF Policy. + # + # @see #create_application_security_waf_policy_with_http_info + def create_application_security_waf_policy(body, opts = {}) + data, _status_code, _headers = create_application_security_waf_policy_with_http_info(body, opts) + data + end + + # Create a WAF Policy. + # + # Create a new WAF policy. + # + # @param body [ApplicationSecurityPolicyCreateRequest] The new WAF policy. + # @param opts [Hash] the optional parameters + # @return [Array<(ApplicationSecurityPolicyResponse, Integer, Hash)>] ApplicationSecurityPolicyResponse data, response status code and response headers + def create_application_security_waf_policy_with_http_info(body, opts = {}) + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: ApplicationSecurityAPI.create_application_security_waf_policy ...' + end + # verify the required parameter 'body' is set + if @api_client.config.client_side_validation && body.nil? + fail ArgumentError, "Missing the required parameter 'body' when calling ApplicationSecurityAPI.create_application_security_waf_policy" + end + # resource path + local_var_path = '/api/v2/remote_config/products/asm/waf/policies' + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + # HTTP header 'Content-Type' + header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] || @api_client.object_to_http_body(body) + + # return_type + return_type = opts[:debug_return_type] || 'ApplicationSecurityPolicyResponse' + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth] + + new_options = opts.merge( + :operation => :create_application_security_waf_policy, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type, + :api_version => "V2" + ) + + data, status_code, headers = @api_client.call_api(Net::HTTP::Post, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: ApplicationSecurityAPI#create_application_security_waf_policy\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + # Delete a WAF Custom Rule. # # @see #delete_application_security_waf_custom_rule_with_http_info @@ -290,6 +357,71 @@ def delete_application_security_waf_exclusion_filter_with_http_info(exclusion_fi return data, status_code, headers end + # Delete a WAF Policy. + # + # @see #delete_application_security_waf_policy_with_http_info + def delete_application_security_waf_policy(policy_id, opts = {}) + delete_application_security_waf_policy_with_http_info(policy_id, opts) + nil + end + + # Delete a WAF Policy. + # + # Delete a specific WAF policy. + # + # @param policy_id [String] The ID of the policy. + # @param opts [Hash] the optional parameters + # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers + def delete_application_security_waf_policy_with_http_info(policy_id, opts = {}) + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: ApplicationSecurityAPI.delete_application_security_waf_policy ...' + end + # verify the required parameter 'policy_id' is set + if @api_client.config.client_side_validation && policy_id.nil? + fail ArgumentError, "Missing the required parameter 'policy_id' when calling ApplicationSecurityAPI.delete_application_security_waf_policy" + end + # resource path + local_var_path = '/api/v2/remote_config/products/asm/waf/policies/{policy_id}'.sub('{policy_id}', CGI.escape(policy_id.to_s).gsub('%2F', '/')) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['*/*']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth] + + new_options = opts.merge( + :operation => :delete_application_security_waf_policy, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type, + :api_version => "V2" + ) + + data, status_code, headers = @api_client.call_api(Net::HTTP::Delete, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: ApplicationSecurityAPI#delete_application_security_waf_policy\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + # Get a WAF custom rule. # # @see #get_application_security_waf_custom_rule_with_http_info @@ -420,6 +552,71 @@ def get_application_security_waf_exclusion_filter_with_http_info(exclusion_filte return data, status_code, headers end + # Get a WAF Policy. + # + # @see #get_application_security_waf_policy_with_http_info + def get_application_security_waf_policy(policy_id, opts = {}) + data, _status_code, _headers = get_application_security_waf_policy_with_http_info(policy_id, opts) + data + end + + # Get a WAF Policy. + # + # Retrieve a WAF policy by ID. + # + # @param policy_id [String] The ID of the policy. + # @param opts [Hash] the optional parameters + # @return [Array<(ApplicationSecurityPolicyResponse, Integer, Hash)>] ApplicationSecurityPolicyResponse data, response status code and response headers + def get_application_security_waf_policy_with_http_info(policy_id, opts = {}) + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: ApplicationSecurityAPI.get_application_security_waf_policy ...' + end + # verify the required parameter 'policy_id' is set + if @api_client.config.client_side_validation && policy_id.nil? + fail ArgumentError, "Missing the required parameter 'policy_id' when calling ApplicationSecurityAPI.get_application_security_waf_policy" + end + # resource path + local_var_path = '/api/v2/remote_config/products/asm/waf/policies/{policy_id}'.sub('{policy_id}', CGI.escape(policy_id.to_s).gsub('%2F', '/')) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'ApplicationSecurityPolicyResponse' + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth] + + new_options = opts.merge( + :operation => :get_application_security_waf_policy, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type, + :api_version => "V2" + ) + + data, status_code, headers = @api_client.call_api(Net::HTTP::Get, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: ApplicationSecurityAPI#get_application_security_waf_policy\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + # List all WAF custom rules. # # @see #list_application_security_waf_custom_rules_with_http_info @@ -540,6 +737,66 @@ def list_application_security_waf_exclusion_filters_with_http_info(opts = {}) return data, status_code, headers end + # List all WAF policies. + # + # @see #list_application_security_waf_policies_with_http_info + def list_application_security_waf_policies(opts = {}) + data, _status_code, _headers = list_application_security_waf_policies_with_http_info(opts) + data + end + + # List all WAF policies. + # + # Retrieve a list of WAF policies. + # + # @param opts [Hash] the optional parameters + # @return [Array<(ApplicationSecurityPolicyListResponse, Integer, Hash)>] ApplicationSecurityPolicyListResponse data, response status code and response headers + def list_application_security_waf_policies_with_http_info(opts = {}) + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: ApplicationSecurityAPI.list_application_security_waf_policies ...' + end + # resource path + local_var_path = '/api/v2/remote_config/products/asm/waf/policies' + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'ApplicationSecurityPolicyListResponse' + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth] + + new_options = opts.merge( + :operation => :list_application_security_waf_policies, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type, + :api_version => "V2" + ) + + data, status_code, headers = @api_client.call_api(Net::HTTP::Get, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: ApplicationSecurityAPI#list_application_security_waf_policies\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + # Update a WAF Custom Rule. # # @see #update_application_security_waf_custom_rule_with_http_info @@ -685,5 +942,78 @@ def update_application_security_waf_exclusion_filter_with_http_info(exclusion_fi end return data, status_code, headers end + + # Update a WAF Policy. + # + # @see #update_application_security_waf_policy_with_http_info + def update_application_security_waf_policy(policy_id, body, opts = {}) + data, _status_code, _headers = update_application_security_waf_policy_with_http_info(policy_id, body, opts) + data + end + + # Update a WAF Policy. + # + # Update a specific WAF policy. + # Returns the Policy object when the request is successful. + # + # @param policy_id [String] The ID of the policy. + # @param body [ApplicationSecurityPolicyUpdateRequest] New WAF Policy. + # @param opts [Hash] the optional parameters + # @return [Array<(ApplicationSecurityPolicyResponse, Integer, Hash)>] ApplicationSecurityPolicyResponse data, response status code and response headers + def update_application_security_waf_policy_with_http_info(policy_id, body, opts = {}) + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: ApplicationSecurityAPI.update_application_security_waf_policy ...' + end + # verify the required parameter 'policy_id' is set + if @api_client.config.client_side_validation && policy_id.nil? + fail ArgumentError, "Missing the required parameter 'policy_id' when calling ApplicationSecurityAPI.update_application_security_waf_policy" + end + # verify the required parameter 'body' is set + if @api_client.config.client_side_validation && body.nil? + fail ArgumentError, "Missing the required parameter 'body' when calling ApplicationSecurityAPI.update_application_security_waf_policy" + end + # resource path + local_var_path = '/api/v2/remote_config/products/asm/waf/policies/{policy_id}'.sub('{policy_id}', CGI.escape(policy_id.to_s).gsub('%2F', '/')) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + # HTTP header 'Content-Type' + header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] || @api_client.object_to_http_body(body) + + # return_type + return_type = opts[:debug_return_type] || 'ApplicationSecurityPolicyResponse' + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth] + + new_options = opts.merge( + :operation => :update_application_security_waf_policy, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type, + :api_version => "V2" + ) + + data, status_code, headers = @api_client.call_api(Net::HTTP::Put, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: ApplicationSecurityAPI#update_application_security_waf_policy\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end end end diff --git a/lib/datadog_api_client/v2/models/application_security_policy_attributes.rb b/lib/datadog_api_client/v2/models/application_security_policy_attributes.rb new file mode 100644 index 000000000000..1c7b0c3bab76 --- /dev/null +++ b/lib/datadog_api_client/v2/models/application_security_policy_attributes.rb @@ -0,0 +1,200 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # A WAF policy. + class ApplicationSecurityPolicyAttributes + include BaseGenericModel + + # Description of the WAF policy. + attr_reader :description + + # Make this policy the default policy. The default policy is applied to every services not specifically added to another policy. + attr_accessor :is_default + + # The Name of the WAF policy. + attr_reader :name + + # Presets enabled on this policy. + attr_accessor :protection_presets + + # Rule overrides applied by the policy. + attr_accessor :rules + + # The scope of the WAF policy. + attr_accessor :scope + + # Version of the WAF ruleset maintained by Datadog used by this policy. 0 is the default value. + attr_accessor :version + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'description' => :'description', + :'is_default' => :'isDefault', + :'name' => :'name', + :'protection_presets' => :'protectionPresets', + :'rules' => :'rules', + :'scope' => :'scope', + :'version' => :'version' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'description' => :'String', + :'is_default' => :'Boolean', + :'name' => :'String', + :'protection_presets' => :'Array', + :'rules' => :'Array', + :'scope' => :'Array', + :'version' => :'Integer' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::ApplicationSecurityPolicyAttributes` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'description') + self.description = attributes[:'description'] + end + + if attributes.key?(:'is_default') + self.is_default = attributes[:'is_default'] + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'protection_presets') + if (value = attributes[:'protection_presets']).is_a?(Array) + self.protection_presets = value + end + end + + if attributes.key?(:'rules') + if (value = attributes[:'rules']).is_a?(Array) + self.rules = value + end + end + + if attributes.key?(:'scope') + if (value = attributes[:'scope']).is_a?(Array) + self.scope = value + end + end + + if attributes.key?(:'version') + self.version = attributes[:'version'] + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @description.nil? + return false if @name.nil? + true + end + + # Custom attribute writer method with validation + # @param description [Object] Object to be assigned + # @!visibility private + def description=(description) + if description.nil? + fail ArgumentError, 'invalid value for "description", description cannot be nil.' + end + @description = description + end + + # Custom attribute writer method with validation + # @param name [Object] Object to be assigned + # @!visibility private + def name=(name) + if name.nil? + fail ArgumentError, 'invalid value for "name", name cannot be nil.' + end + @name = name + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + description == o.description && + is_default == o.is_default && + name == o.name && + protection_presets == o.protection_presets && + rules == o.rules && + scope == o.scope && + version == o.version && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [description, is_default, name, protection_presets, rules, scope, version, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/application_security_policy_create_attributes.rb b/lib/datadog_api_client/v2/models/application_security_policy_create_attributes.rb new file mode 100644 index 000000000000..0d8d723b33d1 --- /dev/null +++ b/lib/datadog_api_client/v2/models/application_security_policy_create_attributes.rb @@ -0,0 +1,221 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Create a new WAF policy. + class ApplicationSecurityPolicyCreateAttributes + include BaseGenericModel + + # When creating a new policy, clone the policy indicated by this identifier. + attr_reader :based_on + + # Description of the WAF policy. + attr_reader :description + + # Make this policy the default policy. The default policy is applied to every services not specifically added to another policy. + attr_accessor :is_default + + # The Name of the WAF policy. + attr_reader :name + + # Presets enabled on this policy. + attr_accessor :protection_presets + + # Rule overrides applied by the policy. + attr_accessor :rules + + # The scope of the WAF policy. + attr_accessor :scope + + # Version of the WAF ruleset maintained by Datadog used by this policy. 0 is the default value. + attr_accessor :version + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'based_on' => :'basedOn', + :'description' => :'description', + :'is_default' => :'isDefault', + :'name' => :'name', + :'protection_presets' => :'protectionPresets', + :'rules' => :'rules', + :'scope' => :'scope', + :'version' => :'version' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'based_on' => :'String', + :'description' => :'String', + :'is_default' => :'Boolean', + :'name' => :'String', + :'protection_presets' => :'Array', + :'rules' => :'Array', + :'scope' => :'Array', + :'version' => :'Integer' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::ApplicationSecurityPolicyCreateAttributes` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'based_on') + self.based_on = attributes[:'based_on'] + end + + if attributes.key?(:'description') + self.description = attributes[:'description'] + end + + if attributes.key?(:'is_default') + self.is_default = attributes[:'is_default'] + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'protection_presets') + if (value = attributes[:'protection_presets']).is_a?(Array) + self.protection_presets = value + end + end + + if attributes.key?(:'rules') + if (value = attributes[:'rules']).is_a?(Array) + self.rules = value + end + end + + if attributes.key?(:'scope') + if (value = attributes[:'scope']).is_a?(Array) + self.scope = value + end + end + + if attributes.key?(:'version') + self.version = attributes[:'version'] + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @based_on.nil? + return false if @description.nil? + return false if @name.nil? + true + end + + # Custom attribute writer method with validation + # @param based_on [Object] Object to be assigned + # @!visibility private + def based_on=(based_on) + if based_on.nil? + fail ArgumentError, 'invalid value for "based_on", based_on cannot be nil.' + end + @based_on = based_on + end + + # Custom attribute writer method with validation + # @param description [Object] Object to be assigned + # @!visibility private + def description=(description) + if description.nil? + fail ArgumentError, 'invalid value for "description", description cannot be nil.' + end + @description = description + end + + # Custom attribute writer method with validation + # @param name [Object] Object to be assigned + # @!visibility private + def name=(name) + if name.nil? + fail ArgumentError, 'invalid value for "name", name cannot be nil.' + end + @name = name + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + based_on == o.based_on && + description == o.description && + is_default == o.is_default && + name == o.name && + protection_presets == o.protection_presets && + rules == o.rules && + scope == o.scope && + version == o.version && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [based_on, description, is_default, name, protection_presets, rules, scope, version, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/application_security_policy_create_data.rb b/lib/datadog_api_client/v2/models/application_security_policy_create_data.rb new file mode 100644 index 000000000000..2fd9f673c38a --- /dev/null +++ b/lib/datadog_api_client/v2/models/application_security_policy_create_data.rb @@ -0,0 +1,144 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Object for a single WAF policy. + class ApplicationSecurityPolicyCreateData + include BaseGenericModel + + # Create a new WAF policy. + attr_reader :attributes + + # The type of the resource. The value should always be `policy`. + attr_reader :type + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'attributes' => :'attributes', + :'type' => :'type' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'attributes' => :'ApplicationSecurityPolicyCreateAttributes', + :'type' => :'ApplicationSecurityPolicyType' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::ApplicationSecurityPolicyCreateData` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'attributes') + self.attributes = attributes[:'attributes'] + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @attributes.nil? + return false if @type.nil? + true + end + + # Custom attribute writer method with validation + # @param attributes [Object] Object to be assigned + # @!visibility private + def attributes=(attributes) + if attributes.nil? + fail ArgumentError, 'invalid value for "attributes", attributes cannot be nil.' + end + @attributes = attributes + end + + # Custom attribute writer method with validation + # @param type [Object] Object to be assigned + # @!visibility private + def type=(type) + if type.nil? + fail ArgumentError, 'invalid value for "type", type cannot be nil.' + end + @type = type + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + attributes == o.attributes && + type == o.type && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [attributes, type, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/application_security_policy_create_request.rb b/lib/datadog_api_client/v2/models/application_security_policy_create_request.rb new file mode 100644 index 000000000000..e1d35fdb9be0 --- /dev/null +++ b/lib/datadog_api_client/v2/models/application_security_policy_create_request.rb @@ -0,0 +1,123 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Request object that includes the policy to create. + class ApplicationSecurityPolicyCreateRequest + include BaseGenericModel + + # Object for a single WAF policy. + attr_reader :data + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'data' => :'data' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'data' => :'ApplicationSecurityPolicyCreateData' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::ApplicationSecurityPolicyCreateRequest` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'data') + self.data = attributes[:'data'] + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @data.nil? + true + end + + # Custom attribute writer method with validation + # @param data [Object] Object to be assigned + # @!visibility private + def data=(data) + if data.nil? + fail ArgumentError, 'invalid value for "data", data cannot be nil.' + end + @data = data + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + data == o.data && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [data, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/application_security_policy_data.rb b/lib/datadog_api_client/v2/models/application_security_policy_data.rb new file mode 100644 index 000000000000..07ff346badc3 --- /dev/null +++ b/lib/datadog_api_client/v2/models/application_security_policy_data.rb @@ -0,0 +1,135 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Object for a single WAF policy. + class ApplicationSecurityPolicyData + include BaseGenericModel + + # A WAF policy. + attr_accessor :attributes + + # The ID of the policy. + attr_accessor :id + + # Metadata associated with the WAF policy. + attr_accessor :metadata + + # The type of the resource. The value should always be `policy`. + attr_accessor :type + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'attributes' => :'attributes', + :'id' => :'id', + :'metadata' => :'metadata', + :'type' => :'type' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'attributes' => :'ApplicationSecurityPolicyAttributes', + :'id' => :'String', + :'metadata' => :'ApplicationSecurityPolicyMetadata', + :'type' => :'ApplicationSecurityPolicyType' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::ApplicationSecurityPolicyData` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'attributes') + self.attributes = attributes[:'attributes'] + end + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + end + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + attributes == o.attributes && + id == o.id && + metadata == o.metadata && + type == o.type && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [attributes, id, metadata, type, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/application_security_policy_list_response.rb b/lib/datadog_api_client/v2/models/application_security_policy_list_response.rb new file mode 100644 index 000000000000..becd25c199a4 --- /dev/null +++ b/lib/datadog_api_client/v2/models/application_security_policy_list_response.rb @@ -0,0 +1,107 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Response object that includes a list of WAF policies. + class ApplicationSecurityPolicyListResponse + include BaseGenericModel + + # The WAF policy data. + attr_accessor :data + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'data' => :'data' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'data' => :'Array' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::ApplicationSecurityPolicyListResponse` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'data') + if (value = attributes[:'data']).is_a?(Array) + self.data = value + end + end + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + data == o.data && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [data, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/application_security_policy_metadata.rb b/lib/datadog_api_client/v2/models/application_security_policy_metadata.rb new file mode 100644 index 000000000000..d6f70397274e --- /dev/null +++ b/lib/datadog_api_client/v2/models/application_security_policy_metadata.rb @@ -0,0 +1,155 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Metadata associated with the WAF policy. + class ApplicationSecurityPolicyMetadata + include BaseGenericModel + + # The date and time the WAF policy was created. + attr_accessor :added_at + + # The handle of the user who created the WAF policy. + attr_accessor :added_by + + # The name of the user who created the WAF policy. + attr_accessor :added_by_name + + # The date and time the WAF policy was last updated. + attr_accessor :modified_at + + # The handle of the user who last updated the WAF policy. + attr_accessor :modified_by + + # The name of the user who last updated the WAF policy. + attr_accessor :modified_by_name + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'added_at' => :'added_at', + :'added_by' => :'added_by', + :'added_by_name' => :'added_by_name', + :'modified_at' => :'modified_at', + :'modified_by' => :'modified_by', + :'modified_by_name' => :'modified_by_name' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'added_at' => :'Time', + :'added_by' => :'String', + :'added_by_name' => :'String', + :'modified_at' => :'Time', + :'modified_by' => :'String', + :'modified_by_name' => :'String' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::ApplicationSecurityPolicyMetadata` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'added_at') + self.added_at = attributes[:'added_at'] + end + + if attributes.key?(:'added_by') + self.added_by = attributes[:'added_by'] + end + + if attributes.key?(:'added_by_name') + self.added_by_name = attributes[:'added_by_name'] + end + + if attributes.key?(:'modified_at') + self.modified_at = attributes[:'modified_at'] + end + + if attributes.key?(:'modified_by') + self.modified_by = attributes[:'modified_by'] + end + + if attributes.key?(:'modified_by_name') + self.modified_by_name = attributes[:'modified_by_name'] + end + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + added_at == o.added_at && + added_by == o.added_by && + added_by_name == o.added_by_name && + modified_at == o.modified_at && + modified_by == o.modified_by && + modified_by_name == o.modified_by_name && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [added_at, added_by, added_by_name, modified_at, modified_by, modified_by_name, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/application_security_policy_response.rb b/lib/datadog_api_client/v2/models/application_security_policy_response.rb new file mode 100644 index 000000000000..210dc46eba89 --- /dev/null +++ b/lib/datadog_api_client/v2/models/application_security_policy_response.rb @@ -0,0 +1,105 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Response object that includes a single WAF policy. + class ApplicationSecurityPolicyResponse + include BaseGenericModel + + # Object for a single WAF policy. + attr_accessor :data + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'data' => :'data' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'data' => :'ApplicationSecurityPolicyData' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::ApplicationSecurityPolicyResponse` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'data') + self.data = attributes[:'data'] + end + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + data == o.data && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [data, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/application_security_policy_rule_override.rb b/lib/datadog_api_client/v2/models/application_security_policy_rule_override.rb new file mode 100644 index 000000000000..e234c6bca4e5 --- /dev/null +++ b/lib/datadog_api_client/v2/models/application_security_policy_rule_override.rb @@ -0,0 +1,165 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Override WAF rule parameters for services in a policy. + class ApplicationSecurityPolicyRuleOverride + include BaseGenericModel + + # When blocking is enabled, the rule will block the traffic matched by this rule. + attr_reader :blocking + + # When false, this rule will not match any traffic. + attr_reader :enabled + + # Override the parameters for this WAF rule identifier. + attr_reader :id + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'blocking' => :'blocking', + :'enabled' => :'enabled', + :'id' => :'id' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'blocking' => :'Boolean', + :'enabled' => :'Boolean', + :'id' => :'String' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::ApplicationSecurityPolicyRuleOverride` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'blocking') + self.blocking = attributes[:'blocking'] + end + + if attributes.key?(:'enabled') + self.enabled = attributes[:'enabled'] + end + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @blocking.nil? + return false if @enabled.nil? + return false if @id.nil? + true + end + + # Custom attribute writer method with validation + # @param blocking [Object] Object to be assigned + # @!visibility private + def blocking=(blocking) + if blocking.nil? + fail ArgumentError, 'invalid value for "blocking", blocking cannot be nil.' + end + @blocking = blocking + end + + # Custom attribute writer method with validation + # @param enabled [Object] Object to be assigned + # @!visibility private + def enabled=(enabled) + if enabled.nil? + fail ArgumentError, 'invalid value for "enabled", enabled cannot be nil.' + end + @enabled = enabled + end + + # Custom attribute writer method with validation + # @param id [Object] Object to be assigned + # @!visibility private + def id=(id) + if id.nil? + fail ArgumentError, 'invalid value for "id", id cannot be nil.' + end + @id = id + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + blocking == o.blocking && + enabled == o.enabled && + id == o.id && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [blocking, enabled, id, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/application_security_policy_scope.rb b/lib/datadog_api_client/v2/models/application_security_policy_scope.rb new file mode 100644 index 000000000000..9c522b0d99d6 --- /dev/null +++ b/lib/datadog_api_client/v2/models/application_security_policy_scope.rb @@ -0,0 +1,144 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # The scope of the WAF policy. + class ApplicationSecurityPolicyScope + include BaseGenericModel + + # The environment scope for the WAF policy. + attr_reader :env + + # The service scope for the WAF policy. + attr_reader :service + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'env' => :'env', + :'service' => :'service' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'env' => :'String', + :'service' => :'String' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::ApplicationSecurityPolicyScope` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'env') + self.env = attributes[:'env'] + end + + if attributes.key?(:'service') + self.service = attributes[:'service'] + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @env.nil? + return false if @service.nil? + true + end + + # Custom attribute writer method with validation + # @param env [Object] Object to be assigned + # @!visibility private + def env=(env) + if env.nil? + fail ArgumentError, 'invalid value for "env", env cannot be nil.' + end + @env = env + end + + # Custom attribute writer method with validation + # @param service [Object] Object to be assigned + # @!visibility private + def service=(service) + if service.nil? + fail ArgumentError, 'invalid value for "service", service cannot be nil.' + end + @service = service + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + env == o.env && + service == o.service && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [env, service, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/application_security_policy_type.rb b/lib/datadog_api_client/v2/models/application_security_policy_type.rb new file mode 100644 index 000000000000..d0ada53e1fd5 --- /dev/null +++ b/lib/datadog_api_client/v2/models/application_security_policy_type.rb @@ -0,0 +1,26 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # The type of the resource. The value should always be `policy`. + class ApplicationSecurityPolicyType + include BaseEnumModel + + POLICY = "policy".freeze + end +end diff --git a/lib/datadog_api_client/v2/models/application_security_policy_update_attributes.rb b/lib/datadog_api_client/v2/models/application_security_policy_update_attributes.rb new file mode 100644 index 000000000000..c0c0707b5193 --- /dev/null +++ b/lib/datadog_api_client/v2/models/application_security_policy_update_attributes.rb @@ -0,0 +1,255 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Update a WAF policy. + class ApplicationSecurityPolicyUpdateAttributes + include BaseGenericModel + + # Description of the WAF policy. + attr_reader :description + + # Make this policy the default policy. The default policy is applied to every services not specifically added to another policy. + attr_reader :is_default + + # The Name of the WAF policy. + attr_reader :name + + # Presets enabled on this policy. + attr_reader :protection_presets + + # Rule overrides applied by the policy. + attr_reader :rules + + # The scope of the WAF policy. + attr_reader :scope + + # Version of the WAF ruleset maintained by Datadog used by this policy. 0 is the default value. + attr_reader :version + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'description' => :'description', + :'is_default' => :'isDefault', + :'name' => :'name', + :'protection_presets' => :'protectionPresets', + :'rules' => :'rules', + :'scope' => :'scope', + :'version' => :'version' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'description' => :'String', + :'is_default' => :'Boolean', + :'name' => :'String', + :'protection_presets' => :'Array', + :'rules' => :'Array', + :'scope' => :'Array', + :'version' => :'Integer' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::ApplicationSecurityPolicyUpdateAttributes` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'description') + self.description = attributes[:'description'] + end + + if attributes.key?(:'is_default') + self.is_default = attributes[:'is_default'] + end + + if attributes.key?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'protection_presets') + if (value = attributes[:'protection_presets']).is_a?(Array) + self.protection_presets = value + end + end + + if attributes.key?(:'rules') + if (value = attributes[:'rules']).is_a?(Array) + self.rules = value + end + end + + if attributes.key?(:'scope') + if (value = attributes[:'scope']).is_a?(Array) + self.scope = value + end + end + + if attributes.key?(:'version') + self.version = attributes[:'version'] + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @description.nil? + return false if @is_default.nil? + return false if @name.nil? + return false if @protection_presets.nil? + return false if @rules.nil? + return false if @scope.nil? + return false if @version.nil? + true + end + + # Custom attribute writer method with validation + # @param description [Object] Object to be assigned + # @!visibility private + def description=(description) + if description.nil? + fail ArgumentError, 'invalid value for "description", description cannot be nil.' + end + @description = description + end + + # Custom attribute writer method with validation + # @param is_default [Object] Object to be assigned + # @!visibility private + def is_default=(is_default) + if is_default.nil? + fail ArgumentError, 'invalid value for "is_default", is_default cannot be nil.' + end + @is_default = is_default + end + + # Custom attribute writer method with validation + # @param name [Object] Object to be assigned + # @!visibility private + def name=(name) + if name.nil? + fail ArgumentError, 'invalid value for "name", name cannot be nil.' + end + @name = name + end + + # Custom attribute writer method with validation + # @param protection_presets [Object] Object to be assigned + # @!visibility private + def protection_presets=(protection_presets) + if protection_presets.nil? + fail ArgumentError, 'invalid value for "protection_presets", protection_presets cannot be nil.' + end + @protection_presets = protection_presets + end + + # Custom attribute writer method with validation + # @param rules [Object] Object to be assigned + # @!visibility private + def rules=(rules) + if rules.nil? + fail ArgumentError, 'invalid value for "rules", rules cannot be nil.' + end + @rules = rules + end + + # Custom attribute writer method with validation + # @param scope [Object] Object to be assigned + # @!visibility private + def scope=(scope) + if scope.nil? + fail ArgumentError, 'invalid value for "scope", scope cannot be nil.' + end + @scope = scope + end + + # Custom attribute writer method with validation + # @param version [Object] Object to be assigned + # @!visibility private + def version=(version) + if version.nil? + fail ArgumentError, 'invalid value for "version", version cannot be nil.' + end + @version = version + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + description == o.description && + is_default == o.is_default && + name == o.name && + protection_presets == o.protection_presets && + rules == o.rules && + scope == o.scope && + version == o.version && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [description, is_default, name, protection_presets, rules, scope, version, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/application_security_policy_update_data.rb b/lib/datadog_api_client/v2/models/application_security_policy_update_data.rb new file mode 100644 index 000000000000..ffd02bc371b9 --- /dev/null +++ b/lib/datadog_api_client/v2/models/application_security_policy_update_data.rb @@ -0,0 +1,144 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Object for a single WAF policy. + class ApplicationSecurityPolicyUpdateData + include BaseGenericModel + + # Update a WAF policy. + attr_reader :attributes + + # The type of the resource. The value should always be `policy`. + attr_reader :type + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'attributes' => :'attributes', + :'type' => :'type' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'attributes' => :'ApplicationSecurityPolicyUpdateAttributes', + :'type' => :'ApplicationSecurityPolicyType' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::ApplicationSecurityPolicyUpdateData` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'attributes') + self.attributes = attributes[:'attributes'] + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @attributes.nil? + return false if @type.nil? + true + end + + # Custom attribute writer method with validation + # @param attributes [Object] Object to be assigned + # @!visibility private + def attributes=(attributes) + if attributes.nil? + fail ArgumentError, 'invalid value for "attributes", attributes cannot be nil.' + end + @attributes = attributes + end + + # Custom attribute writer method with validation + # @param type [Object] Object to be assigned + # @!visibility private + def type=(type) + if type.nil? + fail ArgumentError, 'invalid value for "type", type cannot be nil.' + end + @type = type + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + attributes == o.attributes && + type == o.type && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [attributes, type, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/application_security_policy_update_request.rb b/lib/datadog_api_client/v2/models/application_security_policy_update_request.rb new file mode 100644 index 000000000000..c1d82242eeff --- /dev/null +++ b/lib/datadog_api_client/v2/models/application_security_policy_update_request.rb @@ -0,0 +1,123 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + 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 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Request object that includes the policy to update. + class ApplicationSecurityPolicyUpdateRequest + include BaseGenericModel + + # Object for a single WAF policy. + attr_reader :data + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'data' => :'data' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'data' => :'ApplicationSecurityPolicyUpdateData' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::ApplicationSecurityPolicyUpdateRequest` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'data') + self.data = attributes[:'data'] + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + return false if @data.nil? + true + end + + # Custom attribute writer method with validation + # @param data [Object] Object to be assigned + # @!visibility private + def data=(data) + if data.nil? + fail ArgumentError, 'invalid value for "data", data cannot be nil.' + end + @data = data + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + data == o.data && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [data, additional_properties].hash + end + end +end