diff --git a/.apigentools-info b/.apigentools-info index e6a8572bf44..b895f2e35e3 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.6.6", - "regenerated": "2025-03-05 21:00:33.112254", - "spec_repo_commit": "6105a175" + "regenerated": "2025-03-06 16:19:15.713066", + "spec_repo_commit": "1a11ef53" }, "v2": { "apigentools_version": "1.6.6", - "regenerated": "2025-03-05 21:00:33.127833", - "spec_repo_commit": "6105a175" + "regenerated": "2025-03-06 16:19:15.728784", + "spec_repo_commit": "1a11ef53" } } } \ No newline at end of file diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 9f21c1aa9db..5d5efbeb664 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -148,6 +148,22 @@ components: required: false schema: $ref: '#/components/schemas/ApplicationKeysSort' + ApplicationSecurityWafCustomRuleIDParam: + description: The ID of the custom rule. + example: 3b5-v82-ns6 + in: path + name: custom_rule_id + required: true + schema: + type: string + ApplicationSecurityWafExclusionFilterID: + description: The identifier of the WAF exclusion filter. + example: 3b5-v82-ns6 + in: path + name: exclusion_filter_id + required: true + schema: + type: string ArchiveID: description: The ID of the archive. in: path @@ -2441,6 +2457,770 @@ components: type: string x-enum-varnames: - APPLICATION_KEYS + ApplicationSecurityWafCustomRuleAction: + description: The definition of `ApplicationSecurityWafCustomRuleAction` object. + properties: + action: + $ref: '#/components/schemas/ApplicationSecurityWafCustomRuleActionAction' + parameters: + $ref: '#/components/schemas/ApplicationSecurityWafCustomRuleActionParameters' + type: object + ApplicationSecurityWafCustomRuleActionAction: + default: block_request + description: Override the default action to take when the WAF custom rule would + block. + enum: + - redirect_request + - block_request + example: block_request + type: string + x-enum-varnames: + - REDIRECT_REQUEST + - BLOCK_REQUEST + ApplicationSecurityWafCustomRuleActionParameters: + description: The definition of `ApplicationSecurityWafCustomRuleActionParameters` + object. + properties: + location: + description: The location to redirect to when the WAF custom rule triggers. + example: /blocking + type: string + status_code: + default: 403 + description: The status code to return when the WAF custom rule triggers. + example: 403 + format: int64 + type: integer + type: object + ApplicationSecurityWafCustomRuleAttributes: + description: A WAF custom rule. + properties: + action: + $ref: '#/components/schemas/ApplicationSecurityWafCustomRuleAction' + blocking: + description: Indicates whether the WAF custom rule will block the request. + example: false + type: boolean + conditions: + description: 'Conditions for which the WAF Custom Rule will triggers, all + conditions needs to match in order for the WAF + + rule to trigger.' + items: + $ref: '#/components/schemas/ApplicationSecurityWafCustomRuleCondition' + type: array + enabled: + description: Indicates whether the WAF custom rule is enabled. + example: false + type: boolean + metadata: + $ref: '#/components/schemas/ApplicationSecurityWafCustomRuleMetadata' + name: + description: The Name of the WAF custom rule. + example: Block request from bad useragent + type: string + path_glob: + description: The path glob for the WAF custom rule. + example: /api/search/* + type: string + scope: + description: The scope of the WAF custom rule. + items: + $ref: '#/components/schemas/ApplicationSecurityWafCustomRuleScope' + type: array + tags: + $ref: '#/components/schemas/ApplicationSecurityWafCustomRuleTags' + required: + - enabled + - blocking + - name + - tags + - conditions + type: object + ApplicationSecurityWafCustomRuleCondition: + description: One condition of the WAF Custom Rule. + properties: + operator: + $ref: '#/components/schemas/ApplicationSecurityWafCustomRuleConditionOperator' + parameters: + $ref: '#/components/schemas/ApplicationSecurityWafCustomRuleConditionParameters' + required: + - operator + - parameters + type: object + ApplicationSecurityWafCustomRuleConditionInput: + description: Input from the request on which the condition should apply. + properties: + address: + $ref: '#/components/schemas/ApplicationSecurityWafCustomRuleConditionInputAddress' + key_path: + description: Specific path for the input. + items: + type: string + type: array + required: + - address + type: object + ApplicationSecurityWafCustomRuleConditionInputAddress: + description: Input from the request on which the condition should apply. + enum: + - server.db.statement + - server.io.fs.file + - server.io.net.url + - server.sys.shell.cmd + - server.request.method + - server.request.uri.raw + - server.request.path_params + - server.request.query + - server.request.headers.no_cookies + - server.request.cookies + - server.request.trailers + - server.request.body + - server.response.status + - server.response.headers.no_cookies + - server.response.trailers + - grpc.server.request.metadata + - grpc.server.request.message + - grpc.server.method + - graphql.server.all_resolvers + - usr.id + - http.client_ip + example: server.db.statement + type: string + x-enum-varnames: + - SERVER_DB_STATEMENT + - SERVER_IO_FS_FILE + - SERVER_IO_NET_URL + - SERVER_SYS_SHELL_CMD + - SERVER_REQUEST_METHOD + - SERVER_REQUEST_URI_RAW + - SERVER_REQUEST_PATH_PARAMS + - SERVER_REQUEST_QUERY + - SERVER_REQUEST_HEADERS_NO_COOKIES + - SERVER_REQUEST_COOKIES + - SERVER_REQUEST_TRAILERS + - SERVER_REQUEST_BODY + - SERVER_RESPONSE_STATUS + - SERVER_RESPONSE_HEADERS_NO_COOKIES + - SERVER_RESPONSE_TRAILERS + - GRPC_SERVER_REQUEST_METADATA + - GRPC_SERVER_REQUEST_MESSAGE + - GRPC_SERVER_METHOD + - GRAPHQL_SERVER_ALL_RESOLVERS + - USR_ID + - HTTP_CLIENT_IP + ApplicationSecurityWafCustomRuleConditionOperator: + description: Operator to use for the WAF Condition. + enum: + - match_regex + - '!match_regex' + - phrase_match + - '!phrase_match' + - is_xss + - is_sqli + - exact_match + - '!exact_match' + - ip_match + - '!ip_match' + - capture_data + example: match_regex + type: string + x-enum-varnames: + - MATCH_REGEX + - NOT_MATCH_REGEX + - PHRASE_MATCH + - NOT_PHRASE_MATCH + - IS_XSS + - IS_SQLI + - EXACT_MATCH + - NOT_EXACT_MATCH + - IP_MATCH + - NOT_IP_MATCH + - CAPTURE_DATA + ApplicationSecurityWafCustomRuleConditionOptions: + description: Options for the operator of this condition. + properties: + case_sensitive: + default: false + description: Evaluate the value as case sensitive. + type: boolean + min_length: + default: 0 + description: Only evaluate this condition if the value has a minimum amount + of characters. + format: int64 + type: integer + type: object + ApplicationSecurityWafCustomRuleConditionParameters: + description: The scope of the WAF custom rule. + properties: + data: + description: Identifier of a list of data from the denylist. Can only be + used as substitution from the list parameter. + example: blocked_users + type: string + inputs: + description: List of inputs on which at least one should match with the + given operator. + items: + $ref: '#/components/schemas/ApplicationSecurityWafCustomRuleConditionInput' + type: array + list: + description: 'List of value to use with the condition. Only used with the + phrase_match, !phrase_match, exact_match and + + !exact_match operator.' + items: + type: string + type: array + options: + $ref: '#/components/schemas/ApplicationSecurityWafCustomRuleConditionOptions' + regex: + description: Regex to use with the condition. Only used with match_regex + and !match_regex operator. + example: path.* + type: string + value: + description: Store the captured value in the specified tag name. Only used + with the capture_data operator. + example: custom_tag + type: string + required: + - inputs + type: object + ApplicationSecurityWafCustomRuleCreateAttributes: + description: Create a new WAF custom rule. + properties: + action: + $ref: '#/components/schemas/ApplicationSecurityWafCustomRuleAction' + blocking: + description: Indicates whether the WAF custom rule will block the request. + example: false + type: boolean + conditions: + description: 'Conditions for which the WAF Custom Rule will triggers, all + conditions needs to match in order for the WAF + + rule to trigger' + items: + $ref: '#/components/schemas/ApplicationSecurityWafCustomRuleCondition' + type: array + enabled: + description: Indicates whether the WAF custom rule is enabled. + example: false + type: boolean + name: + description: The Name of the WAF custom rule. + example: Block request from a bad useragent + type: string + path_glob: + description: The path glob for the WAF custom rule. + example: /api/search/* + type: string + scope: + description: The scope of the WAF custom rule. + items: + $ref: '#/components/schemas/ApplicationSecurityWafCustomRuleScope' + type: array + tags: + $ref: '#/components/schemas/ApplicationSecurityWafCustomRuleTags' + required: + - enabled + - blocking + - name + - tags + - conditions + type: object + ApplicationSecurityWafCustomRuleCreateData: + description: Object for a single WAF custom rule. + properties: + attributes: + $ref: '#/components/schemas/ApplicationSecurityWafCustomRuleCreateAttributes' + type: + $ref: '#/components/schemas/ApplicationSecurityWafCustomRuleType' + required: + - attributes + - type + type: object + ApplicationSecurityWafCustomRuleCreateRequest: + description: Request object that includes the custom rule to create. + properties: + data: + $ref: '#/components/schemas/ApplicationSecurityWafCustomRuleCreateData' + required: + - data + type: object + ApplicationSecurityWafCustomRuleData: + description: Object for a single WAF custom rule. + properties: + attributes: + $ref: '#/components/schemas/ApplicationSecurityWafCustomRuleAttributes' + id: + description: The ID of the custom rule. + example: 2857c47d-1e3a-4300-8b2f-dc24089c084b + readOnly: true + type: string + type: + $ref: '#/components/schemas/ApplicationSecurityWafCustomRuleType' + type: object + ApplicationSecurityWafCustomRuleListResponse: + description: Response object that includes a list of WAF custom rules. + properties: + data: + description: The WAF custom rule data. + items: + $ref: '#/components/schemas/ApplicationSecurityWafCustomRuleData' + type: array + type: object + ApplicationSecurityWafCustomRuleMetadata: + description: Metadata associated with the WAF Custom Rule. + properties: + added_at: + description: The date and time the WAF custom rule 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 custom rule. + example: john.doe@datadoghq.com + type: string + added_by_name: + description: The name of the user who created the WAF custom rule. + example: John Doe + type: string + modified_at: + description: The date and time the WAF custom rule 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 custom rule. + example: john.doe@datadoghq.com + type: string + modified_by_name: + description: The name of the user who last updated the WAF custom rule. + example: John Doe + type: string + readOnly: true + type: object + ApplicationSecurityWafCustomRuleResponse: + description: Response object that includes a single WAF custom rule. + properties: + data: + $ref: '#/components/schemas/ApplicationSecurityWafCustomRuleData' + type: object + ApplicationSecurityWafCustomRuleScope: + description: The scope of the WAF custom rule. + properties: + env: + description: The environment scope for the WAF custom rule. + example: prod + type: string + service: + description: The service scope for the WAF custom rule. + example: billing-service + type: string + required: + - service + - env + type: object + ApplicationSecurityWafCustomRuleTags: + additionalProperties: + type: string + description: 'Tags associated with the WAF Custom Rule. The concatenation of + category and type will form the security + + activity field associated with the traces.' + maxProperties: 32 + properties: + category: + $ref: '#/components/schemas/ApplicationSecurityWafCustomRuleTagsCategory' + type: + description: The type of the WAF rule, associated with the category will + form the security activity. + example: users.login.success + type: string + required: + - category + - type + type: object + ApplicationSecurityWafCustomRuleTagsCategory: + description: The category of the WAF Rule, can be either `business_logic`, `attack_attempt` + or `security_response`. + enum: + - attack_attempt + - business_logic + - security_responses + example: business_logic + type: string + x-enum-varnames: + - ATTACK_ATTEMPT + - BUSINESS_LOGIC + - SECURITY_RESPONSES + ApplicationSecurityWafCustomRuleType: + default: custom_rule + description: The type of the resource. The value should always be `custom_rule`. + enum: + - custom_rule + example: custom_rule + type: string + x-enum-varnames: + - CUSTOM_RULE + ApplicationSecurityWafCustomRuleUpdateAttributes: + description: Update a WAF custom rule. + properties: + action: + $ref: '#/components/schemas/ApplicationSecurityWafCustomRuleAction' + blocking: + description: Indicates whether the WAF custom rule will block the request. + example: false + type: boolean + conditions: + description: 'Conditions for which the WAF Custom Rule will triggers, all + conditions needs to match in order for the WAF + + rule to trigger.' + items: + $ref: '#/components/schemas/ApplicationSecurityWafCustomRuleCondition' + type: array + enabled: + description: Indicates whether the WAF custom rule is enabled. + example: false + type: boolean + name: + description: The Name of the WAF custom rule. + example: Block request from bad useragent + type: string + path_glob: + description: The path glob for the WAF custom rule. + example: /api/search/* + type: string + scope: + description: The scope of the WAF custom rule. + items: + $ref: '#/components/schemas/ApplicationSecurityWafCustomRuleScope' + type: array + tags: + $ref: '#/components/schemas/ApplicationSecurityWafCustomRuleTags' + required: + - enabled + - blocking + - name + - tags + - conditions + type: object + ApplicationSecurityWafCustomRuleUpdateData: + description: Object for a single WAF Custom Rule. + properties: + attributes: + $ref: '#/components/schemas/ApplicationSecurityWafCustomRuleUpdateAttributes' + type: + $ref: '#/components/schemas/ApplicationSecurityWafCustomRuleType' + required: + - attributes + - type + type: object + ApplicationSecurityWafCustomRuleUpdateRequest: + description: Request object that includes the Custom Rule to update. + properties: + data: + $ref: '#/components/schemas/ApplicationSecurityWafCustomRuleUpdateData' + required: + - data + type: object + ApplicationSecurityWafExclusionFilterAttributes: + description: Attributes describing a WAF exclusion filter. + properties: + description: + description: A description for the exclusion filter. + example: Exclude false positives on a path + type: string + enabled: + description: Indicates whether the exclusion filter is enabled. + example: true + type: boolean + event_query: + description: The event query matched by the legacy exclusion filter. Cannot + be created nor updated. + type: string + ip_list: + description: The client IP addresses matched by the exclusion filter (CIDR + notation is supported). + items: + example: 198.51.100.72 + type: string + type: array + metadata: + $ref: '#/components/schemas/ApplicationSecurityWafExclusionFilterMetadata' + on_match: + $ref: '#/components/schemas/ApplicationSecurityWafExclusionFilterOnMatch' + parameters: + description: A list of parameters matched by the exclusion filter in the + HTTP query string and HTTP request body. Nested parameters can be matched + by joining fields with a dot character. + items: + example: list.search.query + type: string + type: array + path_glob: + description: The HTTP path glob expression matched by the exclusion filter. + example: /accounts/* + type: string + rules_target: + description: The WAF rules targeted by the exclusion filter. + items: + $ref: '#/components/schemas/ApplicationSecurityWafExclusionFilterRulesTarget' + type: array + scope: + description: The services where the exclusion filter is deployed. + items: + $ref: '#/components/schemas/ApplicationSecurityWafExclusionFilterScope' + type: array + search_query: + description: Generated event search query for traces matching the exclusion + filter. + readOnly: true + type: string + type: object + ApplicationSecurityWafExclusionFilterCreateAttributes: + description: Attributes for creating a WAF exclusion filter. + properties: + description: + description: A description for the exclusion filter. + example: Exclude false positives on a path + type: string + enabled: + description: Indicates whether the exclusion filter is enabled. + example: true + type: boolean + ip_list: + description: The client IP addresses matched by the exclusion filter (CIDR + notation is supported). + items: + example: 198.51.100.72 + type: string + type: array + on_match: + $ref: '#/components/schemas/ApplicationSecurityWafExclusionFilterOnMatch' + parameters: + description: A list of parameters matched by the exclusion filter in the + HTTP query string and HTTP request body. Nested parameters can be matched + by joining fields with a dot character. + items: + example: list.search.query + type: string + type: array + path_glob: + description: The HTTP path glob expression matched by the exclusion filter. + example: /accounts/* + type: string + rules_target: + description: The WAF rules targeted by the exclusion filter. + items: + $ref: '#/components/schemas/ApplicationSecurityWafExclusionFilterRulesTarget' + type: array + scope: + description: The services where the exclusion filter is deployed. + items: + $ref: '#/components/schemas/ApplicationSecurityWafExclusionFilterScope' + type: array + required: + - description + - enabled + type: object + ApplicationSecurityWafExclusionFilterCreateData: + description: Object for creating a single WAF exclusion filter. + properties: + attributes: + $ref: '#/components/schemas/ApplicationSecurityWafExclusionFilterCreateAttributes' + type: + $ref: '#/components/schemas/ApplicationSecurityWafExclusionFilterType' + required: + - attributes + - type + type: object + ApplicationSecurityWafExclusionFilterCreateRequest: + description: Request object for creating a single WAF exclusion filter. + properties: + data: + $ref: '#/components/schemas/ApplicationSecurityWafExclusionFilterCreateData' + required: + - data + type: object + ApplicationSecurityWafExclusionFilterID: + description: The identifier of the WAF exclusion filter. + example: 3dd-0uc-h1s + readOnly: true + type: string + ApplicationSecurityWafExclusionFilterMetadata: + description: Extra information about the exclusion filter. + properties: + added_at: + description: The creation date of the exclusion filter. + format: date-time + type: string + added_by: + description: The handle of the user who created the exclusion filter. + type: string + added_by_name: + description: The name of the user who created the exclusion filter. + type: string + modified_at: + description: The last modification date of the exclusion filter. + format: date-time + type: string + modified_by: + description: The handle of the user who last modified the exclusion filter. + type: string + modified_by_name: + description: The name of the user who last modified the exclusion filter. + type: string + readOnly: true + type: object + ApplicationSecurityWafExclusionFilterOnMatch: + description: The action taken when the exclusion filter matches. When set to + `monitor`, security traces are emitted but the requests are not blocked. By + default, security traces are not emitted and the requests are not blocked. + enum: + - monitor + type: string + x-enum-varnames: + - MONITOR + ApplicationSecurityWafExclusionFilterResource: + description: A JSON:API resource for an WAF exclusion filter. + properties: + attributes: + $ref: '#/components/schemas/ApplicationSecurityWafExclusionFilterAttributes' + id: + $ref: '#/components/schemas/ApplicationSecurityWafExclusionFilterID' + type: + $ref: '#/components/schemas/ApplicationSecurityWafExclusionFilterType' + type: object + ApplicationSecurityWafExclusionFilterResponse: + description: Response object for a single WAF exclusion filter. + properties: + data: + $ref: '#/components/schemas/ApplicationSecurityWafExclusionFilterResource' + type: object + ApplicationSecurityWafExclusionFilterRulesTarget: + description: Target WAF rules based either on an identifier or tags. + properties: + rule_id: + description: Target a single WAF rule based on its identifier. + example: dog-913-009 + type: string + tags: + $ref: '#/components/schemas/ApplicationSecurityWafExclusionFilterRulesTargetTags' + type: object + ApplicationSecurityWafExclusionFilterRulesTargetTags: + additionalProperties: + type: string + description: Target multiple WAF rules based on their tags. + properties: + category: + description: The category of the targeted WAF rules. + example: attack_attempt + type: string + type: + description: The type of the targeted WAF rules. + example: lfi + type: string + type: object + ApplicationSecurityWafExclusionFilterScope: + description: Deploy on services based on their environment and/or service name. + properties: + env: + description: Deploy on this environment. + example: www + type: string + service: + description: Deploy on this service. + example: prod + type: string + type: object + ApplicationSecurityWafExclusionFilterType: + default: exclusion_filter + description: Type of the resource. The value should always be `exclusion_filter`. + enum: + - exclusion_filter + example: exclusion_filter + type: string + x-enum-varnames: + - EXCLUSION_FILTER + ApplicationSecurityWafExclusionFilterUpdateAttributes: + description: Attributes for updating a WAF exclusion filter. + properties: + description: + description: A description for the exclusion filter. + example: Exclude false positives on a path + type: string + enabled: + description: Indicates whether the exclusion filter is enabled. + example: true + type: boolean + ip_list: + description: The client IP addresses matched by the exclusion filter (CIDR + notation is supported). + items: + example: 198.51.100.72 + type: string + type: array + on_match: + $ref: '#/components/schemas/ApplicationSecurityWafExclusionFilterOnMatch' + parameters: + description: A list of parameters matched by the exclusion filter in the + HTTP query string and HTTP request body. Nested parameters can be matched + by joining fields with a dot character. + items: + example: list.search.query + type: string + type: array + path_glob: + description: The HTTP path glob expression matched by the exclusion filter. + example: /accounts/* + type: string + rules_target: + description: The WAF rules targeted by the exclusion filter. + items: + $ref: '#/components/schemas/ApplicationSecurityWafExclusionFilterRulesTarget' + type: array + scope: + description: The services where the exclusion filter is deployed. + items: + $ref: '#/components/schemas/ApplicationSecurityWafExclusionFilterScope' + type: array + required: + - description + - enabled + type: object + ApplicationSecurityWafExclusionFilterUpdateData: + description: Object for updating a single WAF exclusion filter. + properties: + attributes: + $ref: '#/components/schemas/ApplicationSecurityWafExclusionFilterUpdateAttributes' + type: + $ref: '#/components/schemas/ApplicationSecurityWafExclusionFilterType' + required: + - attributes + - type + type: object + ApplicationSecurityWafExclusionFilterUpdateRequest: + description: Request object for updating a single WAF exclusion filter. + properties: + data: + $ref: '#/components/schemas/ApplicationSecurityWafExclusionFilterUpdateData' + required: + - data + type: object + ApplicationSecurityWafExclusionFiltersResponse: + description: Response object for multiple WAF exclusion filters. + properties: + data: + description: A list of WAF exclusion filters. + items: + $ref: '#/components/schemas/ApplicationSecurityWafExclusionFilterResource' + type: array + type: object AppsSortField: description: The field and direction to sort apps by enum: @@ -43942,6 +44722,285 @@ paths: operator: OR permissions: - timeseries_query + /api/v2/remote_config/products/asm/waf/custom_rules: + get: + description: Retrieve a list of WAF custom rule. + operationId: ListApplicationSecurityWAFCustomRules + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/ApplicationSecurityWafCustomRuleListResponse' + description: OK + '403': + $ref: '#/components/responses/NotAuthorizedResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: List all WAF custom rules + tags: + - Application Security + post: + description: Create a new WAF custom rule with the given parameters. + operationId: CreateApplicationSecurityWafCustomRule + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ApplicationSecurityWafCustomRuleCreateRequest' + description: The definition of the new WAF Custom Rule. + required: true + responses: + '201': + content: + application/json: + schema: + $ref: '#/components/schemas/ApplicationSecurityWafCustomRuleResponse' + 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 custom rule + tags: + - Application Security + x-codegen-request-body-name: body + /api/v2/remote_config/products/asm/waf/custom_rules/{custom_rule_id}: + delete: + description: Delete a specific WAF custom rule. + operationId: DeleteApplicationSecurityWafCustomRule + parameters: + - $ref: '#/components/parameters/ApplicationSecurityWafCustomRuleIDParam' + 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 Custom Rule + tags: + - Application Security + x-terraform-resource: appsec_waf_custom_rule + get: + description: Retrieve a WAF custom rule by ID. + operationId: GetApplicationSecurityWafCustomRule + parameters: + - $ref: '#/components/parameters/ApplicationSecurityWafCustomRuleIDParam' + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/ApplicationSecurityWafCustomRuleResponse' + description: OK + '403': + $ref: '#/components/responses/NotAuthorizedResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: Get a WAF custom rule + tags: + - Application Security + x-terraform-resource: appsec_waf_custom_rule + put: + description: 'Update a specific WAF custom Rule. + + Returns the Custom Rule object when the request is successful.' + operationId: UpdateApplicationSecurityWafCustomRule + parameters: + - $ref: '#/components/parameters/ApplicationSecurityWafCustomRuleIDParam' + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ApplicationSecurityWafCustomRuleUpdateRequest' + description: New definition of the WAF Custom Rule. + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/ApplicationSecurityWafCustomRuleResponse' + 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 Custom Rule + tags: + - Application Security + x-codegen-request-body-name: body + x-terraform-resource: appsec_waf_custom_rule + /api/v2/remote_config/products/asm/waf/exclusion_filters: + get: + description: Retrieve a list of WAF exclusion filters. + operationId: ListApplicationSecurityWafExclusionFilters + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/ApplicationSecurityWafExclusionFiltersResponse' + description: OK + '403': + $ref: '#/components/responses/NotAuthorizedResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: List all WAF exclusion filters + tags: + - Application Security + x-permission: + operator: AND + permissions: + - appsec_protect_read + x-terraform-resource: appsec_waf_exclusion_filter + post: + description: 'Create a new WAF exclusion filter with the given parameters. + + + A request matched by an exclusion filter will be ignored by the Application + Security WAF product. + + Go to https://app.datadoghq.com/security/appsec/passlist to review existing + exclusion filters (also called passlist entries).' + operationId: CreateApplicationSecurityWafExclusionFilter + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ApplicationSecurityWafExclusionFilterCreateRequest' + description: The definition of the new WAF exclusion filter. + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/ApplicationSecurityWafExclusionFilterResponse' + description: OK + '400': + $ref: '#/components/responses/BadRequestResponse' + '403': + $ref: '#/components/responses/NotAuthorizedResponse' + '409': + $ref: '#/components/responses/ConcurrentModificationResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: Create a WAF exclusion filter + tags: + - Application Security + x-codegen-request-body-name: body + x-permission: + operator: AND + permissions: + - appsec_protect_write + x-terraform-resource: appsec_waf_exclusion_filter + /api/v2/remote_config/products/asm/waf/exclusion_filters/{exclusion_filter_id}: + delete: + description: Delete a specific WAF exclusion filter using its identifier. + operationId: DeleteApplicationSecurityWafExclusionFilter + parameters: + - $ref: '#/components/parameters/ApplicationSecurityWafExclusionFilterID' + responses: + '204': + description: OK + '403': + $ref: '#/components/responses/NotAuthorizedResponse' + '404': + $ref: '#/components/responses/NotFoundResponse' + '409': + $ref: '#/components/responses/ConcurrentModificationResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: Delete a WAF exclusion filter + tags: + - Application Security + x-permission: + operator: AND + permissions: + - appsec_protect_write + x-terraform-resource: appsec_waf_exclusion_filter + get: + description: Retrieve a specific WAF exclusion filter using its identifier. + operationId: GetApplicationSecurityWafExclusionFilter + parameters: + - $ref: '#/components/parameters/ApplicationSecurityWafExclusionFilterID' + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/ApplicationSecurityWafExclusionFilterResponse' + description: OK + '403': + $ref: '#/components/responses/NotAuthorizedResponse' + '404': + $ref: '#/components/responses/NotFoundResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: Get a WAF exclusion filter + tags: + - Application Security + x-permission: + operator: AND + permissions: + - appsec_protect_read + x-terraform-resource: appsec_waf_exclusion_filter + put: + description: 'Update a specific WAF exclusion filter using its identifier. + + Returns the exclusion filter object when the request is successful.' + operationId: UpdateApplicationSecurityWafExclusionFilter + parameters: + - $ref: '#/components/parameters/ApplicationSecurityWafExclusionFilterID' + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ApplicationSecurityWafExclusionFilterUpdateRequest' + description: The exclusion filter to update. + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/ApplicationSecurityWafExclusionFilterResponse' + 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 exclusion filter + tags: + - Application Security + x-codegen-request-body-name: body + x-permission: + operator: AND + permissions: + - appsec_protect_write + x-terraform-resource: appsec_waf_exclusion_filter /api/v2/remote_config/products/cws/agent_rules: get: description: Get the list of Cloud Security Management Threats Agent rules. @@ -52017,6 +53076,22 @@ tags: are built to accelerate remediation at scale. These API endpoints allow you to create, read, update, delete, and publish apps. name: App Builder +- description: '[Datadog Application Security](https://docs.datadoghq.com/security/application_security/) + provides protection against + + application-level attacks that aim to exploit code-level vulnerabilities, + + such as Server-Side-Request-Forgery (SSRF), SQL injection, Log4Shell, and + + Reflected Cross-Site-Scripting (XSS). You can monitor and protect apps + + hosted directly on a server, Docker, Kubernetes, Amazon ECS, and (for + + supported languages) AWS Fargate.' + externalDocs: + description: Find out more at + url: https://docs.datadoghq.com/security/application_security/ + name: Application Security - description: Search your Audit Logs events over HTTP. name: Audit - description: '[The AuthN Mappings API](https://docs.datadoghq.com/account_management/authn_mapping/?tab=example) diff --git a/api/datadogV2/api_application_security.go b/api/datadogV2/api_application_security.go new file mode 100644 index 00000000000..07235fcb7eb --- /dev/null +++ b/api/datadogV2/api_application_security.go @@ -0,0 +1,726 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + _context "context" + _nethttp "net/http" + _neturl "net/url" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// ApplicationSecurityApi service type +type ApplicationSecurityApi datadog.Service + +// CreateApplicationSecurityWafCustomRule Create a WAF custom rule. +// Create a new WAF custom rule with the given parameters. +func (a *ApplicationSecurityApi) CreateApplicationSecurityWafCustomRule(ctx _context.Context, body ApplicationSecurityWafCustomRuleCreateRequest) (ApplicationSecurityWafCustomRuleResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPost + localVarPostBody interface{} + localVarReturnValue ApplicationSecurityWafCustomRuleResponse + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.ApplicationSecurityApi.CreateApplicationSecurityWafCustomRule") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/remote_config/products/asm/waf/custom_rules" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Content-Type"] = "application/json" + localVarHeaderParams["Accept"] = "application/json" + + // body params + localVarPostBody = &body + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 409 || localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +// CreateApplicationSecurityWafExclusionFilter Create a WAF exclusion filter. +// Create a new WAF exclusion filter with the given parameters. +// +// A request matched by an exclusion filter will be ignored by the Application Security WAF product. +// Go to https://app.datadoghq.com/security/appsec/passlist to review existing exclusion filters (also called passlist entries). +func (a *ApplicationSecurityApi) CreateApplicationSecurityWafExclusionFilter(ctx _context.Context, body ApplicationSecurityWafExclusionFilterCreateRequest) (ApplicationSecurityWafExclusionFilterResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPost + localVarPostBody interface{} + localVarReturnValue ApplicationSecurityWafExclusionFilterResponse + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.ApplicationSecurityApi.CreateApplicationSecurityWafExclusionFilter") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/remote_config/products/asm/waf/exclusion_filters" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Content-Type"] = "application/json" + localVarHeaderParams["Accept"] = "application/json" + + // body params + localVarPostBody = &body + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 409 || localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +// DeleteApplicationSecurityWafCustomRule Delete a WAF Custom Rule. +// Delete a specific WAF custom rule. +func (a *ApplicationSecurityApi) DeleteApplicationSecurityWafCustomRule(ctx _context.Context, customRuleId string) (*_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodDelete + localVarPostBody interface{} + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.ApplicationSecurityApi.DeleteApplicationSecurityWafCustomRule") + if err != nil { + return nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/remote_config/products/asm/waf/custom_rules/{custom_rule_id}" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{custom_rule_id}", _neturl.PathEscape(datadog.ParameterToString(customRuleId, ""))) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Accept"] = "*/*" + + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 404 || localVarHTTPResponse.StatusCode == 409 || localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarHTTPResponse, newErr + } + + return localVarHTTPResponse, nil +} + +// DeleteApplicationSecurityWafExclusionFilter Delete a WAF exclusion filter. +// Delete a specific WAF exclusion filter using its identifier. +func (a *ApplicationSecurityApi) DeleteApplicationSecurityWafExclusionFilter(ctx _context.Context, exclusionFilterId string) (*_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodDelete + localVarPostBody interface{} + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.ApplicationSecurityApi.DeleteApplicationSecurityWafExclusionFilter") + if err != nil { + return nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/remote_config/products/asm/waf/exclusion_filters/{exclusion_filter_id}" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{exclusion_filter_id}", _neturl.PathEscape(datadog.ParameterToString(exclusionFilterId, ""))) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Accept"] = "*/*" + + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 404 || localVarHTTPResponse.StatusCode == 409 || localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarHTTPResponse, newErr + } + + return localVarHTTPResponse, nil +} + +// GetApplicationSecurityWafCustomRule Get a WAF custom rule. +// Retrieve a WAF custom rule by ID. +func (a *ApplicationSecurityApi) GetApplicationSecurityWafCustomRule(ctx _context.Context, customRuleId string) (ApplicationSecurityWafCustomRuleResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarReturnValue ApplicationSecurityWafCustomRuleResponse + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.ApplicationSecurityApi.GetApplicationSecurityWafCustomRule") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/remote_config/products/asm/waf/custom_rules/{custom_rule_id}" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{custom_rule_id}", _neturl.PathEscape(datadog.ParameterToString(customRuleId, ""))) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Accept"] = "application/json" + + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +// GetApplicationSecurityWafExclusionFilter Get a WAF exclusion filter. +// Retrieve a specific WAF exclusion filter using its identifier. +func (a *ApplicationSecurityApi) GetApplicationSecurityWafExclusionFilter(ctx _context.Context, exclusionFilterId string) (ApplicationSecurityWafExclusionFilterResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarReturnValue ApplicationSecurityWafExclusionFilterResponse + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.ApplicationSecurityApi.GetApplicationSecurityWafExclusionFilter") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/remote_config/products/asm/waf/exclusion_filters/{exclusion_filter_id}" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{exclusion_filter_id}", _neturl.PathEscape(datadog.ParameterToString(exclusionFilterId, ""))) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Accept"] = "application/json" + + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 404 || localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +// ListApplicationSecurityWAFCustomRules List all WAF custom rules. +// Retrieve a list of WAF custom rule. +func (a *ApplicationSecurityApi) ListApplicationSecurityWAFCustomRules(ctx _context.Context) (ApplicationSecurityWafCustomRuleListResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarReturnValue ApplicationSecurityWafCustomRuleListResponse + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.ApplicationSecurityApi.ListApplicationSecurityWAFCustomRules") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/remote_config/products/asm/waf/custom_rules" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Accept"] = "application/json" + + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +// ListApplicationSecurityWafExclusionFilters List all WAF exclusion filters. +// Retrieve a list of WAF exclusion filters. +func (a *ApplicationSecurityApi) ListApplicationSecurityWafExclusionFilters(ctx _context.Context) (ApplicationSecurityWafExclusionFiltersResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarReturnValue ApplicationSecurityWafExclusionFiltersResponse + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.ApplicationSecurityApi.ListApplicationSecurityWafExclusionFilters") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/remote_config/products/asm/waf/exclusion_filters" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Accept"] = "application/json" + + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +// UpdateApplicationSecurityWafCustomRule Update a WAF Custom Rule. +// Update a specific WAF custom Rule. +// Returns the Custom Rule object when the request is successful. +func (a *ApplicationSecurityApi) UpdateApplicationSecurityWafCustomRule(ctx _context.Context, customRuleId string, body ApplicationSecurityWafCustomRuleUpdateRequest) (ApplicationSecurityWafCustomRuleResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPut + localVarPostBody interface{} + localVarReturnValue ApplicationSecurityWafCustomRuleResponse + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.ApplicationSecurityApi.UpdateApplicationSecurityWafCustomRule") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/remote_config/products/asm/waf/custom_rules/{custom_rule_id}" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{custom_rule_id}", _neturl.PathEscape(datadog.ParameterToString(customRuleId, ""))) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Content-Type"] = "application/json" + localVarHeaderParams["Accept"] = "application/json" + + // body params + localVarPostBody = &body + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 404 || localVarHTTPResponse.StatusCode == 409 || localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +// UpdateApplicationSecurityWafExclusionFilter Update a WAF exclusion filter. +// Update a specific WAF exclusion filter using its identifier. +// Returns the exclusion filter object when the request is successful. +func (a *ApplicationSecurityApi) UpdateApplicationSecurityWafExclusionFilter(ctx _context.Context, exclusionFilterId string, body ApplicationSecurityWafExclusionFilterUpdateRequest) (ApplicationSecurityWafExclusionFilterResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPut + localVarPostBody interface{} + localVarReturnValue ApplicationSecurityWafExclusionFilterResponse + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.ApplicationSecurityApi.UpdateApplicationSecurityWafExclusionFilter") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/remote_config/products/asm/waf/exclusion_filters/{exclusion_filter_id}" + localVarPath = datadog.ReplacePathParameter(localVarPath, "{exclusion_filter_id}", _neturl.PathEscape(datadog.ParameterToString(exclusionFilterId, ""))) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + localVarHeaderParams["Content-Type"] = "application/json" + localVarHeaderParams["Accept"] = "application/json" + + // body params + localVarPostBody = &body + datadog.SetAuthKeys( + ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := datadog.ReadBody(localVarHTTPResponse) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 404 || localVarHTTPResponse.StatusCode == 409 || localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +// NewApplicationSecurityApi Returns NewApplicationSecurityApi. +func NewApplicationSecurityApi(client *datadog.APIClient) *ApplicationSecurityApi { + return &ApplicationSecurityApi{ + Client: client, + } +} diff --git a/api/datadogV2/doc.go b/api/datadogV2/doc.go index 2cf01d31d7f..74da38c053a 100644 --- a/api/datadogV2/doc.go +++ b/api/datadogV2/doc.go @@ -41,6 +41,16 @@ // - [AppBuilderApi.PublishApp] // - [AppBuilderApi.UnpublishApp] // - [AppBuilderApi.UpdateApp] +// - [ApplicationSecurityApi.CreateApplicationSecurityWafCustomRule] +// - [ApplicationSecurityApi.CreateApplicationSecurityWafExclusionFilter] +// - [ApplicationSecurityApi.DeleteApplicationSecurityWafCustomRule] +// - [ApplicationSecurityApi.DeleteApplicationSecurityWafExclusionFilter] +// - [ApplicationSecurityApi.GetApplicationSecurityWafCustomRule] +// - [ApplicationSecurityApi.GetApplicationSecurityWafExclusionFilter] +// - [ApplicationSecurityApi.ListApplicationSecurityWAFCustomRules] +// - [ApplicationSecurityApi.ListApplicationSecurityWafExclusionFilters] +// - [ApplicationSecurityApi.UpdateApplicationSecurityWafCustomRule] +// - [ApplicationSecurityApi.UpdateApplicationSecurityWafExclusionFilter] // - [AuditApi.ListAuditLogs] // - [AuditApi.SearchAuditLogs] // - [AuthNMappingsApi.CreateAuthNMapping] diff --git a/api/datadogV2/model_application_security_waf_custom_rule_action.go b/api/datadogV2/model_application_security_waf_custom_rule_action.go new file mode 100644 index 00000000000..9b56678758f --- /dev/null +++ b/api/datadogV2/model_application_security_waf_custom_rule_action.go @@ -0,0 +1,154 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// ApplicationSecurityWafCustomRuleAction The definition of `ApplicationSecurityWafCustomRuleAction` object. +type ApplicationSecurityWafCustomRuleAction struct { + // Override the default action to take when the WAF custom rule would block. + Action *ApplicationSecurityWafCustomRuleActionAction `json:"action,omitempty"` + // The definition of `ApplicationSecurityWafCustomRuleActionParameters` object. + Parameters *ApplicationSecurityWafCustomRuleActionParameters `json:"parameters,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewApplicationSecurityWafCustomRuleAction instantiates a new ApplicationSecurityWafCustomRuleAction object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewApplicationSecurityWafCustomRuleAction() *ApplicationSecurityWafCustomRuleAction { + this := ApplicationSecurityWafCustomRuleAction{} + var action ApplicationSecurityWafCustomRuleActionAction = APPLICATIONSECURITYWAFCUSTOMRULEACTIONACTION_BLOCK_REQUEST + this.Action = &action + return &this +} + +// NewApplicationSecurityWafCustomRuleActionWithDefaults instantiates a new ApplicationSecurityWafCustomRuleAction object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewApplicationSecurityWafCustomRuleActionWithDefaults() *ApplicationSecurityWafCustomRuleAction { + this := ApplicationSecurityWafCustomRuleAction{} + var action ApplicationSecurityWafCustomRuleActionAction = APPLICATIONSECURITYWAFCUSTOMRULEACTIONACTION_BLOCK_REQUEST + this.Action = &action + return &this +} + +// GetAction returns the Action field value if set, zero value otherwise. +func (o *ApplicationSecurityWafCustomRuleAction) GetAction() ApplicationSecurityWafCustomRuleActionAction { + if o == nil || o.Action == nil { + var ret ApplicationSecurityWafCustomRuleActionAction + return ret + } + return *o.Action +} + +// GetActionOk returns a tuple with the Action field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafCustomRuleAction) GetActionOk() (*ApplicationSecurityWafCustomRuleActionAction, bool) { + if o == nil || o.Action == nil { + return nil, false + } + return o.Action, true +} + +// HasAction returns a boolean if a field has been set. +func (o *ApplicationSecurityWafCustomRuleAction) HasAction() bool { + return o != nil && o.Action != nil +} + +// SetAction gets a reference to the given ApplicationSecurityWafCustomRuleActionAction and assigns it to the Action field. +func (o *ApplicationSecurityWafCustomRuleAction) SetAction(v ApplicationSecurityWafCustomRuleActionAction) { + o.Action = &v +} + +// GetParameters returns the Parameters field value if set, zero value otherwise. +func (o *ApplicationSecurityWafCustomRuleAction) GetParameters() ApplicationSecurityWafCustomRuleActionParameters { + if o == nil || o.Parameters == nil { + var ret ApplicationSecurityWafCustomRuleActionParameters + return ret + } + return *o.Parameters +} + +// GetParametersOk returns a tuple with the Parameters field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafCustomRuleAction) GetParametersOk() (*ApplicationSecurityWafCustomRuleActionParameters, bool) { + if o == nil || o.Parameters == nil { + return nil, false + } + return o.Parameters, true +} + +// HasParameters returns a boolean if a field has been set. +func (o *ApplicationSecurityWafCustomRuleAction) HasParameters() bool { + return o != nil && o.Parameters != nil +} + +// SetParameters gets a reference to the given ApplicationSecurityWafCustomRuleActionParameters and assigns it to the Parameters field. +func (o *ApplicationSecurityWafCustomRuleAction) SetParameters(v ApplicationSecurityWafCustomRuleActionParameters) { + o.Parameters = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ApplicationSecurityWafCustomRuleAction) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Action != nil { + toSerialize["action"] = o.Action + } + if o.Parameters != nil { + toSerialize["parameters"] = o.Parameters + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *ApplicationSecurityWafCustomRuleAction) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Action *ApplicationSecurityWafCustomRuleActionAction `json:"action,omitempty"` + Parameters *ApplicationSecurityWafCustomRuleActionParameters `json:"parameters,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"action", "parameters"}) + } else { + return err + } + + hasInvalidField := false + if all.Action != nil && !all.Action.IsValid() { + hasInvalidField = true + } else { + o.Action = all.Action + } + if all.Parameters != nil && all.Parameters.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Parameters = all.Parameters + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_application_security_waf_custom_rule_action_action.go b/api/datadogV2/model_application_security_waf_custom_rule_action_action.go new file mode 100644 index 00000000000..6864ae27abd --- /dev/null +++ b/api/datadogV2/model_application_security_waf_custom_rule_action_action.go @@ -0,0 +1,66 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// ApplicationSecurityWafCustomRuleActionAction Override the default action to take when the WAF custom rule would block. +type ApplicationSecurityWafCustomRuleActionAction string + +// List of ApplicationSecurityWafCustomRuleActionAction. +const ( + APPLICATIONSECURITYWAFCUSTOMRULEACTIONACTION_REDIRECT_REQUEST ApplicationSecurityWafCustomRuleActionAction = "redirect_request" + APPLICATIONSECURITYWAFCUSTOMRULEACTIONACTION_BLOCK_REQUEST ApplicationSecurityWafCustomRuleActionAction = "block_request" +) + +var allowedApplicationSecurityWafCustomRuleActionActionEnumValues = []ApplicationSecurityWafCustomRuleActionAction{ + APPLICATIONSECURITYWAFCUSTOMRULEACTIONACTION_REDIRECT_REQUEST, + APPLICATIONSECURITYWAFCUSTOMRULEACTIONACTION_BLOCK_REQUEST, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *ApplicationSecurityWafCustomRuleActionAction) GetAllowedValues() []ApplicationSecurityWafCustomRuleActionAction { + return allowedApplicationSecurityWafCustomRuleActionActionEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *ApplicationSecurityWafCustomRuleActionAction) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = ApplicationSecurityWafCustomRuleActionAction(value) + return nil +} + +// NewApplicationSecurityWafCustomRuleActionActionFromValue returns a pointer to a valid ApplicationSecurityWafCustomRuleActionAction +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewApplicationSecurityWafCustomRuleActionActionFromValue(v string) (*ApplicationSecurityWafCustomRuleActionAction, error) { + ev := ApplicationSecurityWafCustomRuleActionAction(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for ApplicationSecurityWafCustomRuleActionAction: valid values are %v", v, allowedApplicationSecurityWafCustomRuleActionActionEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v ApplicationSecurityWafCustomRuleActionAction) IsValid() bool { + for _, existing := range allowedApplicationSecurityWafCustomRuleActionActionEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to ApplicationSecurityWafCustomRuleActionAction value. +func (v ApplicationSecurityWafCustomRuleActionAction) Ptr() *ApplicationSecurityWafCustomRuleActionAction { + return &v +} diff --git a/api/datadogV2/model_application_security_waf_custom_rule_action_parameters.go b/api/datadogV2/model_application_security_waf_custom_rule_action_parameters.go new file mode 100644 index 00000000000..1bd14542af5 --- /dev/null +++ b/api/datadogV2/model_application_security_waf_custom_rule_action_parameters.go @@ -0,0 +1,141 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// ApplicationSecurityWafCustomRuleActionParameters The definition of `ApplicationSecurityWafCustomRuleActionParameters` object. +type ApplicationSecurityWafCustomRuleActionParameters struct { + // The location to redirect to when the WAF custom rule triggers. + Location *string `json:"location,omitempty"` + // The status code to return when the WAF custom rule triggers. + StatusCode *int64 `json:"status_code,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewApplicationSecurityWafCustomRuleActionParameters instantiates a new ApplicationSecurityWafCustomRuleActionParameters object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewApplicationSecurityWafCustomRuleActionParameters() *ApplicationSecurityWafCustomRuleActionParameters { + this := ApplicationSecurityWafCustomRuleActionParameters{} + var statusCode int64 = 403 + this.StatusCode = &statusCode + return &this +} + +// NewApplicationSecurityWafCustomRuleActionParametersWithDefaults instantiates a new ApplicationSecurityWafCustomRuleActionParameters object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewApplicationSecurityWafCustomRuleActionParametersWithDefaults() *ApplicationSecurityWafCustomRuleActionParameters { + this := ApplicationSecurityWafCustomRuleActionParameters{} + var statusCode int64 = 403 + this.StatusCode = &statusCode + return &this +} + +// GetLocation returns the Location field value if set, zero value otherwise. +func (o *ApplicationSecurityWafCustomRuleActionParameters) GetLocation() string { + if o == nil || o.Location == nil { + var ret string + return ret + } + return *o.Location +} + +// GetLocationOk returns a tuple with the Location field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafCustomRuleActionParameters) GetLocationOk() (*string, bool) { + if o == nil || o.Location == nil { + return nil, false + } + return o.Location, true +} + +// HasLocation returns a boolean if a field has been set. +func (o *ApplicationSecurityWafCustomRuleActionParameters) HasLocation() bool { + return o != nil && o.Location != nil +} + +// SetLocation gets a reference to the given string and assigns it to the Location field. +func (o *ApplicationSecurityWafCustomRuleActionParameters) SetLocation(v string) { + o.Location = &v +} + +// GetStatusCode returns the StatusCode field value if set, zero value otherwise. +func (o *ApplicationSecurityWafCustomRuleActionParameters) GetStatusCode() int64 { + if o == nil || o.StatusCode == nil { + var ret int64 + return ret + } + return *o.StatusCode +} + +// GetStatusCodeOk returns a tuple with the StatusCode field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafCustomRuleActionParameters) GetStatusCodeOk() (*int64, bool) { + if o == nil || o.StatusCode == nil { + return nil, false + } + return o.StatusCode, true +} + +// HasStatusCode returns a boolean if a field has been set. +func (o *ApplicationSecurityWafCustomRuleActionParameters) HasStatusCode() bool { + return o != nil && o.StatusCode != nil +} + +// SetStatusCode gets a reference to the given int64 and assigns it to the StatusCode field. +func (o *ApplicationSecurityWafCustomRuleActionParameters) SetStatusCode(v int64) { + o.StatusCode = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ApplicationSecurityWafCustomRuleActionParameters) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Location != nil { + toSerialize["location"] = o.Location + } + if o.StatusCode != nil { + toSerialize["status_code"] = o.StatusCode + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *ApplicationSecurityWafCustomRuleActionParameters) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Location *string `json:"location,omitempty"` + StatusCode *int64 `json:"status_code,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"location", "status_code"}) + } else { + return err + } + o.Location = all.Location + o.StatusCode = all.StatusCode + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_application_security_waf_custom_rule_attributes.go b/api/datadogV2/model_application_security_waf_custom_rule_attributes.go new file mode 100644 index 00000000000..50ecec14d06 --- /dev/null +++ b/api/datadogV2/model_application_security_waf_custom_rule_attributes.go @@ -0,0 +1,386 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// ApplicationSecurityWafCustomRuleAttributes A WAF custom rule. +type ApplicationSecurityWafCustomRuleAttributes struct { + // The definition of `ApplicationSecurityWafCustomRuleAction` object. + Action *ApplicationSecurityWafCustomRuleAction `json:"action,omitempty"` + // Indicates whether the WAF custom rule will block the request. + Blocking bool `json:"blocking"` + // Conditions for which the WAF Custom Rule will triggers, all conditions needs to match in order for the WAF + // rule to trigger. + Conditions []ApplicationSecurityWafCustomRuleCondition `json:"conditions"` + // Indicates whether the WAF custom rule is enabled. + Enabled bool `json:"enabled"` + // Metadata associated with the WAF Custom Rule. + Metadata *ApplicationSecurityWafCustomRuleMetadata `json:"metadata,omitempty"` + // The Name of the WAF custom rule. + Name string `json:"name"` + // The path glob for the WAF custom rule. + PathGlob *string `json:"path_glob,omitempty"` + // The scope of the WAF custom rule. + Scope []ApplicationSecurityWafCustomRuleScope `json:"scope,omitempty"` + // Tags associated with the WAF Custom Rule. The concatenation of category and type will form the security + // activity field associated with the traces. + Tags ApplicationSecurityWafCustomRuleTags `json:"tags"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewApplicationSecurityWafCustomRuleAttributes instantiates a new ApplicationSecurityWafCustomRuleAttributes object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewApplicationSecurityWafCustomRuleAttributes(blocking bool, conditions []ApplicationSecurityWafCustomRuleCondition, enabled bool, name string, tags ApplicationSecurityWafCustomRuleTags) *ApplicationSecurityWafCustomRuleAttributes { + this := ApplicationSecurityWafCustomRuleAttributes{} + this.Blocking = blocking + this.Conditions = conditions + this.Enabled = enabled + this.Name = name + this.Tags = tags + return &this +} + +// NewApplicationSecurityWafCustomRuleAttributesWithDefaults instantiates a new ApplicationSecurityWafCustomRuleAttributes object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewApplicationSecurityWafCustomRuleAttributesWithDefaults() *ApplicationSecurityWafCustomRuleAttributes { + this := ApplicationSecurityWafCustomRuleAttributes{} + return &this +} + +// GetAction returns the Action field value if set, zero value otherwise. +func (o *ApplicationSecurityWafCustomRuleAttributes) GetAction() ApplicationSecurityWafCustomRuleAction { + if o == nil || o.Action == nil { + var ret ApplicationSecurityWafCustomRuleAction + return ret + } + return *o.Action +} + +// GetActionOk returns a tuple with the Action field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafCustomRuleAttributes) GetActionOk() (*ApplicationSecurityWafCustomRuleAction, bool) { + if o == nil || o.Action == nil { + return nil, false + } + return o.Action, true +} + +// HasAction returns a boolean if a field has been set. +func (o *ApplicationSecurityWafCustomRuleAttributes) HasAction() bool { + return o != nil && o.Action != nil +} + +// SetAction gets a reference to the given ApplicationSecurityWafCustomRuleAction and assigns it to the Action field. +func (o *ApplicationSecurityWafCustomRuleAttributes) SetAction(v ApplicationSecurityWafCustomRuleAction) { + o.Action = &v +} + +// GetBlocking returns the Blocking field value. +func (o *ApplicationSecurityWafCustomRuleAttributes) GetBlocking() bool { + if o == nil { + var ret bool + return ret + } + return o.Blocking +} + +// GetBlockingOk returns a tuple with the Blocking field value +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafCustomRuleAttributes) GetBlockingOk() (*bool, bool) { + if o == nil { + return nil, false + } + return &o.Blocking, true +} + +// SetBlocking sets field value. +func (o *ApplicationSecurityWafCustomRuleAttributes) SetBlocking(v bool) { + o.Blocking = v +} + +// GetConditions returns the Conditions field value. +func (o *ApplicationSecurityWafCustomRuleAttributes) GetConditions() []ApplicationSecurityWafCustomRuleCondition { + if o == nil { + var ret []ApplicationSecurityWafCustomRuleCondition + return ret + } + return o.Conditions +} + +// GetConditionsOk returns a tuple with the Conditions field value +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafCustomRuleAttributes) GetConditionsOk() (*[]ApplicationSecurityWafCustomRuleCondition, bool) { + if o == nil { + return nil, false + } + return &o.Conditions, true +} + +// SetConditions sets field value. +func (o *ApplicationSecurityWafCustomRuleAttributes) SetConditions(v []ApplicationSecurityWafCustomRuleCondition) { + o.Conditions = v +} + +// GetEnabled returns the Enabled field value. +func (o *ApplicationSecurityWafCustomRuleAttributes) GetEnabled() bool { + if o == nil { + var ret bool + return ret + } + return o.Enabled +} + +// GetEnabledOk returns a tuple with the Enabled field value +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafCustomRuleAttributes) GetEnabledOk() (*bool, bool) { + if o == nil { + return nil, false + } + return &o.Enabled, true +} + +// SetEnabled sets field value. +func (o *ApplicationSecurityWafCustomRuleAttributes) SetEnabled(v bool) { + o.Enabled = v +} + +// GetMetadata returns the Metadata field value if set, zero value otherwise. +func (o *ApplicationSecurityWafCustomRuleAttributes) GetMetadata() ApplicationSecurityWafCustomRuleMetadata { + if o == nil || o.Metadata == nil { + var ret ApplicationSecurityWafCustomRuleMetadata + return ret + } + return *o.Metadata +} + +// GetMetadataOk returns a tuple with the Metadata field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafCustomRuleAttributes) GetMetadataOk() (*ApplicationSecurityWafCustomRuleMetadata, bool) { + if o == nil || o.Metadata == nil { + return nil, false + } + return o.Metadata, true +} + +// HasMetadata returns a boolean if a field has been set. +func (o *ApplicationSecurityWafCustomRuleAttributes) HasMetadata() bool { + return o != nil && o.Metadata != nil +} + +// SetMetadata gets a reference to the given ApplicationSecurityWafCustomRuleMetadata and assigns it to the Metadata field. +func (o *ApplicationSecurityWafCustomRuleAttributes) SetMetadata(v ApplicationSecurityWafCustomRuleMetadata) { + o.Metadata = &v +} + +// GetName returns the Name field value. +func (o *ApplicationSecurityWafCustomRuleAttributes) GetName() string { + if o == nil { + var ret string + return ret + } + return o.Name +} + +// GetNameOk returns a tuple with the Name field value +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafCustomRuleAttributes) GetNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Name, true +} + +// SetName sets field value. +func (o *ApplicationSecurityWafCustomRuleAttributes) SetName(v string) { + o.Name = v +} + +// GetPathGlob returns the PathGlob field value if set, zero value otherwise. +func (o *ApplicationSecurityWafCustomRuleAttributes) GetPathGlob() string { + if o == nil || o.PathGlob == nil { + var ret string + return ret + } + return *o.PathGlob +} + +// GetPathGlobOk returns a tuple with the PathGlob field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafCustomRuleAttributes) GetPathGlobOk() (*string, bool) { + if o == nil || o.PathGlob == nil { + return nil, false + } + return o.PathGlob, true +} + +// HasPathGlob returns a boolean if a field has been set. +func (o *ApplicationSecurityWafCustomRuleAttributes) HasPathGlob() bool { + return o != nil && o.PathGlob != nil +} + +// SetPathGlob gets a reference to the given string and assigns it to the PathGlob field. +func (o *ApplicationSecurityWafCustomRuleAttributes) SetPathGlob(v string) { + o.PathGlob = &v +} + +// GetScope returns the Scope field value if set, zero value otherwise. +func (o *ApplicationSecurityWafCustomRuleAttributes) GetScope() []ApplicationSecurityWafCustomRuleScope { + if o == nil || o.Scope == nil { + var ret []ApplicationSecurityWafCustomRuleScope + return ret + } + return o.Scope +} + +// GetScopeOk returns a tuple with the Scope field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafCustomRuleAttributes) GetScopeOk() (*[]ApplicationSecurityWafCustomRuleScope, bool) { + if o == nil || o.Scope == nil { + return nil, false + } + return &o.Scope, true +} + +// HasScope returns a boolean if a field has been set. +func (o *ApplicationSecurityWafCustomRuleAttributes) HasScope() bool { + return o != nil && o.Scope != nil +} + +// SetScope gets a reference to the given []ApplicationSecurityWafCustomRuleScope and assigns it to the Scope field. +func (o *ApplicationSecurityWafCustomRuleAttributes) SetScope(v []ApplicationSecurityWafCustomRuleScope) { + o.Scope = v +} + +// GetTags returns the Tags field value. +func (o *ApplicationSecurityWafCustomRuleAttributes) GetTags() ApplicationSecurityWafCustomRuleTags { + if o == nil { + var ret ApplicationSecurityWafCustomRuleTags + return ret + } + return o.Tags +} + +// GetTagsOk returns a tuple with the Tags field value +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafCustomRuleAttributes) GetTagsOk() (*ApplicationSecurityWafCustomRuleTags, bool) { + if o == nil { + return nil, false + } + return &o.Tags, true +} + +// SetTags sets field value. +func (o *ApplicationSecurityWafCustomRuleAttributes) SetTags(v ApplicationSecurityWafCustomRuleTags) { + o.Tags = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ApplicationSecurityWafCustomRuleAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Action != nil { + toSerialize["action"] = o.Action + } + toSerialize["blocking"] = o.Blocking + toSerialize["conditions"] = o.Conditions + toSerialize["enabled"] = o.Enabled + if o.Metadata != nil { + toSerialize["metadata"] = o.Metadata + } + toSerialize["name"] = o.Name + if o.PathGlob != nil { + toSerialize["path_glob"] = o.PathGlob + } + if o.Scope != nil { + toSerialize["scope"] = o.Scope + } + toSerialize["tags"] = o.Tags + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *ApplicationSecurityWafCustomRuleAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Action *ApplicationSecurityWafCustomRuleAction `json:"action,omitempty"` + Blocking *bool `json:"blocking"` + Conditions *[]ApplicationSecurityWafCustomRuleCondition `json:"conditions"` + Enabled *bool `json:"enabled"` + Metadata *ApplicationSecurityWafCustomRuleMetadata `json:"metadata,omitempty"` + Name *string `json:"name"` + PathGlob *string `json:"path_glob,omitempty"` + Scope []ApplicationSecurityWafCustomRuleScope `json:"scope,omitempty"` + Tags *ApplicationSecurityWafCustomRuleTags `json:"tags"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Blocking == nil { + return fmt.Errorf("required field blocking missing") + } + if all.Conditions == nil { + return fmt.Errorf("required field conditions missing") + } + if all.Enabled == nil { + return fmt.Errorf("required field enabled missing") + } + if all.Name == nil { + return fmt.Errorf("required field name missing") + } + if all.Tags == nil { + return fmt.Errorf("required field tags missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"action", "blocking", "conditions", "enabled", "metadata", "name", "path_glob", "scope", "tags"}) + } else { + return err + } + + hasInvalidField := false + if all.Action != nil && all.Action.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Action = all.Action + o.Blocking = *all.Blocking + o.Conditions = *all.Conditions + o.Enabled = *all.Enabled + if all.Metadata != nil && all.Metadata.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Metadata = all.Metadata + o.Name = *all.Name + o.PathGlob = all.PathGlob + o.Scope = all.Scope + if all.Tags.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Tags = *all.Tags + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_application_security_waf_custom_rule_condition.go b/api/datadogV2/model_application_security_waf_custom_rule_condition.go new file mode 100644 index 00000000000..292ee2d51b4 --- /dev/null +++ b/api/datadogV2/model_application_security_waf_custom_rule_condition.go @@ -0,0 +1,146 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// ApplicationSecurityWafCustomRuleCondition One condition of the WAF Custom Rule. +type ApplicationSecurityWafCustomRuleCondition struct { + // Operator to use for the WAF Condition. + Operator ApplicationSecurityWafCustomRuleConditionOperator `json:"operator"` + // The scope of the WAF custom rule. + Parameters ApplicationSecurityWafCustomRuleConditionParameters `json:"parameters"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewApplicationSecurityWafCustomRuleCondition instantiates a new ApplicationSecurityWafCustomRuleCondition object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewApplicationSecurityWafCustomRuleCondition(operator ApplicationSecurityWafCustomRuleConditionOperator, parameters ApplicationSecurityWafCustomRuleConditionParameters) *ApplicationSecurityWafCustomRuleCondition { + this := ApplicationSecurityWafCustomRuleCondition{} + this.Operator = operator + this.Parameters = parameters + return &this +} + +// NewApplicationSecurityWafCustomRuleConditionWithDefaults instantiates a new ApplicationSecurityWafCustomRuleCondition object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewApplicationSecurityWafCustomRuleConditionWithDefaults() *ApplicationSecurityWafCustomRuleCondition { + this := ApplicationSecurityWafCustomRuleCondition{} + return &this +} + +// GetOperator returns the Operator field value. +func (o *ApplicationSecurityWafCustomRuleCondition) GetOperator() ApplicationSecurityWafCustomRuleConditionOperator { + if o == nil { + var ret ApplicationSecurityWafCustomRuleConditionOperator + return ret + } + return o.Operator +} + +// GetOperatorOk returns a tuple with the Operator field value +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafCustomRuleCondition) GetOperatorOk() (*ApplicationSecurityWafCustomRuleConditionOperator, bool) { + if o == nil { + return nil, false + } + return &o.Operator, true +} + +// SetOperator sets field value. +func (o *ApplicationSecurityWafCustomRuleCondition) SetOperator(v ApplicationSecurityWafCustomRuleConditionOperator) { + o.Operator = v +} + +// GetParameters returns the Parameters field value. +func (o *ApplicationSecurityWafCustomRuleCondition) GetParameters() ApplicationSecurityWafCustomRuleConditionParameters { + if o == nil { + var ret ApplicationSecurityWafCustomRuleConditionParameters + return ret + } + return o.Parameters +} + +// GetParametersOk returns a tuple with the Parameters field value +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafCustomRuleCondition) GetParametersOk() (*ApplicationSecurityWafCustomRuleConditionParameters, bool) { + if o == nil { + return nil, false + } + return &o.Parameters, true +} + +// SetParameters sets field value. +func (o *ApplicationSecurityWafCustomRuleCondition) SetParameters(v ApplicationSecurityWafCustomRuleConditionParameters) { + o.Parameters = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ApplicationSecurityWafCustomRuleCondition) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["operator"] = o.Operator + toSerialize["parameters"] = o.Parameters + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *ApplicationSecurityWafCustomRuleCondition) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Operator *ApplicationSecurityWafCustomRuleConditionOperator `json:"operator"` + Parameters *ApplicationSecurityWafCustomRuleConditionParameters `json:"parameters"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Operator == nil { + return fmt.Errorf("required field operator missing") + } + if all.Parameters == nil { + return fmt.Errorf("required field parameters missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"operator", "parameters"}) + } else { + return err + } + + hasInvalidField := false + if !all.Operator.IsValid() { + hasInvalidField = true + } else { + o.Operator = *all.Operator + } + if all.Parameters.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Parameters = *all.Parameters + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_application_security_waf_custom_rule_condition_input.go b/api/datadogV2/model_application_security_waf_custom_rule_condition_input.go new file mode 100644 index 00000000000..7d8ddbf8742 --- /dev/null +++ b/api/datadogV2/model_application_security_waf_custom_rule_condition_input.go @@ -0,0 +1,146 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// ApplicationSecurityWafCustomRuleConditionInput Input from the request on which the condition should apply. +type ApplicationSecurityWafCustomRuleConditionInput struct { + // Input from the request on which the condition should apply. + Address ApplicationSecurityWafCustomRuleConditionInputAddress `json:"address"` + // Specific path for the input. + KeyPath []string `json:"key_path,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewApplicationSecurityWafCustomRuleConditionInput instantiates a new ApplicationSecurityWafCustomRuleConditionInput object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewApplicationSecurityWafCustomRuleConditionInput(address ApplicationSecurityWafCustomRuleConditionInputAddress) *ApplicationSecurityWafCustomRuleConditionInput { + this := ApplicationSecurityWafCustomRuleConditionInput{} + this.Address = address + return &this +} + +// NewApplicationSecurityWafCustomRuleConditionInputWithDefaults instantiates a new ApplicationSecurityWafCustomRuleConditionInput object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewApplicationSecurityWafCustomRuleConditionInputWithDefaults() *ApplicationSecurityWafCustomRuleConditionInput { + this := ApplicationSecurityWafCustomRuleConditionInput{} + return &this +} + +// GetAddress returns the Address field value. +func (o *ApplicationSecurityWafCustomRuleConditionInput) GetAddress() ApplicationSecurityWafCustomRuleConditionInputAddress { + if o == nil { + var ret ApplicationSecurityWafCustomRuleConditionInputAddress + return ret + } + return o.Address +} + +// GetAddressOk returns a tuple with the Address field value +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafCustomRuleConditionInput) GetAddressOk() (*ApplicationSecurityWafCustomRuleConditionInputAddress, bool) { + if o == nil { + return nil, false + } + return &o.Address, true +} + +// SetAddress sets field value. +func (o *ApplicationSecurityWafCustomRuleConditionInput) SetAddress(v ApplicationSecurityWafCustomRuleConditionInputAddress) { + o.Address = v +} + +// GetKeyPath returns the KeyPath field value if set, zero value otherwise. +func (o *ApplicationSecurityWafCustomRuleConditionInput) GetKeyPath() []string { + if o == nil || o.KeyPath == nil { + var ret []string + return ret + } + return o.KeyPath +} + +// GetKeyPathOk returns a tuple with the KeyPath field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafCustomRuleConditionInput) GetKeyPathOk() (*[]string, bool) { + if o == nil || o.KeyPath == nil { + return nil, false + } + return &o.KeyPath, true +} + +// HasKeyPath returns a boolean if a field has been set. +func (o *ApplicationSecurityWafCustomRuleConditionInput) HasKeyPath() bool { + return o != nil && o.KeyPath != nil +} + +// SetKeyPath gets a reference to the given []string and assigns it to the KeyPath field. +func (o *ApplicationSecurityWafCustomRuleConditionInput) SetKeyPath(v []string) { + o.KeyPath = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ApplicationSecurityWafCustomRuleConditionInput) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["address"] = o.Address + if o.KeyPath != nil { + toSerialize["key_path"] = o.KeyPath + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *ApplicationSecurityWafCustomRuleConditionInput) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Address *ApplicationSecurityWafCustomRuleConditionInputAddress `json:"address"` + KeyPath []string `json:"key_path,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Address == nil { + return fmt.Errorf("required field address missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"address", "key_path"}) + } else { + return err + } + + hasInvalidField := false + if !all.Address.IsValid() { + hasInvalidField = true + } else { + o.Address = *all.Address + } + o.KeyPath = all.KeyPath + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_application_security_waf_custom_rule_condition_input_address.go b/api/datadogV2/model_application_security_waf_custom_rule_condition_input_address.go new file mode 100644 index 00000000000..7cb6a28ee04 --- /dev/null +++ b/api/datadogV2/model_application_security_waf_custom_rule_condition_input_address.go @@ -0,0 +1,104 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// ApplicationSecurityWafCustomRuleConditionInputAddress Input from the request on which the condition should apply. +type ApplicationSecurityWafCustomRuleConditionInputAddress string + +// List of ApplicationSecurityWafCustomRuleConditionInputAddress. +const ( + APPLICATIONSECURITYWAFCUSTOMRULECONDITIONINPUTADDRESS_SERVER_DB_STATEMENT ApplicationSecurityWafCustomRuleConditionInputAddress = "server.db.statement" + APPLICATIONSECURITYWAFCUSTOMRULECONDITIONINPUTADDRESS_SERVER_IO_FS_FILE ApplicationSecurityWafCustomRuleConditionInputAddress = "server.io.fs.file" + APPLICATIONSECURITYWAFCUSTOMRULECONDITIONINPUTADDRESS_SERVER_IO_NET_URL ApplicationSecurityWafCustomRuleConditionInputAddress = "server.io.net.url" + APPLICATIONSECURITYWAFCUSTOMRULECONDITIONINPUTADDRESS_SERVER_SYS_SHELL_CMD ApplicationSecurityWafCustomRuleConditionInputAddress = "server.sys.shell.cmd" + APPLICATIONSECURITYWAFCUSTOMRULECONDITIONINPUTADDRESS_SERVER_REQUEST_METHOD ApplicationSecurityWafCustomRuleConditionInputAddress = "server.request.method" + APPLICATIONSECURITYWAFCUSTOMRULECONDITIONINPUTADDRESS_SERVER_REQUEST_URI_RAW ApplicationSecurityWafCustomRuleConditionInputAddress = "server.request.uri.raw" + APPLICATIONSECURITYWAFCUSTOMRULECONDITIONINPUTADDRESS_SERVER_REQUEST_PATH_PARAMS ApplicationSecurityWafCustomRuleConditionInputAddress = "server.request.path_params" + APPLICATIONSECURITYWAFCUSTOMRULECONDITIONINPUTADDRESS_SERVER_REQUEST_QUERY ApplicationSecurityWafCustomRuleConditionInputAddress = "server.request.query" + APPLICATIONSECURITYWAFCUSTOMRULECONDITIONINPUTADDRESS_SERVER_REQUEST_HEADERS_NO_COOKIES ApplicationSecurityWafCustomRuleConditionInputAddress = "server.request.headers.no_cookies" + APPLICATIONSECURITYWAFCUSTOMRULECONDITIONINPUTADDRESS_SERVER_REQUEST_COOKIES ApplicationSecurityWafCustomRuleConditionInputAddress = "server.request.cookies" + APPLICATIONSECURITYWAFCUSTOMRULECONDITIONINPUTADDRESS_SERVER_REQUEST_TRAILERS ApplicationSecurityWafCustomRuleConditionInputAddress = "server.request.trailers" + APPLICATIONSECURITYWAFCUSTOMRULECONDITIONINPUTADDRESS_SERVER_REQUEST_BODY ApplicationSecurityWafCustomRuleConditionInputAddress = "server.request.body" + APPLICATIONSECURITYWAFCUSTOMRULECONDITIONINPUTADDRESS_SERVER_RESPONSE_STATUS ApplicationSecurityWafCustomRuleConditionInputAddress = "server.response.status" + APPLICATIONSECURITYWAFCUSTOMRULECONDITIONINPUTADDRESS_SERVER_RESPONSE_HEADERS_NO_COOKIES ApplicationSecurityWafCustomRuleConditionInputAddress = "server.response.headers.no_cookies" + APPLICATIONSECURITYWAFCUSTOMRULECONDITIONINPUTADDRESS_SERVER_RESPONSE_TRAILERS ApplicationSecurityWafCustomRuleConditionInputAddress = "server.response.trailers" + APPLICATIONSECURITYWAFCUSTOMRULECONDITIONINPUTADDRESS_GRPC_SERVER_REQUEST_METADATA ApplicationSecurityWafCustomRuleConditionInputAddress = "grpc.server.request.metadata" + APPLICATIONSECURITYWAFCUSTOMRULECONDITIONINPUTADDRESS_GRPC_SERVER_REQUEST_MESSAGE ApplicationSecurityWafCustomRuleConditionInputAddress = "grpc.server.request.message" + APPLICATIONSECURITYWAFCUSTOMRULECONDITIONINPUTADDRESS_GRPC_SERVER_METHOD ApplicationSecurityWafCustomRuleConditionInputAddress = "grpc.server.method" + APPLICATIONSECURITYWAFCUSTOMRULECONDITIONINPUTADDRESS_GRAPHQL_SERVER_ALL_RESOLVERS ApplicationSecurityWafCustomRuleConditionInputAddress = "graphql.server.all_resolvers" + APPLICATIONSECURITYWAFCUSTOMRULECONDITIONINPUTADDRESS_USR_ID ApplicationSecurityWafCustomRuleConditionInputAddress = "usr.id" + APPLICATIONSECURITYWAFCUSTOMRULECONDITIONINPUTADDRESS_HTTP_CLIENT_IP ApplicationSecurityWafCustomRuleConditionInputAddress = "http.client_ip" +) + +var allowedApplicationSecurityWafCustomRuleConditionInputAddressEnumValues = []ApplicationSecurityWafCustomRuleConditionInputAddress{ + APPLICATIONSECURITYWAFCUSTOMRULECONDITIONINPUTADDRESS_SERVER_DB_STATEMENT, + APPLICATIONSECURITYWAFCUSTOMRULECONDITIONINPUTADDRESS_SERVER_IO_FS_FILE, + APPLICATIONSECURITYWAFCUSTOMRULECONDITIONINPUTADDRESS_SERVER_IO_NET_URL, + APPLICATIONSECURITYWAFCUSTOMRULECONDITIONINPUTADDRESS_SERVER_SYS_SHELL_CMD, + APPLICATIONSECURITYWAFCUSTOMRULECONDITIONINPUTADDRESS_SERVER_REQUEST_METHOD, + APPLICATIONSECURITYWAFCUSTOMRULECONDITIONINPUTADDRESS_SERVER_REQUEST_URI_RAW, + APPLICATIONSECURITYWAFCUSTOMRULECONDITIONINPUTADDRESS_SERVER_REQUEST_PATH_PARAMS, + APPLICATIONSECURITYWAFCUSTOMRULECONDITIONINPUTADDRESS_SERVER_REQUEST_QUERY, + APPLICATIONSECURITYWAFCUSTOMRULECONDITIONINPUTADDRESS_SERVER_REQUEST_HEADERS_NO_COOKIES, + APPLICATIONSECURITYWAFCUSTOMRULECONDITIONINPUTADDRESS_SERVER_REQUEST_COOKIES, + APPLICATIONSECURITYWAFCUSTOMRULECONDITIONINPUTADDRESS_SERVER_REQUEST_TRAILERS, + APPLICATIONSECURITYWAFCUSTOMRULECONDITIONINPUTADDRESS_SERVER_REQUEST_BODY, + APPLICATIONSECURITYWAFCUSTOMRULECONDITIONINPUTADDRESS_SERVER_RESPONSE_STATUS, + APPLICATIONSECURITYWAFCUSTOMRULECONDITIONINPUTADDRESS_SERVER_RESPONSE_HEADERS_NO_COOKIES, + APPLICATIONSECURITYWAFCUSTOMRULECONDITIONINPUTADDRESS_SERVER_RESPONSE_TRAILERS, + APPLICATIONSECURITYWAFCUSTOMRULECONDITIONINPUTADDRESS_GRPC_SERVER_REQUEST_METADATA, + APPLICATIONSECURITYWAFCUSTOMRULECONDITIONINPUTADDRESS_GRPC_SERVER_REQUEST_MESSAGE, + APPLICATIONSECURITYWAFCUSTOMRULECONDITIONINPUTADDRESS_GRPC_SERVER_METHOD, + APPLICATIONSECURITYWAFCUSTOMRULECONDITIONINPUTADDRESS_GRAPHQL_SERVER_ALL_RESOLVERS, + APPLICATIONSECURITYWAFCUSTOMRULECONDITIONINPUTADDRESS_USR_ID, + APPLICATIONSECURITYWAFCUSTOMRULECONDITIONINPUTADDRESS_HTTP_CLIENT_IP, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *ApplicationSecurityWafCustomRuleConditionInputAddress) GetAllowedValues() []ApplicationSecurityWafCustomRuleConditionInputAddress { + return allowedApplicationSecurityWafCustomRuleConditionInputAddressEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *ApplicationSecurityWafCustomRuleConditionInputAddress) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = ApplicationSecurityWafCustomRuleConditionInputAddress(value) + return nil +} + +// NewApplicationSecurityWafCustomRuleConditionInputAddressFromValue returns a pointer to a valid ApplicationSecurityWafCustomRuleConditionInputAddress +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewApplicationSecurityWafCustomRuleConditionInputAddressFromValue(v string) (*ApplicationSecurityWafCustomRuleConditionInputAddress, error) { + ev := ApplicationSecurityWafCustomRuleConditionInputAddress(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for ApplicationSecurityWafCustomRuleConditionInputAddress: valid values are %v", v, allowedApplicationSecurityWafCustomRuleConditionInputAddressEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v ApplicationSecurityWafCustomRuleConditionInputAddress) IsValid() bool { + for _, existing := range allowedApplicationSecurityWafCustomRuleConditionInputAddressEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to ApplicationSecurityWafCustomRuleConditionInputAddress value. +func (v ApplicationSecurityWafCustomRuleConditionInputAddress) Ptr() *ApplicationSecurityWafCustomRuleConditionInputAddress { + return &v +} diff --git a/api/datadogV2/model_application_security_waf_custom_rule_condition_operator.go b/api/datadogV2/model_application_security_waf_custom_rule_condition_operator.go new file mode 100644 index 00000000000..8832a36c7fd --- /dev/null +++ b/api/datadogV2/model_application_security_waf_custom_rule_condition_operator.go @@ -0,0 +1,84 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// ApplicationSecurityWafCustomRuleConditionOperator Operator to use for the WAF Condition. +type ApplicationSecurityWafCustomRuleConditionOperator string + +// List of ApplicationSecurityWafCustomRuleConditionOperator. +const ( + APPLICATIONSECURITYWAFCUSTOMRULECONDITIONOPERATOR_MATCH_REGEX ApplicationSecurityWafCustomRuleConditionOperator = "match_regex" + APPLICATIONSECURITYWAFCUSTOMRULECONDITIONOPERATOR_NOT_MATCH_REGEX ApplicationSecurityWafCustomRuleConditionOperator = "!match_regex" + APPLICATIONSECURITYWAFCUSTOMRULECONDITIONOPERATOR_PHRASE_MATCH ApplicationSecurityWafCustomRuleConditionOperator = "phrase_match" + APPLICATIONSECURITYWAFCUSTOMRULECONDITIONOPERATOR_NOT_PHRASE_MATCH ApplicationSecurityWafCustomRuleConditionOperator = "!phrase_match" + APPLICATIONSECURITYWAFCUSTOMRULECONDITIONOPERATOR_IS_XSS ApplicationSecurityWafCustomRuleConditionOperator = "is_xss" + APPLICATIONSECURITYWAFCUSTOMRULECONDITIONOPERATOR_IS_SQLI ApplicationSecurityWafCustomRuleConditionOperator = "is_sqli" + APPLICATIONSECURITYWAFCUSTOMRULECONDITIONOPERATOR_EXACT_MATCH ApplicationSecurityWafCustomRuleConditionOperator = "exact_match" + APPLICATIONSECURITYWAFCUSTOMRULECONDITIONOPERATOR_NOT_EXACT_MATCH ApplicationSecurityWafCustomRuleConditionOperator = "!exact_match" + APPLICATIONSECURITYWAFCUSTOMRULECONDITIONOPERATOR_IP_MATCH ApplicationSecurityWafCustomRuleConditionOperator = "ip_match" + APPLICATIONSECURITYWAFCUSTOMRULECONDITIONOPERATOR_NOT_IP_MATCH ApplicationSecurityWafCustomRuleConditionOperator = "!ip_match" + APPLICATIONSECURITYWAFCUSTOMRULECONDITIONOPERATOR_CAPTURE_DATA ApplicationSecurityWafCustomRuleConditionOperator = "capture_data" +) + +var allowedApplicationSecurityWafCustomRuleConditionOperatorEnumValues = []ApplicationSecurityWafCustomRuleConditionOperator{ + APPLICATIONSECURITYWAFCUSTOMRULECONDITIONOPERATOR_MATCH_REGEX, + APPLICATIONSECURITYWAFCUSTOMRULECONDITIONOPERATOR_NOT_MATCH_REGEX, + APPLICATIONSECURITYWAFCUSTOMRULECONDITIONOPERATOR_PHRASE_MATCH, + APPLICATIONSECURITYWAFCUSTOMRULECONDITIONOPERATOR_NOT_PHRASE_MATCH, + APPLICATIONSECURITYWAFCUSTOMRULECONDITIONOPERATOR_IS_XSS, + APPLICATIONSECURITYWAFCUSTOMRULECONDITIONOPERATOR_IS_SQLI, + APPLICATIONSECURITYWAFCUSTOMRULECONDITIONOPERATOR_EXACT_MATCH, + APPLICATIONSECURITYWAFCUSTOMRULECONDITIONOPERATOR_NOT_EXACT_MATCH, + APPLICATIONSECURITYWAFCUSTOMRULECONDITIONOPERATOR_IP_MATCH, + APPLICATIONSECURITYWAFCUSTOMRULECONDITIONOPERATOR_NOT_IP_MATCH, + APPLICATIONSECURITYWAFCUSTOMRULECONDITIONOPERATOR_CAPTURE_DATA, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *ApplicationSecurityWafCustomRuleConditionOperator) GetAllowedValues() []ApplicationSecurityWafCustomRuleConditionOperator { + return allowedApplicationSecurityWafCustomRuleConditionOperatorEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *ApplicationSecurityWafCustomRuleConditionOperator) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = ApplicationSecurityWafCustomRuleConditionOperator(value) + return nil +} + +// NewApplicationSecurityWafCustomRuleConditionOperatorFromValue returns a pointer to a valid ApplicationSecurityWafCustomRuleConditionOperator +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewApplicationSecurityWafCustomRuleConditionOperatorFromValue(v string) (*ApplicationSecurityWafCustomRuleConditionOperator, error) { + ev := ApplicationSecurityWafCustomRuleConditionOperator(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for ApplicationSecurityWafCustomRuleConditionOperator: valid values are %v", v, allowedApplicationSecurityWafCustomRuleConditionOperatorEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v ApplicationSecurityWafCustomRuleConditionOperator) IsValid() bool { + for _, existing := range allowedApplicationSecurityWafCustomRuleConditionOperatorEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to ApplicationSecurityWafCustomRuleConditionOperator value. +func (v ApplicationSecurityWafCustomRuleConditionOperator) Ptr() *ApplicationSecurityWafCustomRuleConditionOperator { + return &v +} diff --git a/api/datadogV2/model_application_security_waf_custom_rule_condition_options.go b/api/datadogV2/model_application_security_waf_custom_rule_condition_options.go new file mode 100644 index 00000000000..d4741f027be --- /dev/null +++ b/api/datadogV2/model_application_security_waf_custom_rule_condition_options.go @@ -0,0 +1,145 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// ApplicationSecurityWafCustomRuleConditionOptions Options for the operator of this condition. +type ApplicationSecurityWafCustomRuleConditionOptions struct { + // Evaluate the value as case sensitive. + CaseSensitive *bool `json:"case_sensitive,omitempty"` + // Only evaluate this condition if the value has a minimum amount of characters. + MinLength *int64 `json:"min_length,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewApplicationSecurityWafCustomRuleConditionOptions instantiates a new ApplicationSecurityWafCustomRuleConditionOptions object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewApplicationSecurityWafCustomRuleConditionOptions() *ApplicationSecurityWafCustomRuleConditionOptions { + this := ApplicationSecurityWafCustomRuleConditionOptions{} + var caseSensitive bool = false + this.CaseSensitive = &caseSensitive + var minLength int64 = 0 + this.MinLength = &minLength + return &this +} + +// NewApplicationSecurityWafCustomRuleConditionOptionsWithDefaults instantiates a new ApplicationSecurityWafCustomRuleConditionOptions object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewApplicationSecurityWafCustomRuleConditionOptionsWithDefaults() *ApplicationSecurityWafCustomRuleConditionOptions { + this := ApplicationSecurityWafCustomRuleConditionOptions{} + var caseSensitive bool = false + this.CaseSensitive = &caseSensitive + var minLength int64 = 0 + this.MinLength = &minLength + return &this +} + +// GetCaseSensitive returns the CaseSensitive field value if set, zero value otherwise. +func (o *ApplicationSecurityWafCustomRuleConditionOptions) GetCaseSensitive() bool { + if o == nil || o.CaseSensitive == nil { + var ret bool + return ret + } + return *o.CaseSensitive +} + +// GetCaseSensitiveOk returns a tuple with the CaseSensitive field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafCustomRuleConditionOptions) GetCaseSensitiveOk() (*bool, bool) { + if o == nil || o.CaseSensitive == nil { + return nil, false + } + return o.CaseSensitive, true +} + +// HasCaseSensitive returns a boolean if a field has been set. +func (o *ApplicationSecurityWafCustomRuleConditionOptions) HasCaseSensitive() bool { + return o != nil && o.CaseSensitive != nil +} + +// SetCaseSensitive gets a reference to the given bool and assigns it to the CaseSensitive field. +func (o *ApplicationSecurityWafCustomRuleConditionOptions) SetCaseSensitive(v bool) { + o.CaseSensitive = &v +} + +// GetMinLength returns the MinLength field value if set, zero value otherwise. +func (o *ApplicationSecurityWafCustomRuleConditionOptions) GetMinLength() int64 { + if o == nil || o.MinLength == nil { + var ret int64 + return ret + } + return *o.MinLength +} + +// GetMinLengthOk returns a tuple with the MinLength field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafCustomRuleConditionOptions) GetMinLengthOk() (*int64, bool) { + if o == nil || o.MinLength == nil { + return nil, false + } + return o.MinLength, true +} + +// HasMinLength returns a boolean if a field has been set. +func (o *ApplicationSecurityWafCustomRuleConditionOptions) HasMinLength() bool { + return o != nil && o.MinLength != nil +} + +// SetMinLength gets a reference to the given int64 and assigns it to the MinLength field. +func (o *ApplicationSecurityWafCustomRuleConditionOptions) SetMinLength(v int64) { + o.MinLength = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ApplicationSecurityWafCustomRuleConditionOptions) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.CaseSensitive != nil { + toSerialize["case_sensitive"] = o.CaseSensitive + } + if o.MinLength != nil { + toSerialize["min_length"] = o.MinLength + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *ApplicationSecurityWafCustomRuleConditionOptions) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + CaseSensitive *bool `json:"case_sensitive,omitempty"` + MinLength *int64 `json:"min_length,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"case_sensitive", "min_length"}) + } else { + return err + } + o.CaseSensitive = all.CaseSensitive + o.MinLength = all.MinLength + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_application_security_waf_custom_rule_condition_parameters.go b/api/datadogV2/model_application_security_waf_custom_rule_condition_parameters.go new file mode 100644 index 00000000000..e8d2355f573 --- /dev/null +++ b/api/datadogV2/model_application_security_waf_custom_rule_condition_parameters.go @@ -0,0 +1,286 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// ApplicationSecurityWafCustomRuleConditionParameters The scope of the WAF custom rule. +type ApplicationSecurityWafCustomRuleConditionParameters struct { + // Identifier of a list of data from the denylist. Can only be used as substitution from the list parameter. + Data *string `json:"data,omitempty"` + // List of inputs on which at least one should match with the given operator. + Inputs []ApplicationSecurityWafCustomRuleConditionInput `json:"inputs"` + // List of value to use with the condition. Only used with the phrase_match, !phrase_match, exact_match and + // !exact_match operator. + List []string `json:"list,omitempty"` + // Options for the operator of this condition. + Options *ApplicationSecurityWafCustomRuleConditionOptions `json:"options,omitempty"` + // Regex to use with the condition. Only used with match_regex and !match_regex operator. + Regex *string `json:"regex,omitempty"` + // Store the captured value in the specified tag name. Only used with the capture_data operator. + Value *string `json:"value,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewApplicationSecurityWafCustomRuleConditionParameters instantiates a new ApplicationSecurityWafCustomRuleConditionParameters object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewApplicationSecurityWafCustomRuleConditionParameters(inputs []ApplicationSecurityWafCustomRuleConditionInput) *ApplicationSecurityWafCustomRuleConditionParameters { + this := ApplicationSecurityWafCustomRuleConditionParameters{} + this.Inputs = inputs + return &this +} + +// NewApplicationSecurityWafCustomRuleConditionParametersWithDefaults instantiates a new ApplicationSecurityWafCustomRuleConditionParameters object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewApplicationSecurityWafCustomRuleConditionParametersWithDefaults() *ApplicationSecurityWafCustomRuleConditionParameters { + this := ApplicationSecurityWafCustomRuleConditionParameters{} + return &this +} + +// GetData returns the Data field value if set, zero value otherwise. +func (o *ApplicationSecurityWafCustomRuleConditionParameters) GetData() string { + if o == nil || o.Data == nil { + var ret string + return ret + } + return *o.Data +} + +// GetDataOk returns a tuple with the Data field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafCustomRuleConditionParameters) GetDataOk() (*string, bool) { + if o == nil || o.Data == nil { + return nil, false + } + return o.Data, true +} + +// HasData returns a boolean if a field has been set. +func (o *ApplicationSecurityWafCustomRuleConditionParameters) HasData() bool { + return o != nil && o.Data != nil +} + +// SetData gets a reference to the given string and assigns it to the Data field. +func (o *ApplicationSecurityWafCustomRuleConditionParameters) SetData(v string) { + o.Data = &v +} + +// GetInputs returns the Inputs field value. +func (o *ApplicationSecurityWafCustomRuleConditionParameters) GetInputs() []ApplicationSecurityWafCustomRuleConditionInput { + if o == nil { + var ret []ApplicationSecurityWafCustomRuleConditionInput + return ret + } + return o.Inputs +} + +// GetInputsOk returns a tuple with the Inputs field value +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafCustomRuleConditionParameters) GetInputsOk() (*[]ApplicationSecurityWafCustomRuleConditionInput, bool) { + if o == nil { + return nil, false + } + return &o.Inputs, true +} + +// SetInputs sets field value. +func (o *ApplicationSecurityWafCustomRuleConditionParameters) SetInputs(v []ApplicationSecurityWafCustomRuleConditionInput) { + o.Inputs = v +} + +// GetList returns the List field value if set, zero value otherwise. +func (o *ApplicationSecurityWafCustomRuleConditionParameters) GetList() []string { + if o == nil || o.List == nil { + var ret []string + return ret + } + return o.List +} + +// GetListOk returns a tuple with the List field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafCustomRuleConditionParameters) GetListOk() (*[]string, bool) { + if o == nil || o.List == nil { + return nil, false + } + return &o.List, true +} + +// HasList returns a boolean if a field has been set. +func (o *ApplicationSecurityWafCustomRuleConditionParameters) HasList() bool { + return o != nil && o.List != nil +} + +// SetList gets a reference to the given []string and assigns it to the List field. +func (o *ApplicationSecurityWafCustomRuleConditionParameters) SetList(v []string) { + o.List = v +} + +// GetOptions returns the Options field value if set, zero value otherwise. +func (o *ApplicationSecurityWafCustomRuleConditionParameters) GetOptions() ApplicationSecurityWafCustomRuleConditionOptions { + if o == nil || o.Options == nil { + var ret ApplicationSecurityWafCustomRuleConditionOptions + return ret + } + return *o.Options +} + +// GetOptionsOk returns a tuple with the Options field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafCustomRuleConditionParameters) GetOptionsOk() (*ApplicationSecurityWafCustomRuleConditionOptions, bool) { + if o == nil || o.Options == nil { + return nil, false + } + return o.Options, true +} + +// HasOptions returns a boolean if a field has been set. +func (o *ApplicationSecurityWafCustomRuleConditionParameters) HasOptions() bool { + return o != nil && o.Options != nil +} + +// SetOptions gets a reference to the given ApplicationSecurityWafCustomRuleConditionOptions and assigns it to the Options field. +func (o *ApplicationSecurityWafCustomRuleConditionParameters) SetOptions(v ApplicationSecurityWafCustomRuleConditionOptions) { + o.Options = &v +} + +// GetRegex returns the Regex field value if set, zero value otherwise. +func (o *ApplicationSecurityWafCustomRuleConditionParameters) GetRegex() string { + if o == nil || o.Regex == nil { + var ret string + return ret + } + return *o.Regex +} + +// GetRegexOk returns a tuple with the Regex field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafCustomRuleConditionParameters) GetRegexOk() (*string, bool) { + if o == nil || o.Regex == nil { + return nil, false + } + return o.Regex, true +} + +// HasRegex returns a boolean if a field has been set. +func (o *ApplicationSecurityWafCustomRuleConditionParameters) HasRegex() bool { + return o != nil && o.Regex != nil +} + +// SetRegex gets a reference to the given string and assigns it to the Regex field. +func (o *ApplicationSecurityWafCustomRuleConditionParameters) SetRegex(v string) { + o.Regex = &v +} + +// GetValue returns the Value field value if set, zero value otherwise. +func (o *ApplicationSecurityWafCustomRuleConditionParameters) GetValue() string { + if o == nil || o.Value == nil { + var ret string + return ret + } + return *o.Value +} + +// GetValueOk returns a tuple with the Value field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafCustomRuleConditionParameters) GetValueOk() (*string, bool) { + if o == nil || o.Value == nil { + return nil, false + } + return o.Value, true +} + +// HasValue returns a boolean if a field has been set. +func (o *ApplicationSecurityWafCustomRuleConditionParameters) HasValue() bool { + return o != nil && o.Value != nil +} + +// SetValue gets a reference to the given string and assigns it to the Value field. +func (o *ApplicationSecurityWafCustomRuleConditionParameters) SetValue(v string) { + o.Value = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ApplicationSecurityWafCustomRuleConditionParameters) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Data != nil { + toSerialize["data"] = o.Data + } + toSerialize["inputs"] = o.Inputs + if o.List != nil { + toSerialize["list"] = o.List + } + if o.Options != nil { + toSerialize["options"] = o.Options + } + if o.Regex != nil { + toSerialize["regex"] = o.Regex + } + if o.Value != nil { + toSerialize["value"] = o.Value + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *ApplicationSecurityWafCustomRuleConditionParameters) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *string `json:"data,omitempty"` + Inputs *[]ApplicationSecurityWafCustomRuleConditionInput `json:"inputs"` + List []string `json:"list,omitempty"` + Options *ApplicationSecurityWafCustomRuleConditionOptions `json:"options,omitempty"` + Regex *string `json:"regex,omitempty"` + Value *string `json:"value,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Inputs == nil { + return fmt.Errorf("required field inputs missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data", "inputs", "list", "options", "regex", "value"}) + } else { + return err + } + + hasInvalidField := false + o.Data = all.Data + o.Inputs = *all.Inputs + o.List = all.List + if all.Options != nil && all.Options.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Options = all.Options + o.Regex = all.Regex + o.Value = all.Value + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_application_security_waf_custom_rule_create_attributes.go b/api/datadogV2/model_application_security_waf_custom_rule_create_attributes.go new file mode 100644 index 00000000000..65511b88024 --- /dev/null +++ b/api/datadogV2/model_application_security_waf_custom_rule_create_attributes.go @@ -0,0 +1,348 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// ApplicationSecurityWafCustomRuleCreateAttributes Create a new WAF custom rule. +type ApplicationSecurityWafCustomRuleCreateAttributes struct { + // The definition of `ApplicationSecurityWafCustomRuleAction` object. + Action *ApplicationSecurityWafCustomRuleAction `json:"action,omitempty"` + // Indicates whether the WAF custom rule will block the request. + Blocking bool `json:"blocking"` + // Conditions for which the WAF Custom Rule will triggers, all conditions needs to match in order for the WAF + // rule to trigger + Conditions []ApplicationSecurityWafCustomRuleCondition `json:"conditions"` + // Indicates whether the WAF custom rule is enabled. + Enabled bool `json:"enabled"` + // The Name of the WAF custom rule. + Name string `json:"name"` + // The path glob for the WAF custom rule. + PathGlob *string `json:"path_glob,omitempty"` + // The scope of the WAF custom rule. + Scope []ApplicationSecurityWafCustomRuleScope `json:"scope,omitempty"` + // Tags associated with the WAF Custom Rule. The concatenation of category and type will form the security + // activity field associated with the traces. + Tags ApplicationSecurityWafCustomRuleTags `json:"tags"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewApplicationSecurityWafCustomRuleCreateAttributes instantiates a new ApplicationSecurityWafCustomRuleCreateAttributes object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewApplicationSecurityWafCustomRuleCreateAttributes(blocking bool, conditions []ApplicationSecurityWafCustomRuleCondition, enabled bool, name string, tags ApplicationSecurityWafCustomRuleTags) *ApplicationSecurityWafCustomRuleCreateAttributes { + this := ApplicationSecurityWafCustomRuleCreateAttributes{} + this.Blocking = blocking + this.Conditions = conditions + this.Enabled = enabled + this.Name = name + this.Tags = tags + return &this +} + +// NewApplicationSecurityWafCustomRuleCreateAttributesWithDefaults instantiates a new ApplicationSecurityWafCustomRuleCreateAttributes object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewApplicationSecurityWafCustomRuleCreateAttributesWithDefaults() *ApplicationSecurityWafCustomRuleCreateAttributes { + this := ApplicationSecurityWafCustomRuleCreateAttributes{} + return &this +} + +// GetAction returns the Action field value if set, zero value otherwise. +func (o *ApplicationSecurityWafCustomRuleCreateAttributes) GetAction() ApplicationSecurityWafCustomRuleAction { + if o == nil || o.Action == nil { + var ret ApplicationSecurityWafCustomRuleAction + return ret + } + return *o.Action +} + +// GetActionOk returns a tuple with the Action field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafCustomRuleCreateAttributes) GetActionOk() (*ApplicationSecurityWafCustomRuleAction, bool) { + if o == nil || o.Action == nil { + return nil, false + } + return o.Action, true +} + +// HasAction returns a boolean if a field has been set. +func (o *ApplicationSecurityWafCustomRuleCreateAttributes) HasAction() bool { + return o != nil && o.Action != nil +} + +// SetAction gets a reference to the given ApplicationSecurityWafCustomRuleAction and assigns it to the Action field. +func (o *ApplicationSecurityWafCustomRuleCreateAttributes) SetAction(v ApplicationSecurityWafCustomRuleAction) { + o.Action = &v +} + +// GetBlocking returns the Blocking field value. +func (o *ApplicationSecurityWafCustomRuleCreateAttributes) GetBlocking() bool { + if o == nil { + var ret bool + return ret + } + return o.Blocking +} + +// GetBlockingOk returns a tuple with the Blocking field value +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafCustomRuleCreateAttributes) GetBlockingOk() (*bool, bool) { + if o == nil { + return nil, false + } + return &o.Blocking, true +} + +// SetBlocking sets field value. +func (o *ApplicationSecurityWafCustomRuleCreateAttributes) SetBlocking(v bool) { + o.Blocking = v +} + +// GetConditions returns the Conditions field value. +func (o *ApplicationSecurityWafCustomRuleCreateAttributes) GetConditions() []ApplicationSecurityWafCustomRuleCondition { + if o == nil { + var ret []ApplicationSecurityWafCustomRuleCondition + return ret + } + return o.Conditions +} + +// GetConditionsOk returns a tuple with the Conditions field value +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafCustomRuleCreateAttributes) GetConditionsOk() (*[]ApplicationSecurityWafCustomRuleCondition, bool) { + if o == nil { + return nil, false + } + return &o.Conditions, true +} + +// SetConditions sets field value. +func (o *ApplicationSecurityWafCustomRuleCreateAttributes) SetConditions(v []ApplicationSecurityWafCustomRuleCondition) { + o.Conditions = v +} + +// GetEnabled returns the Enabled field value. +func (o *ApplicationSecurityWafCustomRuleCreateAttributes) GetEnabled() bool { + if o == nil { + var ret bool + return ret + } + return o.Enabled +} + +// GetEnabledOk returns a tuple with the Enabled field value +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafCustomRuleCreateAttributes) GetEnabledOk() (*bool, bool) { + if o == nil { + return nil, false + } + return &o.Enabled, true +} + +// SetEnabled sets field value. +func (o *ApplicationSecurityWafCustomRuleCreateAttributes) SetEnabled(v bool) { + o.Enabled = v +} + +// GetName returns the Name field value. +func (o *ApplicationSecurityWafCustomRuleCreateAttributes) GetName() string { + if o == nil { + var ret string + return ret + } + return o.Name +} + +// GetNameOk returns a tuple with the Name field value +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafCustomRuleCreateAttributes) GetNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Name, true +} + +// SetName sets field value. +func (o *ApplicationSecurityWafCustomRuleCreateAttributes) SetName(v string) { + o.Name = v +} + +// GetPathGlob returns the PathGlob field value if set, zero value otherwise. +func (o *ApplicationSecurityWafCustomRuleCreateAttributes) GetPathGlob() string { + if o == nil || o.PathGlob == nil { + var ret string + return ret + } + return *o.PathGlob +} + +// GetPathGlobOk returns a tuple with the PathGlob field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafCustomRuleCreateAttributes) GetPathGlobOk() (*string, bool) { + if o == nil || o.PathGlob == nil { + return nil, false + } + return o.PathGlob, true +} + +// HasPathGlob returns a boolean if a field has been set. +func (o *ApplicationSecurityWafCustomRuleCreateAttributes) HasPathGlob() bool { + return o != nil && o.PathGlob != nil +} + +// SetPathGlob gets a reference to the given string and assigns it to the PathGlob field. +func (o *ApplicationSecurityWafCustomRuleCreateAttributes) SetPathGlob(v string) { + o.PathGlob = &v +} + +// GetScope returns the Scope field value if set, zero value otherwise. +func (o *ApplicationSecurityWafCustomRuleCreateAttributes) GetScope() []ApplicationSecurityWafCustomRuleScope { + if o == nil || o.Scope == nil { + var ret []ApplicationSecurityWafCustomRuleScope + return ret + } + return o.Scope +} + +// GetScopeOk returns a tuple with the Scope field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafCustomRuleCreateAttributes) GetScopeOk() (*[]ApplicationSecurityWafCustomRuleScope, bool) { + if o == nil || o.Scope == nil { + return nil, false + } + return &o.Scope, true +} + +// HasScope returns a boolean if a field has been set. +func (o *ApplicationSecurityWafCustomRuleCreateAttributes) HasScope() bool { + return o != nil && o.Scope != nil +} + +// SetScope gets a reference to the given []ApplicationSecurityWafCustomRuleScope and assigns it to the Scope field. +func (o *ApplicationSecurityWafCustomRuleCreateAttributes) SetScope(v []ApplicationSecurityWafCustomRuleScope) { + o.Scope = v +} + +// GetTags returns the Tags field value. +func (o *ApplicationSecurityWafCustomRuleCreateAttributes) GetTags() ApplicationSecurityWafCustomRuleTags { + if o == nil { + var ret ApplicationSecurityWafCustomRuleTags + return ret + } + return o.Tags +} + +// GetTagsOk returns a tuple with the Tags field value +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafCustomRuleCreateAttributes) GetTagsOk() (*ApplicationSecurityWafCustomRuleTags, bool) { + if o == nil { + return nil, false + } + return &o.Tags, true +} + +// SetTags sets field value. +func (o *ApplicationSecurityWafCustomRuleCreateAttributes) SetTags(v ApplicationSecurityWafCustomRuleTags) { + o.Tags = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ApplicationSecurityWafCustomRuleCreateAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Action != nil { + toSerialize["action"] = o.Action + } + toSerialize["blocking"] = o.Blocking + toSerialize["conditions"] = o.Conditions + toSerialize["enabled"] = o.Enabled + toSerialize["name"] = o.Name + if o.PathGlob != nil { + toSerialize["path_glob"] = o.PathGlob + } + if o.Scope != nil { + toSerialize["scope"] = o.Scope + } + toSerialize["tags"] = o.Tags + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *ApplicationSecurityWafCustomRuleCreateAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Action *ApplicationSecurityWafCustomRuleAction `json:"action,omitempty"` + Blocking *bool `json:"blocking"` + Conditions *[]ApplicationSecurityWafCustomRuleCondition `json:"conditions"` + Enabled *bool `json:"enabled"` + Name *string `json:"name"` + PathGlob *string `json:"path_glob,omitempty"` + Scope []ApplicationSecurityWafCustomRuleScope `json:"scope,omitempty"` + Tags *ApplicationSecurityWafCustomRuleTags `json:"tags"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Blocking == nil { + return fmt.Errorf("required field blocking missing") + } + if all.Conditions == nil { + return fmt.Errorf("required field conditions missing") + } + if all.Enabled == nil { + return fmt.Errorf("required field enabled missing") + } + if all.Name == nil { + return fmt.Errorf("required field name missing") + } + if all.Tags == nil { + return fmt.Errorf("required field tags missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"action", "blocking", "conditions", "enabled", "name", "path_glob", "scope", "tags"}) + } else { + return err + } + + hasInvalidField := false + if all.Action != nil && all.Action.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Action = all.Action + o.Blocking = *all.Blocking + o.Conditions = *all.Conditions + o.Enabled = *all.Enabled + o.Name = *all.Name + o.PathGlob = all.PathGlob + o.Scope = all.Scope + if all.Tags.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Tags = *all.Tags + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_application_security_waf_custom_rule_create_data.go b/api/datadogV2/model_application_security_waf_custom_rule_create_data.go new file mode 100644 index 00000000000..821a780e54e --- /dev/null +++ b/api/datadogV2/model_application_security_waf_custom_rule_create_data.go @@ -0,0 +1,148 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// ApplicationSecurityWafCustomRuleCreateData Object for a single WAF custom rule. +type ApplicationSecurityWafCustomRuleCreateData struct { + // Create a new WAF custom rule. + Attributes ApplicationSecurityWafCustomRuleCreateAttributes `json:"attributes"` + // The type of the resource. The value should always be `custom_rule`. + Type ApplicationSecurityWafCustomRuleType `json:"type"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewApplicationSecurityWafCustomRuleCreateData instantiates a new ApplicationSecurityWafCustomRuleCreateData object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewApplicationSecurityWafCustomRuleCreateData(attributes ApplicationSecurityWafCustomRuleCreateAttributes, typeVar ApplicationSecurityWafCustomRuleType) *ApplicationSecurityWafCustomRuleCreateData { + this := ApplicationSecurityWafCustomRuleCreateData{} + this.Attributes = attributes + this.Type = typeVar + return &this +} + +// NewApplicationSecurityWafCustomRuleCreateDataWithDefaults instantiates a new ApplicationSecurityWafCustomRuleCreateData object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewApplicationSecurityWafCustomRuleCreateDataWithDefaults() *ApplicationSecurityWafCustomRuleCreateData { + this := ApplicationSecurityWafCustomRuleCreateData{} + var typeVar ApplicationSecurityWafCustomRuleType = APPLICATIONSECURITYWAFCUSTOMRULETYPE_CUSTOM_RULE + this.Type = typeVar + return &this +} + +// GetAttributes returns the Attributes field value. +func (o *ApplicationSecurityWafCustomRuleCreateData) GetAttributes() ApplicationSecurityWafCustomRuleCreateAttributes { + if o == nil { + var ret ApplicationSecurityWafCustomRuleCreateAttributes + return ret + } + return o.Attributes +} + +// GetAttributesOk returns a tuple with the Attributes field value +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafCustomRuleCreateData) GetAttributesOk() (*ApplicationSecurityWafCustomRuleCreateAttributes, bool) { + if o == nil { + return nil, false + } + return &o.Attributes, true +} + +// SetAttributes sets field value. +func (o *ApplicationSecurityWafCustomRuleCreateData) SetAttributes(v ApplicationSecurityWafCustomRuleCreateAttributes) { + o.Attributes = v +} + +// GetType returns the Type field value. +func (o *ApplicationSecurityWafCustomRuleCreateData) GetType() ApplicationSecurityWafCustomRuleType { + if o == nil { + var ret ApplicationSecurityWafCustomRuleType + return ret + } + return o.Type +} + +// GetTypeOk returns a tuple with the Type field value +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafCustomRuleCreateData) GetTypeOk() (*ApplicationSecurityWafCustomRuleType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *ApplicationSecurityWafCustomRuleCreateData) SetType(v ApplicationSecurityWafCustomRuleType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ApplicationSecurityWafCustomRuleCreateData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["attributes"] = o.Attributes + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *ApplicationSecurityWafCustomRuleCreateData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *ApplicationSecurityWafCustomRuleCreateAttributes `json:"attributes"` + Type *ApplicationSecurityWafCustomRuleType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Attributes == nil { + return fmt.Errorf("required field attributes missing") + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "type"}) + } else { + return err + } + + hasInvalidField := false + if all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Attributes = *all.Attributes + if !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = *all.Type + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_application_security_waf_custom_rule_create_request.go b/api/datadogV2/model_application_security_waf_custom_rule_create_request.go new file mode 100644 index 00000000000..37a4eb248a0 --- /dev/null +++ b/api/datadogV2/model_application_security_waf_custom_rule_create_request.go @@ -0,0 +1,110 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// ApplicationSecurityWafCustomRuleCreateRequest Request object that includes the custom rule to create. +type ApplicationSecurityWafCustomRuleCreateRequest struct { + // Object for a single WAF custom rule. + Data ApplicationSecurityWafCustomRuleCreateData `json:"data"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewApplicationSecurityWafCustomRuleCreateRequest instantiates a new ApplicationSecurityWafCustomRuleCreateRequest object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewApplicationSecurityWafCustomRuleCreateRequest(data ApplicationSecurityWafCustomRuleCreateData) *ApplicationSecurityWafCustomRuleCreateRequest { + this := ApplicationSecurityWafCustomRuleCreateRequest{} + this.Data = data + return &this +} + +// NewApplicationSecurityWafCustomRuleCreateRequestWithDefaults instantiates a new ApplicationSecurityWafCustomRuleCreateRequest object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewApplicationSecurityWafCustomRuleCreateRequestWithDefaults() *ApplicationSecurityWafCustomRuleCreateRequest { + this := ApplicationSecurityWafCustomRuleCreateRequest{} + return &this +} + +// GetData returns the Data field value. +func (o *ApplicationSecurityWafCustomRuleCreateRequest) GetData() ApplicationSecurityWafCustomRuleCreateData { + if o == nil { + var ret ApplicationSecurityWafCustomRuleCreateData + return ret + } + return o.Data +} + +// GetDataOk returns a tuple with the Data field value +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafCustomRuleCreateRequest) GetDataOk() (*ApplicationSecurityWafCustomRuleCreateData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *ApplicationSecurityWafCustomRuleCreateRequest) SetData(v ApplicationSecurityWafCustomRuleCreateData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ApplicationSecurityWafCustomRuleCreateRequest) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["data"] = o.Data + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *ApplicationSecurityWafCustomRuleCreateRequest) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *ApplicationSecurityWafCustomRuleCreateData `json:"data"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Data == nil { + return fmt.Errorf("required field data missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + + hasInvalidField := false + if all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Data = *all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_application_security_waf_custom_rule_data.go b/api/datadogV2/model_application_security_waf_custom_rule_data.go new file mode 100644 index 00000000000..6dbfb55757c --- /dev/null +++ b/api/datadogV2/model_application_security_waf_custom_rule_data.go @@ -0,0 +1,189 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// ApplicationSecurityWafCustomRuleData Object for a single WAF custom rule. +type ApplicationSecurityWafCustomRuleData struct { + // A WAF custom rule. + Attributes *ApplicationSecurityWafCustomRuleAttributes `json:"attributes,omitempty"` + // The ID of the custom rule. + Id *string `json:"id,omitempty"` + // The type of the resource. The value should always be `custom_rule`. + Type *ApplicationSecurityWafCustomRuleType `json:"type,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewApplicationSecurityWafCustomRuleData instantiates a new ApplicationSecurityWafCustomRuleData object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewApplicationSecurityWafCustomRuleData() *ApplicationSecurityWafCustomRuleData { + this := ApplicationSecurityWafCustomRuleData{} + var typeVar ApplicationSecurityWafCustomRuleType = APPLICATIONSECURITYWAFCUSTOMRULETYPE_CUSTOM_RULE + this.Type = &typeVar + return &this +} + +// NewApplicationSecurityWafCustomRuleDataWithDefaults instantiates a new ApplicationSecurityWafCustomRuleData object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewApplicationSecurityWafCustomRuleDataWithDefaults() *ApplicationSecurityWafCustomRuleData { + this := ApplicationSecurityWafCustomRuleData{} + var typeVar ApplicationSecurityWafCustomRuleType = APPLICATIONSECURITYWAFCUSTOMRULETYPE_CUSTOM_RULE + this.Type = &typeVar + return &this +} + +// GetAttributes returns the Attributes field value if set, zero value otherwise. +func (o *ApplicationSecurityWafCustomRuleData) GetAttributes() ApplicationSecurityWafCustomRuleAttributes { + if o == nil || o.Attributes == nil { + var ret ApplicationSecurityWafCustomRuleAttributes + return ret + } + return *o.Attributes +} + +// GetAttributesOk returns a tuple with the Attributes field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafCustomRuleData) GetAttributesOk() (*ApplicationSecurityWafCustomRuleAttributes, bool) { + if o == nil || o.Attributes == nil { + return nil, false + } + return o.Attributes, true +} + +// HasAttributes returns a boolean if a field has been set. +func (o *ApplicationSecurityWafCustomRuleData) HasAttributes() bool { + return o != nil && o.Attributes != nil +} + +// SetAttributes gets a reference to the given ApplicationSecurityWafCustomRuleAttributes and assigns it to the Attributes field. +func (o *ApplicationSecurityWafCustomRuleData) SetAttributes(v ApplicationSecurityWafCustomRuleAttributes) { + o.Attributes = &v +} + +// GetId returns the Id field value if set, zero value otherwise. +func (o *ApplicationSecurityWafCustomRuleData) GetId() string { + if o == nil || o.Id == nil { + var ret string + return ret + } + return *o.Id +} + +// GetIdOk returns a tuple with the Id field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafCustomRuleData) GetIdOk() (*string, bool) { + if o == nil || o.Id == nil { + return nil, false + } + return o.Id, true +} + +// HasId returns a boolean if a field has been set. +func (o *ApplicationSecurityWafCustomRuleData) HasId() bool { + return o != nil && o.Id != nil +} + +// SetId gets a reference to the given string and assigns it to the Id field. +func (o *ApplicationSecurityWafCustomRuleData) SetId(v string) { + o.Id = &v +} + +// GetType returns the Type field value if set, zero value otherwise. +func (o *ApplicationSecurityWafCustomRuleData) GetType() ApplicationSecurityWafCustomRuleType { + if o == nil || o.Type == nil { + var ret ApplicationSecurityWafCustomRuleType + return ret + } + return *o.Type +} + +// GetTypeOk returns a tuple with the Type field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafCustomRuleData) GetTypeOk() (*ApplicationSecurityWafCustomRuleType, bool) { + if o == nil || o.Type == nil { + return nil, false + } + return o.Type, true +} + +// HasType returns a boolean if a field has been set. +func (o *ApplicationSecurityWafCustomRuleData) HasType() bool { + return o != nil && o.Type != nil +} + +// SetType gets a reference to the given ApplicationSecurityWafCustomRuleType and assigns it to the Type field. +func (o *ApplicationSecurityWafCustomRuleData) SetType(v ApplicationSecurityWafCustomRuleType) { + o.Type = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ApplicationSecurityWafCustomRuleData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Attributes != nil { + toSerialize["attributes"] = o.Attributes + } + if o.Id != nil { + toSerialize["id"] = o.Id + } + if o.Type != nil { + toSerialize["type"] = o.Type + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *ApplicationSecurityWafCustomRuleData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *ApplicationSecurityWafCustomRuleAttributes `json:"attributes,omitempty"` + Id *string `json:"id,omitempty"` + Type *ApplicationSecurityWafCustomRuleType `json:"type,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "id", "type"}) + } else { + return err + } + + hasInvalidField := false + if all.Attributes != nil && all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Attributes = all.Attributes + o.Id = all.Id + if all.Type != nil && !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = all.Type + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_application_security_waf_custom_rule_list_response.go b/api/datadogV2/model_application_security_waf_custom_rule_list_response.go new file mode 100644 index 00000000000..3989d065707 --- /dev/null +++ b/api/datadogV2/model_application_security_waf_custom_rule_list_response.go @@ -0,0 +1,102 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// ApplicationSecurityWafCustomRuleListResponse Response object that includes a list of WAF custom rules. +type ApplicationSecurityWafCustomRuleListResponse struct { + // The WAF custom rule data. + Data []ApplicationSecurityWafCustomRuleData `json:"data,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewApplicationSecurityWafCustomRuleListResponse instantiates a new ApplicationSecurityWafCustomRuleListResponse object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewApplicationSecurityWafCustomRuleListResponse() *ApplicationSecurityWafCustomRuleListResponse { + this := ApplicationSecurityWafCustomRuleListResponse{} + return &this +} + +// NewApplicationSecurityWafCustomRuleListResponseWithDefaults instantiates a new ApplicationSecurityWafCustomRuleListResponse object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewApplicationSecurityWafCustomRuleListResponseWithDefaults() *ApplicationSecurityWafCustomRuleListResponse { + this := ApplicationSecurityWafCustomRuleListResponse{} + return &this +} + +// GetData returns the Data field value if set, zero value otherwise. +func (o *ApplicationSecurityWafCustomRuleListResponse) GetData() []ApplicationSecurityWafCustomRuleData { + if o == nil || o.Data == nil { + var ret []ApplicationSecurityWafCustomRuleData + return ret + } + return o.Data +} + +// GetDataOk returns a tuple with the Data field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafCustomRuleListResponse) GetDataOk() (*[]ApplicationSecurityWafCustomRuleData, bool) { + if o == nil || o.Data == nil { + return nil, false + } + return &o.Data, true +} + +// HasData returns a boolean if a field has been set. +func (o *ApplicationSecurityWafCustomRuleListResponse) HasData() bool { + return o != nil && o.Data != nil +} + +// SetData gets a reference to the given []ApplicationSecurityWafCustomRuleData and assigns it to the Data field. +func (o *ApplicationSecurityWafCustomRuleListResponse) SetData(v []ApplicationSecurityWafCustomRuleData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ApplicationSecurityWafCustomRuleListResponse) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Data != nil { + toSerialize["data"] = o.Data + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *ApplicationSecurityWafCustomRuleListResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data []ApplicationSecurityWafCustomRuleData `json:"data,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + o.Data = all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_application_security_waf_custom_rule_metadata.go b/api/datadogV2/model_application_security_waf_custom_rule_metadata.go new file mode 100644 index 00000000000..e13acd88946 --- /dev/null +++ b/api/datadogV2/model_application_security_waf_custom_rule_metadata.go @@ -0,0 +1,287 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "time" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// ApplicationSecurityWafCustomRuleMetadata Metadata associated with the WAF Custom Rule. +type ApplicationSecurityWafCustomRuleMetadata struct { + // The date and time the WAF custom rule was created. + AddedAt *time.Time `json:"added_at,omitempty"` + // The handle of the user who created the WAF custom rule. + AddedBy *string `json:"added_by,omitempty"` + // The name of the user who created the WAF custom rule. + AddedByName *string `json:"added_by_name,omitempty"` + // The date and time the WAF custom rule was last updated. + ModifiedAt *time.Time `json:"modified_at,omitempty"` + // The handle of the user who last updated the WAF custom rule. + ModifiedBy *string `json:"modified_by,omitempty"` + // The name of the user who last updated the WAF custom rule. + ModifiedByName *string `json:"modified_by_name,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewApplicationSecurityWafCustomRuleMetadata instantiates a new ApplicationSecurityWafCustomRuleMetadata object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewApplicationSecurityWafCustomRuleMetadata() *ApplicationSecurityWafCustomRuleMetadata { + this := ApplicationSecurityWafCustomRuleMetadata{} + return &this +} + +// NewApplicationSecurityWafCustomRuleMetadataWithDefaults instantiates a new ApplicationSecurityWafCustomRuleMetadata object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewApplicationSecurityWafCustomRuleMetadataWithDefaults() *ApplicationSecurityWafCustomRuleMetadata { + this := ApplicationSecurityWafCustomRuleMetadata{} + return &this +} + +// GetAddedAt returns the AddedAt field value if set, zero value otherwise. +func (o *ApplicationSecurityWafCustomRuleMetadata) GetAddedAt() time.Time { + if o == nil || o.AddedAt == nil { + var ret time.Time + return ret + } + return *o.AddedAt +} + +// GetAddedAtOk returns a tuple with the AddedAt field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafCustomRuleMetadata) GetAddedAtOk() (*time.Time, bool) { + if o == nil || o.AddedAt == nil { + return nil, false + } + return o.AddedAt, true +} + +// HasAddedAt returns a boolean if a field has been set. +func (o *ApplicationSecurityWafCustomRuleMetadata) HasAddedAt() bool { + return o != nil && o.AddedAt != nil +} + +// SetAddedAt gets a reference to the given time.Time and assigns it to the AddedAt field. +func (o *ApplicationSecurityWafCustomRuleMetadata) SetAddedAt(v time.Time) { + o.AddedAt = &v +} + +// GetAddedBy returns the AddedBy field value if set, zero value otherwise. +func (o *ApplicationSecurityWafCustomRuleMetadata) GetAddedBy() string { + if o == nil || o.AddedBy == nil { + var ret string + return ret + } + return *o.AddedBy +} + +// GetAddedByOk returns a tuple with the AddedBy field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafCustomRuleMetadata) GetAddedByOk() (*string, bool) { + if o == nil || o.AddedBy == nil { + return nil, false + } + return o.AddedBy, true +} + +// HasAddedBy returns a boolean if a field has been set. +func (o *ApplicationSecurityWafCustomRuleMetadata) HasAddedBy() bool { + return o != nil && o.AddedBy != nil +} + +// SetAddedBy gets a reference to the given string and assigns it to the AddedBy field. +func (o *ApplicationSecurityWafCustomRuleMetadata) SetAddedBy(v string) { + o.AddedBy = &v +} + +// GetAddedByName returns the AddedByName field value if set, zero value otherwise. +func (o *ApplicationSecurityWafCustomRuleMetadata) GetAddedByName() string { + if o == nil || o.AddedByName == nil { + var ret string + return ret + } + return *o.AddedByName +} + +// GetAddedByNameOk returns a tuple with the AddedByName field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafCustomRuleMetadata) GetAddedByNameOk() (*string, bool) { + if o == nil || o.AddedByName == nil { + return nil, false + } + return o.AddedByName, true +} + +// HasAddedByName returns a boolean if a field has been set. +func (o *ApplicationSecurityWafCustomRuleMetadata) HasAddedByName() bool { + return o != nil && o.AddedByName != nil +} + +// SetAddedByName gets a reference to the given string and assigns it to the AddedByName field. +func (o *ApplicationSecurityWafCustomRuleMetadata) SetAddedByName(v string) { + o.AddedByName = &v +} + +// GetModifiedAt returns the ModifiedAt field value if set, zero value otherwise. +func (o *ApplicationSecurityWafCustomRuleMetadata) GetModifiedAt() time.Time { + if o == nil || o.ModifiedAt == nil { + var ret time.Time + return ret + } + return *o.ModifiedAt +} + +// GetModifiedAtOk returns a tuple with the ModifiedAt field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafCustomRuleMetadata) GetModifiedAtOk() (*time.Time, bool) { + if o == nil || o.ModifiedAt == nil { + return nil, false + } + return o.ModifiedAt, true +} + +// HasModifiedAt returns a boolean if a field has been set. +func (o *ApplicationSecurityWafCustomRuleMetadata) HasModifiedAt() bool { + return o != nil && o.ModifiedAt != nil +} + +// SetModifiedAt gets a reference to the given time.Time and assigns it to the ModifiedAt field. +func (o *ApplicationSecurityWafCustomRuleMetadata) SetModifiedAt(v time.Time) { + o.ModifiedAt = &v +} + +// GetModifiedBy returns the ModifiedBy field value if set, zero value otherwise. +func (o *ApplicationSecurityWafCustomRuleMetadata) GetModifiedBy() string { + if o == nil || o.ModifiedBy == nil { + var ret string + return ret + } + return *o.ModifiedBy +} + +// GetModifiedByOk returns a tuple with the ModifiedBy field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafCustomRuleMetadata) GetModifiedByOk() (*string, bool) { + if o == nil || o.ModifiedBy == nil { + return nil, false + } + return o.ModifiedBy, true +} + +// HasModifiedBy returns a boolean if a field has been set. +func (o *ApplicationSecurityWafCustomRuleMetadata) HasModifiedBy() bool { + return o != nil && o.ModifiedBy != nil +} + +// SetModifiedBy gets a reference to the given string and assigns it to the ModifiedBy field. +func (o *ApplicationSecurityWafCustomRuleMetadata) SetModifiedBy(v string) { + o.ModifiedBy = &v +} + +// GetModifiedByName returns the ModifiedByName field value if set, zero value otherwise. +func (o *ApplicationSecurityWafCustomRuleMetadata) GetModifiedByName() string { + if o == nil || o.ModifiedByName == nil { + var ret string + return ret + } + return *o.ModifiedByName +} + +// GetModifiedByNameOk returns a tuple with the ModifiedByName field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafCustomRuleMetadata) GetModifiedByNameOk() (*string, bool) { + if o == nil || o.ModifiedByName == nil { + return nil, false + } + return o.ModifiedByName, true +} + +// HasModifiedByName returns a boolean if a field has been set. +func (o *ApplicationSecurityWafCustomRuleMetadata) HasModifiedByName() bool { + return o != nil && o.ModifiedByName != nil +} + +// SetModifiedByName gets a reference to the given string and assigns it to the ModifiedByName field. +func (o *ApplicationSecurityWafCustomRuleMetadata) SetModifiedByName(v string) { + o.ModifiedByName = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ApplicationSecurityWafCustomRuleMetadata) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.AddedAt != nil { + if o.AddedAt.Nanosecond() == 0 { + toSerialize["added_at"] = o.AddedAt.Format("2006-01-02T15:04:05Z07:00") + } else { + toSerialize["added_at"] = o.AddedAt.Format("2006-01-02T15:04:05.000Z07:00") + } + } + if o.AddedBy != nil { + toSerialize["added_by"] = o.AddedBy + } + if o.AddedByName != nil { + toSerialize["added_by_name"] = o.AddedByName + } + if o.ModifiedAt != nil { + if o.ModifiedAt.Nanosecond() == 0 { + toSerialize["modified_at"] = o.ModifiedAt.Format("2006-01-02T15:04:05Z07:00") + } else { + toSerialize["modified_at"] = o.ModifiedAt.Format("2006-01-02T15:04:05.000Z07:00") + } + } + if o.ModifiedBy != nil { + toSerialize["modified_by"] = o.ModifiedBy + } + if o.ModifiedByName != nil { + toSerialize["modified_by_name"] = o.ModifiedByName + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *ApplicationSecurityWafCustomRuleMetadata) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + AddedAt *time.Time `json:"added_at,omitempty"` + AddedBy *string `json:"added_by,omitempty"` + AddedByName *string `json:"added_by_name,omitempty"` + ModifiedAt *time.Time `json:"modified_at,omitempty"` + ModifiedBy *string `json:"modified_by,omitempty"` + ModifiedByName *string `json:"modified_by_name,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"added_at", "added_by", "added_by_name", "modified_at", "modified_by", "modified_by_name"}) + } else { + return err + } + o.AddedAt = all.AddedAt + o.AddedBy = all.AddedBy + o.AddedByName = all.AddedByName + o.ModifiedAt = all.ModifiedAt + o.ModifiedBy = all.ModifiedBy + o.ModifiedByName = all.ModifiedByName + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_application_security_waf_custom_rule_response.go b/api/datadogV2/model_application_security_waf_custom_rule_response.go new file mode 100644 index 00000000000..fbfe4f40d1b --- /dev/null +++ b/api/datadogV2/model_application_security_waf_custom_rule_response.go @@ -0,0 +1,111 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// ApplicationSecurityWafCustomRuleResponse Response object that includes a single WAF custom rule. +type ApplicationSecurityWafCustomRuleResponse struct { + // Object for a single WAF custom rule. + Data *ApplicationSecurityWafCustomRuleData `json:"data,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewApplicationSecurityWafCustomRuleResponse instantiates a new ApplicationSecurityWafCustomRuleResponse object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewApplicationSecurityWafCustomRuleResponse() *ApplicationSecurityWafCustomRuleResponse { + this := ApplicationSecurityWafCustomRuleResponse{} + return &this +} + +// NewApplicationSecurityWafCustomRuleResponseWithDefaults instantiates a new ApplicationSecurityWafCustomRuleResponse object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewApplicationSecurityWafCustomRuleResponseWithDefaults() *ApplicationSecurityWafCustomRuleResponse { + this := ApplicationSecurityWafCustomRuleResponse{} + return &this +} + +// GetData returns the Data field value if set, zero value otherwise. +func (o *ApplicationSecurityWafCustomRuleResponse) GetData() ApplicationSecurityWafCustomRuleData { + if o == nil || o.Data == nil { + var ret ApplicationSecurityWafCustomRuleData + return ret + } + return *o.Data +} + +// GetDataOk returns a tuple with the Data field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafCustomRuleResponse) GetDataOk() (*ApplicationSecurityWafCustomRuleData, bool) { + if o == nil || o.Data == nil { + return nil, false + } + return o.Data, true +} + +// HasData returns a boolean if a field has been set. +func (o *ApplicationSecurityWafCustomRuleResponse) HasData() bool { + return o != nil && o.Data != nil +} + +// SetData gets a reference to the given ApplicationSecurityWafCustomRuleData and assigns it to the Data field. +func (o *ApplicationSecurityWafCustomRuleResponse) SetData(v ApplicationSecurityWafCustomRuleData) { + o.Data = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ApplicationSecurityWafCustomRuleResponse) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Data != nil { + toSerialize["data"] = o.Data + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *ApplicationSecurityWafCustomRuleResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *ApplicationSecurityWafCustomRuleData `json:"data,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + + hasInvalidField := false + if all.Data != nil && all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Data = all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_application_security_waf_custom_rule_scope.go b/api/datadogV2/model_application_security_waf_custom_rule_scope.go new file mode 100644 index 00000000000..8abd08f939c --- /dev/null +++ b/api/datadogV2/model_application_security_waf_custom_rule_scope.go @@ -0,0 +1,133 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// ApplicationSecurityWafCustomRuleScope The scope of the WAF custom rule. +type ApplicationSecurityWafCustomRuleScope struct { + // The environment scope for the WAF custom rule. + Env string `json:"env"` + // The service scope for the WAF custom rule. + Service string `json:"service"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewApplicationSecurityWafCustomRuleScope instantiates a new ApplicationSecurityWafCustomRuleScope object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewApplicationSecurityWafCustomRuleScope(env string, service string) *ApplicationSecurityWafCustomRuleScope { + this := ApplicationSecurityWafCustomRuleScope{} + this.Env = env + this.Service = service + return &this +} + +// NewApplicationSecurityWafCustomRuleScopeWithDefaults instantiates a new ApplicationSecurityWafCustomRuleScope object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewApplicationSecurityWafCustomRuleScopeWithDefaults() *ApplicationSecurityWafCustomRuleScope { + this := ApplicationSecurityWafCustomRuleScope{} + return &this +} + +// GetEnv returns the Env field value. +func (o *ApplicationSecurityWafCustomRuleScope) GetEnv() string { + if o == nil { + var ret string + return ret + } + return o.Env +} + +// GetEnvOk returns a tuple with the Env field value +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafCustomRuleScope) GetEnvOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Env, true +} + +// SetEnv sets field value. +func (o *ApplicationSecurityWafCustomRuleScope) SetEnv(v string) { + o.Env = v +} + +// GetService returns the Service field value. +func (o *ApplicationSecurityWafCustomRuleScope) GetService() string { + if o == nil { + var ret string + return ret + } + return o.Service +} + +// GetServiceOk returns a tuple with the Service field value +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafCustomRuleScope) GetServiceOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Service, true +} + +// SetService sets field value. +func (o *ApplicationSecurityWafCustomRuleScope) SetService(v string) { + o.Service = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ApplicationSecurityWafCustomRuleScope) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["env"] = o.Env + toSerialize["service"] = o.Service + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *ApplicationSecurityWafCustomRuleScope) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Env *string `json:"env"` + Service *string `json:"service"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Env == nil { + return fmt.Errorf("required field env missing") + } + if all.Service == nil { + return fmt.Errorf("required field service missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"env", "service"}) + } else { + return err + } + o.Env = *all.Env + o.Service = *all.Service + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_application_security_waf_custom_rule_tags.go b/api/datadogV2/model_application_security_waf_custom_rule_tags.go new file mode 100644 index 00000000000..54a2c11b5b9 --- /dev/null +++ b/api/datadogV2/model_application_security_waf_custom_rule_tags.go @@ -0,0 +1,144 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// ApplicationSecurityWafCustomRuleTags Tags associated with the WAF Custom Rule. The concatenation of category and type will form the security +// activity field associated with the traces. +type ApplicationSecurityWafCustomRuleTags struct { + // The category of the WAF Rule, can be either `business_logic`, `attack_attempt` or `security_response`. + Category ApplicationSecurityWafCustomRuleTagsCategory `json:"category"` + // The type of the WAF rule, associated with the category will form the security activity. + Type string `json:"type"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]string `json:"-"` +} + +// NewApplicationSecurityWafCustomRuleTags instantiates a new ApplicationSecurityWafCustomRuleTags object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewApplicationSecurityWafCustomRuleTags(category ApplicationSecurityWafCustomRuleTagsCategory, typeVar string) *ApplicationSecurityWafCustomRuleTags { + this := ApplicationSecurityWafCustomRuleTags{} + this.Category = category + this.Type = typeVar + return &this +} + +// NewApplicationSecurityWafCustomRuleTagsWithDefaults instantiates a new ApplicationSecurityWafCustomRuleTags object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewApplicationSecurityWafCustomRuleTagsWithDefaults() *ApplicationSecurityWafCustomRuleTags { + this := ApplicationSecurityWafCustomRuleTags{} + return &this +} + +// GetCategory returns the Category field value. +func (o *ApplicationSecurityWafCustomRuleTags) GetCategory() ApplicationSecurityWafCustomRuleTagsCategory { + if o == nil { + var ret ApplicationSecurityWafCustomRuleTagsCategory + return ret + } + return o.Category +} + +// GetCategoryOk returns a tuple with the Category field value +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafCustomRuleTags) GetCategoryOk() (*ApplicationSecurityWafCustomRuleTagsCategory, bool) { + if o == nil { + return nil, false + } + return &o.Category, true +} + +// SetCategory sets field value. +func (o *ApplicationSecurityWafCustomRuleTags) SetCategory(v ApplicationSecurityWafCustomRuleTagsCategory) { + o.Category = v +} + +// GetType returns the Type field value. +func (o *ApplicationSecurityWafCustomRuleTags) GetType() string { + if o == nil { + var ret string + return ret + } + return o.Type +} + +// GetTypeOk returns a tuple with the Type field value +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafCustomRuleTags) GetTypeOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *ApplicationSecurityWafCustomRuleTags) SetType(v string) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ApplicationSecurityWafCustomRuleTags) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["category"] = o.Category + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *ApplicationSecurityWafCustomRuleTags) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Category *ApplicationSecurityWafCustomRuleTagsCategory `json:"category"` + Type *string `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Category == nil { + return fmt.Errorf("required field category missing") + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + additionalProperties := make(map[string]string) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"category", "type"}) + } else { + return err + } + + hasInvalidField := false + if !all.Category.IsValid() { + hasInvalidField = true + } else { + o.Category = *all.Category + } + o.Type = *all.Type + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_application_security_waf_custom_rule_tags_category.go b/api/datadogV2/model_application_security_waf_custom_rule_tags_category.go new file mode 100644 index 00000000000..86cc021ce87 --- /dev/null +++ b/api/datadogV2/model_application_security_waf_custom_rule_tags_category.go @@ -0,0 +1,68 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// ApplicationSecurityWafCustomRuleTagsCategory The category of the WAF Rule, can be either `business_logic`, `attack_attempt` or `security_response`. +type ApplicationSecurityWafCustomRuleTagsCategory string + +// List of ApplicationSecurityWafCustomRuleTagsCategory. +const ( + APPLICATIONSECURITYWAFCUSTOMRULETAGSCATEGORY_ATTACK_ATTEMPT ApplicationSecurityWafCustomRuleTagsCategory = "attack_attempt" + APPLICATIONSECURITYWAFCUSTOMRULETAGSCATEGORY_BUSINESS_LOGIC ApplicationSecurityWafCustomRuleTagsCategory = "business_logic" + APPLICATIONSECURITYWAFCUSTOMRULETAGSCATEGORY_SECURITY_RESPONSES ApplicationSecurityWafCustomRuleTagsCategory = "security_responses" +) + +var allowedApplicationSecurityWafCustomRuleTagsCategoryEnumValues = []ApplicationSecurityWafCustomRuleTagsCategory{ + APPLICATIONSECURITYWAFCUSTOMRULETAGSCATEGORY_ATTACK_ATTEMPT, + APPLICATIONSECURITYWAFCUSTOMRULETAGSCATEGORY_BUSINESS_LOGIC, + APPLICATIONSECURITYWAFCUSTOMRULETAGSCATEGORY_SECURITY_RESPONSES, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *ApplicationSecurityWafCustomRuleTagsCategory) GetAllowedValues() []ApplicationSecurityWafCustomRuleTagsCategory { + return allowedApplicationSecurityWafCustomRuleTagsCategoryEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *ApplicationSecurityWafCustomRuleTagsCategory) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = ApplicationSecurityWafCustomRuleTagsCategory(value) + return nil +} + +// NewApplicationSecurityWafCustomRuleTagsCategoryFromValue returns a pointer to a valid ApplicationSecurityWafCustomRuleTagsCategory +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewApplicationSecurityWafCustomRuleTagsCategoryFromValue(v string) (*ApplicationSecurityWafCustomRuleTagsCategory, error) { + ev := ApplicationSecurityWafCustomRuleTagsCategory(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for ApplicationSecurityWafCustomRuleTagsCategory: valid values are %v", v, allowedApplicationSecurityWafCustomRuleTagsCategoryEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v ApplicationSecurityWafCustomRuleTagsCategory) IsValid() bool { + for _, existing := range allowedApplicationSecurityWafCustomRuleTagsCategoryEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to ApplicationSecurityWafCustomRuleTagsCategory value. +func (v ApplicationSecurityWafCustomRuleTagsCategory) Ptr() *ApplicationSecurityWafCustomRuleTagsCategory { + return &v +} diff --git a/api/datadogV2/model_application_security_waf_custom_rule_type.go b/api/datadogV2/model_application_security_waf_custom_rule_type.go new file mode 100644 index 00000000000..d261dc9b955 --- /dev/null +++ b/api/datadogV2/model_application_security_waf_custom_rule_type.go @@ -0,0 +1,64 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// ApplicationSecurityWafCustomRuleType The type of the resource. The value should always be `custom_rule`. +type ApplicationSecurityWafCustomRuleType string + +// List of ApplicationSecurityWafCustomRuleType. +const ( + APPLICATIONSECURITYWAFCUSTOMRULETYPE_CUSTOM_RULE ApplicationSecurityWafCustomRuleType = "custom_rule" +) + +var allowedApplicationSecurityWafCustomRuleTypeEnumValues = []ApplicationSecurityWafCustomRuleType{ + APPLICATIONSECURITYWAFCUSTOMRULETYPE_CUSTOM_RULE, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *ApplicationSecurityWafCustomRuleType) GetAllowedValues() []ApplicationSecurityWafCustomRuleType { + return allowedApplicationSecurityWafCustomRuleTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *ApplicationSecurityWafCustomRuleType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = ApplicationSecurityWafCustomRuleType(value) + return nil +} + +// NewApplicationSecurityWafCustomRuleTypeFromValue returns a pointer to a valid ApplicationSecurityWafCustomRuleType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewApplicationSecurityWafCustomRuleTypeFromValue(v string) (*ApplicationSecurityWafCustomRuleType, error) { + ev := ApplicationSecurityWafCustomRuleType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for ApplicationSecurityWafCustomRuleType: valid values are %v", v, allowedApplicationSecurityWafCustomRuleTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v ApplicationSecurityWafCustomRuleType) IsValid() bool { + for _, existing := range allowedApplicationSecurityWafCustomRuleTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to ApplicationSecurityWafCustomRuleType value. +func (v ApplicationSecurityWafCustomRuleType) Ptr() *ApplicationSecurityWafCustomRuleType { + return &v +} diff --git a/api/datadogV2/model_application_security_waf_custom_rule_update_attributes.go b/api/datadogV2/model_application_security_waf_custom_rule_update_attributes.go new file mode 100644 index 00000000000..d5fc940ce13 --- /dev/null +++ b/api/datadogV2/model_application_security_waf_custom_rule_update_attributes.go @@ -0,0 +1,348 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// ApplicationSecurityWafCustomRuleUpdateAttributes Update a WAF custom rule. +type ApplicationSecurityWafCustomRuleUpdateAttributes struct { + // The definition of `ApplicationSecurityWafCustomRuleAction` object. + Action *ApplicationSecurityWafCustomRuleAction `json:"action,omitempty"` + // Indicates whether the WAF custom rule will block the request. + Blocking bool `json:"blocking"` + // Conditions for which the WAF Custom Rule will triggers, all conditions needs to match in order for the WAF + // rule to trigger. + Conditions []ApplicationSecurityWafCustomRuleCondition `json:"conditions"` + // Indicates whether the WAF custom rule is enabled. + Enabled bool `json:"enabled"` + // The Name of the WAF custom rule. + Name string `json:"name"` + // The path glob for the WAF custom rule. + PathGlob *string `json:"path_glob,omitempty"` + // The scope of the WAF custom rule. + Scope []ApplicationSecurityWafCustomRuleScope `json:"scope,omitempty"` + // Tags associated with the WAF Custom Rule. The concatenation of category and type will form the security + // activity field associated with the traces. + Tags ApplicationSecurityWafCustomRuleTags `json:"tags"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewApplicationSecurityWafCustomRuleUpdateAttributes instantiates a new ApplicationSecurityWafCustomRuleUpdateAttributes object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewApplicationSecurityWafCustomRuleUpdateAttributes(blocking bool, conditions []ApplicationSecurityWafCustomRuleCondition, enabled bool, name string, tags ApplicationSecurityWafCustomRuleTags) *ApplicationSecurityWafCustomRuleUpdateAttributes { + this := ApplicationSecurityWafCustomRuleUpdateAttributes{} + this.Blocking = blocking + this.Conditions = conditions + this.Enabled = enabled + this.Name = name + this.Tags = tags + return &this +} + +// NewApplicationSecurityWafCustomRuleUpdateAttributesWithDefaults instantiates a new ApplicationSecurityWafCustomRuleUpdateAttributes object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewApplicationSecurityWafCustomRuleUpdateAttributesWithDefaults() *ApplicationSecurityWafCustomRuleUpdateAttributes { + this := ApplicationSecurityWafCustomRuleUpdateAttributes{} + return &this +} + +// GetAction returns the Action field value if set, zero value otherwise. +func (o *ApplicationSecurityWafCustomRuleUpdateAttributes) GetAction() ApplicationSecurityWafCustomRuleAction { + if o == nil || o.Action == nil { + var ret ApplicationSecurityWafCustomRuleAction + return ret + } + return *o.Action +} + +// GetActionOk returns a tuple with the Action field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafCustomRuleUpdateAttributes) GetActionOk() (*ApplicationSecurityWafCustomRuleAction, bool) { + if o == nil || o.Action == nil { + return nil, false + } + return o.Action, true +} + +// HasAction returns a boolean if a field has been set. +func (o *ApplicationSecurityWafCustomRuleUpdateAttributes) HasAction() bool { + return o != nil && o.Action != nil +} + +// SetAction gets a reference to the given ApplicationSecurityWafCustomRuleAction and assigns it to the Action field. +func (o *ApplicationSecurityWafCustomRuleUpdateAttributes) SetAction(v ApplicationSecurityWafCustomRuleAction) { + o.Action = &v +} + +// GetBlocking returns the Blocking field value. +func (o *ApplicationSecurityWafCustomRuleUpdateAttributes) GetBlocking() bool { + if o == nil { + var ret bool + return ret + } + return o.Blocking +} + +// GetBlockingOk returns a tuple with the Blocking field value +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafCustomRuleUpdateAttributes) GetBlockingOk() (*bool, bool) { + if o == nil { + return nil, false + } + return &o.Blocking, true +} + +// SetBlocking sets field value. +func (o *ApplicationSecurityWafCustomRuleUpdateAttributes) SetBlocking(v bool) { + o.Blocking = v +} + +// GetConditions returns the Conditions field value. +func (o *ApplicationSecurityWafCustomRuleUpdateAttributes) GetConditions() []ApplicationSecurityWafCustomRuleCondition { + if o == nil { + var ret []ApplicationSecurityWafCustomRuleCondition + return ret + } + return o.Conditions +} + +// GetConditionsOk returns a tuple with the Conditions field value +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafCustomRuleUpdateAttributes) GetConditionsOk() (*[]ApplicationSecurityWafCustomRuleCondition, bool) { + if o == nil { + return nil, false + } + return &o.Conditions, true +} + +// SetConditions sets field value. +func (o *ApplicationSecurityWafCustomRuleUpdateAttributes) SetConditions(v []ApplicationSecurityWafCustomRuleCondition) { + o.Conditions = v +} + +// GetEnabled returns the Enabled field value. +func (o *ApplicationSecurityWafCustomRuleUpdateAttributes) GetEnabled() bool { + if o == nil { + var ret bool + return ret + } + return o.Enabled +} + +// GetEnabledOk returns a tuple with the Enabled field value +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafCustomRuleUpdateAttributes) GetEnabledOk() (*bool, bool) { + if o == nil { + return nil, false + } + return &o.Enabled, true +} + +// SetEnabled sets field value. +func (o *ApplicationSecurityWafCustomRuleUpdateAttributes) SetEnabled(v bool) { + o.Enabled = v +} + +// GetName returns the Name field value. +func (o *ApplicationSecurityWafCustomRuleUpdateAttributes) GetName() string { + if o == nil { + var ret string + return ret + } + return o.Name +} + +// GetNameOk returns a tuple with the Name field value +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafCustomRuleUpdateAttributes) GetNameOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Name, true +} + +// SetName sets field value. +func (o *ApplicationSecurityWafCustomRuleUpdateAttributes) SetName(v string) { + o.Name = v +} + +// GetPathGlob returns the PathGlob field value if set, zero value otherwise. +func (o *ApplicationSecurityWafCustomRuleUpdateAttributes) GetPathGlob() string { + if o == nil || o.PathGlob == nil { + var ret string + return ret + } + return *o.PathGlob +} + +// GetPathGlobOk returns a tuple with the PathGlob field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafCustomRuleUpdateAttributes) GetPathGlobOk() (*string, bool) { + if o == nil || o.PathGlob == nil { + return nil, false + } + return o.PathGlob, true +} + +// HasPathGlob returns a boolean if a field has been set. +func (o *ApplicationSecurityWafCustomRuleUpdateAttributes) HasPathGlob() bool { + return o != nil && o.PathGlob != nil +} + +// SetPathGlob gets a reference to the given string and assigns it to the PathGlob field. +func (o *ApplicationSecurityWafCustomRuleUpdateAttributes) SetPathGlob(v string) { + o.PathGlob = &v +} + +// GetScope returns the Scope field value if set, zero value otherwise. +func (o *ApplicationSecurityWafCustomRuleUpdateAttributes) GetScope() []ApplicationSecurityWafCustomRuleScope { + if o == nil || o.Scope == nil { + var ret []ApplicationSecurityWafCustomRuleScope + return ret + } + return o.Scope +} + +// GetScopeOk returns a tuple with the Scope field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafCustomRuleUpdateAttributes) GetScopeOk() (*[]ApplicationSecurityWafCustomRuleScope, bool) { + if o == nil || o.Scope == nil { + return nil, false + } + return &o.Scope, true +} + +// HasScope returns a boolean if a field has been set. +func (o *ApplicationSecurityWafCustomRuleUpdateAttributes) HasScope() bool { + return o != nil && o.Scope != nil +} + +// SetScope gets a reference to the given []ApplicationSecurityWafCustomRuleScope and assigns it to the Scope field. +func (o *ApplicationSecurityWafCustomRuleUpdateAttributes) SetScope(v []ApplicationSecurityWafCustomRuleScope) { + o.Scope = v +} + +// GetTags returns the Tags field value. +func (o *ApplicationSecurityWafCustomRuleUpdateAttributes) GetTags() ApplicationSecurityWafCustomRuleTags { + if o == nil { + var ret ApplicationSecurityWafCustomRuleTags + return ret + } + return o.Tags +} + +// GetTagsOk returns a tuple with the Tags field value +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafCustomRuleUpdateAttributes) GetTagsOk() (*ApplicationSecurityWafCustomRuleTags, bool) { + if o == nil { + return nil, false + } + return &o.Tags, true +} + +// SetTags sets field value. +func (o *ApplicationSecurityWafCustomRuleUpdateAttributes) SetTags(v ApplicationSecurityWafCustomRuleTags) { + o.Tags = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ApplicationSecurityWafCustomRuleUpdateAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Action != nil { + toSerialize["action"] = o.Action + } + toSerialize["blocking"] = o.Blocking + toSerialize["conditions"] = o.Conditions + toSerialize["enabled"] = o.Enabled + toSerialize["name"] = o.Name + if o.PathGlob != nil { + toSerialize["path_glob"] = o.PathGlob + } + if o.Scope != nil { + toSerialize["scope"] = o.Scope + } + toSerialize["tags"] = o.Tags + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *ApplicationSecurityWafCustomRuleUpdateAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Action *ApplicationSecurityWafCustomRuleAction `json:"action,omitempty"` + Blocking *bool `json:"blocking"` + Conditions *[]ApplicationSecurityWafCustomRuleCondition `json:"conditions"` + Enabled *bool `json:"enabled"` + Name *string `json:"name"` + PathGlob *string `json:"path_glob,omitempty"` + Scope []ApplicationSecurityWafCustomRuleScope `json:"scope,omitempty"` + Tags *ApplicationSecurityWafCustomRuleTags `json:"tags"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Blocking == nil { + return fmt.Errorf("required field blocking missing") + } + if all.Conditions == nil { + return fmt.Errorf("required field conditions missing") + } + if all.Enabled == nil { + return fmt.Errorf("required field enabled missing") + } + if all.Name == nil { + return fmt.Errorf("required field name missing") + } + if all.Tags == nil { + return fmt.Errorf("required field tags missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"action", "blocking", "conditions", "enabled", "name", "path_glob", "scope", "tags"}) + } else { + return err + } + + hasInvalidField := false + if all.Action != nil && all.Action.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Action = all.Action + o.Blocking = *all.Blocking + o.Conditions = *all.Conditions + o.Enabled = *all.Enabled + o.Name = *all.Name + o.PathGlob = all.PathGlob + o.Scope = all.Scope + if all.Tags.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Tags = *all.Tags + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_application_security_waf_custom_rule_update_data.go b/api/datadogV2/model_application_security_waf_custom_rule_update_data.go new file mode 100644 index 00000000000..606fee4fd18 --- /dev/null +++ b/api/datadogV2/model_application_security_waf_custom_rule_update_data.go @@ -0,0 +1,148 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// ApplicationSecurityWafCustomRuleUpdateData Object for a single WAF Custom Rule. +type ApplicationSecurityWafCustomRuleUpdateData struct { + // Update a WAF custom rule. + Attributes ApplicationSecurityWafCustomRuleUpdateAttributes `json:"attributes"` + // The type of the resource. The value should always be `custom_rule`. + Type ApplicationSecurityWafCustomRuleType `json:"type"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewApplicationSecurityWafCustomRuleUpdateData instantiates a new ApplicationSecurityWafCustomRuleUpdateData object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewApplicationSecurityWafCustomRuleUpdateData(attributes ApplicationSecurityWafCustomRuleUpdateAttributes, typeVar ApplicationSecurityWafCustomRuleType) *ApplicationSecurityWafCustomRuleUpdateData { + this := ApplicationSecurityWafCustomRuleUpdateData{} + this.Attributes = attributes + this.Type = typeVar + return &this +} + +// NewApplicationSecurityWafCustomRuleUpdateDataWithDefaults instantiates a new ApplicationSecurityWafCustomRuleUpdateData object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewApplicationSecurityWafCustomRuleUpdateDataWithDefaults() *ApplicationSecurityWafCustomRuleUpdateData { + this := ApplicationSecurityWafCustomRuleUpdateData{} + var typeVar ApplicationSecurityWafCustomRuleType = APPLICATIONSECURITYWAFCUSTOMRULETYPE_CUSTOM_RULE + this.Type = typeVar + return &this +} + +// GetAttributes returns the Attributes field value. +func (o *ApplicationSecurityWafCustomRuleUpdateData) GetAttributes() ApplicationSecurityWafCustomRuleUpdateAttributes { + if o == nil { + var ret ApplicationSecurityWafCustomRuleUpdateAttributes + return ret + } + return o.Attributes +} + +// GetAttributesOk returns a tuple with the Attributes field value +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafCustomRuleUpdateData) GetAttributesOk() (*ApplicationSecurityWafCustomRuleUpdateAttributes, bool) { + if o == nil { + return nil, false + } + return &o.Attributes, true +} + +// SetAttributes sets field value. +func (o *ApplicationSecurityWafCustomRuleUpdateData) SetAttributes(v ApplicationSecurityWafCustomRuleUpdateAttributes) { + o.Attributes = v +} + +// GetType returns the Type field value. +func (o *ApplicationSecurityWafCustomRuleUpdateData) GetType() ApplicationSecurityWafCustomRuleType { + if o == nil { + var ret ApplicationSecurityWafCustomRuleType + return ret + } + return o.Type +} + +// GetTypeOk returns a tuple with the Type field value +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafCustomRuleUpdateData) GetTypeOk() (*ApplicationSecurityWafCustomRuleType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *ApplicationSecurityWafCustomRuleUpdateData) SetType(v ApplicationSecurityWafCustomRuleType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ApplicationSecurityWafCustomRuleUpdateData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["attributes"] = o.Attributes + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *ApplicationSecurityWafCustomRuleUpdateData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *ApplicationSecurityWafCustomRuleUpdateAttributes `json:"attributes"` + Type *ApplicationSecurityWafCustomRuleType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Attributes == nil { + return fmt.Errorf("required field attributes missing") + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "type"}) + } else { + return err + } + + hasInvalidField := false + if all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Attributes = *all.Attributes + if !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = *all.Type + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_application_security_waf_custom_rule_update_request.go b/api/datadogV2/model_application_security_waf_custom_rule_update_request.go new file mode 100644 index 00000000000..8a21d3d010b --- /dev/null +++ b/api/datadogV2/model_application_security_waf_custom_rule_update_request.go @@ -0,0 +1,110 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// ApplicationSecurityWafCustomRuleUpdateRequest Request object that includes the Custom Rule to update. +type ApplicationSecurityWafCustomRuleUpdateRequest struct { + // Object for a single WAF Custom Rule. + Data ApplicationSecurityWafCustomRuleUpdateData `json:"data"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewApplicationSecurityWafCustomRuleUpdateRequest instantiates a new ApplicationSecurityWafCustomRuleUpdateRequest object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewApplicationSecurityWafCustomRuleUpdateRequest(data ApplicationSecurityWafCustomRuleUpdateData) *ApplicationSecurityWafCustomRuleUpdateRequest { + this := ApplicationSecurityWafCustomRuleUpdateRequest{} + this.Data = data + return &this +} + +// NewApplicationSecurityWafCustomRuleUpdateRequestWithDefaults instantiates a new ApplicationSecurityWafCustomRuleUpdateRequest object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewApplicationSecurityWafCustomRuleUpdateRequestWithDefaults() *ApplicationSecurityWafCustomRuleUpdateRequest { + this := ApplicationSecurityWafCustomRuleUpdateRequest{} + return &this +} + +// GetData returns the Data field value. +func (o *ApplicationSecurityWafCustomRuleUpdateRequest) GetData() ApplicationSecurityWafCustomRuleUpdateData { + if o == nil { + var ret ApplicationSecurityWafCustomRuleUpdateData + return ret + } + return o.Data +} + +// GetDataOk returns a tuple with the Data field value +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafCustomRuleUpdateRequest) GetDataOk() (*ApplicationSecurityWafCustomRuleUpdateData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *ApplicationSecurityWafCustomRuleUpdateRequest) SetData(v ApplicationSecurityWafCustomRuleUpdateData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ApplicationSecurityWafCustomRuleUpdateRequest) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["data"] = o.Data + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *ApplicationSecurityWafCustomRuleUpdateRequest) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *ApplicationSecurityWafCustomRuleUpdateData `json:"data"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Data == nil { + return fmt.Errorf("required field data missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + + hasInvalidField := false + if all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Data = *all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_application_security_waf_exclusion_filter_attributes.go b/api/datadogV2/model_application_security_waf_exclusion_filter_attributes.go new file mode 100644 index 00000000000..66a4541474d --- /dev/null +++ b/api/datadogV2/model_application_security_waf_exclusion_filter_attributes.go @@ -0,0 +1,465 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// ApplicationSecurityWafExclusionFilterAttributes Attributes describing a WAF exclusion filter. +type ApplicationSecurityWafExclusionFilterAttributes struct { + // A description for the exclusion filter. + Description *string `json:"description,omitempty"` + // Indicates whether the exclusion filter is enabled. + Enabled *bool `json:"enabled,omitempty"` + // The event query matched by the legacy exclusion filter. Cannot be created nor updated. + EventQuery *string `json:"event_query,omitempty"` + // The client IP addresses matched by the exclusion filter (CIDR notation is supported). + IpList []string `json:"ip_list,omitempty"` + // Extra information about the exclusion filter. + Metadata *ApplicationSecurityWafExclusionFilterMetadata `json:"metadata,omitempty"` + // The action taken when the exclusion filter matches. When set to `monitor`, security traces are emitted but the requests are not blocked. By default, security traces are not emitted and the requests are not blocked. + OnMatch *ApplicationSecurityWafExclusionFilterOnMatch `json:"on_match,omitempty"` + // A list of parameters matched by the exclusion filter in the HTTP query string and HTTP request body. Nested parameters can be matched by joining fields with a dot character. + Parameters []string `json:"parameters,omitempty"` + // The HTTP path glob expression matched by the exclusion filter. + PathGlob *string `json:"path_glob,omitempty"` + // The WAF rules targeted by the exclusion filter. + RulesTarget []ApplicationSecurityWafExclusionFilterRulesTarget `json:"rules_target,omitempty"` + // The services where the exclusion filter is deployed. + Scope []ApplicationSecurityWafExclusionFilterScope `json:"scope,omitempty"` + // Generated event search query for traces matching the exclusion filter. + SearchQuery *string `json:"search_query,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewApplicationSecurityWafExclusionFilterAttributes instantiates a new ApplicationSecurityWafExclusionFilterAttributes object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewApplicationSecurityWafExclusionFilterAttributes() *ApplicationSecurityWafExclusionFilterAttributes { + this := ApplicationSecurityWafExclusionFilterAttributes{} + return &this +} + +// NewApplicationSecurityWafExclusionFilterAttributesWithDefaults instantiates a new ApplicationSecurityWafExclusionFilterAttributes object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewApplicationSecurityWafExclusionFilterAttributesWithDefaults() *ApplicationSecurityWafExclusionFilterAttributes { + this := ApplicationSecurityWafExclusionFilterAttributes{} + return &this +} + +// GetDescription returns the Description field value if set, zero value otherwise. +func (o *ApplicationSecurityWafExclusionFilterAttributes) GetDescription() string { + if o == nil || o.Description == nil { + var ret string + return ret + } + return *o.Description +} + +// GetDescriptionOk returns a tuple with the Description field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafExclusionFilterAttributes) GetDescriptionOk() (*string, bool) { + if o == nil || o.Description == nil { + return nil, false + } + return o.Description, true +} + +// HasDescription returns a boolean if a field has been set. +func (o *ApplicationSecurityWafExclusionFilterAttributes) HasDescription() bool { + return o != nil && o.Description != nil +} + +// SetDescription gets a reference to the given string and assigns it to the Description field. +func (o *ApplicationSecurityWafExclusionFilterAttributes) SetDescription(v string) { + o.Description = &v +} + +// GetEnabled returns the Enabled field value if set, zero value otherwise. +func (o *ApplicationSecurityWafExclusionFilterAttributes) GetEnabled() bool { + if o == nil || o.Enabled == nil { + var ret bool + return ret + } + return *o.Enabled +} + +// GetEnabledOk returns a tuple with the Enabled field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafExclusionFilterAttributes) GetEnabledOk() (*bool, bool) { + if o == nil || o.Enabled == nil { + return nil, false + } + return o.Enabled, true +} + +// HasEnabled returns a boolean if a field has been set. +func (o *ApplicationSecurityWafExclusionFilterAttributes) HasEnabled() bool { + return o != nil && o.Enabled != nil +} + +// SetEnabled gets a reference to the given bool and assigns it to the Enabled field. +func (o *ApplicationSecurityWafExclusionFilterAttributes) SetEnabled(v bool) { + o.Enabled = &v +} + +// GetEventQuery returns the EventQuery field value if set, zero value otherwise. +func (o *ApplicationSecurityWafExclusionFilterAttributes) GetEventQuery() string { + if o == nil || o.EventQuery == nil { + var ret string + return ret + } + return *o.EventQuery +} + +// GetEventQueryOk returns a tuple with the EventQuery field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafExclusionFilterAttributes) GetEventQueryOk() (*string, bool) { + if o == nil || o.EventQuery == nil { + return nil, false + } + return o.EventQuery, true +} + +// HasEventQuery returns a boolean if a field has been set. +func (o *ApplicationSecurityWafExclusionFilterAttributes) HasEventQuery() bool { + return o != nil && o.EventQuery != nil +} + +// SetEventQuery gets a reference to the given string and assigns it to the EventQuery field. +func (o *ApplicationSecurityWafExclusionFilterAttributes) SetEventQuery(v string) { + o.EventQuery = &v +} + +// GetIpList returns the IpList field value if set, zero value otherwise. +func (o *ApplicationSecurityWafExclusionFilterAttributes) GetIpList() []string { + if o == nil || o.IpList == nil { + var ret []string + return ret + } + return o.IpList +} + +// GetIpListOk returns a tuple with the IpList field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafExclusionFilterAttributes) GetIpListOk() (*[]string, bool) { + if o == nil || o.IpList == nil { + return nil, false + } + return &o.IpList, true +} + +// HasIpList returns a boolean if a field has been set. +func (o *ApplicationSecurityWafExclusionFilterAttributes) HasIpList() bool { + return o != nil && o.IpList != nil +} + +// SetIpList gets a reference to the given []string and assigns it to the IpList field. +func (o *ApplicationSecurityWafExclusionFilterAttributes) SetIpList(v []string) { + o.IpList = v +} + +// GetMetadata returns the Metadata field value if set, zero value otherwise. +func (o *ApplicationSecurityWafExclusionFilterAttributes) GetMetadata() ApplicationSecurityWafExclusionFilterMetadata { + if o == nil || o.Metadata == nil { + var ret ApplicationSecurityWafExclusionFilterMetadata + return ret + } + return *o.Metadata +} + +// GetMetadataOk returns a tuple with the Metadata field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafExclusionFilterAttributes) GetMetadataOk() (*ApplicationSecurityWafExclusionFilterMetadata, bool) { + if o == nil || o.Metadata == nil { + return nil, false + } + return o.Metadata, true +} + +// HasMetadata returns a boolean if a field has been set. +func (o *ApplicationSecurityWafExclusionFilterAttributes) HasMetadata() bool { + return o != nil && o.Metadata != nil +} + +// SetMetadata gets a reference to the given ApplicationSecurityWafExclusionFilterMetadata and assigns it to the Metadata field. +func (o *ApplicationSecurityWafExclusionFilterAttributes) SetMetadata(v ApplicationSecurityWafExclusionFilterMetadata) { + o.Metadata = &v +} + +// GetOnMatch returns the OnMatch field value if set, zero value otherwise. +func (o *ApplicationSecurityWafExclusionFilterAttributes) GetOnMatch() ApplicationSecurityWafExclusionFilterOnMatch { + if o == nil || o.OnMatch == nil { + var ret ApplicationSecurityWafExclusionFilterOnMatch + return ret + } + return *o.OnMatch +} + +// GetOnMatchOk returns a tuple with the OnMatch field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafExclusionFilterAttributes) GetOnMatchOk() (*ApplicationSecurityWafExclusionFilterOnMatch, bool) { + if o == nil || o.OnMatch == nil { + return nil, false + } + return o.OnMatch, true +} + +// HasOnMatch returns a boolean if a field has been set. +func (o *ApplicationSecurityWafExclusionFilterAttributes) HasOnMatch() bool { + return o != nil && o.OnMatch != nil +} + +// SetOnMatch gets a reference to the given ApplicationSecurityWafExclusionFilterOnMatch and assigns it to the OnMatch field. +func (o *ApplicationSecurityWafExclusionFilterAttributes) SetOnMatch(v ApplicationSecurityWafExclusionFilterOnMatch) { + o.OnMatch = &v +} + +// GetParameters returns the Parameters field value if set, zero value otherwise. +func (o *ApplicationSecurityWafExclusionFilterAttributes) GetParameters() []string { + if o == nil || o.Parameters == nil { + var ret []string + return ret + } + return o.Parameters +} + +// GetParametersOk returns a tuple with the Parameters field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafExclusionFilterAttributes) GetParametersOk() (*[]string, bool) { + if o == nil || o.Parameters == nil { + return nil, false + } + return &o.Parameters, true +} + +// HasParameters returns a boolean if a field has been set. +func (o *ApplicationSecurityWafExclusionFilterAttributes) HasParameters() bool { + return o != nil && o.Parameters != nil +} + +// SetParameters gets a reference to the given []string and assigns it to the Parameters field. +func (o *ApplicationSecurityWafExclusionFilterAttributes) SetParameters(v []string) { + o.Parameters = v +} + +// GetPathGlob returns the PathGlob field value if set, zero value otherwise. +func (o *ApplicationSecurityWafExclusionFilterAttributes) GetPathGlob() string { + if o == nil || o.PathGlob == nil { + var ret string + return ret + } + return *o.PathGlob +} + +// GetPathGlobOk returns a tuple with the PathGlob field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafExclusionFilterAttributes) GetPathGlobOk() (*string, bool) { + if o == nil || o.PathGlob == nil { + return nil, false + } + return o.PathGlob, true +} + +// HasPathGlob returns a boolean if a field has been set. +func (o *ApplicationSecurityWafExclusionFilterAttributes) HasPathGlob() bool { + return o != nil && o.PathGlob != nil +} + +// SetPathGlob gets a reference to the given string and assigns it to the PathGlob field. +func (o *ApplicationSecurityWafExclusionFilterAttributes) SetPathGlob(v string) { + o.PathGlob = &v +} + +// GetRulesTarget returns the RulesTarget field value if set, zero value otherwise. +func (o *ApplicationSecurityWafExclusionFilterAttributes) GetRulesTarget() []ApplicationSecurityWafExclusionFilterRulesTarget { + if o == nil || o.RulesTarget == nil { + var ret []ApplicationSecurityWafExclusionFilterRulesTarget + return ret + } + return o.RulesTarget +} + +// GetRulesTargetOk returns a tuple with the RulesTarget field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafExclusionFilterAttributes) GetRulesTargetOk() (*[]ApplicationSecurityWafExclusionFilterRulesTarget, bool) { + if o == nil || o.RulesTarget == nil { + return nil, false + } + return &o.RulesTarget, true +} + +// HasRulesTarget returns a boolean if a field has been set. +func (o *ApplicationSecurityWafExclusionFilterAttributes) HasRulesTarget() bool { + return o != nil && o.RulesTarget != nil +} + +// SetRulesTarget gets a reference to the given []ApplicationSecurityWafExclusionFilterRulesTarget and assigns it to the RulesTarget field. +func (o *ApplicationSecurityWafExclusionFilterAttributes) SetRulesTarget(v []ApplicationSecurityWafExclusionFilterRulesTarget) { + o.RulesTarget = v +} + +// GetScope returns the Scope field value if set, zero value otherwise. +func (o *ApplicationSecurityWafExclusionFilterAttributes) GetScope() []ApplicationSecurityWafExclusionFilterScope { + if o == nil || o.Scope == nil { + var ret []ApplicationSecurityWafExclusionFilterScope + return ret + } + return o.Scope +} + +// GetScopeOk returns a tuple with the Scope field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafExclusionFilterAttributes) GetScopeOk() (*[]ApplicationSecurityWafExclusionFilterScope, bool) { + if o == nil || o.Scope == nil { + return nil, false + } + return &o.Scope, true +} + +// HasScope returns a boolean if a field has been set. +func (o *ApplicationSecurityWafExclusionFilterAttributes) HasScope() bool { + return o != nil && o.Scope != nil +} + +// SetScope gets a reference to the given []ApplicationSecurityWafExclusionFilterScope and assigns it to the Scope field. +func (o *ApplicationSecurityWafExclusionFilterAttributes) SetScope(v []ApplicationSecurityWafExclusionFilterScope) { + o.Scope = v +} + +// GetSearchQuery returns the SearchQuery field value if set, zero value otherwise. +func (o *ApplicationSecurityWafExclusionFilterAttributes) GetSearchQuery() string { + if o == nil || o.SearchQuery == nil { + var ret string + return ret + } + return *o.SearchQuery +} + +// GetSearchQueryOk returns a tuple with the SearchQuery field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafExclusionFilterAttributes) GetSearchQueryOk() (*string, bool) { + if o == nil || o.SearchQuery == nil { + return nil, false + } + return o.SearchQuery, true +} + +// HasSearchQuery returns a boolean if a field has been set. +func (o *ApplicationSecurityWafExclusionFilterAttributes) HasSearchQuery() bool { + return o != nil && o.SearchQuery != nil +} + +// SetSearchQuery gets a reference to the given string and assigns it to the SearchQuery field. +func (o *ApplicationSecurityWafExclusionFilterAttributes) SetSearchQuery(v string) { + o.SearchQuery = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ApplicationSecurityWafExclusionFilterAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Description != nil { + toSerialize["description"] = o.Description + } + if o.Enabled != nil { + toSerialize["enabled"] = o.Enabled + } + if o.EventQuery != nil { + toSerialize["event_query"] = o.EventQuery + } + if o.IpList != nil { + toSerialize["ip_list"] = o.IpList + } + if o.Metadata != nil { + toSerialize["metadata"] = o.Metadata + } + if o.OnMatch != nil { + toSerialize["on_match"] = o.OnMatch + } + if o.Parameters != nil { + toSerialize["parameters"] = o.Parameters + } + if o.PathGlob != nil { + toSerialize["path_glob"] = o.PathGlob + } + if o.RulesTarget != nil { + toSerialize["rules_target"] = o.RulesTarget + } + if o.Scope != nil { + toSerialize["scope"] = o.Scope + } + if o.SearchQuery != nil { + toSerialize["search_query"] = o.SearchQuery + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *ApplicationSecurityWafExclusionFilterAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Description *string `json:"description,omitempty"` + Enabled *bool `json:"enabled,omitempty"` + EventQuery *string `json:"event_query,omitempty"` + IpList []string `json:"ip_list,omitempty"` + Metadata *ApplicationSecurityWafExclusionFilterMetadata `json:"metadata,omitempty"` + OnMatch *ApplicationSecurityWafExclusionFilterOnMatch `json:"on_match,omitempty"` + Parameters []string `json:"parameters,omitempty"` + PathGlob *string `json:"path_glob,omitempty"` + RulesTarget []ApplicationSecurityWafExclusionFilterRulesTarget `json:"rules_target,omitempty"` + Scope []ApplicationSecurityWafExclusionFilterScope `json:"scope,omitempty"` + SearchQuery *string `json:"search_query,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"description", "enabled", "event_query", "ip_list", "metadata", "on_match", "parameters", "path_glob", "rules_target", "scope", "search_query"}) + } else { + return err + } + + hasInvalidField := false + o.Description = all.Description + o.Enabled = all.Enabled + o.EventQuery = all.EventQuery + o.IpList = all.IpList + if all.Metadata != nil && all.Metadata.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Metadata = all.Metadata + if all.OnMatch != nil && !all.OnMatch.IsValid() { + hasInvalidField = true + } else { + o.OnMatch = all.OnMatch + } + o.Parameters = all.Parameters + o.PathGlob = all.PathGlob + o.RulesTarget = all.RulesTarget + o.Scope = all.Scope + o.SearchQuery = all.SearchQuery + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_application_security_waf_exclusion_filter_create_attributes.go b/api/datadogV2/model_application_security_waf_exclusion_filter_create_attributes.go new file mode 100644 index 00000000000..607c7b78eae --- /dev/null +++ b/api/datadogV2/model_application_security_waf_exclusion_filter_create_attributes.go @@ -0,0 +1,353 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// ApplicationSecurityWafExclusionFilterCreateAttributes Attributes for creating a WAF exclusion filter. +type ApplicationSecurityWafExclusionFilterCreateAttributes struct { + // A description for the exclusion filter. + Description string `json:"description"` + // Indicates whether the exclusion filter is enabled. + Enabled bool `json:"enabled"` + // The client IP addresses matched by the exclusion filter (CIDR notation is supported). + IpList []string `json:"ip_list,omitempty"` + // The action taken when the exclusion filter matches. When set to `monitor`, security traces are emitted but the requests are not blocked. By default, security traces are not emitted and the requests are not blocked. + OnMatch *ApplicationSecurityWafExclusionFilterOnMatch `json:"on_match,omitempty"` + // A list of parameters matched by the exclusion filter in the HTTP query string and HTTP request body. Nested parameters can be matched by joining fields with a dot character. + Parameters []string `json:"parameters,omitempty"` + // The HTTP path glob expression matched by the exclusion filter. + PathGlob *string `json:"path_glob,omitempty"` + // The WAF rules targeted by the exclusion filter. + RulesTarget []ApplicationSecurityWafExclusionFilterRulesTarget `json:"rules_target,omitempty"` + // The services where the exclusion filter is deployed. + Scope []ApplicationSecurityWafExclusionFilterScope `json:"scope,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewApplicationSecurityWafExclusionFilterCreateAttributes instantiates a new ApplicationSecurityWafExclusionFilterCreateAttributes object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewApplicationSecurityWafExclusionFilterCreateAttributes(description string, enabled bool) *ApplicationSecurityWafExclusionFilterCreateAttributes { + this := ApplicationSecurityWafExclusionFilterCreateAttributes{} + this.Description = description + this.Enabled = enabled + return &this +} + +// NewApplicationSecurityWafExclusionFilterCreateAttributesWithDefaults instantiates a new ApplicationSecurityWafExclusionFilterCreateAttributes object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewApplicationSecurityWafExclusionFilterCreateAttributesWithDefaults() *ApplicationSecurityWafExclusionFilterCreateAttributes { + this := ApplicationSecurityWafExclusionFilterCreateAttributes{} + return &this +} + +// GetDescription returns the Description field value. +func (o *ApplicationSecurityWafExclusionFilterCreateAttributes) GetDescription() string { + if o == nil { + var ret string + return ret + } + return o.Description +} + +// GetDescriptionOk returns a tuple with the Description field value +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafExclusionFilterCreateAttributes) GetDescriptionOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Description, true +} + +// SetDescription sets field value. +func (o *ApplicationSecurityWafExclusionFilterCreateAttributes) SetDescription(v string) { + o.Description = v +} + +// GetEnabled returns the Enabled field value. +func (o *ApplicationSecurityWafExclusionFilterCreateAttributes) GetEnabled() bool { + if o == nil { + var ret bool + return ret + } + return o.Enabled +} + +// GetEnabledOk returns a tuple with the Enabled field value +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafExclusionFilterCreateAttributes) GetEnabledOk() (*bool, bool) { + if o == nil { + return nil, false + } + return &o.Enabled, true +} + +// SetEnabled sets field value. +func (o *ApplicationSecurityWafExclusionFilterCreateAttributes) SetEnabled(v bool) { + o.Enabled = v +} + +// GetIpList returns the IpList field value if set, zero value otherwise. +func (o *ApplicationSecurityWafExclusionFilterCreateAttributes) GetIpList() []string { + if o == nil || o.IpList == nil { + var ret []string + return ret + } + return o.IpList +} + +// GetIpListOk returns a tuple with the IpList field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafExclusionFilterCreateAttributes) GetIpListOk() (*[]string, bool) { + if o == nil || o.IpList == nil { + return nil, false + } + return &o.IpList, true +} + +// HasIpList returns a boolean if a field has been set. +func (o *ApplicationSecurityWafExclusionFilterCreateAttributes) HasIpList() bool { + return o != nil && o.IpList != nil +} + +// SetIpList gets a reference to the given []string and assigns it to the IpList field. +func (o *ApplicationSecurityWafExclusionFilterCreateAttributes) SetIpList(v []string) { + o.IpList = v +} + +// GetOnMatch returns the OnMatch field value if set, zero value otherwise. +func (o *ApplicationSecurityWafExclusionFilterCreateAttributes) GetOnMatch() ApplicationSecurityWafExclusionFilterOnMatch { + if o == nil || o.OnMatch == nil { + var ret ApplicationSecurityWafExclusionFilterOnMatch + return ret + } + return *o.OnMatch +} + +// GetOnMatchOk returns a tuple with the OnMatch field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafExclusionFilterCreateAttributes) GetOnMatchOk() (*ApplicationSecurityWafExclusionFilterOnMatch, bool) { + if o == nil || o.OnMatch == nil { + return nil, false + } + return o.OnMatch, true +} + +// HasOnMatch returns a boolean if a field has been set. +func (o *ApplicationSecurityWafExclusionFilterCreateAttributes) HasOnMatch() bool { + return o != nil && o.OnMatch != nil +} + +// SetOnMatch gets a reference to the given ApplicationSecurityWafExclusionFilterOnMatch and assigns it to the OnMatch field. +func (o *ApplicationSecurityWafExclusionFilterCreateAttributes) SetOnMatch(v ApplicationSecurityWafExclusionFilterOnMatch) { + o.OnMatch = &v +} + +// GetParameters returns the Parameters field value if set, zero value otherwise. +func (o *ApplicationSecurityWafExclusionFilterCreateAttributes) GetParameters() []string { + if o == nil || o.Parameters == nil { + var ret []string + return ret + } + return o.Parameters +} + +// GetParametersOk returns a tuple with the Parameters field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafExclusionFilterCreateAttributes) GetParametersOk() (*[]string, bool) { + if o == nil || o.Parameters == nil { + return nil, false + } + return &o.Parameters, true +} + +// HasParameters returns a boolean if a field has been set. +func (o *ApplicationSecurityWafExclusionFilterCreateAttributes) HasParameters() bool { + return o != nil && o.Parameters != nil +} + +// SetParameters gets a reference to the given []string and assigns it to the Parameters field. +func (o *ApplicationSecurityWafExclusionFilterCreateAttributes) SetParameters(v []string) { + o.Parameters = v +} + +// GetPathGlob returns the PathGlob field value if set, zero value otherwise. +func (o *ApplicationSecurityWafExclusionFilterCreateAttributes) GetPathGlob() string { + if o == nil || o.PathGlob == nil { + var ret string + return ret + } + return *o.PathGlob +} + +// GetPathGlobOk returns a tuple with the PathGlob field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafExclusionFilterCreateAttributes) GetPathGlobOk() (*string, bool) { + if o == nil || o.PathGlob == nil { + return nil, false + } + return o.PathGlob, true +} + +// HasPathGlob returns a boolean if a field has been set. +func (o *ApplicationSecurityWafExclusionFilterCreateAttributes) HasPathGlob() bool { + return o != nil && o.PathGlob != nil +} + +// SetPathGlob gets a reference to the given string and assigns it to the PathGlob field. +func (o *ApplicationSecurityWafExclusionFilterCreateAttributes) SetPathGlob(v string) { + o.PathGlob = &v +} + +// GetRulesTarget returns the RulesTarget field value if set, zero value otherwise. +func (o *ApplicationSecurityWafExclusionFilterCreateAttributes) GetRulesTarget() []ApplicationSecurityWafExclusionFilterRulesTarget { + if o == nil || o.RulesTarget == nil { + var ret []ApplicationSecurityWafExclusionFilterRulesTarget + return ret + } + return o.RulesTarget +} + +// GetRulesTargetOk returns a tuple with the RulesTarget field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafExclusionFilterCreateAttributes) GetRulesTargetOk() (*[]ApplicationSecurityWafExclusionFilterRulesTarget, bool) { + if o == nil || o.RulesTarget == nil { + return nil, false + } + return &o.RulesTarget, true +} + +// HasRulesTarget returns a boolean if a field has been set. +func (o *ApplicationSecurityWafExclusionFilterCreateAttributes) HasRulesTarget() bool { + return o != nil && o.RulesTarget != nil +} + +// SetRulesTarget gets a reference to the given []ApplicationSecurityWafExclusionFilterRulesTarget and assigns it to the RulesTarget field. +func (o *ApplicationSecurityWafExclusionFilterCreateAttributes) SetRulesTarget(v []ApplicationSecurityWafExclusionFilterRulesTarget) { + o.RulesTarget = v +} + +// GetScope returns the Scope field value if set, zero value otherwise. +func (o *ApplicationSecurityWafExclusionFilterCreateAttributes) GetScope() []ApplicationSecurityWafExclusionFilterScope { + if o == nil || o.Scope == nil { + var ret []ApplicationSecurityWafExclusionFilterScope + return ret + } + return o.Scope +} + +// GetScopeOk returns a tuple with the Scope field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafExclusionFilterCreateAttributes) GetScopeOk() (*[]ApplicationSecurityWafExclusionFilterScope, bool) { + if o == nil || o.Scope == nil { + return nil, false + } + return &o.Scope, true +} + +// HasScope returns a boolean if a field has been set. +func (o *ApplicationSecurityWafExclusionFilterCreateAttributes) HasScope() bool { + return o != nil && o.Scope != nil +} + +// SetScope gets a reference to the given []ApplicationSecurityWafExclusionFilterScope and assigns it to the Scope field. +func (o *ApplicationSecurityWafExclusionFilterCreateAttributes) SetScope(v []ApplicationSecurityWafExclusionFilterScope) { + o.Scope = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ApplicationSecurityWafExclusionFilterCreateAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["description"] = o.Description + toSerialize["enabled"] = o.Enabled + if o.IpList != nil { + toSerialize["ip_list"] = o.IpList + } + if o.OnMatch != nil { + toSerialize["on_match"] = o.OnMatch + } + if o.Parameters != nil { + toSerialize["parameters"] = o.Parameters + } + if o.PathGlob != nil { + toSerialize["path_glob"] = o.PathGlob + } + if o.RulesTarget != nil { + toSerialize["rules_target"] = o.RulesTarget + } + if o.Scope != nil { + toSerialize["scope"] = o.Scope + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *ApplicationSecurityWafExclusionFilterCreateAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Description *string `json:"description"` + Enabled *bool `json:"enabled"` + IpList []string `json:"ip_list,omitempty"` + OnMatch *ApplicationSecurityWafExclusionFilterOnMatch `json:"on_match,omitempty"` + Parameters []string `json:"parameters,omitempty"` + PathGlob *string `json:"path_glob,omitempty"` + RulesTarget []ApplicationSecurityWafExclusionFilterRulesTarget `json:"rules_target,omitempty"` + Scope []ApplicationSecurityWafExclusionFilterScope `json:"scope,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Description == nil { + return fmt.Errorf("required field description missing") + } + if all.Enabled == nil { + return fmt.Errorf("required field enabled missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"description", "enabled", "ip_list", "on_match", "parameters", "path_glob", "rules_target", "scope"}) + } else { + return err + } + + hasInvalidField := false + o.Description = *all.Description + o.Enabled = *all.Enabled + o.IpList = all.IpList + if all.OnMatch != nil && !all.OnMatch.IsValid() { + hasInvalidField = true + } else { + o.OnMatch = all.OnMatch + } + o.Parameters = all.Parameters + o.PathGlob = all.PathGlob + o.RulesTarget = all.RulesTarget + o.Scope = all.Scope + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_application_security_waf_exclusion_filter_create_data.go b/api/datadogV2/model_application_security_waf_exclusion_filter_create_data.go new file mode 100644 index 00000000000..2ddd766e4c4 --- /dev/null +++ b/api/datadogV2/model_application_security_waf_exclusion_filter_create_data.go @@ -0,0 +1,148 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// ApplicationSecurityWafExclusionFilterCreateData Object for creating a single WAF exclusion filter. +type ApplicationSecurityWafExclusionFilterCreateData struct { + // Attributes for creating a WAF exclusion filter. + Attributes ApplicationSecurityWafExclusionFilterCreateAttributes `json:"attributes"` + // Type of the resource. The value should always be `exclusion_filter`. + Type ApplicationSecurityWafExclusionFilterType `json:"type"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewApplicationSecurityWafExclusionFilterCreateData instantiates a new ApplicationSecurityWafExclusionFilterCreateData object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewApplicationSecurityWafExclusionFilterCreateData(attributes ApplicationSecurityWafExclusionFilterCreateAttributes, typeVar ApplicationSecurityWafExclusionFilterType) *ApplicationSecurityWafExclusionFilterCreateData { + this := ApplicationSecurityWafExclusionFilterCreateData{} + this.Attributes = attributes + this.Type = typeVar + return &this +} + +// NewApplicationSecurityWafExclusionFilterCreateDataWithDefaults instantiates a new ApplicationSecurityWafExclusionFilterCreateData object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewApplicationSecurityWafExclusionFilterCreateDataWithDefaults() *ApplicationSecurityWafExclusionFilterCreateData { + this := ApplicationSecurityWafExclusionFilterCreateData{} + var typeVar ApplicationSecurityWafExclusionFilterType = APPLICATIONSECURITYWAFEXCLUSIONFILTERTYPE_EXCLUSION_FILTER + this.Type = typeVar + return &this +} + +// GetAttributes returns the Attributes field value. +func (o *ApplicationSecurityWafExclusionFilterCreateData) GetAttributes() ApplicationSecurityWafExclusionFilterCreateAttributes { + if o == nil { + var ret ApplicationSecurityWafExclusionFilterCreateAttributes + return ret + } + return o.Attributes +} + +// GetAttributesOk returns a tuple with the Attributes field value +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafExclusionFilterCreateData) GetAttributesOk() (*ApplicationSecurityWafExclusionFilterCreateAttributes, bool) { + if o == nil { + return nil, false + } + return &o.Attributes, true +} + +// SetAttributes sets field value. +func (o *ApplicationSecurityWafExclusionFilterCreateData) SetAttributes(v ApplicationSecurityWafExclusionFilterCreateAttributes) { + o.Attributes = v +} + +// GetType returns the Type field value. +func (o *ApplicationSecurityWafExclusionFilterCreateData) GetType() ApplicationSecurityWafExclusionFilterType { + if o == nil { + var ret ApplicationSecurityWafExclusionFilterType + return ret + } + return o.Type +} + +// GetTypeOk returns a tuple with the Type field value +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafExclusionFilterCreateData) GetTypeOk() (*ApplicationSecurityWafExclusionFilterType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *ApplicationSecurityWafExclusionFilterCreateData) SetType(v ApplicationSecurityWafExclusionFilterType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ApplicationSecurityWafExclusionFilterCreateData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["attributes"] = o.Attributes + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *ApplicationSecurityWafExclusionFilterCreateData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *ApplicationSecurityWafExclusionFilterCreateAttributes `json:"attributes"` + Type *ApplicationSecurityWafExclusionFilterType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Attributes == nil { + return fmt.Errorf("required field attributes missing") + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "type"}) + } else { + return err + } + + hasInvalidField := false + if all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Attributes = *all.Attributes + if !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = *all.Type + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_application_security_waf_exclusion_filter_create_request.go b/api/datadogV2/model_application_security_waf_exclusion_filter_create_request.go new file mode 100644 index 00000000000..d8b9e8c9f79 --- /dev/null +++ b/api/datadogV2/model_application_security_waf_exclusion_filter_create_request.go @@ -0,0 +1,110 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// ApplicationSecurityWafExclusionFilterCreateRequest Request object for creating a single WAF exclusion filter. +type ApplicationSecurityWafExclusionFilterCreateRequest struct { + // Object for creating a single WAF exclusion filter. + Data ApplicationSecurityWafExclusionFilterCreateData `json:"data"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewApplicationSecurityWafExclusionFilterCreateRequest instantiates a new ApplicationSecurityWafExclusionFilterCreateRequest object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewApplicationSecurityWafExclusionFilterCreateRequest(data ApplicationSecurityWafExclusionFilterCreateData) *ApplicationSecurityWafExclusionFilterCreateRequest { + this := ApplicationSecurityWafExclusionFilterCreateRequest{} + this.Data = data + return &this +} + +// NewApplicationSecurityWafExclusionFilterCreateRequestWithDefaults instantiates a new ApplicationSecurityWafExclusionFilterCreateRequest object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewApplicationSecurityWafExclusionFilterCreateRequestWithDefaults() *ApplicationSecurityWafExclusionFilterCreateRequest { + this := ApplicationSecurityWafExclusionFilterCreateRequest{} + return &this +} + +// GetData returns the Data field value. +func (o *ApplicationSecurityWafExclusionFilterCreateRequest) GetData() ApplicationSecurityWafExclusionFilterCreateData { + if o == nil { + var ret ApplicationSecurityWafExclusionFilterCreateData + return ret + } + return o.Data +} + +// GetDataOk returns a tuple with the Data field value +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafExclusionFilterCreateRequest) GetDataOk() (*ApplicationSecurityWafExclusionFilterCreateData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *ApplicationSecurityWafExclusionFilterCreateRequest) SetData(v ApplicationSecurityWafExclusionFilterCreateData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ApplicationSecurityWafExclusionFilterCreateRequest) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["data"] = o.Data + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *ApplicationSecurityWafExclusionFilterCreateRequest) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *ApplicationSecurityWafExclusionFilterCreateData `json:"data"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Data == nil { + return fmt.Errorf("required field data missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + + hasInvalidField := false + if all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Data = *all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_application_security_waf_exclusion_filter_metadata.go b/api/datadogV2/model_application_security_waf_exclusion_filter_metadata.go new file mode 100644 index 00000000000..541ba354857 --- /dev/null +++ b/api/datadogV2/model_application_security_waf_exclusion_filter_metadata.go @@ -0,0 +1,287 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "time" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// ApplicationSecurityWafExclusionFilterMetadata Extra information about the exclusion filter. +type ApplicationSecurityWafExclusionFilterMetadata struct { + // The creation date of the exclusion filter. + AddedAt *time.Time `json:"added_at,omitempty"` + // The handle of the user who created the exclusion filter. + AddedBy *string `json:"added_by,omitempty"` + // The name of the user who created the exclusion filter. + AddedByName *string `json:"added_by_name,omitempty"` + // The last modification date of the exclusion filter. + ModifiedAt *time.Time `json:"modified_at,omitempty"` + // The handle of the user who last modified the exclusion filter. + ModifiedBy *string `json:"modified_by,omitempty"` + // The name of the user who last modified the exclusion filter. + ModifiedByName *string `json:"modified_by_name,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewApplicationSecurityWafExclusionFilterMetadata instantiates a new ApplicationSecurityWafExclusionFilterMetadata object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewApplicationSecurityWafExclusionFilterMetadata() *ApplicationSecurityWafExclusionFilterMetadata { + this := ApplicationSecurityWafExclusionFilterMetadata{} + return &this +} + +// NewApplicationSecurityWafExclusionFilterMetadataWithDefaults instantiates a new ApplicationSecurityWafExclusionFilterMetadata object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewApplicationSecurityWafExclusionFilterMetadataWithDefaults() *ApplicationSecurityWafExclusionFilterMetadata { + this := ApplicationSecurityWafExclusionFilterMetadata{} + return &this +} + +// GetAddedAt returns the AddedAt field value if set, zero value otherwise. +func (o *ApplicationSecurityWafExclusionFilterMetadata) GetAddedAt() time.Time { + if o == nil || o.AddedAt == nil { + var ret time.Time + return ret + } + return *o.AddedAt +} + +// GetAddedAtOk returns a tuple with the AddedAt field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafExclusionFilterMetadata) GetAddedAtOk() (*time.Time, bool) { + if o == nil || o.AddedAt == nil { + return nil, false + } + return o.AddedAt, true +} + +// HasAddedAt returns a boolean if a field has been set. +func (o *ApplicationSecurityWafExclusionFilterMetadata) HasAddedAt() bool { + return o != nil && o.AddedAt != nil +} + +// SetAddedAt gets a reference to the given time.Time and assigns it to the AddedAt field. +func (o *ApplicationSecurityWafExclusionFilterMetadata) SetAddedAt(v time.Time) { + o.AddedAt = &v +} + +// GetAddedBy returns the AddedBy field value if set, zero value otherwise. +func (o *ApplicationSecurityWafExclusionFilterMetadata) GetAddedBy() string { + if o == nil || o.AddedBy == nil { + var ret string + return ret + } + return *o.AddedBy +} + +// GetAddedByOk returns a tuple with the AddedBy field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafExclusionFilterMetadata) GetAddedByOk() (*string, bool) { + if o == nil || o.AddedBy == nil { + return nil, false + } + return o.AddedBy, true +} + +// HasAddedBy returns a boolean if a field has been set. +func (o *ApplicationSecurityWafExclusionFilterMetadata) HasAddedBy() bool { + return o != nil && o.AddedBy != nil +} + +// SetAddedBy gets a reference to the given string and assigns it to the AddedBy field. +func (o *ApplicationSecurityWafExclusionFilterMetadata) SetAddedBy(v string) { + o.AddedBy = &v +} + +// GetAddedByName returns the AddedByName field value if set, zero value otherwise. +func (o *ApplicationSecurityWafExclusionFilterMetadata) GetAddedByName() string { + if o == nil || o.AddedByName == nil { + var ret string + return ret + } + return *o.AddedByName +} + +// GetAddedByNameOk returns a tuple with the AddedByName field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafExclusionFilterMetadata) GetAddedByNameOk() (*string, bool) { + if o == nil || o.AddedByName == nil { + return nil, false + } + return o.AddedByName, true +} + +// HasAddedByName returns a boolean if a field has been set. +func (o *ApplicationSecurityWafExclusionFilterMetadata) HasAddedByName() bool { + return o != nil && o.AddedByName != nil +} + +// SetAddedByName gets a reference to the given string and assigns it to the AddedByName field. +func (o *ApplicationSecurityWafExclusionFilterMetadata) SetAddedByName(v string) { + o.AddedByName = &v +} + +// GetModifiedAt returns the ModifiedAt field value if set, zero value otherwise. +func (o *ApplicationSecurityWafExclusionFilterMetadata) GetModifiedAt() time.Time { + if o == nil || o.ModifiedAt == nil { + var ret time.Time + return ret + } + return *o.ModifiedAt +} + +// GetModifiedAtOk returns a tuple with the ModifiedAt field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafExclusionFilterMetadata) GetModifiedAtOk() (*time.Time, bool) { + if o == nil || o.ModifiedAt == nil { + return nil, false + } + return o.ModifiedAt, true +} + +// HasModifiedAt returns a boolean if a field has been set. +func (o *ApplicationSecurityWafExclusionFilterMetadata) HasModifiedAt() bool { + return o != nil && o.ModifiedAt != nil +} + +// SetModifiedAt gets a reference to the given time.Time and assigns it to the ModifiedAt field. +func (o *ApplicationSecurityWafExclusionFilterMetadata) SetModifiedAt(v time.Time) { + o.ModifiedAt = &v +} + +// GetModifiedBy returns the ModifiedBy field value if set, zero value otherwise. +func (o *ApplicationSecurityWafExclusionFilterMetadata) GetModifiedBy() string { + if o == nil || o.ModifiedBy == nil { + var ret string + return ret + } + return *o.ModifiedBy +} + +// GetModifiedByOk returns a tuple with the ModifiedBy field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafExclusionFilterMetadata) GetModifiedByOk() (*string, bool) { + if o == nil || o.ModifiedBy == nil { + return nil, false + } + return o.ModifiedBy, true +} + +// HasModifiedBy returns a boolean if a field has been set. +func (o *ApplicationSecurityWafExclusionFilterMetadata) HasModifiedBy() bool { + return o != nil && o.ModifiedBy != nil +} + +// SetModifiedBy gets a reference to the given string and assigns it to the ModifiedBy field. +func (o *ApplicationSecurityWafExclusionFilterMetadata) SetModifiedBy(v string) { + o.ModifiedBy = &v +} + +// GetModifiedByName returns the ModifiedByName field value if set, zero value otherwise. +func (o *ApplicationSecurityWafExclusionFilterMetadata) GetModifiedByName() string { + if o == nil || o.ModifiedByName == nil { + var ret string + return ret + } + return *o.ModifiedByName +} + +// GetModifiedByNameOk returns a tuple with the ModifiedByName field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafExclusionFilterMetadata) GetModifiedByNameOk() (*string, bool) { + if o == nil || o.ModifiedByName == nil { + return nil, false + } + return o.ModifiedByName, true +} + +// HasModifiedByName returns a boolean if a field has been set. +func (o *ApplicationSecurityWafExclusionFilterMetadata) HasModifiedByName() bool { + return o != nil && o.ModifiedByName != nil +} + +// SetModifiedByName gets a reference to the given string and assigns it to the ModifiedByName field. +func (o *ApplicationSecurityWafExclusionFilterMetadata) SetModifiedByName(v string) { + o.ModifiedByName = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ApplicationSecurityWafExclusionFilterMetadata) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.AddedAt != nil { + if o.AddedAt.Nanosecond() == 0 { + toSerialize["added_at"] = o.AddedAt.Format("2006-01-02T15:04:05Z07:00") + } else { + toSerialize["added_at"] = o.AddedAt.Format("2006-01-02T15:04:05.000Z07:00") + } + } + if o.AddedBy != nil { + toSerialize["added_by"] = o.AddedBy + } + if o.AddedByName != nil { + toSerialize["added_by_name"] = o.AddedByName + } + if o.ModifiedAt != nil { + if o.ModifiedAt.Nanosecond() == 0 { + toSerialize["modified_at"] = o.ModifiedAt.Format("2006-01-02T15:04:05Z07:00") + } else { + toSerialize["modified_at"] = o.ModifiedAt.Format("2006-01-02T15:04:05.000Z07:00") + } + } + if o.ModifiedBy != nil { + toSerialize["modified_by"] = o.ModifiedBy + } + if o.ModifiedByName != nil { + toSerialize["modified_by_name"] = o.ModifiedByName + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *ApplicationSecurityWafExclusionFilterMetadata) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + AddedAt *time.Time `json:"added_at,omitempty"` + AddedBy *string `json:"added_by,omitempty"` + AddedByName *string `json:"added_by_name,omitempty"` + ModifiedAt *time.Time `json:"modified_at,omitempty"` + ModifiedBy *string `json:"modified_by,omitempty"` + ModifiedByName *string `json:"modified_by_name,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"added_at", "added_by", "added_by_name", "modified_at", "modified_by", "modified_by_name"}) + } else { + return err + } + o.AddedAt = all.AddedAt + o.AddedBy = all.AddedBy + o.AddedByName = all.AddedByName + o.ModifiedAt = all.ModifiedAt + o.ModifiedBy = all.ModifiedBy + o.ModifiedByName = all.ModifiedByName + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_application_security_waf_exclusion_filter_on_match.go b/api/datadogV2/model_application_security_waf_exclusion_filter_on_match.go new file mode 100644 index 00000000000..11a45e0ad4a --- /dev/null +++ b/api/datadogV2/model_application_security_waf_exclusion_filter_on_match.go @@ -0,0 +1,64 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// ApplicationSecurityWafExclusionFilterOnMatch The action taken when the exclusion filter matches. When set to `monitor`, security traces are emitted but the requests are not blocked. By default, security traces are not emitted and the requests are not blocked. +type ApplicationSecurityWafExclusionFilterOnMatch string + +// List of ApplicationSecurityWafExclusionFilterOnMatch. +const ( + APPLICATIONSECURITYWAFEXCLUSIONFILTERONMATCH_MONITOR ApplicationSecurityWafExclusionFilterOnMatch = "monitor" +) + +var allowedApplicationSecurityWafExclusionFilterOnMatchEnumValues = []ApplicationSecurityWafExclusionFilterOnMatch{ + APPLICATIONSECURITYWAFEXCLUSIONFILTERONMATCH_MONITOR, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *ApplicationSecurityWafExclusionFilterOnMatch) GetAllowedValues() []ApplicationSecurityWafExclusionFilterOnMatch { + return allowedApplicationSecurityWafExclusionFilterOnMatchEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *ApplicationSecurityWafExclusionFilterOnMatch) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = ApplicationSecurityWafExclusionFilterOnMatch(value) + return nil +} + +// NewApplicationSecurityWafExclusionFilterOnMatchFromValue returns a pointer to a valid ApplicationSecurityWafExclusionFilterOnMatch +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewApplicationSecurityWafExclusionFilterOnMatchFromValue(v string) (*ApplicationSecurityWafExclusionFilterOnMatch, error) { + ev := ApplicationSecurityWafExclusionFilterOnMatch(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for ApplicationSecurityWafExclusionFilterOnMatch: valid values are %v", v, allowedApplicationSecurityWafExclusionFilterOnMatchEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v ApplicationSecurityWafExclusionFilterOnMatch) IsValid() bool { + for _, existing := range allowedApplicationSecurityWafExclusionFilterOnMatchEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to ApplicationSecurityWafExclusionFilterOnMatch value. +func (v ApplicationSecurityWafExclusionFilterOnMatch) Ptr() *ApplicationSecurityWafExclusionFilterOnMatch { + return &v +} diff --git a/api/datadogV2/model_application_security_waf_exclusion_filter_resource.go b/api/datadogV2/model_application_security_waf_exclusion_filter_resource.go new file mode 100644 index 00000000000..18d9e8ff0c1 --- /dev/null +++ b/api/datadogV2/model_application_security_waf_exclusion_filter_resource.go @@ -0,0 +1,189 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// ApplicationSecurityWafExclusionFilterResource A JSON:API resource for an WAF exclusion filter. +type ApplicationSecurityWafExclusionFilterResource struct { + // Attributes describing a WAF exclusion filter. + Attributes *ApplicationSecurityWafExclusionFilterAttributes `json:"attributes,omitempty"` + // The identifier of the WAF exclusion filter. + Id *string `json:"id,omitempty"` + // Type of the resource. The value should always be `exclusion_filter`. + Type *ApplicationSecurityWafExclusionFilterType `json:"type,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewApplicationSecurityWafExclusionFilterResource instantiates a new ApplicationSecurityWafExclusionFilterResource object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewApplicationSecurityWafExclusionFilterResource() *ApplicationSecurityWafExclusionFilterResource { + this := ApplicationSecurityWafExclusionFilterResource{} + var typeVar ApplicationSecurityWafExclusionFilterType = APPLICATIONSECURITYWAFEXCLUSIONFILTERTYPE_EXCLUSION_FILTER + this.Type = &typeVar + return &this +} + +// NewApplicationSecurityWafExclusionFilterResourceWithDefaults instantiates a new ApplicationSecurityWafExclusionFilterResource object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewApplicationSecurityWafExclusionFilterResourceWithDefaults() *ApplicationSecurityWafExclusionFilterResource { + this := ApplicationSecurityWafExclusionFilterResource{} + var typeVar ApplicationSecurityWafExclusionFilterType = APPLICATIONSECURITYWAFEXCLUSIONFILTERTYPE_EXCLUSION_FILTER + this.Type = &typeVar + return &this +} + +// GetAttributes returns the Attributes field value if set, zero value otherwise. +func (o *ApplicationSecurityWafExclusionFilterResource) GetAttributes() ApplicationSecurityWafExclusionFilterAttributes { + if o == nil || o.Attributes == nil { + var ret ApplicationSecurityWafExclusionFilterAttributes + return ret + } + return *o.Attributes +} + +// GetAttributesOk returns a tuple with the Attributes field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafExclusionFilterResource) GetAttributesOk() (*ApplicationSecurityWafExclusionFilterAttributes, bool) { + if o == nil || o.Attributes == nil { + return nil, false + } + return o.Attributes, true +} + +// HasAttributes returns a boolean if a field has been set. +func (o *ApplicationSecurityWafExclusionFilterResource) HasAttributes() bool { + return o != nil && o.Attributes != nil +} + +// SetAttributes gets a reference to the given ApplicationSecurityWafExclusionFilterAttributes and assigns it to the Attributes field. +func (o *ApplicationSecurityWafExclusionFilterResource) SetAttributes(v ApplicationSecurityWafExclusionFilterAttributes) { + o.Attributes = &v +} + +// GetId returns the Id field value if set, zero value otherwise. +func (o *ApplicationSecurityWafExclusionFilterResource) GetId() string { + if o == nil || o.Id == nil { + var ret string + return ret + } + return *o.Id +} + +// GetIdOk returns a tuple with the Id field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafExclusionFilterResource) GetIdOk() (*string, bool) { + if o == nil || o.Id == nil { + return nil, false + } + return o.Id, true +} + +// HasId returns a boolean if a field has been set. +func (o *ApplicationSecurityWafExclusionFilterResource) HasId() bool { + return o != nil && o.Id != nil +} + +// SetId gets a reference to the given string and assigns it to the Id field. +func (o *ApplicationSecurityWafExclusionFilterResource) SetId(v string) { + o.Id = &v +} + +// GetType returns the Type field value if set, zero value otherwise. +func (o *ApplicationSecurityWafExclusionFilterResource) GetType() ApplicationSecurityWafExclusionFilterType { + if o == nil || o.Type == nil { + var ret ApplicationSecurityWafExclusionFilterType + return ret + } + return *o.Type +} + +// GetTypeOk returns a tuple with the Type field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafExclusionFilterResource) GetTypeOk() (*ApplicationSecurityWafExclusionFilterType, bool) { + if o == nil || o.Type == nil { + return nil, false + } + return o.Type, true +} + +// HasType returns a boolean if a field has been set. +func (o *ApplicationSecurityWafExclusionFilterResource) HasType() bool { + return o != nil && o.Type != nil +} + +// SetType gets a reference to the given ApplicationSecurityWafExclusionFilterType and assigns it to the Type field. +func (o *ApplicationSecurityWafExclusionFilterResource) SetType(v ApplicationSecurityWafExclusionFilterType) { + o.Type = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ApplicationSecurityWafExclusionFilterResource) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Attributes != nil { + toSerialize["attributes"] = o.Attributes + } + if o.Id != nil { + toSerialize["id"] = o.Id + } + if o.Type != nil { + toSerialize["type"] = o.Type + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *ApplicationSecurityWafExclusionFilterResource) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *ApplicationSecurityWafExclusionFilterAttributes `json:"attributes,omitempty"` + Id *string `json:"id,omitempty"` + Type *ApplicationSecurityWafExclusionFilterType `json:"type,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "id", "type"}) + } else { + return err + } + + hasInvalidField := false + if all.Attributes != nil && all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Attributes = all.Attributes + o.Id = all.Id + if all.Type != nil && !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = all.Type + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_application_security_waf_exclusion_filter_response.go b/api/datadogV2/model_application_security_waf_exclusion_filter_response.go new file mode 100644 index 00000000000..aeaf4ae38d9 --- /dev/null +++ b/api/datadogV2/model_application_security_waf_exclusion_filter_response.go @@ -0,0 +1,111 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// ApplicationSecurityWafExclusionFilterResponse Response object for a single WAF exclusion filter. +type ApplicationSecurityWafExclusionFilterResponse struct { + // A JSON:API resource for an WAF exclusion filter. + Data *ApplicationSecurityWafExclusionFilterResource `json:"data,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewApplicationSecurityWafExclusionFilterResponse instantiates a new ApplicationSecurityWafExclusionFilterResponse object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewApplicationSecurityWafExclusionFilterResponse() *ApplicationSecurityWafExclusionFilterResponse { + this := ApplicationSecurityWafExclusionFilterResponse{} + return &this +} + +// NewApplicationSecurityWafExclusionFilterResponseWithDefaults instantiates a new ApplicationSecurityWafExclusionFilterResponse object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewApplicationSecurityWafExclusionFilterResponseWithDefaults() *ApplicationSecurityWafExclusionFilterResponse { + this := ApplicationSecurityWafExclusionFilterResponse{} + return &this +} + +// GetData returns the Data field value if set, zero value otherwise. +func (o *ApplicationSecurityWafExclusionFilterResponse) GetData() ApplicationSecurityWafExclusionFilterResource { + if o == nil || o.Data == nil { + var ret ApplicationSecurityWafExclusionFilterResource + return ret + } + return *o.Data +} + +// GetDataOk returns a tuple with the Data field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafExclusionFilterResponse) GetDataOk() (*ApplicationSecurityWafExclusionFilterResource, bool) { + if o == nil || o.Data == nil { + return nil, false + } + return o.Data, true +} + +// HasData returns a boolean if a field has been set. +func (o *ApplicationSecurityWafExclusionFilterResponse) HasData() bool { + return o != nil && o.Data != nil +} + +// SetData gets a reference to the given ApplicationSecurityWafExclusionFilterResource and assigns it to the Data field. +func (o *ApplicationSecurityWafExclusionFilterResponse) SetData(v ApplicationSecurityWafExclusionFilterResource) { + o.Data = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ApplicationSecurityWafExclusionFilterResponse) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Data != nil { + toSerialize["data"] = o.Data + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *ApplicationSecurityWafExclusionFilterResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *ApplicationSecurityWafExclusionFilterResource `json:"data,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + + hasInvalidField := false + if all.Data != nil && all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Data = all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_application_security_waf_exclusion_filter_rules_target.go b/api/datadogV2/model_application_security_waf_exclusion_filter_rules_target.go new file mode 100644 index 00000000000..643670cb382 --- /dev/null +++ b/api/datadogV2/model_application_security_waf_exclusion_filter_rules_target.go @@ -0,0 +1,146 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// ApplicationSecurityWafExclusionFilterRulesTarget Target WAF rules based either on an identifier or tags. +type ApplicationSecurityWafExclusionFilterRulesTarget struct { + // Target a single WAF rule based on its identifier. + RuleId *string `json:"rule_id,omitempty"` + // Target multiple WAF rules based on their tags. + Tags *ApplicationSecurityWafExclusionFilterRulesTargetTags `json:"tags,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewApplicationSecurityWafExclusionFilterRulesTarget instantiates a new ApplicationSecurityWafExclusionFilterRulesTarget object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewApplicationSecurityWafExclusionFilterRulesTarget() *ApplicationSecurityWafExclusionFilterRulesTarget { + this := ApplicationSecurityWafExclusionFilterRulesTarget{} + return &this +} + +// NewApplicationSecurityWafExclusionFilterRulesTargetWithDefaults instantiates a new ApplicationSecurityWafExclusionFilterRulesTarget object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewApplicationSecurityWafExclusionFilterRulesTargetWithDefaults() *ApplicationSecurityWafExclusionFilterRulesTarget { + this := ApplicationSecurityWafExclusionFilterRulesTarget{} + return &this +} + +// GetRuleId returns the RuleId field value if set, zero value otherwise. +func (o *ApplicationSecurityWafExclusionFilterRulesTarget) GetRuleId() string { + if o == nil || o.RuleId == nil { + var ret string + return ret + } + return *o.RuleId +} + +// GetRuleIdOk returns a tuple with the RuleId field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafExclusionFilterRulesTarget) GetRuleIdOk() (*string, bool) { + if o == nil || o.RuleId == nil { + return nil, false + } + return o.RuleId, true +} + +// HasRuleId returns a boolean if a field has been set. +func (o *ApplicationSecurityWafExclusionFilterRulesTarget) HasRuleId() bool { + return o != nil && o.RuleId != nil +} + +// SetRuleId gets a reference to the given string and assigns it to the RuleId field. +func (o *ApplicationSecurityWafExclusionFilterRulesTarget) SetRuleId(v string) { + o.RuleId = &v +} + +// GetTags returns the Tags field value if set, zero value otherwise. +func (o *ApplicationSecurityWafExclusionFilterRulesTarget) GetTags() ApplicationSecurityWafExclusionFilterRulesTargetTags { + if o == nil || o.Tags == nil { + var ret ApplicationSecurityWafExclusionFilterRulesTargetTags + return ret + } + return *o.Tags +} + +// GetTagsOk returns a tuple with the Tags field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafExclusionFilterRulesTarget) GetTagsOk() (*ApplicationSecurityWafExclusionFilterRulesTargetTags, bool) { + if o == nil || o.Tags == nil { + return nil, false + } + return o.Tags, true +} + +// HasTags returns a boolean if a field has been set. +func (o *ApplicationSecurityWafExclusionFilterRulesTarget) HasTags() bool { + return o != nil && o.Tags != nil +} + +// SetTags gets a reference to the given ApplicationSecurityWafExclusionFilterRulesTargetTags and assigns it to the Tags field. +func (o *ApplicationSecurityWafExclusionFilterRulesTarget) SetTags(v ApplicationSecurityWafExclusionFilterRulesTargetTags) { + o.Tags = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ApplicationSecurityWafExclusionFilterRulesTarget) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.RuleId != nil { + toSerialize["rule_id"] = o.RuleId + } + if o.Tags != nil { + toSerialize["tags"] = o.Tags + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *ApplicationSecurityWafExclusionFilterRulesTarget) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + RuleId *string `json:"rule_id,omitempty"` + Tags *ApplicationSecurityWafExclusionFilterRulesTargetTags `json:"tags,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"rule_id", "tags"}) + } else { + return err + } + + hasInvalidField := false + o.RuleId = all.RuleId + if all.Tags != nil && all.Tags.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Tags = all.Tags + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_application_security_waf_exclusion_filter_rules_target_tags.go b/api/datadogV2/model_application_security_waf_exclusion_filter_rules_target_tags.go new file mode 100644 index 00000000000..ac7216a7569 --- /dev/null +++ b/api/datadogV2/model_application_security_waf_exclusion_filter_rules_target_tags.go @@ -0,0 +1,137 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// ApplicationSecurityWafExclusionFilterRulesTargetTags Target multiple WAF rules based on their tags. +type ApplicationSecurityWafExclusionFilterRulesTargetTags struct { + // The category of the targeted WAF rules. + Category *string `json:"category,omitempty"` + // The type of the targeted WAF rules. + Type *string `json:"type,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]string `json:"-"` +} + +// NewApplicationSecurityWafExclusionFilterRulesTargetTags instantiates a new ApplicationSecurityWafExclusionFilterRulesTargetTags object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewApplicationSecurityWafExclusionFilterRulesTargetTags() *ApplicationSecurityWafExclusionFilterRulesTargetTags { + this := ApplicationSecurityWafExclusionFilterRulesTargetTags{} + return &this +} + +// NewApplicationSecurityWafExclusionFilterRulesTargetTagsWithDefaults instantiates a new ApplicationSecurityWafExclusionFilterRulesTargetTags object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewApplicationSecurityWafExclusionFilterRulesTargetTagsWithDefaults() *ApplicationSecurityWafExclusionFilterRulesTargetTags { + this := ApplicationSecurityWafExclusionFilterRulesTargetTags{} + return &this +} + +// GetCategory returns the Category field value if set, zero value otherwise. +func (o *ApplicationSecurityWafExclusionFilterRulesTargetTags) GetCategory() string { + if o == nil || o.Category == nil { + var ret string + return ret + } + return *o.Category +} + +// GetCategoryOk returns a tuple with the Category field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafExclusionFilterRulesTargetTags) GetCategoryOk() (*string, bool) { + if o == nil || o.Category == nil { + return nil, false + } + return o.Category, true +} + +// HasCategory returns a boolean if a field has been set. +func (o *ApplicationSecurityWafExclusionFilterRulesTargetTags) HasCategory() bool { + return o != nil && o.Category != nil +} + +// SetCategory gets a reference to the given string and assigns it to the Category field. +func (o *ApplicationSecurityWafExclusionFilterRulesTargetTags) SetCategory(v string) { + o.Category = &v +} + +// GetType returns the Type field value if set, zero value otherwise. +func (o *ApplicationSecurityWafExclusionFilterRulesTargetTags) GetType() string { + if o == nil || o.Type == nil { + var ret string + return ret + } + return *o.Type +} + +// GetTypeOk returns a tuple with the Type field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafExclusionFilterRulesTargetTags) GetTypeOk() (*string, bool) { + if o == nil || o.Type == nil { + return nil, false + } + return o.Type, true +} + +// HasType returns a boolean if a field has been set. +func (o *ApplicationSecurityWafExclusionFilterRulesTargetTags) HasType() bool { + return o != nil && o.Type != nil +} + +// SetType gets a reference to the given string and assigns it to the Type field. +func (o *ApplicationSecurityWafExclusionFilterRulesTargetTags) SetType(v string) { + o.Type = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ApplicationSecurityWafExclusionFilterRulesTargetTags) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Category != nil { + toSerialize["category"] = o.Category + } + if o.Type != nil { + toSerialize["type"] = o.Type + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *ApplicationSecurityWafExclusionFilterRulesTargetTags) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Category *string `json:"category,omitempty"` + Type *string `json:"type,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]string) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"category", "type"}) + } else { + return err + } + o.Category = all.Category + o.Type = all.Type + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_application_security_waf_exclusion_filter_scope.go b/api/datadogV2/model_application_security_waf_exclusion_filter_scope.go new file mode 100644 index 00000000000..e3f868d0d46 --- /dev/null +++ b/api/datadogV2/model_application_security_waf_exclusion_filter_scope.go @@ -0,0 +1,137 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// ApplicationSecurityWafExclusionFilterScope Deploy on services based on their environment and/or service name. +type ApplicationSecurityWafExclusionFilterScope struct { + // Deploy on this environment. + Env *string `json:"env,omitempty"` + // Deploy on this service. + Service *string `json:"service,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewApplicationSecurityWafExclusionFilterScope instantiates a new ApplicationSecurityWafExclusionFilterScope object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewApplicationSecurityWafExclusionFilterScope() *ApplicationSecurityWafExclusionFilterScope { + this := ApplicationSecurityWafExclusionFilterScope{} + return &this +} + +// NewApplicationSecurityWafExclusionFilterScopeWithDefaults instantiates a new ApplicationSecurityWafExclusionFilterScope object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewApplicationSecurityWafExclusionFilterScopeWithDefaults() *ApplicationSecurityWafExclusionFilterScope { + this := ApplicationSecurityWafExclusionFilterScope{} + return &this +} + +// GetEnv returns the Env field value if set, zero value otherwise. +func (o *ApplicationSecurityWafExclusionFilterScope) GetEnv() string { + if o == nil || o.Env == nil { + var ret string + return ret + } + return *o.Env +} + +// GetEnvOk returns a tuple with the Env field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafExclusionFilterScope) GetEnvOk() (*string, bool) { + if o == nil || o.Env == nil { + return nil, false + } + return o.Env, true +} + +// HasEnv returns a boolean if a field has been set. +func (o *ApplicationSecurityWafExclusionFilterScope) HasEnv() bool { + return o != nil && o.Env != nil +} + +// SetEnv gets a reference to the given string and assigns it to the Env field. +func (o *ApplicationSecurityWafExclusionFilterScope) SetEnv(v string) { + o.Env = &v +} + +// GetService returns the Service field value if set, zero value otherwise. +func (o *ApplicationSecurityWafExclusionFilterScope) GetService() string { + if o == nil || o.Service == nil { + var ret string + return ret + } + return *o.Service +} + +// GetServiceOk returns a tuple with the Service field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafExclusionFilterScope) GetServiceOk() (*string, bool) { + if o == nil || o.Service == nil { + return nil, false + } + return o.Service, true +} + +// HasService returns a boolean if a field has been set. +func (o *ApplicationSecurityWafExclusionFilterScope) HasService() bool { + return o != nil && o.Service != nil +} + +// SetService gets a reference to the given string and assigns it to the Service field. +func (o *ApplicationSecurityWafExclusionFilterScope) SetService(v string) { + o.Service = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ApplicationSecurityWafExclusionFilterScope) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Env != nil { + toSerialize["env"] = o.Env + } + if o.Service != nil { + toSerialize["service"] = o.Service + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *ApplicationSecurityWafExclusionFilterScope) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Env *string `json:"env,omitempty"` + Service *string `json:"service,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"env", "service"}) + } else { + return err + } + o.Env = all.Env + o.Service = all.Service + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_application_security_waf_exclusion_filter_type.go b/api/datadogV2/model_application_security_waf_exclusion_filter_type.go new file mode 100644 index 00000000000..3aa03e3051f --- /dev/null +++ b/api/datadogV2/model_application_security_waf_exclusion_filter_type.go @@ -0,0 +1,64 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// ApplicationSecurityWafExclusionFilterType Type of the resource. The value should always be `exclusion_filter`. +type ApplicationSecurityWafExclusionFilterType string + +// List of ApplicationSecurityWafExclusionFilterType. +const ( + APPLICATIONSECURITYWAFEXCLUSIONFILTERTYPE_EXCLUSION_FILTER ApplicationSecurityWafExclusionFilterType = "exclusion_filter" +) + +var allowedApplicationSecurityWafExclusionFilterTypeEnumValues = []ApplicationSecurityWafExclusionFilterType{ + APPLICATIONSECURITYWAFEXCLUSIONFILTERTYPE_EXCLUSION_FILTER, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *ApplicationSecurityWafExclusionFilterType) GetAllowedValues() []ApplicationSecurityWafExclusionFilterType { + return allowedApplicationSecurityWafExclusionFilterTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *ApplicationSecurityWafExclusionFilterType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = ApplicationSecurityWafExclusionFilterType(value) + return nil +} + +// NewApplicationSecurityWafExclusionFilterTypeFromValue returns a pointer to a valid ApplicationSecurityWafExclusionFilterType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewApplicationSecurityWafExclusionFilterTypeFromValue(v string) (*ApplicationSecurityWafExclusionFilterType, error) { + ev := ApplicationSecurityWafExclusionFilterType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for ApplicationSecurityWafExclusionFilterType: valid values are %v", v, allowedApplicationSecurityWafExclusionFilterTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v ApplicationSecurityWafExclusionFilterType) IsValid() bool { + for _, existing := range allowedApplicationSecurityWafExclusionFilterTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to ApplicationSecurityWafExclusionFilterType value. +func (v ApplicationSecurityWafExclusionFilterType) Ptr() *ApplicationSecurityWafExclusionFilterType { + return &v +} diff --git a/api/datadogV2/model_application_security_waf_exclusion_filter_update_attributes.go b/api/datadogV2/model_application_security_waf_exclusion_filter_update_attributes.go new file mode 100644 index 00000000000..5e3688d9728 --- /dev/null +++ b/api/datadogV2/model_application_security_waf_exclusion_filter_update_attributes.go @@ -0,0 +1,353 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// ApplicationSecurityWafExclusionFilterUpdateAttributes Attributes for updating a WAF exclusion filter. +type ApplicationSecurityWafExclusionFilterUpdateAttributes struct { + // A description for the exclusion filter. + Description string `json:"description"` + // Indicates whether the exclusion filter is enabled. + Enabled bool `json:"enabled"` + // The client IP addresses matched by the exclusion filter (CIDR notation is supported). + IpList []string `json:"ip_list,omitempty"` + // The action taken when the exclusion filter matches. When set to `monitor`, security traces are emitted but the requests are not blocked. By default, security traces are not emitted and the requests are not blocked. + OnMatch *ApplicationSecurityWafExclusionFilterOnMatch `json:"on_match,omitempty"` + // A list of parameters matched by the exclusion filter in the HTTP query string and HTTP request body. Nested parameters can be matched by joining fields with a dot character. + Parameters []string `json:"parameters,omitempty"` + // The HTTP path glob expression matched by the exclusion filter. + PathGlob *string `json:"path_glob,omitempty"` + // The WAF rules targeted by the exclusion filter. + RulesTarget []ApplicationSecurityWafExclusionFilterRulesTarget `json:"rules_target,omitempty"` + // The services where the exclusion filter is deployed. + Scope []ApplicationSecurityWafExclusionFilterScope `json:"scope,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewApplicationSecurityWafExclusionFilterUpdateAttributes instantiates a new ApplicationSecurityWafExclusionFilterUpdateAttributes object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewApplicationSecurityWafExclusionFilterUpdateAttributes(description string, enabled bool) *ApplicationSecurityWafExclusionFilterUpdateAttributes { + this := ApplicationSecurityWafExclusionFilterUpdateAttributes{} + this.Description = description + this.Enabled = enabled + return &this +} + +// NewApplicationSecurityWafExclusionFilterUpdateAttributesWithDefaults instantiates a new ApplicationSecurityWafExclusionFilterUpdateAttributes object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewApplicationSecurityWafExclusionFilterUpdateAttributesWithDefaults() *ApplicationSecurityWafExclusionFilterUpdateAttributes { + this := ApplicationSecurityWafExclusionFilterUpdateAttributes{} + return &this +} + +// GetDescription returns the Description field value. +func (o *ApplicationSecurityWafExclusionFilterUpdateAttributes) GetDescription() string { + if o == nil { + var ret string + return ret + } + return o.Description +} + +// GetDescriptionOk returns a tuple with the Description field value +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafExclusionFilterUpdateAttributes) GetDescriptionOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Description, true +} + +// SetDescription sets field value. +func (o *ApplicationSecurityWafExclusionFilterUpdateAttributes) SetDescription(v string) { + o.Description = v +} + +// GetEnabled returns the Enabled field value. +func (o *ApplicationSecurityWafExclusionFilterUpdateAttributes) GetEnabled() bool { + if o == nil { + var ret bool + return ret + } + return o.Enabled +} + +// GetEnabledOk returns a tuple with the Enabled field value +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafExclusionFilterUpdateAttributes) GetEnabledOk() (*bool, bool) { + if o == nil { + return nil, false + } + return &o.Enabled, true +} + +// SetEnabled sets field value. +func (o *ApplicationSecurityWafExclusionFilterUpdateAttributes) SetEnabled(v bool) { + o.Enabled = v +} + +// GetIpList returns the IpList field value if set, zero value otherwise. +func (o *ApplicationSecurityWafExclusionFilterUpdateAttributes) GetIpList() []string { + if o == nil || o.IpList == nil { + var ret []string + return ret + } + return o.IpList +} + +// GetIpListOk returns a tuple with the IpList field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafExclusionFilterUpdateAttributes) GetIpListOk() (*[]string, bool) { + if o == nil || o.IpList == nil { + return nil, false + } + return &o.IpList, true +} + +// HasIpList returns a boolean if a field has been set. +func (o *ApplicationSecurityWafExclusionFilterUpdateAttributes) HasIpList() bool { + return o != nil && o.IpList != nil +} + +// SetIpList gets a reference to the given []string and assigns it to the IpList field. +func (o *ApplicationSecurityWafExclusionFilterUpdateAttributes) SetIpList(v []string) { + o.IpList = v +} + +// GetOnMatch returns the OnMatch field value if set, zero value otherwise. +func (o *ApplicationSecurityWafExclusionFilterUpdateAttributes) GetOnMatch() ApplicationSecurityWafExclusionFilterOnMatch { + if o == nil || o.OnMatch == nil { + var ret ApplicationSecurityWafExclusionFilterOnMatch + return ret + } + return *o.OnMatch +} + +// GetOnMatchOk returns a tuple with the OnMatch field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafExclusionFilterUpdateAttributes) GetOnMatchOk() (*ApplicationSecurityWafExclusionFilterOnMatch, bool) { + if o == nil || o.OnMatch == nil { + return nil, false + } + return o.OnMatch, true +} + +// HasOnMatch returns a boolean if a field has been set. +func (o *ApplicationSecurityWafExclusionFilterUpdateAttributes) HasOnMatch() bool { + return o != nil && o.OnMatch != nil +} + +// SetOnMatch gets a reference to the given ApplicationSecurityWafExclusionFilterOnMatch and assigns it to the OnMatch field. +func (o *ApplicationSecurityWafExclusionFilterUpdateAttributes) SetOnMatch(v ApplicationSecurityWafExclusionFilterOnMatch) { + o.OnMatch = &v +} + +// GetParameters returns the Parameters field value if set, zero value otherwise. +func (o *ApplicationSecurityWafExclusionFilterUpdateAttributes) GetParameters() []string { + if o == nil || o.Parameters == nil { + var ret []string + return ret + } + return o.Parameters +} + +// GetParametersOk returns a tuple with the Parameters field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafExclusionFilterUpdateAttributes) GetParametersOk() (*[]string, bool) { + if o == nil || o.Parameters == nil { + return nil, false + } + return &o.Parameters, true +} + +// HasParameters returns a boolean if a field has been set. +func (o *ApplicationSecurityWafExclusionFilterUpdateAttributes) HasParameters() bool { + return o != nil && o.Parameters != nil +} + +// SetParameters gets a reference to the given []string and assigns it to the Parameters field. +func (o *ApplicationSecurityWafExclusionFilterUpdateAttributes) SetParameters(v []string) { + o.Parameters = v +} + +// GetPathGlob returns the PathGlob field value if set, zero value otherwise. +func (o *ApplicationSecurityWafExclusionFilterUpdateAttributes) GetPathGlob() string { + if o == nil || o.PathGlob == nil { + var ret string + return ret + } + return *o.PathGlob +} + +// GetPathGlobOk returns a tuple with the PathGlob field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafExclusionFilterUpdateAttributes) GetPathGlobOk() (*string, bool) { + if o == nil || o.PathGlob == nil { + return nil, false + } + return o.PathGlob, true +} + +// HasPathGlob returns a boolean if a field has been set. +func (o *ApplicationSecurityWafExclusionFilterUpdateAttributes) HasPathGlob() bool { + return o != nil && o.PathGlob != nil +} + +// SetPathGlob gets a reference to the given string and assigns it to the PathGlob field. +func (o *ApplicationSecurityWafExclusionFilterUpdateAttributes) SetPathGlob(v string) { + o.PathGlob = &v +} + +// GetRulesTarget returns the RulesTarget field value if set, zero value otherwise. +func (o *ApplicationSecurityWafExclusionFilterUpdateAttributes) GetRulesTarget() []ApplicationSecurityWafExclusionFilterRulesTarget { + if o == nil || o.RulesTarget == nil { + var ret []ApplicationSecurityWafExclusionFilterRulesTarget + return ret + } + return o.RulesTarget +} + +// GetRulesTargetOk returns a tuple with the RulesTarget field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafExclusionFilterUpdateAttributes) GetRulesTargetOk() (*[]ApplicationSecurityWafExclusionFilterRulesTarget, bool) { + if o == nil || o.RulesTarget == nil { + return nil, false + } + return &o.RulesTarget, true +} + +// HasRulesTarget returns a boolean if a field has been set. +func (o *ApplicationSecurityWafExclusionFilterUpdateAttributes) HasRulesTarget() bool { + return o != nil && o.RulesTarget != nil +} + +// SetRulesTarget gets a reference to the given []ApplicationSecurityWafExclusionFilterRulesTarget and assigns it to the RulesTarget field. +func (o *ApplicationSecurityWafExclusionFilterUpdateAttributes) SetRulesTarget(v []ApplicationSecurityWafExclusionFilterRulesTarget) { + o.RulesTarget = v +} + +// GetScope returns the Scope field value if set, zero value otherwise. +func (o *ApplicationSecurityWafExclusionFilterUpdateAttributes) GetScope() []ApplicationSecurityWafExclusionFilterScope { + if o == nil || o.Scope == nil { + var ret []ApplicationSecurityWafExclusionFilterScope + return ret + } + return o.Scope +} + +// GetScopeOk returns a tuple with the Scope field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafExclusionFilterUpdateAttributes) GetScopeOk() (*[]ApplicationSecurityWafExclusionFilterScope, bool) { + if o == nil || o.Scope == nil { + return nil, false + } + return &o.Scope, true +} + +// HasScope returns a boolean if a field has been set. +func (o *ApplicationSecurityWafExclusionFilterUpdateAttributes) HasScope() bool { + return o != nil && o.Scope != nil +} + +// SetScope gets a reference to the given []ApplicationSecurityWafExclusionFilterScope and assigns it to the Scope field. +func (o *ApplicationSecurityWafExclusionFilterUpdateAttributes) SetScope(v []ApplicationSecurityWafExclusionFilterScope) { + o.Scope = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ApplicationSecurityWafExclusionFilterUpdateAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["description"] = o.Description + toSerialize["enabled"] = o.Enabled + if o.IpList != nil { + toSerialize["ip_list"] = o.IpList + } + if o.OnMatch != nil { + toSerialize["on_match"] = o.OnMatch + } + if o.Parameters != nil { + toSerialize["parameters"] = o.Parameters + } + if o.PathGlob != nil { + toSerialize["path_glob"] = o.PathGlob + } + if o.RulesTarget != nil { + toSerialize["rules_target"] = o.RulesTarget + } + if o.Scope != nil { + toSerialize["scope"] = o.Scope + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *ApplicationSecurityWafExclusionFilterUpdateAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Description *string `json:"description"` + Enabled *bool `json:"enabled"` + IpList []string `json:"ip_list,omitempty"` + OnMatch *ApplicationSecurityWafExclusionFilterOnMatch `json:"on_match,omitempty"` + Parameters []string `json:"parameters,omitempty"` + PathGlob *string `json:"path_glob,omitempty"` + RulesTarget []ApplicationSecurityWafExclusionFilterRulesTarget `json:"rules_target,omitempty"` + Scope []ApplicationSecurityWafExclusionFilterScope `json:"scope,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Description == nil { + return fmt.Errorf("required field description missing") + } + if all.Enabled == nil { + return fmt.Errorf("required field enabled missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"description", "enabled", "ip_list", "on_match", "parameters", "path_glob", "rules_target", "scope"}) + } else { + return err + } + + hasInvalidField := false + o.Description = *all.Description + o.Enabled = *all.Enabled + o.IpList = all.IpList + if all.OnMatch != nil && !all.OnMatch.IsValid() { + hasInvalidField = true + } else { + o.OnMatch = all.OnMatch + } + o.Parameters = all.Parameters + o.PathGlob = all.PathGlob + o.RulesTarget = all.RulesTarget + o.Scope = all.Scope + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_application_security_waf_exclusion_filter_update_data.go b/api/datadogV2/model_application_security_waf_exclusion_filter_update_data.go new file mode 100644 index 00000000000..e6eebc5222d --- /dev/null +++ b/api/datadogV2/model_application_security_waf_exclusion_filter_update_data.go @@ -0,0 +1,148 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// ApplicationSecurityWafExclusionFilterUpdateData Object for updating a single WAF exclusion filter. +type ApplicationSecurityWafExclusionFilterUpdateData struct { + // Attributes for updating a WAF exclusion filter. + Attributes ApplicationSecurityWafExclusionFilterUpdateAttributes `json:"attributes"` + // Type of the resource. The value should always be `exclusion_filter`. + Type ApplicationSecurityWafExclusionFilterType `json:"type"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewApplicationSecurityWafExclusionFilterUpdateData instantiates a new ApplicationSecurityWafExclusionFilterUpdateData object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewApplicationSecurityWafExclusionFilterUpdateData(attributes ApplicationSecurityWafExclusionFilterUpdateAttributes, typeVar ApplicationSecurityWafExclusionFilterType) *ApplicationSecurityWafExclusionFilterUpdateData { + this := ApplicationSecurityWafExclusionFilterUpdateData{} + this.Attributes = attributes + this.Type = typeVar + return &this +} + +// NewApplicationSecurityWafExclusionFilterUpdateDataWithDefaults instantiates a new ApplicationSecurityWafExclusionFilterUpdateData object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewApplicationSecurityWafExclusionFilterUpdateDataWithDefaults() *ApplicationSecurityWafExclusionFilterUpdateData { + this := ApplicationSecurityWafExclusionFilterUpdateData{} + var typeVar ApplicationSecurityWafExclusionFilterType = APPLICATIONSECURITYWAFEXCLUSIONFILTERTYPE_EXCLUSION_FILTER + this.Type = typeVar + return &this +} + +// GetAttributes returns the Attributes field value. +func (o *ApplicationSecurityWafExclusionFilterUpdateData) GetAttributes() ApplicationSecurityWafExclusionFilterUpdateAttributes { + if o == nil { + var ret ApplicationSecurityWafExclusionFilterUpdateAttributes + return ret + } + return o.Attributes +} + +// GetAttributesOk returns a tuple with the Attributes field value +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafExclusionFilterUpdateData) GetAttributesOk() (*ApplicationSecurityWafExclusionFilterUpdateAttributes, bool) { + if o == nil { + return nil, false + } + return &o.Attributes, true +} + +// SetAttributes sets field value. +func (o *ApplicationSecurityWafExclusionFilterUpdateData) SetAttributes(v ApplicationSecurityWafExclusionFilterUpdateAttributes) { + o.Attributes = v +} + +// GetType returns the Type field value. +func (o *ApplicationSecurityWafExclusionFilterUpdateData) GetType() ApplicationSecurityWafExclusionFilterType { + if o == nil { + var ret ApplicationSecurityWafExclusionFilterType + return ret + } + return o.Type +} + +// GetTypeOk returns a tuple with the Type field value +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafExclusionFilterUpdateData) GetTypeOk() (*ApplicationSecurityWafExclusionFilterType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *ApplicationSecurityWafExclusionFilterUpdateData) SetType(v ApplicationSecurityWafExclusionFilterType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ApplicationSecurityWafExclusionFilterUpdateData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["attributes"] = o.Attributes + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *ApplicationSecurityWafExclusionFilterUpdateData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *ApplicationSecurityWafExclusionFilterUpdateAttributes `json:"attributes"` + Type *ApplicationSecurityWafExclusionFilterType `json:"type"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Attributes == nil { + return fmt.Errorf("required field attributes missing") + } + if all.Type == nil { + return fmt.Errorf("required field type missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"attributes", "type"}) + } else { + return err + } + + hasInvalidField := false + if all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Attributes = *all.Attributes + if !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = *all.Type + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_application_security_waf_exclusion_filter_update_request.go b/api/datadogV2/model_application_security_waf_exclusion_filter_update_request.go new file mode 100644 index 00000000000..6c38ed3c02f --- /dev/null +++ b/api/datadogV2/model_application_security_waf_exclusion_filter_update_request.go @@ -0,0 +1,110 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// ApplicationSecurityWafExclusionFilterUpdateRequest Request object for updating a single WAF exclusion filter. +type ApplicationSecurityWafExclusionFilterUpdateRequest struct { + // Object for updating a single WAF exclusion filter. + Data ApplicationSecurityWafExclusionFilterUpdateData `json:"data"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewApplicationSecurityWafExclusionFilterUpdateRequest instantiates a new ApplicationSecurityWafExclusionFilterUpdateRequest object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewApplicationSecurityWafExclusionFilterUpdateRequest(data ApplicationSecurityWafExclusionFilterUpdateData) *ApplicationSecurityWafExclusionFilterUpdateRequest { + this := ApplicationSecurityWafExclusionFilterUpdateRequest{} + this.Data = data + return &this +} + +// NewApplicationSecurityWafExclusionFilterUpdateRequestWithDefaults instantiates a new ApplicationSecurityWafExclusionFilterUpdateRequest object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewApplicationSecurityWafExclusionFilterUpdateRequestWithDefaults() *ApplicationSecurityWafExclusionFilterUpdateRequest { + this := ApplicationSecurityWafExclusionFilterUpdateRequest{} + return &this +} + +// GetData returns the Data field value. +func (o *ApplicationSecurityWafExclusionFilterUpdateRequest) GetData() ApplicationSecurityWafExclusionFilterUpdateData { + if o == nil { + var ret ApplicationSecurityWafExclusionFilterUpdateData + return ret + } + return o.Data +} + +// GetDataOk returns a tuple with the Data field value +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafExclusionFilterUpdateRequest) GetDataOk() (*ApplicationSecurityWafExclusionFilterUpdateData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *ApplicationSecurityWafExclusionFilterUpdateRequest) SetData(v ApplicationSecurityWafExclusionFilterUpdateData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ApplicationSecurityWafExclusionFilterUpdateRequest) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["data"] = o.Data + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *ApplicationSecurityWafExclusionFilterUpdateRequest) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *ApplicationSecurityWafExclusionFilterUpdateData `json:"data"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + if all.Data == nil { + return fmt.Errorf("required field data missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + + hasInvalidField := false + if all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Data = *all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_application_security_waf_exclusion_filters_response.go b/api/datadogV2/model_application_security_waf_exclusion_filters_response.go new file mode 100644 index 00000000000..5505ca89065 --- /dev/null +++ b/api/datadogV2/model_application_security_waf_exclusion_filters_response.go @@ -0,0 +1,102 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// ApplicationSecurityWafExclusionFiltersResponse Response object for multiple WAF exclusion filters. +type ApplicationSecurityWafExclusionFiltersResponse struct { + // A list of WAF exclusion filters. + Data []ApplicationSecurityWafExclusionFilterResource `json:"data,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewApplicationSecurityWafExclusionFiltersResponse instantiates a new ApplicationSecurityWafExclusionFiltersResponse object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewApplicationSecurityWafExclusionFiltersResponse() *ApplicationSecurityWafExclusionFiltersResponse { + this := ApplicationSecurityWafExclusionFiltersResponse{} + return &this +} + +// NewApplicationSecurityWafExclusionFiltersResponseWithDefaults instantiates a new ApplicationSecurityWafExclusionFiltersResponse object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewApplicationSecurityWafExclusionFiltersResponseWithDefaults() *ApplicationSecurityWafExclusionFiltersResponse { + this := ApplicationSecurityWafExclusionFiltersResponse{} + return &this +} + +// GetData returns the Data field value if set, zero value otherwise. +func (o *ApplicationSecurityWafExclusionFiltersResponse) GetData() []ApplicationSecurityWafExclusionFilterResource { + if o == nil || o.Data == nil { + var ret []ApplicationSecurityWafExclusionFilterResource + return ret + } + return o.Data +} + +// GetDataOk returns a tuple with the Data field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ApplicationSecurityWafExclusionFiltersResponse) GetDataOk() (*[]ApplicationSecurityWafExclusionFilterResource, bool) { + if o == nil || o.Data == nil { + return nil, false + } + return &o.Data, true +} + +// HasData returns a boolean if a field has been set. +func (o *ApplicationSecurityWafExclusionFiltersResponse) HasData() bool { + return o != nil && o.Data != nil +} + +// SetData gets a reference to the given []ApplicationSecurityWafExclusionFilterResource and assigns it to the Data field. +func (o *ApplicationSecurityWafExclusionFiltersResponse) SetData(v []ApplicationSecurityWafExclusionFilterResource) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ApplicationSecurityWafExclusionFiltersResponse) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Data != nil { + toSerialize["data"] = o.Data + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *ApplicationSecurityWafExclusionFiltersResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data []ApplicationSecurityWafExclusionFilterResource `json:"data,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + } else { + return err + } + o.Data = all.Data + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/examples/v2/application-security/CreateApplicationSecurityWafCustomRule.go b/examples/v2/application-security/CreateApplicationSecurityWafCustomRule.go new file mode 100644 index 00000000000..822580b6565 --- /dev/null +++ b/examples/v2/application-security/CreateApplicationSecurityWafCustomRule.go @@ -0,0 +1,78 @@ +// Create a WAF custom rule returns "Created" response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + body := datadogV2.ApplicationSecurityWafCustomRuleCreateRequest{ + Data: datadogV2.ApplicationSecurityWafCustomRuleCreateData{ + Attributes: datadogV2.ApplicationSecurityWafCustomRuleCreateAttributes{ + Action: &datadogV2.ApplicationSecurityWafCustomRuleAction{ + Action: datadogV2.APPLICATIONSECURITYWAFCUSTOMRULEACTIONACTION_BLOCK_REQUEST.Ptr(), + Parameters: &datadogV2.ApplicationSecurityWafCustomRuleActionParameters{ + Location: datadog.PtrString("/blocking"), + StatusCode: datadog.PtrInt64(403), + }, + }, + Blocking: false, + Conditions: []datadogV2.ApplicationSecurityWafCustomRuleCondition{ + { + Operator: datadogV2.APPLICATIONSECURITYWAFCUSTOMRULECONDITIONOPERATOR_MATCH_REGEX, + Parameters: datadogV2.ApplicationSecurityWafCustomRuleConditionParameters{ + Data: datadog.PtrString("blocked_users"), + Inputs: []datadogV2.ApplicationSecurityWafCustomRuleConditionInput{ + { + Address: datadogV2.APPLICATIONSECURITYWAFCUSTOMRULECONDITIONINPUTADDRESS_SERVER_DB_STATEMENT, + KeyPath: []string{}, + }, + }, + List: []string{}, + Options: &datadogV2.ApplicationSecurityWafCustomRuleConditionOptions{ + CaseSensitive: datadog.PtrBool(false), + MinLength: datadog.PtrInt64(0), + }, + Regex: datadog.PtrString("path.*"), + Value: datadog.PtrString("custom_tag"), + }, + }, + }, + Enabled: false, + Name: "Block request from a bad useragent", + PathGlob: datadog.PtrString("/api/search/*"), + Scope: []datadogV2.ApplicationSecurityWafCustomRuleScope{ + { + Env: "prod", + Service: "billing-service", + }, + }, + Tags: datadogV2.ApplicationSecurityWafCustomRuleTags{ + Category: datadogV2.APPLICATIONSECURITYWAFCUSTOMRULETAGSCATEGORY_BUSINESS_LOGIC, + Type: "users.login.success", + }, + }, + Type: datadogV2.APPLICATIONSECURITYWAFCUSTOMRULETYPE_CUSTOM_RULE, + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewApplicationSecurityApi(apiClient) + resp, r, err := api.CreateApplicationSecurityWafCustomRule(ctx, body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `ApplicationSecurityApi.CreateApplicationSecurityWafCustomRule`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `ApplicationSecurityApi.CreateApplicationSecurityWafCustomRule`:\n%s\n", responseContent) +} diff --git a/examples/v2/application-security/CreateApplicationSecurityWafExclusionFilter.go b/examples/v2/application-security/CreateApplicationSecurityWafExclusionFilter.go new file mode 100644 index 00000000000..ab52788aa06 --- /dev/null +++ b/examples/v2/application-security/CreateApplicationSecurityWafExclusionFilter.go @@ -0,0 +1,56 @@ +// Create a WAF exclusion filter returns "OK" response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + body := datadogV2.ApplicationSecurityWafExclusionFilterCreateRequest{ + Data: datadogV2.ApplicationSecurityWafExclusionFilterCreateData{ + Attributes: datadogV2.ApplicationSecurityWafExclusionFilterCreateAttributes{ + Description: "Exclude false positives on a path", + Enabled: true, + Parameters: []string{ + "list.search.query", + }, + PathGlob: datadog.PtrString("/accounts/*"), + RulesTarget: []datadogV2.ApplicationSecurityWafExclusionFilterRulesTarget{ + { + Tags: &datadogV2.ApplicationSecurityWafExclusionFilterRulesTargetTags{ + Category: datadog.PtrString("attack_attempt"), + Type: datadog.PtrString("lfi"), + }, + }, + }, + Scope: []datadogV2.ApplicationSecurityWafExclusionFilterScope{ + { + Env: datadog.PtrString("www"), + Service: datadog.PtrString("prod"), + }, + }, + }, + Type: datadogV2.APPLICATIONSECURITYWAFEXCLUSIONFILTERTYPE_EXCLUSION_FILTER, + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewApplicationSecurityApi(apiClient) + resp, r, err := api.CreateApplicationSecurityWafExclusionFilter(ctx, body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `ApplicationSecurityApi.CreateApplicationSecurityWafExclusionFilter`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `ApplicationSecurityApi.CreateApplicationSecurityWafExclusionFilter`:\n%s\n", responseContent) +} diff --git a/examples/v2/application-security/DeleteApplicationSecurityWafCustomRule.go b/examples/v2/application-security/DeleteApplicationSecurityWafCustomRule.go new file mode 100644 index 00000000000..45629247213 --- /dev/null +++ b/examples/v2/application-security/DeleteApplicationSecurityWafCustomRule.go @@ -0,0 +1,25 @@ +// Delete a WAF Custom Rule returns "No Content" response + +package main + +import ( + "context" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewApplicationSecurityApi(apiClient) + r, err := api.DeleteApplicationSecurityWafCustomRule(ctx, "custom_rule_id") + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `ApplicationSecurityApi.DeleteApplicationSecurityWafCustomRule`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } +} diff --git a/examples/v2/application-security/DeleteApplicationSecurityWafExclusionFilter.go b/examples/v2/application-security/DeleteApplicationSecurityWafExclusionFilter.go new file mode 100644 index 00000000000..0544af2213d --- /dev/null +++ b/examples/v2/application-security/DeleteApplicationSecurityWafExclusionFilter.go @@ -0,0 +1,28 @@ +// Delete a WAF exclusion filter returns "OK" response + +package main + +import ( + "context" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + // there is a valid "exclusion_filter" in the system + ExclusionFilterDataID := os.Getenv("EXCLUSION_FILTER_DATA_ID") + + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewApplicationSecurityApi(apiClient) + r, err := api.DeleteApplicationSecurityWafExclusionFilter(ctx, ExclusionFilterDataID) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `ApplicationSecurityApi.DeleteApplicationSecurityWafExclusionFilter`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } +} diff --git a/examples/v2/application-security/GetApplicationSecurityWafCustomRule.go b/examples/v2/application-security/GetApplicationSecurityWafCustomRule.go new file mode 100644 index 00000000000..68e8efa2062 --- /dev/null +++ b/examples/v2/application-security/GetApplicationSecurityWafCustomRule.go @@ -0,0 +1,29 @@ +// Get a WAF custom rule returns "OK" response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewApplicationSecurityApi(apiClient) + resp, r, err := api.GetApplicationSecurityWafCustomRule(ctx, "custom_rule_id") + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `ApplicationSecurityApi.GetApplicationSecurityWafCustomRule`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `ApplicationSecurityApi.GetApplicationSecurityWafCustomRule`:\n%s\n", responseContent) +} diff --git a/examples/v2/application-security/GetApplicationSecurityWafExclusionFilter.go b/examples/v2/application-security/GetApplicationSecurityWafExclusionFilter.go new file mode 100644 index 00000000000..2fecdceb94b --- /dev/null +++ b/examples/v2/application-security/GetApplicationSecurityWafExclusionFilter.go @@ -0,0 +1,32 @@ +// Get a WAF exclusion filter returns "OK" response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + // there is a valid "exclusion_filter" in the system + ExclusionFilterDataID := os.Getenv("EXCLUSION_FILTER_DATA_ID") + + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewApplicationSecurityApi(apiClient) + resp, r, err := api.GetApplicationSecurityWafExclusionFilter(ctx, ExclusionFilterDataID) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `ApplicationSecurityApi.GetApplicationSecurityWafExclusionFilter`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `ApplicationSecurityApi.GetApplicationSecurityWafExclusionFilter`:\n%s\n", responseContent) +} diff --git a/examples/v2/application-security/ListApplicationSecurityWAFCustomRules.go b/examples/v2/application-security/ListApplicationSecurityWAFCustomRules.go new file mode 100644 index 00000000000..0b9bbe11607 --- /dev/null +++ b/examples/v2/application-security/ListApplicationSecurityWAFCustomRules.go @@ -0,0 +1,29 @@ +// List all WAF custom rules returns "OK" response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewApplicationSecurityApi(apiClient) + resp, r, err := api.ListApplicationSecurityWAFCustomRules(ctx) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `ApplicationSecurityApi.ListApplicationSecurityWAFCustomRules`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `ApplicationSecurityApi.ListApplicationSecurityWAFCustomRules`:\n%s\n", responseContent) +} diff --git a/examples/v2/application-security/ListApplicationSecurityWafExclusionFilters.go b/examples/v2/application-security/ListApplicationSecurityWafExclusionFilters.go new file mode 100644 index 00000000000..3a7c20bd27f --- /dev/null +++ b/examples/v2/application-security/ListApplicationSecurityWafExclusionFilters.go @@ -0,0 +1,29 @@ +// List all WAF exclusion filters returns "OK" response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewApplicationSecurityApi(apiClient) + resp, r, err := api.ListApplicationSecurityWafExclusionFilters(ctx) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `ApplicationSecurityApi.ListApplicationSecurityWafExclusionFilters`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `ApplicationSecurityApi.ListApplicationSecurityWafExclusionFilters`:\n%s\n", responseContent) +} diff --git a/examples/v2/application-security/UpdateApplicationSecurityWafCustomRule.go b/examples/v2/application-security/UpdateApplicationSecurityWafCustomRule.go new file mode 100644 index 00000000000..e1e2cca6ea9 --- /dev/null +++ b/examples/v2/application-security/UpdateApplicationSecurityWafCustomRule.go @@ -0,0 +1,69 @@ +// Update a WAF Custom Rule returns "OK" response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + // there is a valid "custom_rule" in the system + CustomRuleDataID := os.Getenv("CUSTOM_RULE_DATA_ID") + + body := datadogV2.ApplicationSecurityWafCustomRuleUpdateRequest{ + Data: datadogV2.ApplicationSecurityWafCustomRuleUpdateData{ + Type: datadogV2.APPLICATIONSECURITYWAFCUSTOMRULETYPE_CUSTOM_RULE, + Attributes: datadogV2.ApplicationSecurityWafCustomRuleUpdateAttributes{ + Blocking: false, + Conditions: []datadogV2.ApplicationSecurityWafCustomRuleCondition{ + { + Operator: datadogV2.APPLICATIONSECURITYWAFCUSTOMRULECONDITIONOPERATOR_MATCH_REGEX, + Parameters: datadogV2.ApplicationSecurityWafCustomRuleConditionParameters{ + Inputs: []datadogV2.ApplicationSecurityWafCustomRuleConditionInput{ + { + Address: datadogV2.APPLICATIONSECURITYWAFCUSTOMRULECONDITIONINPUTADDRESS_SERVER_REQUEST_QUERY, + KeyPath: []string{ + "id", + }, + }, + }, + Regex: datadog.PtrString("badactor"), + }, + }, + }, + Enabled: false, + Name: "test", + PathGlob: datadog.PtrString("/test"), + Scope: []datadogV2.ApplicationSecurityWafCustomRuleScope{ + { + Env: "test", + Service: "test", + }, + }, + Tags: datadogV2.ApplicationSecurityWafCustomRuleTags{ + Category: datadogV2.APPLICATIONSECURITYWAFCUSTOMRULETAGSCATEGORY_ATTACK_ATTEMPT, + Type: "test", + }, + }, + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewApplicationSecurityApi(apiClient) + resp, r, err := api.UpdateApplicationSecurityWafCustomRule(ctx, CustomRuleDataID, body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `ApplicationSecurityApi.UpdateApplicationSecurityWafCustomRule`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `ApplicationSecurityApi.UpdateApplicationSecurityWafCustomRule`:\n%s\n", responseContent) +} diff --git a/examples/v2/application-security/UpdateApplicationSecurityWafExclusionFilter.go b/examples/v2/application-security/UpdateApplicationSecurityWafExclusionFilter.go new file mode 100644 index 00000000000..efd79795ba1 --- /dev/null +++ b/examples/v2/application-security/UpdateApplicationSecurityWafExclusionFilter.go @@ -0,0 +1,45 @@ +// Update a WAF exclusion filter returns "OK" response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + // there is a valid "exclusion_filter" in the system + ExclusionFilterDataID := os.Getenv("EXCLUSION_FILTER_DATA_ID") + + body := datadogV2.ApplicationSecurityWafExclusionFilterUpdateRequest{ + Data: datadogV2.ApplicationSecurityWafExclusionFilterUpdateData{ + Attributes: datadogV2.ApplicationSecurityWafExclusionFilterUpdateAttributes{ + Description: "Exclude false positives on a path", + Enabled: false, + IpList: []string{ + "198.51.100.72", + }, + OnMatch: datadogV2.APPLICATIONSECURITYWAFEXCLUSIONFILTERONMATCH_MONITOR.Ptr(), + }, + Type: datadogV2.APPLICATIONSECURITYWAFEXCLUSIONFILTERTYPE_EXCLUSION_FILTER, + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewApplicationSecurityApi(apiClient) + resp, r, err := api.UpdateApplicationSecurityWafExclusionFilter(ctx, ExclusionFilterDataID, body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `ApplicationSecurityApi.UpdateApplicationSecurityWafExclusionFilter`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `ApplicationSecurityApi.UpdateApplicationSecurityWafExclusionFilter`:\n%s\n", responseContent) +} diff --git a/tests/scenarios/api_mappings.go b/tests/scenarios/api_mappings.go index a38bab78f8f..5f3217ecad7 100644 --- a/tests/scenarios/api_mappings.go +++ b/tests/scenarios/api_mappings.go @@ -92,6 +92,7 @@ var apiMappings = map[string]map[string]reflect.Value{ "SecurityMonitoringApi": reflect.ValueOf(datadogV2.NewSecurityMonitoringApi), "PowerpackApi": reflect.ValueOf(datadogV2.NewPowerpackApi), "ProcessesApi": reflect.ValueOf(datadogV2.NewProcessesApi), + "ApplicationSecurityApi": reflect.ValueOf(datadogV2.NewApplicationSecurityApi), "CSMThreatsApi": reflect.ValueOf(datadogV2.NewCSMThreatsApi), "RestrictionPoliciesApi": reflect.ValueOf(datadogV2.NewRestrictionPoliciesApi), "RUMApi": reflect.ValueOf(datadogV2.NewRUMApi), diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Application_Security/Scenario_Create_a_WAF_exclusion_filter_returns_OK_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Application_Security/Scenario_Create_a_WAF_exclusion_filter_returns_OK_response.freeze new file mode 100644 index 00000000000..adb04ee8d8c --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Application_Security/Scenario_Create_a_WAF_exclusion_filter_returns_OK_response.freeze @@ -0,0 +1 @@ +2025-02-25T19:11:25.882Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Application_Security/Scenario_Create_a_WAF_exclusion_filter_returns_OK_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Application_Security/Scenario_Create_a_WAF_exclusion_filter_returns_OK_response.yaml new file mode 100644 index 00000000000..d5e05671c0a --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Application_Security/Scenario_Create_a_WAF_exclusion_filter_returns_OK_response.yaml @@ -0,0 +1,49 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"description":"Exclude false positives on a path","enabled":true,"parameters":["list.search.query"],"path_glob":"/accounts/*","rules_target":[{"tags":{"category":"attack_attempt","type":"lfi"}}],"scope":[{"env":"www","service":"prod"}]},"type":"exclusion_filter"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v2/remote_config/products/asm/waf/exclusion_filters + response: + body: '{"data":{"id":"662e28c3-e4fe-42c8-bc93-79b73cd04d48","type":"exclusion_filter","attributes":{"description":"Exclude + false positives on a path","enabled":true,"metadata":{"added_at":"2025-02-25T19:11:26Z","added_by":"9919ec9b-ebc7-49ee-8dc8-03626e717cca","added_by_name":"CI + Account"},"parameters":["list.search.query"],"path_glob":"/accounts/*","rules_target":[{"tags":{"category":"attack_attempt","type":"lfi"}}],"scope":[{"env":"www","service":"prod"}],"search_query":"(env:www + AND service:prod) AND (@http.url_details.path:\\/accounts\\/* OR @rpc.grpc.full_method:\\/accounts\\/*) + AND ((@appsec.triggers.rule_matches.parameters.address:server.request.query + AND (@appsec.triggers.rule_matches.parameters.key:list.search.query OR @appsec.triggers.rule_matches.parameters.params.key:list.search.query)) + OR (@appsec.triggers.rule_matches.parameters.address:server.request.body AND + (@appsec.triggers.rule_matches.parameters.key:list.search.query OR @appsec.triggers.rule_matches.parameters.params.key:list.search.query)) + OR (@appsec.triggers.rule_matches.parameters.address:server.request.path_params + AND (@appsec.triggers.rule_matches.parameters.key:list.search.query OR @appsec.triggers.rule_matches.parameters.params.key:list.search.query))) + AND (@appsec.category:attack_attempt AND @appsec.type:lfi)"}}}' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/json + status: 200 OK +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 1 + method: DELETE + url: https://api.datadoghq.com/api/v2/remote_config/products/asm/waf/exclusion_filters/662e28c3-e4fe-42c8-bc93-79b73cd04d48 + response: + body: '' + code: 204 + duration: 0ms + headers: + Content-Type: + - application/json + status: 204 No Content +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Application_Security/Scenario_Create_a_legacy_WAF_exclusion_filter_returns_Bad_Request_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Application_Security/Scenario_Create_a_legacy_WAF_exclusion_filter_returns_Bad_Request_response.freeze new file mode 100644 index 00000000000..cbc3fb22d20 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Application_Security/Scenario_Create_a_legacy_WAF_exclusion_filter_returns_Bad_Request_response.freeze @@ -0,0 +1 @@ +2025-02-25T19:11:28.040Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Application_Security/Scenario_Create_a_legacy_WAF_exclusion_filter_returns_Bad_Request_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Application_Security/Scenario_Create_a_legacy_WAF_exclusion_filter_returns_Bad_Request_response.yaml new file mode 100644 index 00000000000..c12901507ab --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Application_Security/Scenario_Create_a_legacy_WAF_exclusion_filter_returns_Bad_Request_response.yaml @@ -0,0 +1,24 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"description":"Exclude false positives on a path","enabled":true,"event_query":"test:1"},"type":"exclusion_filter"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v2/remote_config/products/asm/waf/exclusion_filters + response: + body: '{"errors":[{"title":"legacy exclusion filters cannot be created anymore","code":"400"}]} + + ' + code: 400 + duration: 0ms + headers: + Content-Type: + - application/json + status: 400 Bad Request +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Application_Security/Scenario_Delete_a_WAF_exclusion_filter_returns_Not_Found_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Application_Security/Scenario_Delete_a_WAF_exclusion_filter_returns_Not_Found_response.freeze new file mode 100644 index 00000000000..113db280cef --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Application_Security/Scenario_Delete_a_WAF_exclusion_filter_returns_Not_Found_response.freeze @@ -0,0 +1 @@ +2025-02-25T21:02:08.258Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Application_Security/Scenario_Delete_a_WAF_exclusion_filter_returns_Not_Found_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Application_Security/Scenario_Delete_a_WAF_exclusion_filter_returns_Not_Found_response.yaml new file mode 100644 index 00000000000..b7c4fe9cce7 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Application_Security/Scenario_Delete_a_WAF_exclusion_filter_returns_Not_Found_response.yaml @@ -0,0 +1,21 @@ +interactions: +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 0 + method: DELETE + url: https://api.datadoghq.com/api/v2/remote_config/products/asm/waf/exclusion_filters/unknown + response: + body: '{"errors":[{"title":"id not found","code":"404"}]} + + ' + code: 404 + duration: 0ms + headers: + Content-Type: + - application/json + status: 404 Not Found +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Application_Security/Scenario_Delete_a_WAF_exclusion_filter_returns_OK_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Application_Security/Scenario_Delete_a_WAF_exclusion_filter_returns_OK_response.freeze new file mode 100644 index 00000000000..1710cff777d --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Application_Security/Scenario_Delete_a_WAF_exclusion_filter_returns_OK_response.freeze @@ -0,0 +1 @@ +2025-02-25T19:11:28.968Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Application_Security/Scenario_Delete_a_WAF_exclusion_filter_returns_OK_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Application_Security/Scenario_Delete_a_WAF_exclusion_filter_returns_OK_response.yaml new file mode 100644 index 00000000000..4d578442a67 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Application_Security/Scenario_Delete_a_WAF_exclusion_filter_returns_OK_response.yaml @@ -0,0 +1,67 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"description":"My Exclusion Filter","enabled":true,"parameters":["list.search.query"],"path_glob":"*","rules_target":[{"tags":{"category":"attack_attempt","type":"xss"}}],"scope":[{"env":"staging","service":"event-query"}]},"type":"exclusion_filter"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v2/remote_config/products/asm/waf/exclusion_filters + response: + body: '{"data":{"id":"da282618-ff1f-41ed-9f79-947817641a02","type":"exclusion_filter","attributes":{"description":"My + Exclusion Filter","enabled":true,"metadata":{"added_at":"2025-02-25T19:11:29Z","added_by":"9919ec9b-ebc7-49ee-8dc8-03626e717cca","added_by_name":"CI + Account"},"parameters":["list.search.query"],"path_glob":"*","rules_target":[{"tags":{"category":"attack_attempt","type":"xss"}}],"scope":[{"env":"staging","service":"event-query"}],"search_query":"(env:staging + AND service:\"event-query\") AND ((@appsec.triggers.rule_matches.parameters.address:server.request.query + AND (@appsec.triggers.rule_matches.parameters.key:list.search.query OR @appsec.triggers.rule_matches.parameters.params.key:list.search.query)) + OR (@appsec.triggers.rule_matches.parameters.address:server.request.body AND + (@appsec.triggers.rule_matches.parameters.key:list.search.query OR @appsec.triggers.rule_matches.parameters.params.key:list.search.query)) + OR (@appsec.triggers.rule_matches.parameters.address:server.request.path_params + AND (@appsec.triggers.rule_matches.parameters.key:list.search.query OR @appsec.triggers.rule_matches.parameters.params.key:list.search.query))) + AND (@appsec.category:attack_attempt AND @appsec.type:xss)"}}}' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/json + status: 200 OK +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 1 + method: DELETE + url: https://api.datadoghq.com/api/v2/remote_config/products/asm/waf/exclusion_filters/da282618-ff1f-41ed-9f79-947817641a02 + response: + body: '' + code: 204 + duration: 0ms + headers: + Content-Type: + - application/json + status: 204 No Content +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 2 + method: DELETE + url: https://api.datadoghq.com/api/v2/remote_config/products/asm/waf/exclusion_filters/da282618-ff1f-41ed-9f79-947817641a02 + response: + body: '{"errors":[{"title":"id not found","code":"404"}]} + + ' + code: 404 + duration: 0ms + headers: + Content-Type: + - application/json + status: 404 Not Found +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Application_Security/Scenario_Get_a_WAF_exclusion_filter_returns_OK_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Application_Security/Scenario_Get_a_WAF_exclusion_filter_returns_OK_response.freeze new file mode 100644 index 00000000000..cec3c2288e9 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Application_Security/Scenario_Get_a_WAF_exclusion_filter_returns_OK_response.freeze @@ -0,0 +1 @@ +2025-02-25T19:11:31.110Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Application_Security/Scenario_Get_a_WAF_exclusion_filter_returns_OK_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Application_Security/Scenario_Get_a_WAF_exclusion_filter_returns_OK_response.yaml new file mode 100644 index 00000000000..0ff3d715fdb --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Application_Security/Scenario_Get_a_WAF_exclusion_filter_returns_OK_response.yaml @@ -0,0 +1,74 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"description":"My Exclusion Filter","enabled":true,"parameters":["list.search.query"],"path_glob":"*","rules_target":[{"tags":{"category":"attack_attempt","type":"xss"}}],"scope":[{"env":"staging","service":"event-query"}]},"type":"exclusion_filter"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v2/remote_config/products/asm/waf/exclusion_filters + response: + body: '{"data":{"id":"6f9d3e8a-b867-4d11-9164-48cd8eb517d3","type":"exclusion_filter","attributes":{"description":"My + Exclusion Filter","enabled":true,"metadata":{"added_at":"2025-02-25T19:11:31Z","added_by":"9919ec9b-ebc7-49ee-8dc8-03626e717cca","added_by_name":"CI + Account"},"parameters":["list.search.query"],"path_glob":"*","rules_target":[{"tags":{"category":"attack_attempt","type":"xss"}}],"scope":[{"env":"staging","service":"event-query"}],"search_query":"(env:staging + AND service:\"event-query\") AND ((@appsec.triggers.rule_matches.parameters.address:server.request.query + AND (@appsec.triggers.rule_matches.parameters.key:list.search.query OR @appsec.triggers.rule_matches.parameters.params.key:list.search.query)) + OR (@appsec.triggers.rule_matches.parameters.address:server.request.body AND + (@appsec.triggers.rule_matches.parameters.key:list.search.query OR @appsec.triggers.rule_matches.parameters.params.key:list.search.query)) + OR (@appsec.triggers.rule_matches.parameters.address:server.request.path_params + AND (@appsec.triggers.rule_matches.parameters.key:list.search.query OR @appsec.triggers.rule_matches.parameters.params.key:list.search.query))) + AND (@appsec.category:attack_attempt AND @appsec.type:xss)"}}}' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/json + status: 200 OK +- request: + body: '' + form: {} + headers: + Accept: + - application/json + id: 1 + method: GET + url: https://api.datadoghq.com/api/v2/remote_config/products/asm/waf/exclusion_filters/6f9d3e8a-b867-4d11-9164-48cd8eb517d3 + response: + body: '{"data":{"id":"6f9d3e8a-b867-4d11-9164-48cd8eb517d3","type":"exclusion_filter","attributes":{"description":"My + Exclusion Filter","enabled":true,"metadata":{"added_at":"2025-02-25T19:11:31Z","added_by":"9919ec9b-ebc7-49ee-8dc8-03626e717cca","added_by_name":"CI + Account"},"parameters":["list.search.query"],"path_glob":"*","rules_target":[{"tags":{"category":"attack_attempt","type":"xss"}}],"scope":[{"env":"staging","service":"event-query"}],"search_query":"(env:staging + AND service:\"event-query\") AND ((@appsec.triggers.rule_matches.parameters.address:server.request.query + AND (@appsec.triggers.rule_matches.parameters.key:list.search.query OR @appsec.triggers.rule_matches.parameters.params.key:list.search.query)) + OR (@appsec.triggers.rule_matches.parameters.address:server.request.body AND + (@appsec.triggers.rule_matches.parameters.key:list.search.query OR @appsec.triggers.rule_matches.parameters.params.key:list.search.query)) + OR (@appsec.triggers.rule_matches.parameters.address:server.request.path_params + AND (@appsec.triggers.rule_matches.parameters.key:list.search.query OR @appsec.triggers.rule_matches.parameters.params.key:list.search.query))) + AND (@appsec.category:attack_attempt AND @appsec.type:xss)"}}}' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/json + status: 200 OK +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 2 + method: DELETE + url: https://api.datadoghq.com/api/v2/remote_config/products/asm/waf/exclusion_filters/6f9d3e8a-b867-4d11-9164-48cd8eb517d3 + response: + body: '' + code: 204 + duration: 0ms + headers: + Content-Type: + - application/json + status: 204 No Content +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Application_Security/Scenario_List_all_WAF_custom_rules_returns_OK_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Application_Security/Scenario_List_all_WAF_custom_rules_returns_OK_response.freeze new file mode 100644 index 00000000000..45995dbea23 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Application_Security/Scenario_List_all_WAF_custom_rules_returns_OK_response.freeze @@ -0,0 +1 @@ +2025-02-25T19:11:33.301Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Application_Security/Scenario_List_all_WAF_custom_rules_returns_OK_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Application_Security/Scenario_List_all_WAF_custom_rules_returns_OK_response.yaml new file mode 100644 index 00000000000..d01569b757e --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Application_Security/Scenario_List_all_WAF_custom_rules_returns_OK_response.yaml @@ -0,0 +1,25 @@ +interactions: +- request: + body: '' + form: {} + headers: + Accept: + - application/json + id: 0 + method: GET + url: https://api.datadoghq.com/api/v2/remote_config/products/asm/waf/custom_rules + response: + body: '{"data":[{"id":"198b4219-243d-44a5-8bf3-e0cd27b6d16f","type":"custom_rule","attributes":{"blocking":false,"conditions":[{"operator":"match_regex","parameters":{"inputs":[{"address":"server.request.query","key_path":["id"]}],"regex":"badactor","options":{}}}],"enabled":true,"metadata":{"added_at":"2025-02-25T13:44:45Z","added_by":"9919ec9b-ebc7-49ee-8dc8-03626e717cca","added_by_name":"CI + Account"},"name":"test","path_glob":"/test","scope":[{"env":"test","service":"test"}],"tags":{"category":"attack_attempt","test":"1","type":"test"}}},{"id":"86c40038-02ea-4cfd-99f1-2099c9a5e4c8","type":"custom_rule","attributes":{"blocking":false,"conditions":[{"operator":"match_regex","parameters":{"inputs":[{"address":"server.request.query","key_path":["id"]}],"regex":"badactor","options":{}}}],"enabled":false,"metadata":{"modified_at":"2025-02-25T13:44:46Z","modified_by":"9919ec9b-ebc7-49ee-8dc8-03626e717cca","modified_by_name":"CI + Account"},"name":"test - 1","path_glob":"/test","scope":[{"env":"test","service":"test"}],"tags":{"category":"attack_attempt","test":"1","type":"test"}}},{"id":"bcebdf8d-7811-4d8d-801c-a54e13f9d96e","type":"custom_rule","attributes":{"blocking":false,"conditions":[{"operator":"match_regex","parameters":{"inputs":[{"address":"server.request.query","key_path":["id"]}],"regex":"badactor","options":{}}}],"enabled":true,"metadata":{"added_at":"2025-02-25T13:44:47Z","added_by":"9919ec9b-ebc7-49ee-8dc8-03626e717cca","added_by_name":"CI + Account"},"name":"test - 2","path_glob":"/test","scope":[{"env":"test","service":"test"}],"tags":{"category":"attack_attempt","test":"1","type":"test"}}},{"id":"3c7e4949-7376-4aea-9d02-5738d339022e","type":"custom_rule","attributes":{"blocking":false,"conditions":[{"operator":"match_regex","parameters":{"inputs":[{"address":"server.request.query","key_path":["id"]}],"regex":"badactor","options":{}}}],"enabled":true,"metadata":{"added_at":"2025-02-25T16:50:42Z","added_by":"9919ec9b-ebc7-49ee-8dc8-03626e717cca","added_by_name":"CI + Account"},"name":"test - 3","path_glob":"/test","scope":[{"env":"test","service":"test"}],"tags":{"category":"attack_attempt","test":"1","type":"test"}}},{"id":"51028dad-3f06-49e3-9226-1c4a4c0b9f5b","type":"custom_rule","attributes":{"blocking":false,"conditions":[{"operator":"match_regex","parameters":{"inputs":[{"address":"server.request.query","key_path":["id"]}],"regex":"badactor","options":{}}}],"enabled":false,"metadata":{"modified_at":"2025-02-25T16:50:43Z","modified_by":"9919ec9b-ebc7-49ee-8dc8-03626e717cca","modified_by_name":"CI + Account"},"name":"test - 4","path_glob":"/test","scope":[{"env":"test","service":"test"}],"tags":{"category":"attack_attempt","test":"1","type":"test"}}},{"id":"b154ea3d-f6c6-4a4e-8712-88f3055320fb","type":"custom_rule","attributes":{"blocking":false,"conditions":[{"operator":"match_regex","parameters":{"inputs":[{"address":"server.request.query","key_path":["id"]}],"regex":"badactor","options":{}}}],"enabled":true,"metadata":{"added_at":"2025-02-25T16:50:44Z","added_by":"9919ec9b-ebc7-49ee-8dc8-03626e717cca","added_by_name":"CI + Account"},"name":"test - 5","path_glob":"/test","scope":[{"env":"test","service":"test"}],"tags":{"category":"attack_attempt","test":"1","type":"test"}}}]}' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/json + status: 200 OK +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Application_Security/Scenario_List_all_WAF_exclusion_filters_returns_OK_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Application_Security/Scenario_List_all_WAF_exclusion_filters_returns_OK_response.freeze new file mode 100644 index 00000000000..af274be3133 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Application_Security/Scenario_List_all_WAF_exclusion_filters_returns_OK_response.freeze @@ -0,0 +1 @@ +2025-02-25T19:11:33.698Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Application_Security/Scenario_List_all_WAF_exclusion_filters_returns_OK_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Application_Security/Scenario_List_all_WAF_exclusion_filters_returns_OK_response.yaml new file mode 100644 index 00000000000..d98e11f2cfa --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Application_Security/Scenario_List_all_WAF_exclusion_filters_returns_OK_response.yaml @@ -0,0 +1,19 @@ +interactions: +- request: + body: '' + form: {} + headers: + Accept: + - application/json + id: 0 + method: GET + url: https://api.datadoghq.com/api/v2/remote_config/products/asm/waf/exclusion_filters + response: + body: '{"data":[]}' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/json + status: 200 OK +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Application_Security/Scenario_Update_a_WAF_Custom_Rule_returns_Bad_Request_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Application_Security/Scenario_Update_a_WAF_Custom_Rule_returns_Bad_Request_response.freeze new file mode 100644 index 00000000000..74b5b1c843a --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Application_Security/Scenario_Update_a_WAF_Custom_Rule_returns_Bad_Request_response.freeze @@ -0,0 +1 @@ +2025-03-05T21:09:10.913Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Application_Security/Scenario_Update_a_WAF_Custom_Rule_returns_Bad_Request_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Application_Security/Scenario_Update_a_WAF_Custom_Rule_returns_Bad_Request_response.yaml new file mode 100644 index 00000000000..3e05be50156 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Application_Security/Scenario_Update_a_WAF_Custom_Rule_returns_Bad_Request_response.yaml @@ -0,0 +1,62 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"blocking":false,"conditions":[{"operator":"match_regex","parameters":{"inputs":[{"address":"server.request.query","key_path":["id"]}],"regex":"badactor"}}],"enabled":true,"name":"test","path_glob":"/test","scope":[{"env":"test","service":"test"}],"tags":{"category":"attack_attempt","type":"test"}},"type":"custom_rule"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v2/remote_config/products/asm/waf/custom_rules + response: + body: '{"data":{"id":"23343b96-cbde-4029-aad6-09d0fcbf2067","type":"custom_rule","attributes":{"blocking":false,"conditions":[{"operator":"match_regex","parameters":{"inputs":[{"address":"server.request.query","key_path":["id"]}],"regex":"badactor","options":{}}}],"enabled":true,"metadata":{"added_at":"2025-03-05T21:09:11Z","added_by":"frog@datadoghq.com","added_by_name":"frog"},"name":"test + - 12","path_glob":"/test","scope":[{"env":"test","service":"test"}],"tags":{"category":"attack_attempt","type":"test"}}}}' + code: 201 + duration: 0ms + headers: + Content-Type: + - application/json + status: 201 Created +- request: + body: | + {"data":{"attributes":{"blocking":false,"conditions":[{"operator":"match_regex","parameters":{"inputs":[{"address":"server.request.query","key_path":["id"]}],"regex":"\\"}}],"enabled":false,"name":"test","path_glob":"/test","scope":[{"env":"test","service":"test"}],"tags":{"category":"attack_attempt","type":"test"}},"type":"custom_rule"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 1 + method: PUT + url: https://api.datadoghq.com/api/v2/remote_config/products/asm/waf/custom_rules/23343b96-cbde-4029-aad6-09d0fcbf2067 + response: + body: '{"errors":[{"title":"failed to decode request","code":"400"}]} + + ' + code: 400 + duration: 0ms + headers: + Content-Type: + - application/json + status: 400 Bad Request +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 2 + method: DELETE + url: https://api.datadoghq.com/api/v2/remote_config/products/asm/waf/custom_rules/23343b96-cbde-4029-aad6-09d0fcbf2067 + response: + body: '' + code: 204 + duration: 0ms + headers: + Content-Type: + - application/json + status: 204 No Content +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Application_Security/Scenario_Update_a_WAF_Custom_Rule_returns_OK_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Application_Security/Scenario_Update_a_WAF_Custom_Rule_returns_OK_response.freeze new file mode 100644 index 00000000000..30183e26fcf --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Application_Security/Scenario_Update_a_WAF_Custom_Rule_returns_OK_response.freeze @@ -0,0 +1 @@ +2025-03-05T21:09:11.945Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Application_Security/Scenario_Update_a_WAF_Custom_Rule_returns_OK_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Application_Security/Scenario_Update_a_WAF_Custom_Rule_returns_OK_response.yaml new file mode 100644 index 00000000000..5993dd1a811 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Application_Security/Scenario_Update_a_WAF_Custom_Rule_returns_OK_response.yaml @@ -0,0 +1,61 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"blocking":false,"conditions":[{"operator":"match_regex","parameters":{"inputs":[{"address":"server.request.query","key_path":["id"]}],"regex":"badactor"}}],"enabled":true,"name":"test","path_glob":"/test","scope":[{"env":"test","service":"test"}],"tags":{"category":"attack_attempt","type":"test"}},"type":"custom_rule"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v2/remote_config/products/asm/waf/custom_rules + response: + body: '{"data":{"id":"cc8931e2-df6b-43ec-b132-ac2b7ed217e9","type":"custom_rule","attributes":{"blocking":false,"conditions":[{"operator":"match_regex","parameters":{"inputs":[{"address":"server.request.query","key_path":["id"]}],"regex":"badactor","options":{}}}],"enabled":true,"metadata":{"added_at":"2025-03-05T21:09:12Z","added_by":"frog@datadoghq.com","added_by_name":"frog"},"name":"test + - 12","path_glob":"/test","scope":[{"env":"test","service":"test"}],"tags":{"category":"attack_attempt","type":"test"}}}}' + code: 201 + duration: 0ms + headers: + Content-Type: + - application/json + status: 201 Created +- request: + body: | + {"data":{"attributes":{"blocking":false,"conditions":[{"operator":"match_regex","parameters":{"inputs":[{"address":"server.request.query","key_path":["id"]}],"regex":"badactor"}}],"enabled":false,"name":"test","path_glob":"/test","scope":[{"env":"test","service":"test"}],"tags":{"category":"attack_attempt","type":"test"}},"type":"custom_rule"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 1 + method: PUT + url: https://api.datadoghq.com/api/v2/remote_config/products/asm/waf/custom_rules/cc8931e2-df6b-43ec-b132-ac2b7ed217e9 + response: + body: '{"data":{"id":"cc8931e2-df6b-43ec-b132-ac2b7ed217e9","type":"custom_rule","attributes":{"blocking":false,"conditions":[{"operator":"match_regex","parameters":{"inputs":[{"address":"server.request.query","key_path":["id"]}],"regex":"badactor","options":{}}}],"enabled":false,"metadata":{"modified_at":"2025-03-05T21:09:12Z","modified_by":"frog@datadoghq.com","modified_by_name":"frog"},"name":"test + - 12","path_glob":"/test","scope":[{"env":"test","service":"test"}],"tags":{"category":"attack_attempt","type":"test"}}}}' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/json + status: 200 OK +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 2 + method: DELETE + url: https://api.datadoghq.com/api/v2/remote_config/products/asm/waf/custom_rules/cc8931e2-df6b-43ec-b132-ac2b7ed217e9 + response: + body: '' + code: 204 + duration: 0ms + headers: + Content-Type: + - application/json + status: 204 No Content +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Application_Security/Scenario_Update_a_WAF_exclusion_filter_returns_Bad_Request_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Application_Security/Scenario_Update_a_WAF_exclusion_filter_returns_Bad_Request_response.freeze new file mode 100644 index 00000000000..e1554751bc1 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Application_Security/Scenario_Update_a_WAF_exclusion_filter_returns_Bad_Request_response.freeze @@ -0,0 +1 @@ +2025-03-05T21:09:13.430Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Application_Security/Scenario_Update_a_WAF_exclusion_filter_returns_Bad_Request_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Application_Security/Scenario_Update_a_WAF_exclusion_filter_returns_Bad_Request_response.yaml new file mode 100644 index 00000000000..79caac606bf --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Application_Security/Scenario_Update_a_WAF_exclusion_filter_returns_Bad_Request_response.yaml @@ -0,0 +1,62 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"blocking":false,"conditions":[{"operator":"match_regex","parameters":{"inputs":[{"address":"server.request.query","key_path":["id"]}],"regex":"badactor"}}],"enabled":true,"name":"test","path_glob":"/test","scope":[{"env":"test","service":"test"}],"tags":{"category":"attack_attempt","type":"test"}},"type":"custom_rule"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v2/remote_config/products/asm/waf/custom_rules + response: + body: '{"data":{"id":"c72e76c1-ddf7-49bb-b7a2-0b178c16a987","type":"custom_rule","attributes":{"blocking":false,"conditions":[{"operator":"match_regex","parameters":{"inputs":[{"address":"server.request.query","key_path":["id"]}],"regex":"badactor","options":{}}}],"enabled":true,"metadata":{"added_at":"2025-03-05T21:09:13Z","added_by":"frog@datadoghq.com","added_by_name":"frog"},"name":"test + - 12","path_glob":"/test","scope":[{"env":"test","service":"test"}],"tags":{"category":"attack_attempt","type":"test"}}}}' + code: 201 + duration: 0ms + headers: + Content-Type: + - application/json + status: 201 Created +- request: + body: | + {"data":{"attributes":{"description":"Exclude false positives on a path","enabled":false,"ip_list":["198.51.100.72"],"on_match":"monitor","parameters":["list.search.query"],"path_glob":"/accounts/*","rules_target":[{"rule_id":"dog-913-009","tags":{"category":"attack_attempt","type":"lfi"}}],"scope":[{"env":"www","service":"prod"}]},"type":"exclusion_filter"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 1 + method: PUT + url: https://api.datadoghq.com/api/v2/remote_config/products/asm/waf/exclusion_filters/c72e76c1-ddf7-49bb-b7a2-0b178c16a987 + response: + body: '{"errors":[{"title":"only IPs are supported for monitored exclusion filters","code":"400"}]} + + ' + code: 400 + duration: 0ms + headers: + Content-Type: + - application/json + status: 400 Bad Request +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 2 + method: DELETE + url: https://api.datadoghq.com/api/v2/remote_config/products/asm/waf/custom_rules/c72e76c1-ddf7-49bb-b7a2-0b178c16a987 + response: + body: '' + code: 204 + duration: 0ms + headers: + Content-Type: + - application/json + status: 204 No Content +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Application_Security/Scenario_Update_a_WAF_exclusion_filter_returns_Not_Found_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Application_Security/Scenario_Update_a_WAF_exclusion_filter_returns_Not_Found_response.freeze new file mode 100644 index 00000000000..36d56c2b4d7 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Application_Security/Scenario_Update_a_WAF_exclusion_filter_returns_Not_Found_response.freeze @@ -0,0 +1 @@ +2025-02-25T21:02:08.838Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Application_Security/Scenario_Update_a_WAF_exclusion_filter_returns_Not_Found_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Application_Security/Scenario_Update_a_WAF_exclusion_filter_returns_Not_Found_response.yaml new file mode 100644 index 00000000000..82f90671833 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Application_Security/Scenario_Update_a_WAF_exclusion_filter_returns_Not_Found_response.yaml @@ -0,0 +1,24 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"description":"Exclude false positives on a path","enabled":true,"parameters":["list.search.query"],"path_glob":"/accounts/*","rules_target":[{"rule_id":"dog-913-009","tags":{"category":"attack_attempt","type":"lfi"}}],"scope":[{"env":"www","service":"prod"}]},"type":"exclusion_filter"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: PUT + url: https://api.datadoghq.com/api/v2/remote_config/products/asm/waf/exclusion_filters/unknown + response: + body: '{"errors":[{"title":"id not found","code":"404"}]} + + ' + code: 404 + duration: 0ms + headers: + Content-Type: + - application/json + status: 404 Not Found +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Application_Security/Scenario_Update_a_WAF_exclusion_filter_returns_OK_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Application_Security/Scenario_Update_a_WAF_exclusion_filter_returns_OK_response.freeze new file mode 100644 index 00000000000..ee9406812c6 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Application_Security/Scenario_Update_a_WAF_exclusion_filter_returns_OK_response.freeze @@ -0,0 +1 @@ +2025-02-25T19:11:37.988Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Application_Security/Scenario_Update_a_WAF_exclusion_filter_returns_OK_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Application_Security/Scenario_Update_a_WAF_exclusion_filter_returns_OK_response.yaml new file mode 100644 index 00000000000..aadf0886378 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Application_Security/Scenario_Update_a_WAF_exclusion_filter_returns_OK_response.yaml @@ -0,0 +1,70 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"description":"My Exclusion Filter","enabled":true,"parameters":["list.search.query"],"path_glob":"*","rules_target":[{"tags":{"category":"attack_attempt","type":"xss"}}],"scope":[{"env":"staging","service":"event-query"}]},"type":"exclusion_filter"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v2/remote_config/products/asm/waf/exclusion_filters + response: + body: '{"data":{"id":"05b2e632-332e-4c58-947c-40e5c9f22314","type":"exclusion_filter","attributes":{"description":"My + Exclusion Filter","enabled":true,"metadata":{"added_at":"2025-02-25T19:11:38Z","added_by":"9919ec9b-ebc7-49ee-8dc8-03626e717cca","added_by_name":"CI + Account"},"parameters":["list.search.query"],"path_glob":"*","rules_target":[{"tags":{"category":"attack_attempt","type":"xss"}}],"scope":[{"env":"staging","service":"event-query"}],"search_query":"(env:staging + AND service:\"event-query\") AND ((@appsec.triggers.rule_matches.parameters.address:server.request.query + AND (@appsec.triggers.rule_matches.parameters.key:list.search.query OR @appsec.triggers.rule_matches.parameters.params.key:list.search.query)) + OR (@appsec.triggers.rule_matches.parameters.address:server.request.body AND + (@appsec.triggers.rule_matches.parameters.key:list.search.query OR @appsec.triggers.rule_matches.parameters.params.key:list.search.query)) + OR (@appsec.triggers.rule_matches.parameters.address:server.request.path_params + AND (@appsec.triggers.rule_matches.parameters.key:list.search.query OR @appsec.triggers.rule_matches.parameters.params.key:list.search.query))) + AND (@appsec.category:attack_attempt AND @appsec.type:xss)"}}}' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/json + status: 200 OK +- request: + body: | + {"data":{"attributes":{"description":"Exclude false positives on a path","enabled":false,"ip_list":["198.51.100.72"],"on_match":"monitor"},"type":"exclusion_filter"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 1 + method: PUT + url: https://api.datadoghq.com/api/v2/remote_config/products/asm/waf/exclusion_filters/05b2e632-332e-4c58-947c-40e5c9f22314 + response: + body: '{"data":{"id":"05b2e632-332e-4c58-947c-40e5c9f22314","type":"exclusion_filter","attributes":{"description":"Exclude + false positives on a path","enabled":false,"ip_list":["198.51.100.72"],"metadata":{"added_at":"2025-02-25T19:11:38Z","modified_at":"2025-02-25T19:11:39Z","added_by":"9919ec9b-ebc7-49ee-8dc8-03626e717cca","modified_by":"9919ec9b-ebc7-49ee-8dc8-03626e717cca","modified_by_name":"CI + Account"},"on_match":"monitor","search_query":"@http.client_ip:198.51.100.72"}}}' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/json + status: 200 OK +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 2 + method: DELETE + url: https://api.datadoghq.com/api/v2/remote_config/products/asm/waf/exclusion_filters/05b2e632-332e-4c58-947c-40e5c9f22314 + response: + body: '' + code: 204 + duration: 0ms + headers: + Content-Type: + - application/json + status: 204 No Content +version: 2 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Application_Security/Scenario_Update_a_legacy_WAF_exclusion_filter_returns_Bad_Request_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Application_Security/Scenario_Update_a_legacy_WAF_exclusion_filter_returns_Bad_Request_response.freeze new file mode 100644 index 00000000000..92a7c008143 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Application_Security/Scenario_Update_a_legacy_WAF_exclusion_filter_returns_Bad_Request_response.freeze @@ -0,0 +1 @@ +2025-02-25T19:11:40.619Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Application_Security/Scenario_Update_a_legacy_WAF_exclusion_filter_returns_Bad_Request_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Application_Security/Scenario_Update_a_legacy_WAF_exclusion_filter_returns_Bad_Request_response.yaml new file mode 100644 index 00000000000..660854e7eaa --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Application_Security/Scenario_Update_a_legacy_WAF_exclusion_filter_returns_Bad_Request_response.yaml @@ -0,0 +1,70 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"description":"My Exclusion Filter","enabled":true,"parameters":["list.search.query"],"path_glob":"*","rules_target":[{"tags":{"category":"attack_attempt","type":"xss"}}],"scope":[{"env":"staging","service":"event-query"}]},"type":"exclusion_filter"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 0 + method: POST + url: https://api.datadoghq.com/api/v2/remote_config/products/asm/waf/exclusion_filters + response: + body: '{"data":{"id":"bd04e3ac-9f29-4a66-976f-2f409477a329","type":"exclusion_filter","attributes":{"description":"My + Exclusion Filter","enabled":true,"metadata":{"added_at":"2025-02-25T19:11:40Z","added_by":"9919ec9b-ebc7-49ee-8dc8-03626e717cca","added_by_name":"CI + Account"},"parameters":["list.search.query"],"path_glob":"*","rules_target":[{"tags":{"category":"attack_attempt","type":"xss"}}],"scope":[{"env":"staging","service":"event-query"}],"search_query":"(env:staging + AND service:\"event-query\") AND ((@appsec.triggers.rule_matches.parameters.address:server.request.query + AND (@appsec.triggers.rule_matches.parameters.key:list.search.query OR @appsec.triggers.rule_matches.parameters.params.key:list.search.query)) + OR (@appsec.triggers.rule_matches.parameters.address:server.request.body AND + (@appsec.triggers.rule_matches.parameters.key:list.search.query OR @appsec.triggers.rule_matches.parameters.params.key:list.search.query)) + OR (@appsec.triggers.rule_matches.parameters.address:server.request.path_params + AND (@appsec.triggers.rule_matches.parameters.key:list.search.query OR @appsec.triggers.rule_matches.parameters.params.key:list.search.query))) + AND (@appsec.category:attack_attempt AND @appsec.type:xss)"}}}' + code: 200 + duration: 0ms + headers: + Content-Type: + - application/json + status: 200 OK +- request: + body: | + {"data":{"attributes":{"description":"Exclude false positives on a path","enabled":true,"event_query":"test:1"},"type":"exclusion_filter"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + id: 1 + method: PUT + url: https://api.datadoghq.com/api/v2/remote_config/products/asm/waf/exclusion_filters/bd04e3ac-9f29-4a66-976f-2f409477a329 + response: + body: '{"errors":[{"title":"legacy exclusion filters cannot be created anymore","code":"400"}]} + + ' + code: 400 + duration: 0ms + headers: + Content-Type: + - application/json + status: 400 Bad Request +- request: + body: '' + form: {} + headers: + Accept: + - '*/*' + id: 2 + method: DELETE + url: https://api.datadoghq.com/api/v2/remote_config/products/asm/waf/exclusion_filters/bd04e3ac-9f29-4a66-976f-2f409477a329 + response: + body: '' + code: 204 + duration: 0ms + headers: + Content-Type: + - application/json + status: 204 No Content +version: 2 diff --git a/tests/scenarios/features/v2/application_security.feature b/tests/scenarios/features/v2/application_security.feature new file mode 100644 index 00000000000..0a68585a02e --- /dev/null +++ b/tests/scenarios/features/v2/application_security.feature @@ -0,0 +1,218 @@ +@endpoint(application-security) @endpoint(application-security-v2) +Feature: Application Security + [Datadog Application + Security](https://docs.datadoghq.com/security/application_security/) + provides protection against application-level attacks that aim to exploit + code-level vulnerabilities, such as Server-Side-Request-Forgery (SSRF), + SQL injection, Log4Shell, and Reflected Cross-Site-Scripting (XSS). You + can monitor and protect apps hosted directly on a server, Docker, + Kubernetes, Amazon ECS, and (for supported languages) AWS Fargate. + + Background: + Given a valid "apiKeyAuth" key in the system + And a valid "appKeyAuth" key in the system + And an instance of "ApplicationSecurity" API + + @generated @skip @team:DataDog/asm-respond-backend + Scenario: Create a WAF custom rule returns "Bad Request" response + Given new "CreateApplicationSecurityWafCustomRule" request + And body with value {"data": {"attributes": {"action": {"action": "block_request", "parameters": {"location": "/blocking", "status_code": 403}}, "blocking": false, "conditions": [{"operator": "match_regex", "parameters": {"data": "blocked_users", "inputs": [{"address": "server.db.statement", "key_path": []}], "list": [], "options": {"case_sensitive": false, "min_length": 0}, "regex": "path.*", "value": "custom_tag"}}], "enabled": false, "name": "Block request from a bad useragent", "path_glob": "/api/search/*", "scope": [{"env": "prod", "service": "billing-service"}], "tags": {"category": "business_logic", "type": "users.login.success"}}, "type": "custom_rule"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/asm-respond-backend + Scenario: Create a WAF custom rule returns "Concurrent Modification" response + Given new "CreateApplicationSecurityWafCustomRule" request + And body with value {"data": {"attributes": {"action": {"action": "block_request", "parameters": {"location": "/blocking", "status_code": 403}}, "blocking": false, "conditions": [{"operator": "match_regex", "parameters": {"data": "blocked_users", "inputs": [{"address": "server.db.statement", "key_path": []}], "list": [], "options": {"case_sensitive": false, "min_length": 0}, "regex": "path.*", "value": "custom_tag"}}], "enabled": false, "name": "Block request from a bad useragent", "path_glob": "/api/search/*", "scope": [{"env": "prod", "service": "billing-service"}], "tags": {"category": "business_logic", "type": "users.login.success"}}, "type": "custom_rule"}} + When the request is sent + Then the response status is 409 Concurrent Modification + + @generated @skip @team:DataDog/asm-respond-backend + Scenario: Create a WAF custom rule returns "Created" response + Given new "CreateApplicationSecurityWafCustomRule" request + And body with value {"data": {"attributes": {"action": {"action": "block_request", "parameters": {"location": "/blocking", "status_code": 403}}, "blocking": false, "conditions": [{"operator": "match_regex", "parameters": {"data": "blocked_users", "inputs": [{"address": "server.db.statement", "key_path": []}], "list": [], "options": {"case_sensitive": false, "min_length": 0}, "regex": "path.*", "value": "custom_tag"}}], "enabled": false, "name": "Block request from a bad useragent", "path_glob": "/api/search/*", "scope": [{"env": "prod", "service": "billing-service"}], "tags": {"category": "business_logic", "type": "users.login.success"}}, "type": "custom_rule"}} + When the request is sent + Then the response status is 201 Created + + @generated @skip @team:DataDog/asm-respond-backend + Scenario: Create a WAF exclusion filter returns "Bad Request" response + Given new "CreateApplicationSecurityWafExclusionFilter" request + And body with value {"data": {"attributes": {"description": "Exclude false positives on a path", "enabled": true, "ip_list": ["198.51.100.72"], "on_match": "monitor", "parameters": ["list.search.query"], "path_glob": "/accounts/*", "rules_target": [{"rule_id": "dog-913-009", "tags": {"category": "attack_attempt", "type": "lfi"}}], "scope": [{"env": "www", "service": "prod"}]}, "type": "exclusion_filter"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/asm-respond-backend + Scenario: Create a WAF exclusion filter returns "Concurrent Modification" response + Given new "CreateApplicationSecurityWafExclusionFilter" request + And body with value {"data": {"attributes": {"description": "Exclude false positives on a path", "enabled": true, "ip_list": ["198.51.100.72"], "on_match": "monitor", "parameters": ["list.search.query"], "path_glob": "/accounts/*", "rules_target": [{"rule_id": "dog-913-009", "tags": {"category": "attack_attempt", "type": "lfi"}}], "scope": [{"env": "www", "service": "prod"}]}, "type": "exclusion_filter"}} + When the request is sent + Then the response status is 409 Concurrent Modification + + @team:DataDog/asm-respond-backend + Scenario: Create a WAF exclusion filter returns "OK" response + Given new "CreateApplicationSecurityWafExclusionFilter" request + And body with value {"data": {"attributes": {"description": "Exclude false positives on a path", "enabled": true, "parameters": ["list.search.query"], "path_glob": "/accounts/*", "rules_target": [{"tags": {"category": "attack_attempt", "type": "lfi"}}], "scope": [{"env": "www", "service": "prod"}]}, "type": "exclusion_filter"}} + When the request is sent + Then the response status is 200 OK + And the response "data.attributes.enabled" is equal to true + + @team:DataDog/asm-respond-backend + Scenario: Create a legacy WAF exclusion filter returns "Bad Request" response + Given new "CreateApplicationSecurityWafExclusionFilter" request + And body with value {"data": {"attributes": {"description": "Exclude false positives on a path", "enabled": true, "event_query": "test:1"}, "type": "exclusion_filter"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/asm-respond-backend + Scenario: Delete a WAF Custom Rule returns "Concurrent Modification" response + Given new "DeleteApplicationSecurityWafCustomRule" request + And request contains "custom_rule_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 409 Concurrent Modification + + @generated @skip @team:DataDog/asm-respond-backend + Scenario: Delete a WAF Custom Rule returns "No Content" response + Given new "DeleteApplicationSecurityWafCustomRule" request + And request contains "custom_rule_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 204 No Content + + @generated @skip @team:DataDog/asm-respond-backend + Scenario: Delete a WAF Custom Rule returns "Not Found" response + Given new "DeleteApplicationSecurityWafCustomRule" request + And request contains "custom_rule_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/asm-respond-backend + Scenario: Delete a WAF exclusion filter returns "Concurrent Modification" response + Given new "DeleteApplicationSecurityWafExclusionFilter" request + And request contains "exclusion_filter_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 409 Concurrent Modification + + @team:DataDog/asm-respond-backend + Scenario: Delete a WAF exclusion filter returns "Not Found" response + Given new "DeleteApplicationSecurityWafExclusionFilter" request + And request contains "exclusion_filter_id" parameter with value "unknown" + When the request is sent + Then the response status is 404 Not Found + + @team:DataDog/asm-respond-backend + Scenario: Delete a WAF exclusion filter returns "OK" response + Given there is a valid "exclusion_filter" in the system + And new "DeleteApplicationSecurityWafExclusionFilter" request + And request contains "exclusion_filter_id" parameter from "exclusion_filter.data.id" + When the request is sent + Then the response status is 204 OK + + @generated @skip @team:DataDog/asm-respond-backend + Scenario: Get a WAF custom rule returns "OK" response + Given new "GetApplicationSecurityWafCustomRule" request + And request contains "custom_rule_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:DataDog/asm-respond-backend + Scenario: Get a WAF exclusion filter returns "Not Found" response + Given new "GetApplicationSecurityWafExclusionFilter" request + And request contains "exclusion_filter_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @team:DataDog/asm-respond-backend + Scenario: Get a WAF exclusion filter returns "OK" response + Given there is a valid "exclusion_filter" in the system + And new "GetApplicationSecurityWafExclusionFilter" request + And request contains "exclusion_filter_id" parameter from "exclusion_filter.data.id" + When the request is sent + Then the response status is 200 OK + + @team:DataDog/asm-respond-backend + Scenario: List all WAF custom rules returns "OK" response + Given new "ListApplicationSecurityWAFCustomRules" request + When the request is sent + Then the response status is 200 OK + + @team:DataDog/asm-respond-backend + Scenario: List all WAF exclusion filters returns "OK" response + Given new "ListApplicationSecurityWafExclusionFilters" request + When the request is sent + Then the response status is 200 OK + + @team:DataDog/asm-respond-backend + Scenario: Update a WAF Custom Rule returns "Bad Request" response + Given there is a valid "custom_rule" in the system + And new "UpdateApplicationSecurityWafCustomRule" request + And request contains "custom_rule_id" parameter from "custom_rule.data.id" + And body with value {"data": {"type": "custom_rule", "attributes": {"blocking": false, "conditions": [{"operator": "match_regex", "parameters": { "inputs": [ { "address": "server.request.query", "key_path": [ "id" ] } ], "regex": "\\" } } ], "enabled": false, "name": "test", "path_glob": "/test", "scope": [ { "env": "test", "service": "test" } ], "tags": { "category": "attack_attempt", "type": "test"}}}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/asm-respond-backend + Scenario: Update a WAF Custom Rule returns "Concurrent Modification" response + Given new "UpdateApplicationSecurityWafCustomRule" request + And request contains "custom_rule_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"action": {"action": "block_request", "parameters": {"location": "/blocking", "status_code": 403}}, "blocking": false, "conditions": [{"operator": "match_regex", "parameters": {"data": "blocked_users", "inputs": [{"address": "server.db.statement", "key_path": []}], "list": [], "options": {"case_sensitive": false, "min_length": 0}, "regex": "path.*", "value": "custom_tag"}}], "enabled": false, "name": "Block request from bad useragent", "path_glob": "/api/search/*", "scope": [{"env": "prod", "service": "billing-service"}], "tags": {"category": "business_logic", "type": "users.login.success"}}, "type": "custom_rule"}} + When the request is sent + Then the response status is 409 Concurrent Modification + + @generated @skip @team:DataDog/asm-respond-backend + Scenario: Update a WAF Custom Rule returns "Not Found" response + Given new "UpdateApplicationSecurityWafCustomRule" request + And request contains "custom_rule_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"action": {"action": "block_request", "parameters": {"location": "/blocking", "status_code": 403}}, "blocking": false, "conditions": [{"operator": "match_regex", "parameters": {"data": "blocked_users", "inputs": [{"address": "server.db.statement", "key_path": []}], "list": [], "options": {"case_sensitive": false, "min_length": 0}, "regex": "path.*", "value": "custom_tag"}}], "enabled": false, "name": "Block request from bad useragent", "path_glob": "/api/search/*", "scope": [{"env": "prod", "service": "billing-service"}], "tags": {"category": "business_logic", "type": "users.login.success"}}, "type": "custom_rule"}} + When the request is sent + Then the response status is 404 Not Found + + @team:DataDog/asm-respond-backend + Scenario: Update a WAF Custom Rule returns "OK" response + Given there is a valid "custom_rule" in the system + And new "UpdateApplicationSecurityWafCustomRule" request + And request contains "custom_rule_id" parameter from "custom_rule.data.id" + And body with value {"data": {"type": "custom_rule", "attributes": {"blocking": false, "conditions": [{"operator": "match_regex", "parameters": { "inputs": [ { "address": "server.request.query", "key_path": [ "id" ] } ], "regex": "badactor" } } ], "enabled": false, "name": "test", "path_glob": "/test", "scope": [ { "env": "test", "service": "test" } ], "tags": { "category": "attack_attempt", "type": "test"}}}} + When the request is sent + Then the response status is 200 OK + + @team:DataDog/asm-respond-backend + Scenario: Update a WAF exclusion filter returns "Bad Request" response + Given there is a valid "custom_rule" in the system + And new "UpdateApplicationSecurityWafExclusionFilter" request + And request contains "exclusion_filter_id" parameter from "custom_rule.data.id" + And body with value {"data": {"attributes": {"description": "Exclude false positives on a path", "enabled": false, "ip_list": ["198.51.100.72"], "on_match": "monitor", "parameters": ["list.search.query"], "path_glob": "/accounts/*", "rules_target": [{"rule_id": "dog-913-009", "tags": {"category": "attack_attempt", "type": "lfi"}}], "scope": [{"env": "www", "service": "prod"}]}, "type": "exclusion_filter"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/asm-respond-backend + Scenario: Update a WAF exclusion filter returns "Concurrent Modification" response + Given new "UpdateApplicationSecurityWafExclusionFilter" request + And request contains "exclusion_filter_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"description": "Exclude false positives on a path", "enabled": true, "ip_list": ["198.51.100.72"], "on_match": "monitor", "parameters": ["list.search.query"], "path_glob": "/accounts/*", "rules_target": [{"rule_id": "dog-913-009", "tags": {"category": "attack_attempt", "type": "lfi"}}], "scope": [{"env": "www", "service": "prod"}]}, "type": "exclusion_filter"}} + When the request is sent + Then the response status is 409 Concurrent Modification + + @team:DataDog/asm-respond-backend + Scenario: Update a WAF exclusion filter returns "Not Found" response + Given new "UpdateApplicationSecurityWafExclusionFilter" request + And request contains "exclusion_filter_id" parameter with value "unknown" + And body with value {"data": {"attributes": {"description": "Exclude false positives on a path", "enabled": true, "parameters": ["list.search.query"], "path_glob": "/accounts/*", "rules_target": [{"rule_id": "dog-913-009", "tags": {"category": "attack_attempt", "type": "lfi"}}], "scope": [{"env": "www", "service": "prod"}]}, "type": "exclusion_filter"}} + When the request is sent + Then the response status is 404 Not Found + + @team:DataDog/asm-respond-backend + Scenario: Update a WAF exclusion filter returns "OK" response + Given there is a valid "exclusion_filter" in the system + And new "UpdateApplicationSecurityWafExclusionFilter" request + And request contains "exclusion_filter_id" parameter from "exclusion_filter.data.id" + And body with value {"data": {"attributes": {"description": "Exclude false positives on a path", "enabled": false, "ip_list": ["198.51.100.72"], "on_match": "monitor"}, "type": "exclusion_filter"}} + When the request is sent + Then the response status is 200 OK + + @team:DataDog/asm-respond-backend + Scenario: Update a legacy WAF exclusion filter returns "Bad Request" response + Given there is a valid "exclusion_filter" in the system + And new "UpdateApplicationSecurityWafExclusionFilter" request + And request contains "exclusion_filter_id" parameter from "exclusion_filter.data.id" + And body with value {"data": {"attributes": {"description": "Exclude false positives on a path", "enabled": true, "event_query": "test:1"}, "type": "exclusion_filter"}} + When the request is sent + Then the response status is 400 Bad Request diff --git a/tests/scenarios/features/v2/given.json b/tests/scenarios/features/v2/given.json index b3c27699e52..58dfa331fa5 100644 --- a/tests/scenarios/features/v2/given.json +++ b/tests/scenarios/features/v2/given.json @@ -467,6 +467,30 @@ "tag": "Powerpack", "operationId": "CreatePowerpack" }, + { + "parameters": [ + { + "name": "body", + "value": "{\n \"data\": {\n \"type\": \"custom_rule\",\n \"attributes\": {\n \"blocking\": false,\n \"conditions\": [\n {\n \"operator\": \"match_regex\",\n \"parameters\": {\n \"inputs\": [\n {\n \"address\": \"server.request.query\",\n \"key_path\": [\n \"id\"\n ]\n }\n ],\n \"regex\": \"badactor\"\n }\n }\n ],\n \"enabled\": true,\n \"name\": \"test\",\n \"path_glob\": \"/test\",\n \"scope\": [\n {\n \"env\": \"test\",\n \"service\": \"test\"\n }\n ],\n \"tags\": {\n \"category\": \"attack_attempt\",\n \"type\": \"test\"\n }\n }\n }\n}" + } + ], + "step": "there is a valid \"custom_rule\" in the system", + "key": "custom_rule", + "tag": "Application Security", + "operationId": "CreateApplicationSecurityWafCustomRule" + }, + { + "parameters": [ + { + "name": "body", + "value": "{\n \"data\": {\n \"type\": \"exclusion_filter\",\n \"attributes\": {\n \"description\": \"My Exclusion Filter\",\n \"enabled\": true,\n \"path_glob\": \"*\",\n \"parameters\": [\n \"list.search.query\"\n ],\n \"rules_target\": [\n {\n \"tags\": {\n \"category\":\"attack_attempt\",\n \"type\":\"xss\"\n }\n }\n ],\n \"scope\": [\n {\n \"env\": \"staging\",\n \"service\": \"event-query\"\n }\n ]\n }\n }\n}" + } + ], + "step": "there is a valid \"exclusion_filter\" in the system", + "key": "exclusion_filter", + "tag": "Application Security", + "operationId": "CreateApplicationSecurityWafExclusionFilter" + }, { "parameters": [ { diff --git a/tests/scenarios/features/v2/undo.json b/tests/scenarios/features/v2/undo.json index 35fcbc9803e..051da61ffbc 100644 --- a/tests/scenarios/features/v2/undo.json +++ b/tests/scenarios/features/v2/undo.json @@ -1841,6 +1841,80 @@ "type": "idempotent" } }, + "ListApplicationSecurityWAFCustomRules": { + "tag": "Application Security", + "undo": { + "type": "safe" + } + }, + "CreateApplicationSecurityWafCustomRule": { + "tag": "Application Security", + "undo": { + "operationId": "DeleteApplicationSecurityWafCustomRule", + "parameters": [ + { + "name": "custom_rule_id", + "source": "data.id" + } + ], + "type": "unsafe" + } + }, + "DeleteApplicationSecurityWafCustomRule": { + "tag": "Application Security", + "undo": { + "type": "idempotent" + } + }, + "GetApplicationSecurityWafCustomRule": { + "tag": "Application Security", + "undo": { + "type": "safe" + } + }, + "UpdateApplicationSecurityWafCustomRule": { + "tag": "Application Security", + "undo": { + "type": "idempotent" + } + }, + "ListApplicationSecurityWafExclusionFilters": { + "tag": "Application Security", + "undo": { + "type": "safe" + } + }, + "CreateApplicationSecurityWafExclusionFilter": { + "tag": "Application Security", + "undo": { + "operationId": "DeleteApplicationSecurityWafExclusionFilter", + "parameters": [ + { + "name": "exclusion_filter_id", + "source": "data.id" + } + ], + "type": "unsafe" + } + }, + "DeleteApplicationSecurityWafExclusionFilter": { + "tag": "Application Security", + "undo": { + "type": "idempotent" + } + }, + "GetApplicationSecurityWafExclusionFilter": { + "tag": "Application Security", + "undo": { + "type": "safe" + } + }, + "UpdateApplicationSecurityWafExclusionFilter": { + "tag": "Application Security", + "undo": { + "type": "idempotent" + } + }, "ListCSMThreatsAgentRules": { "tag": "CSM Threats", "undo": {