From c31d058d9cf42163f4b146c496afd7938f9181d5 Mon Sep 17 00:00:00 2001 From: "ci.datadog-api-spec" Date: Tue, 15 Oct 2024 08:05:24 +0000 Subject: [PATCH] Regenerate client from commit 5534d64c of spec repo --- .apigentools-info | 8 +- .generator/schemas/v2/openapi.yaml | 450 ++++++++++++++++++ api/datadogV2/api_asm_exclusion_filters.go | 374 +++++++++++++++ api/datadogV2/doc.go | 5 + .../model_asm_exclusion_filter_attributes.go | 356 ++++++++++++++ ..._asm_exclusion_filter_create_attributes.go | 305 ++++++++++++ .../model_asm_exclusion_filter_create_data.go | 148 ++++++ ...del_asm_exclusion_filter_create_request.go | 110 +++++ .../model_asm_exclusion_filter_data.go | 189 ++++++++ ...el_asm_exclusion_filter_list_attributes.go | 356 ++++++++++++++ ...odel_asm_exclusion_filter_list_response.go | 102 ++++ ..._asm_exclusion_filter_list_rules_target.go | 111 +++++ ...exclusion_filter_list_rules_target_tags.go | 137 ++++++ .../model_asm_exclusion_filter_metadata.go | 217 +++++++++ .../model_asm_exclusion_filter_response.go | 102 ++++ ...model_asm_exclusion_filter_rules_target.go | 102 ++++ .../model_asm_exclusion_filter_scope.go | 137 ++++++ .../model_asm_exclusion_filter_type.go | 64 +++ ..._asm_exclusion_filter_update_attributes.go | 305 ++++++++++++ .../model_asm_exclusion_filter_update_data.go | 183 +++++++ ...del_asm_exclusion_filter_update_request.go | 110 +++++ .../model_asm_exclusion_list_filter_data.go | 189 ++++++++ .../CreateASMExclusionFilter.go | 48 ++ .../DeleteASMExclusionFilter.go | 25 + .../GetASMExclusionFilters.go | 29 ++ .../ListASMExclusionFilters.go | 29 ++ .../UpdateASMExclusionFilter.go | 57 +++ tests/scenarios/api_mappings.go | 1 + .../features/v2/asm_exclusion_filters.feature | 89 ++++ tests/scenarios/features/v2/given.json | 12 + tests/scenarios/features/v2/undo.json | 37 ++ 31 files changed, 4383 insertions(+), 4 deletions(-) create mode 100644 api/datadogV2/api_asm_exclusion_filters.go create mode 100644 api/datadogV2/model_asm_exclusion_filter_attributes.go create mode 100644 api/datadogV2/model_asm_exclusion_filter_create_attributes.go create mode 100644 api/datadogV2/model_asm_exclusion_filter_create_data.go create mode 100644 api/datadogV2/model_asm_exclusion_filter_create_request.go create mode 100644 api/datadogV2/model_asm_exclusion_filter_data.go create mode 100644 api/datadogV2/model_asm_exclusion_filter_list_attributes.go create mode 100644 api/datadogV2/model_asm_exclusion_filter_list_response.go create mode 100644 api/datadogV2/model_asm_exclusion_filter_list_rules_target.go create mode 100644 api/datadogV2/model_asm_exclusion_filter_list_rules_target_tags.go create mode 100644 api/datadogV2/model_asm_exclusion_filter_metadata.go create mode 100644 api/datadogV2/model_asm_exclusion_filter_response.go create mode 100644 api/datadogV2/model_asm_exclusion_filter_rules_target.go create mode 100644 api/datadogV2/model_asm_exclusion_filter_scope.go create mode 100644 api/datadogV2/model_asm_exclusion_filter_type.go create mode 100644 api/datadogV2/model_asm_exclusion_filter_update_attributes.go create mode 100644 api/datadogV2/model_asm_exclusion_filter_update_data.go create mode 100644 api/datadogV2/model_asm_exclusion_filter_update_request.go create mode 100644 api/datadogV2/model_asm_exclusion_list_filter_data.go create mode 100644 examples/v2/asm-exclusion-filters/CreateASMExclusionFilter.go create mode 100644 examples/v2/asm-exclusion-filters/DeleteASMExclusionFilter.go create mode 100644 examples/v2/asm-exclusion-filters/GetASMExclusionFilters.go create mode 100644 examples/v2/asm-exclusion-filters/ListASMExclusionFilters.go create mode 100644 examples/v2/asm-exclusion-filters/UpdateASMExclusionFilter.go create mode 100644 tests/scenarios/features/v2/asm_exclusion_filters.feature diff --git a/.apigentools-info b/.apigentools-info index 59823ef0932..8728f7ac628 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.6.6", - "regenerated": "2024-10-10 19:46:01.049645", - "spec_repo_commit": "049920eb" + "regenerated": "2024-10-15 08:03:36.743747", + "spec_repo_commit": "5534d64c" }, "v2": { "apigentools_version": "1.6.6", - "regenerated": "2024-10-10 19:46:01.068188", - "spec_repo_commit": "049920eb" + "regenerated": "2024-10-15 08:03:36.764707", + "spec_repo_commit": "5534d64c" } } } \ No newline at end of file diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index c592c7ff286..71d91f69421 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -84,6 +84,14 @@ components: required: false schema: $ref: '#/components/schemas/APIKeysSort' + ASMExclusionFilterID: + description: The ID of the exclusion filter. + example: 3b5-v82-ns6 + in: path + name: exclusion_filter_id + required: true + schema: + type: string ApplicationKeyFilterCreatedAtEndParameter: description: Only include application keys created on or before the specified date. @@ -955,6 +963,326 @@ components: type: string x-enum-varnames: - API_KEYS + ASMExclusionFilterAttributes: + description: The attributes of the ASM WAF exclusion filter. + properties: + description: + description: A description for the exclusion filter. + example: Test exclude path + type: string + enabled: + description: Indicates whether the exclusion filter is enabled. + example: false + type: boolean + ip_list: + description: The IPs list for the exclusion filter. + items: + example: 127.0.0.1 + type: string + type: array + metadata: + $ref: '#/components/schemas/ASMExclusionFilterMetadata' + parameters: + description: A list of parameters for the exclusion filter. + items: + example: list.search.query + type: string + type: array + path_glob: + description: The path glob for the exclusion filter. + example: /lfi_include/* + type: string + rules_target: + description: A list of rules targeted by the exclusion filter. + items: + $ref: '#/components/schemas/ASMExclusionFilterRulesTarget' + type: array + scope: + description: The scope of the exclusion filter. + items: + $ref: '#/components/schemas/ASMExclusionFilterScope' + type: array + type: object + ASMExclusionFilterCreateAttributes: + description: Create a new ASM WAF exclusion filter. + properties: + description: + description: A description for the exclusion filter. + example: Test exclude path + type: string + enabled: + description: Indicates whether the exclusion filter is enabled. + example: false + type: boolean + ip_list: + description: The IPs list for the exclusion filter. + items: + example: 127.0.0.1 + type: string + type: array + parameters: + description: A list of parameters for the exclusion filter. + items: + example: list.search.query + type: string + type: array + path_glob: + description: The path glob for the exclusion filter. + example: /lfi_include/* + type: string + rules_target: + description: A list of rules targeted by the exclusion filter. + items: + $ref: '#/components/schemas/ASMExclusionFilterRulesTarget' + type: array + scope: + description: The scope of the exclusion filter. + items: + $ref: '#/components/schemas/ASMExclusionFilterScope' + type: array + required: + - description + - enabled + - path_glob + ASMExclusionFilterCreateData: + description: Object for a single exclusion filter. + properties: + attributes: + $ref: '#/components/schemas/ASMExclusionFilterCreateAttributes' + type: + $ref: '#/components/schemas/ASMExclusionFilterType' + required: + - attributes + - type + type: object + ASMExclusionFilterCreateRequest: + description: Request object that includes the exclusion filter to create. + properties: + data: + $ref: '#/components/schemas/ASMExclusionFilterCreateData' + required: + - data + type: object + ASMExclusionFilterData: + description: Object for a single Exclusion filter. + properties: + attributes: + $ref: '#/components/schemas/ASMExclusionFilterAttributes' + id: + description: The ID of the Exclusion filter. + example: 3dd-0uc-h1s + type: string + type: + $ref: '#/components/schemas/ASMExclusionFilterType' + type: object + ASMExclusionFilterID: + description: The ID of the exclusion filter. + example: 3dd-0uc-h1s + type: string + ASMExclusionFilterListAttributes: + description: The attributes of the ASM WAF exclusion filter. + properties: + description: + description: A description for the exclusion filter. + example: Test exclude path + type: string + enabled: + description: Indicates whether the exclusion filter is enabled. + example: false + type: boolean + ip_list: + description: The IPs list for the exclusion filter. + items: + example: 127.0.0.1 + type: string + type: array + metadata: + $ref: '#/components/schemas/ASMExclusionFilterMetadata' + parameters: + description: A list of parameters for the exclusion filter. + items: + example: list.search.query + type: string + type: array + path_glob: + description: The path glob for the exclusion filter. + example: /lfi_include/* + type: string + rules_target: + description: A list of rules targeted by the exclusion filter. + items: + $ref: '#/components/schemas/ASMExclusionFilterListRulesTarget' + type: array + scope: + description: The scope of the exclusion filter. + items: + $ref: '#/components/schemas/ASMExclusionFilterScope' + type: array + type: object + ASMExclusionFilterListResponse: + description: Response object that includes a list of exclusion filters. + properties: + data: + description: The ASMExclusionFilterResponse data. + items: + $ref: '#/components/schemas/ASMExclusionListFilterData' + type: array + type: object + ASMExclusionFilterListRulesTarget: + description: A rule targeted by the exclusion filter. + properties: + tags: + $ref: '#/components/schemas/ASMExclusionFilterListRulesTargetTags' + type: object + ASMExclusionFilterListRulesTargetTags: + description: Tags identifying the category and type of the targeted rule. + properties: + category: + description: The category of the rule. + example: attack_attempt + type: string + type: + description: The type of the rule. + example: lfi + type: string + type: object + ASMExclusionFilterMetadata: + description: Metadata about the exclusion filter. + properties: + added_at: + description: The timestamp when the exclusion filter was added. + example: '2023-05-04T15:26:41Z' + format: date-time + type: string + added_by: + description: The email address of the user who added the exclusion filter. + example: xxxx@xxxx.com + type: string + modified_at: + description: The timestamp when the exclusion filter was last modified. + example: '2023-05-30T15:45:51Z' + format: date-time + type: string + modified_by: + description: The email address of the user who last modified the exclusion + filter. + example: xxx@xxx.com + type: string + type: object + ASMExclusionFilterResponse: + description: Response object that includes a list of exclusion filters. + properties: + data: + description: The ASMExclusionFilterResponse data. + items: + $ref: '#/components/schemas/ASMExclusionFilterData' + type: array + type: object + ASMExclusionFilterRulesTarget: + description: A rule targeted by the exclusion filter. + properties: + rule_id: + description: The ID of the targeted rule. + example: dog-913-009 + type: string + type: object + ASMExclusionFilterScope: + description: The scope of the exclusion filter. + properties: + env: + description: The environment scope for the exclusion filter. + example: dd-appsec-php-support + type: string + service: + description: The service scope for the exclusion filter. + example: anil-php-weblog + type: string + type: object + ASMExclusionFilterType: + default: exclusion_filter + description: The type of the resource. The value should always be `exclusion_filter`. + enum: + - exclusion_filter + example: exclusion_filter + type: string + x-enum-varnames: + - EXCLUSION_FILTER + ASMExclusionFilterUpdateAttributes: + description: Update an existing ASM Exclusion filter. + properties: + description: + description: The description of the Exclusion filter. + example: My Exclusion filter + type: string + enabled: + description: Whether the Exclusion filter is enabled. + example: true + type: boolean + ip_list: + description: The IPs list for the exclusion filter. + items: + example: 127.0.0.1 + type: string + type: array + parameters: + description: A list of parameters for the exclusion filter. + items: + example: list.search.query + type: string + type: array + path_glob: + description: The path glob for the exclusion filter. + example: /lfi_include/* + type: string + rules_target: + description: A list of rules targeted by the exclusion filter. + items: + $ref: '#/components/schemas/ASMExclusionFilterRulesTarget' + type: array + scope: + description: The scope of the exclusion filter. + items: + $ref: '#/components/schemas/ASMExclusionFilterScope' + type: array + required: + - description + - enabled + - path_glob + type: object + ASMExclusionFilterUpdateData: + description: Object for a single Exclusion filter. + properties: + attributes: + $ref: '#/components/schemas/ASMExclusionFilterUpdateAttributes' + id: + $ref: '#/components/schemas/ASMExclusionFilterID' + type: + $ref: '#/components/schemas/ASMExclusionFilterType' + required: + - attributes + - type + type: object + ASMExclusionFilterUpdateRequest: + description: Request object that includes the Exclusion filter with the attributes + to update. + properties: + data: + $ref: '#/components/schemas/ASMExclusionFilterUpdateData' + required: + - data + type: object + ASMExclusionListFilterData: + description: Object for a single Exclusion filter. + properties: + attributes: + $ref: '#/components/schemas/ASMExclusionFilterListAttributes' + id: + description: The ID of the Exclusion filter. + example: 3dd-0uc-h1s + type: string + type: + $ref: '#/components/schemas/ASMExclusionFilterType' + type: object AWSRelatedAccount: description: AWS related account. properties: @@ -34924,6 +35252,125 @@ paths: We are gradually onboarding support for more sources. If you have any feedback, contact [Datadog Support](https://docs.datadoghq.com/help/).' + /api/v2/remote_config/products/asm/waf/exclusion_filters: + get: + description: Retrieve a list of ASM exclusion filters. + operationId: ListASMExclusionFilters + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/ASMExclusionFilterListResponse' + description: OK + '403': + $ref: '#/components/responses/NotAuthorizedResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: List ASM Exclusion Filters + tags: + - ASM Exclusion Filters + post: + description: Create a new exclusion filter with the given parameters. + operationId: CreateASMExclusionFilter + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ASMExclusionFilterCreateRequest' + description: The definition of the new Exclusion filter. + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/ASMExclusionFilterResponse' + description: OK + '400': + $ref: '#/components/responses/BadRequestResponse' + '403': + $ref: '#/components/responses/NotAuthorizedResponse' + '409': + $ref: '#/components/responses/ConflictResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: Create a ASM WAF Exclusion filter + tags: + - ASM Exclusion Filters + x-codegen-request-body-name: body + /api/v2/remote_config/products/asm/waf/exclusion_filters/{exclusion_filter_id}: + delete: + description: Delete a specific ASM Exclusion filter. + operationId: DeleteASMExclusionFilter + parameters: + - $ref: '#/components/parameters/ASMExclusionFilterID' + responses: + '204': + description: OK + '403': + $ref: '#/components/responses/NotAuthorizedResponse' + '404': + $ref: '#/components/responses/NotFoundResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: Delete a ASM Exclusion Filter + tags: + - ASM Exclusion Filters + get: + description: Retrieve a specific ASM exclusion filter by ID. + operationId: GetASMExclusionFilters + parameters: + - $ref: '#/components/parameters/ASMExclusionFilterID' + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/ASMExclusionFilterResponse' + description: OK + '403': + $ref: '#/components/responses/NotAuthorizedResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: Get a specific ASM Exclusion Filter + tags: + - ASM Exclusion Filters + patch: + description: 'Update a specific Exclusion filter. + + Returns the Exclusion filter object when the request is successful.' + operationId: UpdateASMExclusionFilter + parameters: + - $ref: '#/components/parameters/ASMExclusionFilterID' + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ASMExclusionFilterUpdateRequest' + description: New definition of the Exclusion filter. + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/ASMExclusionFilterResponse' + 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 ASM Exclusion filter + tags: + - ASM Exclusion Filters + x-codegen-request-body-name: body /api/v2/remote_config/products/cws/agent_rules: get: description: Get the list of Cloud Security Management Threats Agent rules. @@ -41311,6 +41758,9 @@ tags: description: Find out more at url: https://docs.datadoghq.com/tracing/trace_pipeline/trace_retention/ name: APM Retention Filters +- description: Exclusion filters in ASM libraries are used to circumvent false positives + in protection. + name: ASM Exclusion Filters - description: Search your Audit Logs events over HTTP. name: Audit - description: '[The AuthN Mappings API](https://docs.datadoghq.com/account_management/authn_mapping/?tab=example) diff --git a/api/datadogV2/api_asm_exclusion_filters.go b/api/datadogV2/api_asm_exclusion_filters.go new file mode 100644 index 00000000000..007b0951911 --- /dev/null +++ b/api/datadogV2/api_asm_exclusion_filters.go @@ -0,0 +1,374 @@ +// 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" + "strings" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// ASMExclusionFiltersApi service type +type ASMExclusionFiltersApi datadog.Service + +// CreateASMExclusionFilter Create a ASM WAF Exclusion filter. +// Create a new exclusion filter with the given parameters. +func (a *ASMExclusionFiltersApi) CreateASMExclusionFilter(ctx _context.Context, body ASMExclusionFilterCreateRequest) (ASMExclusionFilterResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPost + localVarPostBody interface{} + localVarReturnValue ASMExclusionFilterResponse + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.ASMExclusionFiltersApi.CreateASMExclusionFilter") + 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 +} + +// DeleteASMExclusionFilter Delete a ASM Exclusion Filter. +// Delete a specific ASM Exclusion filter. +func (a *ASMExclusionFiltersApi) DeleteASMExclusionFilter(ctx _context.Context, exclusionFilterId string) (*_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodDelete + localVarPostBody interface{} + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.ASMExclusionFiltersApi.DeleteASMExclusionFilter") + 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 = strings.Replace(localVarPath, "{"+"exclusion_filter_id"+"}", _neturl.PathEscape(datadog.ParameterToString(exclusionFilterId, "")), -1) + + 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 == 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 +} + +// GetASMExclusionFilters Get a specific ASM Exclusion Filter. +// Retrieve a specific ASM exclusion filter by ID. +func (a *ASMExclusionFiltersApi) GetASMExclusionFilters(ctx _context.Context, exclusionFilterId string) (ASMExclusionFilterResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarReturnValue ASMExclusionFilterResponse + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.ASMExclusionFiltersApi.GetASMExclusionFilters") + 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 = strings.Replace(localVarPath, "{"+"exclusion_filter_id"+"}", _neturl.PathEscape(datadog.ParameterToString(exclusionFilterId, "")), -1) + + 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 +} + +// ListASMExclusionFilters List ASM Exclusion Filters. +// Retrieve a list of ASM exclusion filters. +func (a *ASMExclusionFiltersApi) ListASMExclusionFilters(ctx _context.Context) (ASMExclusionFilterListResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarReturnValue ASMExclusionFilterListResponse + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.ASMExclusionFiltersApi.ListASMExclusionFilters") + 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 +} + +// UpdateASMExclusionFilter Update a ASM Exclusion filter. +// Update a specific Exclusion filter. +// Returns the Exclusion filter object when the request is successful. +func (a *ASMExclusionFiltersApi) UpdateASMExclusionFilter(ctx _context.Context, exclusionFilterId string, body ASMExclusionFilterUpdateRequest) (ASMExclusionFilterResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPatch + localVarPostBody interface{} + localVarReturnValue ASMExclusionFilterResponse + ) + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.ASMExclusionFiltersApi.UpdateASMExclusionFilter") + 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 = strings.Replace(localVarPath, "{"+"exclusion_filter_id"+"}", _neturl.PathEscape(datadog.ParameterToString(exclusionFilterId, "")), -1) + + 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 +} + +// NewASMExclusionFiltersApi Returns NewASMExclusionFiltersApi. +func NewASMExclusionFiltersApi(client *datadog.APIClient) *ASMExclusionFiltersApi { + return &ASMExclusionFiltersApi{ + Client: client, + } +} diff --git a/api/datadogV2/doc.go b/api/datadogV2/doc.go index 8a27584b8b8..fe431d8fa58 100644 --- a/api/datadogV2/doc.go +++ b/api/datadogV2/doc.go @@ -14,6 +14,11 @@ // - [APMRetentionFiltersApi.ListApmRetentionFilters] // - [APMRetentionFiltersApi.ReorderApmRetentionFilters] // - [APMRetentionFiltersApi.UpdateApmRetentionFilter] +// - [ASMExclusionFiltersApi.CreateASMExclusionFilter] +// - [ASMExclusionFiltersApi.DeleteASMExclusionFilter] +// - [ASMExclusionFiltersApi.GetASMExclusionFilters] +// - [ASMExclusionFiltersApi.ListASMExclusionFilters] +// - [ASMExclusionFiltersApi.UpdateASMExclusionFilter] // - [AuditApi.ListAuditLogs] // - [AuditApi.SearchAuditLogs] // - [AuthNMappingsApi.CreateAuthNMapping] diff --git a/api/datadogV2/model_asm_exclusion_filter_attributes.go b/api/datadogV2/model_asm_exclusion_filter_attributes.go new file mode 100644 index 00000000000..4efc6298d6e --- /dev/null +++ b/api/datadogV2/model_asm_exclusion_filter_attributes.go @@ -0,0 +1,356 @@ +// 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" +) + +// ASMExclusionFilterAttributes The attributes of the ASM WAF exclusion filter. +type ASMExclusionFilterAttributes 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 IPs list for the exclusion filter. + IpList []string `json:"ip_list,omitempty"` + // Metadata about the exclusion filter. + Metadata *ASMExclusionFilterMetadata `json:"metadata,omitempty"` + // A list of parameters for the exclusion filter. + Parameters []string `json:"parameters,omitempty"` + // The path glob for the exclusion filter. + PathGlob *string `json:"path_glob,omitempty"` + // A list of rules targeted by the exclusion filter. + RulesTarget []ASMExclusionFilterRulesTarget `json:"rules_target,omitempty"` + // The scope of the exclusion filter. + Scope []ASMExclusionFilterScope `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:"-"` +} + +// NewASMExclusionFilterAttributes instantiates a new ASMExclusionFilterAttributes 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 NewASMExclusionFilterAttributes() *ASMExclusionFilterAttributes { + this := ASMExclusionFilterAttributes{} + return &this +} + +// NewASMExclusionFilterAttributesWithDefaults instantiates a new ASMExclusionFilterAttributes 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 NewASMExclusionFilterAttributesWithDefaults() *ASMExclusionFilterAttributes { + this := ASMExclusionFilterAttributes{} + return &this +} + +// GetDescription returns the Description field value if set, zero value otherwise. +func (o *ASMExclusionFilterAttributes) 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 *ASMExclusionFilterAttributes) 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 *ASMExclusionFilterAttributes) 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 *ASMExclusionFilterAttributes) SetDescription(v string) { + o.Description = &v +} + +// GetEnabled returns the Enabled field value if set, zero value otherwise. +func (o *ASMExclusionFilterAttributes) 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 *ASMExclusionFilterAttributes) 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 *ASMExclusionFilterAttributes) 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 *ASMExclusionFilterAttributes) SetEnabled(v bool) { + o.Enabled = &v +} + +// GetIpList returns the IpList field value if set, zero value otherwise. +func (o *ASMExclusionFilterAttributes) 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 *ASMExclusionFilterAttributes) 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 *ASMExclusionFilterAttributes) 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 *ASMExclusionFilterAttributes) SetIpList(v []string) { + o.IpList = v +} + +// GetMetadata returns the Metadata field value if set, zero value otherwise. +func (o *ASMExclusionFilterAttributes) GetMetadata() ASMExclusionFilterMetadata { + if o == nil || o.Metadata == nil { + var ret ASMExclusionFilterMetadata + 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 *ASMExclusionFilterAttributes) GetMetadataOk() (*ASMExclusionFilterMetadata, 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 *ASMExclusionFilterAttributes) HasMetadata() bool { + return o != nil && o.Metadata != nil +} + +// SetMetadata gets a reference to the given ASMExclusionFilterMetadata and assigns it to the Metadata field. +func (o *ASMExclusionFilterAttributes) SetMetadata(v ASMExclusionFilterMetadata) { + o.Metadata = &v +} + +// GetParameters returns the Parameters field value if set, zero value otherwise. +func (o *ASMExclusionFilterAttributes) 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 *ASMExclusionFilterAttributes) 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 *ASMExclusionFilterAttributes) 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 *ASMExclusionFilterAttributes) SetParameters(v []string) { + o.Parameters = v +} + +// GetPathGlob returns the PathGlob field value if set, zero value otherwise. +func (o *ASMExclusionFilterAttributes) 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 *ASMExclusionFilterAttributes) 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 *ASMExclusionFilterAttributes) 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 *ASMExclusionFilterAttributes) SetPathGlob(v string) { + o.PathGlob = &v +} + +// GetRulesTarget returns the RulesTarget field value if set, zero value otherwise. +func (o *ASMExclusionFilterAttributes) GetRulesTarget() []ASMExclusionFilterRulesTarget { + if o == nil || o.RulesTarget == nil { + var ret []ASMExclusionFilterRulesTarget + 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 *ASMExclusionFilterAttributes) GetRulesTargetOk() (*[]ASMExclusionFilterRulesTarget, 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 *ASMExclusionFilterAttributes) HasRulesTarget() bool { + return o != nil && o.RulesTarget != nil +} + +// SetRulesTarget gets a reference to the given []ASMExclusionFilterRulesTarget and assigns it to the RulesTarget field. +func (o *ASMExclusionFilterAttributes) SetRulesTarget(v []ASMExclusionFilterRulesTarget) { + o.RulesTarget = v +} + +// GetScope returns the Scope field value if set, zero value otherwise. +func (o *ASMExclusionFilterAttributes) GetScope() []ASMExclusionFilterScope { + if o == nil || o.Scope == nil { + var ret []ASMExclusionFilterScope + 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 *ASMExclusionFilterAttributes) GetScopeOk() (*[]ASMExclusionFilterScope, 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 *ASMExclusionFilterAttributes) HasScope() bool { + return o != nil && o.Scope != nil +} + +// SetScope gets a reference to the given []ASMExclusionFilterScope and assigns it to the Scope field. +func (o *ASMExclusionFilterAttributes) SetScope(v []ASMExclusionFilterScope) { + o.Scope = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ASMExclusionFilterAttributes) 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.IpList != nil { + toSerialize["ip_list"] = o.IpList + } + if o.Metadata != nil { + toSerialize["metadata"] = o.Metadata + } + 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 *ASMExclusionFilterAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Description *string `json:"description,omitempty"` + Enabled *bool `json:"enabled,omitempty"` + IpList []string `json:"ip_list,omitempty"` + Metadata *ASMExclusionFilterMetadata `json:"metadata,omitempty"` + Parameters []string `json:"parameters,omitempty"` + PathGlob *string `json:"path_glob,omitempty"` + RulesTarget []ASMExclusionFilterRulesTarget `json:"rules_target,omitempty"` + Scope []ASMExclusionFilterScope `json:"scope,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", "ip_list", "metadata", "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.Metadata != nil && all.Metadata.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Metadata = all.Metadata + 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_asm_exclusion_filter_create_attributes.go b/api/datadogV2/model_asm_exclusion_filter_create_attributes.go new file mode 100644 index 00000000000..b8a17cc9767 --- /dev/null +++ b/api/datadogV2/model_asm_exclusion_filter_create_attributes.go @@ -0,0 +1,305 @@ +// 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" +) + +// ASMExclusionFilterCreateAttributes Create a new ASM WAF exclusion filter. +type ASMExclusionFilterCreateAttributes struct { + // A description for the exclusion filter. + Description string `json:"description"` + // Indicates whether the exclusion filter is enabled. + Enabled bool `json:"enabled"` + // The IPs list for the exclusion filter. + IpList []string `json:"ip_list,omitempty"` + // A list of parameters for the exclusion filter. + Parameters []string `json:"parameters,omitempty"` + // The path glob for the exclusion filter. + PathGlob string `json:"path_glob"` + // A list of rules targeted by the exclusion filter. + RulesTarget []ASMExclusionFilterRulesTarget `json:"rules_target,omitempty"` + // The scope of the exclusion filter. + Scope []ASMExclusionFilterScope `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:"-"` +} + +// NewASMExclusionFilterCreateAttributes instantiates a new ASMExclusionFilterCreateAttributes 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 NewASMExclusionFilterCreateAttributes(description string, enabled bool, pathGlob string) *ASMExclusionFilterCreateAttributes { + this := ASMExclusionFilterCreateAttributes{} + this.Description = description + this.Enabled = enabled + this.PathGlob = pathGlob + return &this +} + +// NewASMExclusionFilterCreateAttributesWithDefaults instantiates a new ASMExclusionFilterCreateAttributes 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 NewASMExclusionFilterCreateAttributesWithDefaults() *ASMExclusionFilterCreateAttributes { + this := ASMExclusionFilterCreateAttributes{} + return &this +} + +// GetDescription returns the Description field value. +func (o *ASMExclusionFilterCreateAttributes) 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 *ASMExclusionFilterCreateAttributes) GetDescriptionOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Description, true +} + +// SetDescription sets field value. +func (o *ASMExclusionFilterCreateAttributes) SetDescription(v string) { + o.Description = v +} + +// GetEnabled returns the Enabled field value. +func (o *ASMExclusionFilterCreateAttributes) 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 *ASMExclusionFilterCreateAttributes) GetEnabledOk() (*bool, bool) { + if o == nil { + return nil, false + } + return &o.Enabled, true +} + +// SetEnabled sets field value. +func (o *ASMExclusionFilterCreateAttributes) SetEnabled(v bool) { + o.Enabled = v +} + +// GetIpList returns the IpList field value if set, zero value otherwise. +func (o *ASMExclusionFilterCreateAttributes) 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 *ASMExclusionFilterCreateAttributes) 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 *ASMExclusionFilterCreateAttributes) 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 *ASMExclusionFilterCreateAttributes) SetIpList(v []string) { + o.IpList = v +} + +// GetParameters returns the Parameters field value if set, zero value otherwise. +func (o *ASMExclusionFilterCreateAttributes) 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 *ASMExclusionFilterCreateAttributes) 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 *ASMExclusionFilterCreateAttributes) 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 *ASMExclusionFilterCreateAttributes) SetParameters(v []string) { + o.Parameters = v +} + +// GetPathGlob returns the PathGlob field value. +func (o *ASMExclusionFilterCreateAttributes) GetPathGlob() string { + if o == nil { + var ret string + return ret + } + return o.PathGlob +} + +// GetPathGlobOk returns a tuple with the PathGlob field value +// and a boolean to check if the value has been set. +func (o *ASMExclusionFilterCreateAttributes) GetPathGlobOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.PathGlob, true +} + +// SetPathGlob sets field value. +func (o *ASMExclusionFilterCreateAttributes) SetPathGlob(v string) { + o.PathGlob = v +} + +// GetRulesTarget returns the RulesTarget field value if set, zero value otherwise. +func (o *ASMExclusionFilterCreateAttributes) GetRulesTarget() []ASMExclusionFilterRulesTarget { + if o == nil || o.RulesTarget == nil { + var ret []ASMExclusionFilterRulesTarget + 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 *ASMExclusionFilterCreateAttributes) GetRulesTargetOk() (*[]ASMExclusionFilterRulesTarget, 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 *ASMExclusionFilterCreateAttributes) HasRulesTarget() bool { + return o != nil && o.RulesTarget != nil +} + +// SetRulesTarget gets a reference to the given []ASMExclusionFilterRulesTarget and assigns it to the RulesTarget field. +func (o *ASMExclusionFilterCreateAttributes) SetRulesTarget(v []ASMExclusionFilterRulesTarget) { + o.RulesTarget = v +} + +// GetScope returns the Scope field value if set, zero value otherwise. +func (o *ASMExclusionFilterCreateAttributes) GetScope() []ASMExclusionFilterScope { + if o == nil || o.Scope == nil { + var ret []ASMExclusionFilterScope + 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 *ASMExclusionFilterCreateAttributes) GetScopeOk() (*[]ASMExclusionFilterScope, 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 *ASMExclusionFilterCreateAttributes) HasScope() bool { + return o != nil && o.Scope != nil +} + +// SetScope gets a reference to the given []ASMExclusionFilterScope and assigns it to the Scope field. +func (o *ASMExclusionFilterCreateAttributes) SetScope(v []ASMExclusionFilterScope) { + o.Scope = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ASMExclusionFilterCreateAttributes) 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.Parameters != nil { + toSerialize["parameters"] = o.Parameters + } + 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 *ASMExclusionFilterCreateAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Description *string `json:"description"` + Enabled *bool `json:"enabled"` + IpList []string `json:"ip_list,omitempty"` + Parameters []string `json:"parameters,omitempty"` + PathGlob *string `json:"path_glob"` + RulesTarget []ASMExclusionFilterRulesTarget `json:"rules_target,omitempty"` + Scope []ASMExclusionFilterScope `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") + } + if all.PathGlob == nil { + return fmt.Errorf("required field path_glob missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"description", "enabled", "ip_list", "parameters", "path_glob", "rules_target", "scope"}) + } else { + return err + } + o.Description = *all.Description + o.Enabled = *all.Enabled + o.IpList = all.IpList + o.Parameters = all.Parameters + o.PathGlob = *all.PathGlob + o.RulesTarget = all.RulesTarget + o.Scope = all.Scope + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_asm_exclusion_filter_create_data.go b/api/datadogV2/model_asm_exclusion_filter_create_data.go new file mode 100644 index 00000000000..27ba8e44c78 --- /dev/null +++ b/api/datadogV2/model_asm_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" +) + +// ASMExclusionFilterCreateData Object for a single exclusion filter. +type ASMExclusionFilterCreateData struct { + // Create a new ASM WAF exclusion filter. + Attributes ASMExclusionFilterCreateAttributes `json:"attributes"` + // The type of the resource. The value should always be `exclusion_filter`. + Type ASMExclusionFilterType `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:"-"` +} + +// NewASMExclusionFilterCreateData instantiates a new ASMExclusionFilterCreateData 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 NewASMExclusionFilterCreateData(attributes ASMExclusionFilterCreateAttributes, typeVar ASMExclusionFilterType) *ASMExclusionFilterCreateData { + this := ASMExclusionFilterCreateData{} + this.Attributes = attributes + this.Type = typeVar + return &this +} + +// NewASMExclusionFilterCreateDataWithDefaults instantiates a new ASMExclusionFilterCreateData 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 NewASMExclusionFilterCreateDataWithDefaults() *ASMExclusionFilterCreateData { + this := ASMExclusionFilterCreateData{} + var typeVar ASMExclusionFilterType = ASMEXCLUSIONFILTERTYPE_EXCLUSION_FILTER + this.Type = typeVar + return &this +} + +// GetAttributes returns the Attributes field value. +func (o *ASMExclusionFilterCreateData) GetAttributes() ASMExclusionFilterCreateAttributes { + if o == nil { + var ret ASMExclusionFilterCreateAttributes + 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 *ASMExclusionFilterCreateData) GetAttributesOk() (*ASMExclusionFilterCreateAttributes, bool) { + if o == nil { + return nil, false + } + return &o.Attributes, true +} + +// SetAttributes sets field value. +func (o *ASMExclusionFilterCreateData) SetAttributes(v ASMExclusionFilterCreateAttributes) { + o.Attributes = v +} + +// GetType returns the Type field value. +func (o *ASMExclusionFilterCreateData) GetType() ASMExclusionFilterType { + if o == nil { + var ret ASMExclusionFilterType + 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 *ASMExclusionFilterCreateData) GetTypeOk() (*ASMExclusionFilterType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *ASMExclusionFilterCreateData) SetType(v ASMExclusionFilterType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ASMExclusionFilterCreateData) 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 *ASMExclusionFilterCreateData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *ASMExclusionFilterCreateAttributes `json:"attributes"` + Type *ASMExclusionFilterType `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_asm_exclusion_filter_create_request.go b/api/datadogV2/model_asm_exclusion_filter_create_request.go new file mode 100644 index 00000000000..461ebd60234 --- /dev/null +++ b/api/datadogV2/model_asm_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" +) + +// ASMExclusionFilterCreateRequest Request object that includes the exclusion filter to create. +type ASMExclusionFilterCreateRequest struct { + // Object for a single exclusion filter. + Data ASMExclusionFilterCreateData `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:"-"` +} + +// NewASMExclusionFilterCreateRequest instantiates a new ASMExclusionFilterCreateRequest 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 NewASMExclusionFilterCreateRequest(data ASMExclusionFilterCreateData) *ASMExclusionFilterCreateRequest { + this := ASMExclusionFilterCreateRequest{} + this.Data = data + return &this +} + +// NewASMExclusionFilterCreateRequestWithDefaults instantiates a new ASMExclusionFilterCreateRequest 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 NewASMExclusionFilterCreateRequestWithDefaults() *ASMExclusionFilterCreateRequest { + this := ASMExclusionFilterCreateRequest{} + return &this +} + +// GetData returns the Data field value. +func (o *ASMExclusionFilterCreateRequest) GetData() ASMExclusionFilterCreateData { + if o == nil { + var ret ASMExclusionFilterCreateData + 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 *ASMExclusionFilterCreateRequest) GetDataOk() (*ASMExclusionFilterCreateData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *ASMExclusionFilterCreateRequest) SetData(v ASMExclusionFilterCreateData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ASMExclusionFilterCreateRequest) 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 *ASMExclusionFilterCreateRequest) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *ASMExclusionFilterCreateData `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_asm_exclusion_filter_data.go b/api/datadogV2/model_asm_exclusion_filter_data.go new file mode 100644 index 00000000000..c4242c1192c --- /dev/null +++ b/api/datadogV2/model_asm_exclusion_filter_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" +) + +// ASMExclusionFilterData Object for a single Exclusion filter. +type ASMExclusionFilterData struct { + // The attributes of the ASM WAF exclusion filter. + Attributes *ASMExclusionFilterAttributes `json:"attributes,omitempty"` + // The ID of the Exclusion filter. + Id *string `json:"id,omitempty"` + // The type of the resource. The value should always be `exclusion_filter`. + Type *ASMExclusionFilterType `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:"-"` +} + +// NewASMExclusionFilterData instantiates a new ASMExclusionFilterData 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 NewASMExclusionFilterData() *ASMExclusionFilterData { + this := ASMExclusionFilterData{} + var typeVar ASMExclusionFilterType = ASMEXCLUSIONFILTERTYPE_EXCLUSION_FILTER + this.Type = &typeVar + return &this +} + +// NewASMExclusionFilterDataWithDefaults instantiates a new ASMExclusionFilterData 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 NewASMExclusionFilterDataWithDefaults() *ASMExclusionFilterData { + this := ASMExclusionFilterData{} + var typeVar ASMExclusionFilterType = ASMEXCLUSIONFILTERTYPE_EXCLUSION_FILTER + this.Type = &typeVar + return &this +} + +// GetAttributes returns the Attributes field value if set, zero value otherwise. +func (o *ASMExclusionFilterData) GetAttributes() ASMExclusionFilterAttributes { + if o == nil || o.Attributes == nil { + var ret ASMExclusionFilterAttributes + 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 *ASMExclusionFilterData) GetAttributesOk() (*ASMExclusionFilterAttributes, 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 *ASMExclusionFilterData) HasAttributes() bool { + return o != nil && o.Attributes != nil +} + +// SetAttributes gets a reference to the given ASMExclusionFilterAttributes and assigns it to the Attributes field. +func (o *ASMExclusionFilterData) SetAttributes(v ASMExclusionFilterAttributes) { + o.Attributes = &v +} + +// GetId returns the Id field value if set, zero value otherwise. +func (o *ASMExclusionFilterData) 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 *ASMExclusionFilterData) 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 *ASMExclusionFilterData) 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 *ASMExclusionFilterData) SetId(v string) { + o.Id = &v +} + +// GetType returns the Type field value if set, zero value otherwise. +func (o *ASMExclusionFilterData) GetType() ASMExclusionFilterType { + if o == nil || o.Type == nil { + var ret ASMExclusionFilterType + 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 *ASMExclusionFilterData) GetTypeOk() (*ASMExclusionFilterType, 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 *ASMExclusionFilterData) HasType() bool { + return o != nil && o.Type != nil +} + +// SetType gets a reference to the given ASMExclusionFilterType and assigns it to the Type field. +func (o *ASMExclusionFilterData) SetType(v ASMExclusionFilterType) { + o.Type = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ASMExclusionFilterData) 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 *ASMExclusionFilterData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *ASMExclusionFilterAttributes `json:"attributes,omitempty"` + Id *string `json:"id,omitempty"` + Type *ASMExclusionFilterType `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_asm_exclusion_filter_list_attributes.go b/api/datadogV2/model_asm_exclusion_filter_list_attributes.go new file mode 100644 index 00000000000..1815dc49fe5 --- /dev/null +++ b/api/datadogV2/model_asm_exclusion_filter_list_attributes.go @@ -0,0 +1,356 @@ +// 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" +) + +// ASMExclusionFilterListAttributes The attributes of the ASM WAF exclusion filter. +type ASMExclusionFilterListAttributes 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 IPs list for the exclusion filter. + IpList []string `json:"ip_list,omitempty"` + // Metadata about the exclusion filter. + Metadata *ASMExclusionFilterMetadata `json:"metadata,omitempty"` + // A list of parameters for the exclusion filter. + Parameters []string `json:"parameters,omitempty"` + // The path glob for the exclusion filter. + PathGlob *string `json:"path_glob,omitempty"` + // A list of rules targeted by the exclusion filter. + RulesTarget []ASMExclusionFilterListRulesTarget `json:"rules_target,omitempty"` + // The scope of the exclusion filter. + Scope []ASMExclusionFilterScope `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:"-"` +} + +// NewASMExclusionFilterListAttributes instantiates a new ASMExclusionFilterListAttributes 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 NewASMExclusionFilterListAttributes() *ASMExclusionFilterListAttributes { + this := ASMExclusionFilterListAttributes{} + return &this +} + +// NewASMExclusionFilterListAttributesWithDefaults instantiates a new ASMExclusionFilterListAttributes 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 NewASMExclusionFilterListAttributesWithDefaults() *ASMExclusionFilterListAttributes { + this := ASMExclusionFilterListAttributes{} + return &this +} + +// GetDescription returns the Description field value if set, zero value otherwise. +func (o *ASMExclusionFilterListAttributes) 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 *ASMExclusionFilterListAttributes) 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 *ASMExclusionFilterListAttributes) 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 *ASMExclusionFilterListAttributes) SetDescription(v string) { + o.Description = &v +} + +// GetEnabled returns the Enabled field value if set, zero value otherwise. +func (o *ASMExclusionFilterListAttributes) 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 *ASMExclusionFilterListAttributes) 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 *ASMExclusionFilterListAttributes) 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 *ASMExclusionFilterListAttributes) SetEnabled(v bool) { + o.Enabled = &v +} + +// GetIpList returns the IpList field value if set, zero value otherwise. +func (o *ASMExclusionFilterListAttributes) 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 *ASMExclusionFilterListAttributes) 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 *ASMExclusionFilterListAttributes) 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 *ASMExclusionFilterListAttributes) SetIpList(v []string) { + o.IpList = v +} + +// GetMetadata returns the Metadata field value if set, zero value otherwise. +func (o *ASMExclusionFilterListAttributes) GetMetadata() ASMExclusionFilterMetadata { + if o == nil || o.Metadata == nil { + var ret ASMExclusionFilterMetadata + 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 *ASMExclusionFilterListAttributes) GetMetadataOk() (*ASMExclusionFilterMetadata, 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 *ASMExclusionFilterListAttributes) HasMetadata() bool { + return o != nil && o.Metadata != nil +} + +// SetMetadata gets a reference to the given ASMExclusionFilterMetadata and assigns it to the Metadata field. +func (o *ASMExclusionFilterListAttributes) SetMetadata(v ASMExclusionFilterMetadata) { + o.Metadata = &v +} + +// GetParameters returns the Parameters field value if set, zero value otherwise. +func (o *ASMExclusionFilterListAttributes) 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 *ASMExclusionFilterListAttributes) 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 *ASMExclusionFilterListAttributes) 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 *ASMExclusionFilterListAttributes) SetParameters(v []string) { + o.Parameters = v +} + +// GetPathGlob returns the PathGlob field value if set, zero value otherwise. +func (o *ASMExclusionFilterListAttributes) 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 *ASMExclusionFilterListAttributes) 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 *ASMExclusionFilterListAttributes) 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 *ASMExclusionFilterListAttributes) SetPathGlob(v string) { + o.PathGlob = &v +} + +// GetRulesTarget returns the RulesTarget field value if set, zero value otherwise. +func (o *ASMExclusionFilterListAttributes) GetRulesTarget() []ASMExclusionFilterListRulesTarget { + if o == nil || o.RulesTarget == nil { + var ret []ASMExclusionFilterListRulesTarget + 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 *ASMExclusionFilterListAttributes) GetRulesTargetOk() (*[]ASMExclusionFilterListRulesTarget, 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 *ASMExclusionFilterListAttributes) HasRulesTarget() bool { + return o != nil && o.RulesTarget != nil +} + +// SetRulesTarget gets a reference to the given []ASMExclusionFilterListRulesTarget and assigns it to the RulesTarget field. +func (o *ASMExclusionFilterListAttributes) SetRulesTarget(v []ASMExclusionFilterListRulesTarget) { + o.RulesTarget = v +} + +// GetScope returns the Scope field value if set, zero value otherwise. +func (o *ASMExclusionFilterListAttributes) GetScope() []ASMExclusionFilterScope { + if o == nil || o.Scope == nil { + var ret []ASMExclusionFilterScope + 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 *ASMExclusionFilterListAttributes) GetScopeOk() (*[]ASMExclusionFilterScope, 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 *ASMExclusionFilterListAttributes) HasScope() bool { + return o != nil && o.Scope != nil +} + +// SetScope gets a reference to the given []ASMExclusionFilterScope and assigns it to the Scope field. +func (o *ASMExclusionFilterListAttributes) SetScope(v []ASMExclusionFilterScope) { + o.Scope = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ASMExclusionFilterListAttributes) 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.IpList != nil { + toSerialize["ip_list"] = o.IpList + } + if o.Metadata != nil { + toSerialize["metadata"] = o.Metadata + } + 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 *ASMExclusionFilterListAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Description *string `json:"description,omitempty"` + Enabled *bool `json:"enabled,omitempty"` + IpList []string `json:"ip_list,omitempty"` + Metadata *ASMExclusionFilterMetadata `json:"metadata,omitempty"` + Parameters []string `json:"parameters,omitempty"` + PathGlob *string `json:"path_glob,omitempty"` + RulesTarget []ASMExclusionFilterListRulesTarget `json:"rules_target,omitempty"` + Scope []ASMExclusionFilterScope `json:"scope,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", "ip_list", "metadata", "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.Metadata != nil && all.Metadata.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Metadata = all.Metadata + 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_asm_exclusion_filter_list_response.go b/api/datadogV2/model_asm_exclusion_filter_list_response.go new file mode 100644 index 00000000000..f472eb640b6 --- /dev/null +++ b/api/datadogV2/model_asm_exclusion_filter_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" +) + +// ASMExclusionFilterListResponse Response object that includes a list of exclusion filters. +type ASMExclusionFilterListResponse struct { + // The ASMExclusionFilterResponse data. + Data []ASMExclusionListFilterData `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:"-"` +} + +// NewASMExclusionFilterListResponse instantiates a new ASMExclusionFilterListResponse 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 NewASMExclusionFilterListResponse() *ASMExclusionFilterListResponse { + this := ASMExclusionFilterListResponse{} + return &this +} + +// NewASMExclusionFilterListResponseWithDefaults instantiates a new ASMExclusionFilterListResponse 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 NewASMExclusionFilterListResponseWithDefaults() *ASMExclusionFilterListResponse { + this := ASMExclusionFilterListResponse{} + return &this +} + +// GetData returns the Data field value if set, zero value otherwise. +func (o *ASMExclusionFilterListResponse) GetData() []ASMExclusionListFilterData { + if o == nil || o.Data == nil { + var ret []ASMExclusionListFilterData + 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 *ASMExclusionFilterListResponse) GetDataOk() (*[]ASMExclusionListFilterData, 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 *ASMExclusionFilterListResponse) HasData() bool { + return o != nil && o.Data != nil +} + +// SetData gets a reference to the given []ASMExclusionListFilterData and assigns it to the Data field. +func (o *ASMExclusionFilterListResponse) SetData(v []ASMExclusionListFilterData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ASMExclusionFilterListResponse) 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 *ASMExclusionFilterListResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data []ASMExclusionListFilterData `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_asm_exclusion_filter_list_rules_target.go b/api/datadogV2/model_asm_exclusion_filter_list_rules_target.go new file mode 100644 index 00000000000..051daab245a --- /dev/null +++ b/api/datadogV2/model_asm_exclusion_filter_list_rules_target.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" +) + +// ASMExclusionFilterListRulesTarget A rule targeted by the exclusion filter. +type ASMExclusionFilterListRulesTarget struct { + // Tags identifying the category and type of the targeted rule. + Tags *ASMExclusionFilterListRulesTargetTags `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:"-"` +} + +// NewASMExclusionFilterListRulesTarget instantiates a new ASMExclusionFilterListRulesTarget 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 NewASMExclusionFilterListRulesTarget() *ASMExclusionFilterListRulesTarget { + this := ASMExclusionFilterListRulesTarget{} + return &this +} + +// NewASMExclusionFilterListRulesTargetWithDefaults instantiates a new ASMExclusionFilterListRulesTarget 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 NewASMExclusionFilterListRulesTargetWithDefaults() *ASMExclusionFilterListRulesTarget { + this := ASMExclusionFilterListRulesTarget{} + return &this +} + +// GetTags returns the Tags field value if set, zero value otherwise. +func (o *ASMExclusionFilterListRulesTarget) GetTags() ASMExclusionFilterListRulesTargetTags { + if o == nil || o.Tags == nil { + var ret ASMExclusionFilterListRulesTargetTags + 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 *ASMExclusionFilterListRulesTarget) GetTagsOk() (*ASMExclusionFilterListRulesTargetTags, 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 *ASMExclusionFilterListRulesTarget) HasTags() bool { + return o != nil && o.Tags != nil +} + +// SetTags gets a reference to the given ASMExclusionFilterListRulesTargetTags and assigns it to the Tags field. +func (o *ASMExclusionFilterListRulesTarget) SetTags(v ASMExclusionFilterListRulesTargetTags) { + o.Tags = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ASMExclusionFilterListRulesTarget) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + 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 *ASMExclusionFilterListRulesTarget) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Tags *ASMExclusionFilterListRulesTargetTags `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{"tags"}) + } else { + return err + } + + hasInvalidField := false + 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_asm_exclusion_filter_list_rules_target_tags.go b/api/datadogV2/model_asm_exclusion_filter_list_rules_target_tags.go new file mode 100644 index 00000000000..33cb2aaf1e8 --- /dev/null +++ b/api/datadogV2/model_asm_exclusion_filter_list_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" +) + +// ASMExclusionFilterListRulesTargetTags Tags identifying the category and type of the targeted rule. +type ASMExclusionFilterListRulesTargetTags struct { + // The category of the rule. + Category *string `json:"category,omitempty"` + // The type of the rule. + 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]interface{} `json:"-"` +} + +// NewASMExclusionFilterListRulesTargetTags instantiates a new ASMExclusionFilterListRulesTargetTags 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 NewASMExclusionFilterListRulesTargetTags() *ASMExclusionFilterListRulesTargetTags { + this := ASMExclusionFilterListRulesTargetTags{} + return &this +} + +// NewASMExclusionFilterListRulesTargetTagsWithDefaults instantiates a new ASMExclusionFilterListRulesTargetTags 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 NewASMExclusionFilterListRulesTargetTagsWithDefaults() *ASMExclusionFilterListRulesTargetTags { + this := ASMExclusionFilterListRulesTargetTags{} + return &this +} + +// GetCategory returns the Category field value if set, zero value otherwise. +func (o *ASMExclusionFilterListRulesTargetTags) 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 *ASMExclusionFilterListRulesTargetTags) 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 *ASMExclusionFilterListRulesTargetTags) 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 *ASMExclusionFilterListRulesTargetTags) SetCategory(v string) { + o.Category = &v +} + +// GetType returns the Type field value if set, zero value otherwise. +func (o *ASMExclusionFilterListRulesTargetTags) 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 *ASMExclusionFilterListRulesTargetTags) 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 *ASMExclusionFilterListRulesTargetTags) 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 *ASMExclusionFilterListRulesTargetTags) SetType(v string) { + o.Type = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ASMExclusionFilterListRulesTargetTags) 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 *ASMExclusionFilterListRulesTargetTags) 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]interface{}) + 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_asm_exclusion_filter_metadata.go b/api/datadogV2/model_asm_exclusion_filter_metadata.go new file mode 100644 index 00000000000..3d1e4aff00c --- /dev/null +++ b/api/datadogV2/model_asm_exclusion_filter_metadata.go @@ -0,0 +1,217 @@ +// 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" +) + +// ASMExclusionFilterMetadata Metadata about the exclusion filter. +type ASMExclusionFilterMetadata struct { + // The timestamp when the exclusion filter was added. + AddedAt *time.Time `json:"added_at,omitempty"` + // The email address of the user who added the exclusion filter. + AddedBy *string `json:"added_by,omitempty"` + // The timestamp when the exclusion filter was last modified. + ModifiedAt *time.Time `json:"modified_at,omitempty"` + // The email address of the user who last modified the exclusion filter. + ModifiedBy *string `json:"modified_by,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:"-"` +} + +// NewASMExclusionFilterMetadata instantiates a new ASMExclusionFilterMetadata 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 NewASMExclusionFilterMetadata() *ASMExclusionFilterMetadata { + this := ASMExclusionFilterMetadata{} + return &this +} + +// NewASMExclusionFilterMetadataWithDefaults instantiates a new ASMExclusionFilterMetadata 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 NewASMExclusionFilterMetadataWithDefaults() *ASMExclusionFilterMetadata { + this := ASMExclusionFilterMetadata{} + return &this +} + +// GetAddedAt returns the AddedAt field value if set, zero value otherwise. +func (o *ASMExclusionFilterMetadata) 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 *ASMExclusionFilterMetadata) 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 *ASMExclusionFilterMetadata) 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 *ASMExclusionFilterMetadata) SetAddedAt(v time.Time) { + o.AddedAt = &v +} + +// GetAddedBy returns the AddedBy field value if set, zero value otherwise. +func (o *ASMExclusionFilterMetadata) 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 *ASMExclusionFilterMetadata) 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 *ASMExclusionFilterMetadata) 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 *ASMExclusionFilterMetadata) SetAddedBy(v string) { + o.AddedBy = &v +} + +// GetModifiedAt returns the ModifiedAt field value if set, zero value otherwise. +func (o *ASMExclusionFilterMetadata) 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 *ASMExclusionFilterMetadata) 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 *ASMExclusionFilterMetadata) 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 *ASMExclusionFilterMetadata) SetModifiedAt(v time.Time) { + o.ModifiedAt = &v +} + +// GetModifiedBy returns the ModifiedBy field value if set, zero value otherwise. +func (o *ASMExclusionFilterMetadata) 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 *ASMExclusionFilterMetadata) 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 *ASMExclusionFilterMetadata) 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 *ASMExclusionFilterMetadata) SetModifiedBy(v string) { + o.ModifiedBy = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ASMExclusionFilterMetadata) 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.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 + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *ASMExclusionFilterMetadata) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + AddedAt *time.Time `json:"added_at,omitempty"` + AddedBy *string `json:"added_by,omitempty"` + ModifiedAt *time.Time `json:"modified_at,omitempty"` + ModifiedBy *string `json:"modified_by,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", "modified_at", "modified_by"}) + } else { + return err + } + o.AddedAt = all.AddedAt + o.AddedBy = all.AddedBy + o.ModifiedAt = all.ModifiedAt + o.ModifiedBy = all.ModifiedBy + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_asm_exclusion_filter_response.go b/api/datadogV2/model_asm_exclusion_filter_response.go new file mode 100644 index 00000000000..e48b4b7fb3d --- /dev/null +++ b/api/datadogV2/model_asm_exclusion_filter_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" +) + +// ASMExclusionFilterResponse Response object that includes a list of exclusion filters. +type ASMExclusionFilterResponse struct { + // The ASMExclusionFilterResponse data. + Data []ASMExclusionFilterData `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:"-"` +} + +// NewASMExclusionFilterResponse instantiates a new ASMExclusionFilterResponse 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 NewASMExclusionFilterResponse() *ASMExclusionFilterResponse { + this := ASMExclusionFilterResponse{} + return &this +} + +// NewASMExclusionFilterResponseWithDefaults instantiates a new ASMExclusionFilterResponse 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 NewASMExclusionFilterResponseWithDefaults() *ASMExclusionFilterResponse { + this := ASMExclusionFilterResponse{} + return &this +} + +// GetData returns the Data field value if set, zero value otherwise. +func (o *ASMExclusionFilterResponse) GetData() []ASMExclusionFilterData { + if o == nil || o.Data == nil { + var ret []ASMExclusionFilterData + 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 *ASMExclusionFilterResponse) GetDataOk() (*[]ASMExclusionFilterData, 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 *ASMExclusionFilterResponse) HasData() bool { + return o != nil && o.Data != nil +} + +// SetData gets a reference to the given []ASMExclusionFilterData and assigns it to the Data field. +func (o *ASMExclusionFilterResponse) SetData(v []ASMExclusionFilterData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ASMExclusionFilterResponse) 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 *ASMExclusionFilterResponse) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data []ASMExclusionFilterData `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_asm_exclusion_filter_rules_target.go b/api/datadogV2/model_asm_exclusion_filter_rules_target.go new file mode 100644 index 00000000000..40f9f3f7453 --- /dev/null +++ b/api/datadogV2/model_asm_exclusion_filter_rules_target.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" +) + +// ASMExclusionFilterRulesTarget A rule targeted by the exclusion filter. +type ASMExclusionFilterRulesTarget struct { + // The ID of the targeted rule. + RuleId *string `json:"rule_id,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:"-"` +} + +// NewASMExclusionFilterRulesTarget instantiates a new ASMExclusionFilterRulesTarget 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 NewASMExclusionFilterRulesTarget() *ASMExclusionFilterRulesTarget { + this := ASMExclusionFilterRulesTarget{} + return &this +} + +// NewASMExclusionFilterRulesTargetWithDefaults instantiates a new ASMExclusionFilterRulesTarget 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 NewASMExclusionFilterRulesTargetWithDefaults() *ASMExclusionFilterRulesTarget { + this := ASMExclusionFilterRulesTarget{} + return &this +} + +// GetRuleId returns the RuleId field value if set, zero value otherwise. +func (o *ASMExclusionFilterRulesTarget) 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 *ASMExclusionFilterRulesTarget) 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 *ASMExclusionFilterRulesTarget) 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 *ASMExclusionFilterRulesTarget) SetRuleId(v string) { + o.RuleId = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ASMExclusionFilterRulesTarget) 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 + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *ASMExclusionFilterRulesTarget) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + RuleId *string `json:"rule_id,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"}) + } else { + return err + } + o.RuleId = all.RuleId + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_asm_exclusion_filter_scope.go b/api/datadogV2/model_asm_exclusion_filter_scope.go new file mode 100644 index 00000000000..782bb29e7e7 --- /dev/null +++ b/api/datadogV2/model_asm_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" +) + +// ASMExclusionFilterScope The scope of the exclusion filter. +type ASMExclusionFilterScope struct { + // The environment scope for the exclusion filter. + Env *string `json:"env,omitempty"` + // The service scope for the exclusion filter. + 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:"-"` +} + +// NewASMExclusionFilterScope instantiates a new ASMExclusionFilterScope 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 NewASMExclusionFilterScope() *ASMExclusionFilterScope { + this := ASMExclusionFilterScope{} + return &this +} + +// NewASMExclusionFilterScopeWithDefaults instantiates a new ASMExclusionFilterScope 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 NewASMExclusionFilterScopeWithDefaults() *ASMExclusionFilterScope { + this := ASMExclusionFilterScope{} + return &this +} + +// GetEnv returns the Env field value if set, zero value otherwise. +func (o *ASMExclusionFilterScope) 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 *ASMExclusionFilterScope) 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 *ASMExclusionFilterScope) 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 *ASMExclusionFilterScope) SetEnv(v string) { + o.Env = &v +} + +// GetService returns the Service field value if set, zero value otherwise. +func (o *ASMExclusionFilterScope) 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 *ASMExclusionFilterScope) 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 *ASMExclusionFilterScope) 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 *ASMExclusionFilterScope) SetService(v string) { + o.Service = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ASMExclusionFilterScope) 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 *ASMExclusionFilterScope) 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_asm_exclusion_filter_type.go b/api/datadogV2/model_asm_exclusion_filter_type.go new file mode 100644 index 00000000000..d2697ba714c --- /dev/null +++ b/api/datadogV2/model_asm_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" +) + +// ASMExclusionFilterType The type of the resource. The value should always be `exclusion_filter`. +type ASMExclusionFilterType string + +// List of ASMExclusionFilterType. +const ( + ASMEXCLUSIONFILTERTYPE_EXCLUSION_FILTER ASMExclusionFilterType = "exclusion_filter" +) + +var allowedASMExclusionFilterTypeEnumValues = []ASMExclusionFilterType{ + ASMEXCLUSIONFILTERTYPE_EXCLUSION_FILTER, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *ASMExclusionFilterType) GetAllowedValues() []ASMExclusionFilterType { + return allowedASMExclusionFilterTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *ASMExclusionFilterType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = ASMExclusionFilterType(value) + return nil +} + +// NewASMExclusionFilterTypeFromValue returns a pointer to a valid ASMExclusionFilterType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewASMExclusionFilterTypeFromValue(v string) (*ASMExclusionFilterType, error) { + ev := ASMExclusionFilterType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for ASMExclusionFilterType: valid values are %v", v, allowedASMExclusionFilterTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v ASMExclusionFilterType) IsValid() bool { + for _, existing := range allowedASMExclusionFilterTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to ASMExclusionFilterType value. +func (v ASMExclusionFilterType) Ptr() *ASMExclusionFilterType { + return &v +} diff --git a/api/datadogV2/model_asm_exclusion_filter_update_attributes.go b/api/datadogV2/model_asm_exclusion_filter_update_attributes.go new file mode 100644 index 00000000000..4eaa5160e1f --- /dev/null +++ b/api/datadogV2/model_asm_exclusion_filter_update_attributes.go @@ -0,0 +1,305 @@ +// 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" +) + +// ASMExclusionFilterUpdateAttributes Update an existing ASM Exclusion filter. +type ASMExclusionFilterUpdateAttributes struct { + // The description of the Exclusion filter. + Description string `json:"description"` + // Whether the Exclusion filter is enabled. + Enabled bool `json:"enabled"` + // The IPs list for the exclusion filter. + IpList []string `json:"ip_list,omitempty"` + // A list of parameters for the exclusion filter. + Parameters []string `json:"parameters,omitempty"` + // The path glob for the exclusion filter. + PathGlob string `json:"path_glob"` + // A list of rules targeted by the exclusion filter. + RulesTarget []ASMExclusionFilterRulesTarget `json:"rules_target,omitempty"` + // The scope of the exclusion filter. + Scope []ASMExclusionFilterScope `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:"-"` +} + +// NewASMExclusionFilterUpdateAttributes instantiates a new ASMExclusionFilterUpdateAttributes 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 NewASMExclusionFilterUpdateAttributes(description string, enabled bool, pathGlob string) *ASMExclusionFilterUpdateAttributes { + this := ASMExclusionFilterUpdateAttributes{} + this.Description = description + this.Enabled = enabled + this.PathGlob = pathGlob + return &this +} + +// NewASMExclusionFilterUpdateAttributesWithDefaults instantiates a new ASMExclusionFilterUpdateAttributes 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 NewASMExclusionFilterUpdateAttributesWithDefaults() *ASMExclusionFilterUpdateAttributes { + this := ASMExclusionFilterUpdateAttributes{} + return &this +} + +// GetDescription returns the Description field value. +func (o *ASMExclusionFilterUpdateAttributes) 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 *ASMExclusionFilterUpdateAttributes) GetDescriptionOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Description, true +} + +// SetDescription sets field value. +func (o *ASMExclusionFilterUpdateAttributes) SetDescription(v string) { + o.Description = v +} + +// GetEnabled returns the Enabled field value. +func (o *ASMExclusionFilterUpdateAttributes) 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 *ASMExclusionFilterUpdateAttributes) GetEnabledOk() (*bool, bool) { + if o == nil { + return nil, false + } + return &o.Enabled, true +} + +// SetEnabled sets field value. +func (o *ASMExclusionFilterUpdateAttributes) SetEnabled(v bool) { + o.Enabled = v +} + +// GetIpList returns the IpList field value if set, zero value otherwise. +func (o *ASMExclusionFilterUpdateAttributes) 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 *ASMExclusionFilterUpdateAttributes) 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 *ASMExclusionFilterUpdateAttributes) 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 *ASMExclusionFilterUpdateAttributes) SetIpList(v []string) { + o.IpList = v +} + +// GetParameters returns the Parameters field value if set, zero value otherwise. +func (o *ASMExclusionFilterUpdateAttributes) 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 *ASMExclusionFilterUpdateAttributes) 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 *ASMExclusionFilterUpdateAttributes) 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 *ASMExclusionFilterUpdateAttributes) SetParameters(v []string) { + o.Parameters = v +} + +// GetPathGlob returns the PathGlob field value. +func (o *ASMExclusionFilterUpdateAttributes) GetPathGlob() string { + if o == nil { + var ret string + return ret + } + return o.PathGlob +} + +// GetPathGlobOk returns a tuple with the PathGlob field value +// and a boolean to check if the value has been set. +func (o *ASMExclusionFilterUpdateAttributes) GetPathGlobOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.PathGlob, true +} + +// SetPathGlob sets field value. +func (o *ASMExclusionFilterUpdateAttributes) SetPathGlob(v string) { + o.PathGlob = v +} + +// GetRulesTarget returns the RulesTarget field value if set, zero value otherwise. +func (o *ASMExclusionFilterUpdateAttributes) GetRulesTarget() []ASMExclusionFilterRulesTarget { + if o == nil || o.RulesTarget == nil { + var ret []ASMExclusionFilterRulesTarget + 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 *ASMExclusionFilterUpdateAttributes) GetRulesTargetOk() (*[]ASMExclusionFilterRulesTarget, 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 *ASMExclusionFilterUpdateAttributes) HasRulesTarget() bool { + return o != nil && o.RulesTarget != nil +} + +// SetRulesTarget gets a reference to the given []ASMExclusionFilterRulesTarget and assigns it to the RulesTarget field. +func (o *ASMExclusionFilterUpdateAttributes) SetRulesTarget(v []ASMExclusionFilterRulesTarget) { + o.RulesTarget = v +} + +// GetScope returns the Scope field value if set, zero value otherwise. +func (o *ASMExclusionFilterUpdateAttributes) GetScope() []ASMExclusionFilterScope { + if o == nil || o.Scope == nil { + var ret []ASMExclusionFilterScope + 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 *ASMExclusionFilterUpdateAttributes) GetScopeOk() (*[]ASMExclusionFilterScope, 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 *ASMExclusionFilterUpdateAttributes) HasScope() bool { + return o != nil && o.Scope != nil +} + +// SetScope gets a reference to the given []ASMExclusionFilterScope and assigns it to the Scope field. +func (o *ASMExclusionFilterUpdateAttributes) SetScope(v []ASMExclusionFilterScope) { + o.Scope = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ASMExclusionFilterUpdateAttributes) 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.Parameters != nil { + toSerialize["parameters"] = o.Parameters + } + 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 *ASMExclusionFilterUpdateAttributes) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Description *string `json:"description"` + Enabled *bool `json:"enabled"` + IpList []string `json:"ip_list,omitempty"` + Parameters []string `json:"parameters,omitempty"` + PathGlob *string `json:"path_glob"` + RulesTarget []ASMExclusionFilterRulesTarget `json:"rules_target,omitempty"` + Scope []ASMExclusionFilterScope `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") + } + if all.PathGlob == nil { + return fmt.Errorf("required field path_glob missing") + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"description", "enabled", "ip_list", "parameters", "path_glob", "rules_target", "scope"}) + } else { + return err + } + o.Description = *all.Description + o.Enabled = *all.Enabled + o.IpList = all.IpList + o.Parameters = all.Parameters + o.PathGlob = *all.PathGlob + o.RulesTarget = all.RulesTarget + o.Scope = all.Scope + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/api/datadogV2/model_asm_exclusion_filter_update_data.go b/api/datadogV2/model_asm_exclusion_filter_update_data.go new file mode 100644 index 00000000000..bab9131a521 --- /dev/null +++ b/api/datadogV2/model_asm_exclusion_filter_update_data.go @@ -0,0 +1,183 @@ +// 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" +) + +// ASMExclusionFilterUpdateData Object for a single Exclusion filter. +type ASMExclusionFilterUpdateData struct { + // Update an existing ASM Exclusion filter. + Attributes ASMExclusionFilterUpdateAttributes `json:"attributes"` + // The ID of the exclusion filter. + Id *string `json:"id,omitempty"` + // The type of the resource. The value should always be `exclusion_filter`. + Type ASMExclusionFilterType `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:"-"` +} + +// NewASMExclusionFilterUpdateData instantiates a new ASMExclusionFilterUpdateData 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 NewASMExclusionFilterUpdateData(attributes ASMExclusionFilterUpdateAttributes, typeVar ASMExclusionFilterType) *ASMExclusionFilterUpdateData { + this := ASMExclusionFilterUpdateData{} + this.Attributes = attributes + this.Type = typeVar + return &this +} + +// NewASMExclusionFilterUpdateDataWithDefaults instantiates a new ASMExclusionFilterUpdateData 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 NewASMExclusionFilterUpdateDataWithDefaults() *ASMExclusionFilterUpdateData { + this := ASMExclusionFilterUpdateData{} + var typeVar ASMExclusionFilterType = ASMEXCLUSIONFILTERTYPE_EXCLUSION_FILTER + this.Type = typeVar + return &this +} + +// GetAttributes returns the Attributes field value. +func (o *ASMExclusionFilterUpdateData) GetAttributes() ASMExclusionFilterUpdateAttributes { + if o == nil { + var ret ASMExclusionFilterUpdateAttributes + 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 *ASMExclusionFilterUpdateData) GetAttributesOk() (*ASMExclusionFilterUpdateAttributes, bool) { + if o == nil { + return nil, false + } + return &o.Attributes, true +} + +// SetAttributes sets field value. +func (o *ASMExclusionFilterUpdateData) SetAttributes(v ASMExclusionFilterUpdateAttributes) { + o.Attributes = v +} + +// GetId returns the Id field value if set, zero value otherwise. +func (o *ASMExclusionFilterUpdateData) 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 *ASMExclusionFilterUpdateData) 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 *ASMExclusionFilterUpdateData) 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 *ASMExclusionFilterUpdateData) SetId(v string) { + o.Id = &v +} + +// GetType returns the Type field value. +func (o *ASMExclusionFilterUpdateData) GetType() ASMExclusionFilterType { + if o == nil { + var ret ASMExclusionFilterType + 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 *ASMExclusionFilterUpdateData) GetTypeOk() (*ASMExclusionFilterType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *ASMExclusionFilterUpdateData) SetType(v ASMExclusionFilterType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ASMExclusionFilterUpdateData) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + toSerialize["attributes"] = o.Attributes + if o.Id != nil { + toSerialize["id"] = o.Id + } + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *ASMExclusionFilterUpdateData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *ASMExclusionFilterUpdateAttributes `json:"attributes"` + Id *string `json:"id,omitempty"` + Type *ASMExclusionFilterType `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", "id", "type"}) + } else { + return err + } + + hasInvalidField := false + if all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Attributes = *all.Attributes + o.Id = all.Id + 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_asm_exclusion_filter_update_request.go b/api/datadogV2/model_asm_exclusion_filter_update_request.go new file mode 100644 index 00000000000..7ca37126e66 --- /dev/null +++ b/api/datadogV2/model_asm_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" +) + +// ASMExclusionFilterUpdateRequest Request object that includes the Exclusion filter with the attributes to update. +type ASMExclusionFilterUpdateRequest struct { + // Object for a single Exclusion filter. + Data ASMExclusionFilterUpdateData `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:"-"` +} + +// NewASMExclusionFilterUpdateRequest instantiates a new ASMExclusionFilterUpdateRequest 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 NewASMExclusionFilterUpdateRequest(data ASMExclusionFilterUpdateData) *ASMExclusionFilterUpdateRequest { + this := ASMExclusionFilterUpdateRequest{} + this.Data = data + return &this +} + +// NewASMExclusionFilterUpdateRequestWithDefaults instantiates a new ASMExclusionFilterUpdateRequest 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 NewASMExclusionFilterUpdateRequestWithDefaults() *ASMExclusionFilterUpdateRequest { + this := ASMExclusionFilterUpdateRequest{} + return &this +} + +// GetData returns the Data field value. +func (o *ASMExclusionFilterUpdateRequest) GetData() ASMExclusionFilterUpdateData { + if o == nil { + var ret ASMExclusionFilterUpdateData + 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 *ASMExclusionFilterUpdateRequest) GetDataOk() (*ASMExclusionFilterUpdateData, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *ASMExclusionFilterUpdateRequest) SetData(v ASMExclusionFilterUpdateData) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ASMExclusionFilterUpdateRequest) 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 *ASMExclusionFilterUpdateRequest) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Data *ASMExclusionFilterUpdateData `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_asm_exclusion_list_filter_data.go b/api/datadogV2/model_asm_exclusion_list_filter_data.go new file mode 100644 index 00000000000..a37b0d2b8e7 --- /dev/null +++ b/api/datadogV2/model_asm_exclusion_list_filter_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" +) + +// ASMExclusionListFilterData Object for a single Exclusion filter. +type ASMExclusionListFilterData struct { + // The attributes of the ASM WAF exclusion filter. + Attributes *ASMExclusionFilterListAttributes `json:"attributes,omitempty"` + // The ID of the Exclusion filter. + Id *string `json:"id,omitempty"` + // The type of the resource. The value should always be `exclusion_filter`. + Type *ASMExclusionFilterType `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:"-"` +} + +// NewASMExclusionListFilterData instantiates a new ASMExclusionListFilterData 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 NewASMExclusionListFilterData() *ASMExclusionListFilterData { + this := ASMExclusionListFilterData{} + var typeVar ASMExclusionFilterType = ASMEXCLUSIONFILTERTYPE_EXCLUSION_FILTER + this.Type = &typeVar + return &this +} + +// NewASMExclusionListFilterDataWithDefaults instantiates a new ASMExclusionListFilterData 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 NewASMExclusionListFilterDataWithDefaults() *ASMExclusionListFilterData { + this := ASMExclusionListFilterData{} + var typeVar ASMExclusionFilterType = ASMEXCLUSIONFILTERTYPE_EXCLUSION_FILTER + this.Type = &typeVar + return &this +} + +// GetAttributes returns the Attributes field value if set, zero value otherwise. +func (o *ASMExclusionListFilterData) GetAttributes() ASMExclusionFilterListAttributes { + if o == nil || o.Attributes == nil { + var ret ASMExclusionFilterListAttributes + 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 *ASMExclusionListFilterData) GetAttributesOk() (*ASMExclusionFilterListAttributes, 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 *ASMExclusionListFilterData) HasAttributes() bool { + return o != nil && o.Attributes != nil +} + +// SetAttributes gets a reference to the given ASMExclusionFilterListAttributes and assigns it to the Attributes field. +func (o *ASMExclusionListFilterData) SetAttributes(v ASMExclusionFilterListAttributes) { + o.Attributes = &v +} + +// GetId returns the Id field value if set, zero value otherwise. +func (o *ASMExclusionListFilterData) 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 *ASMExclusionListFilterData) 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 *ASMExclusionListFilterData) 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 *ASMExclusionListFilterData) SetId(v string) { + o.Id = &v +} + +// GetType returns the Type field value if set, zero value otherwise. +func (o *ASMExclusionListFilterData) GetType() ASMExclusionFilterType { + if o == nil || o.Type == nil { + var ret ASMExclusionFilterType + 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 *ASMExclusionListFilterData) GetTypeOk() (*ASMExclusionFilterType, 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 *ASMExclusionListFilterData) HasType() bool { + return o != nil && o.Type != nil +} + +// SetType gets a reference to the given ASMExclusionFilterType and assigns it to the Type field. +func (o *ASMExclusionListFilterData) SetType(v ASMExclusionFilterType) { + o.Type = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ASMExclusionListFilterData) 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 *ASMExclusionListFilterData) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Attributes *ASMExclusionFilterListAttributes `json:"attributes,omitempty"` + Id *string `json:"id,omitempty"` + Type *ASMExclusionFilterType `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/examples/v2/asm-exclusion-filters/CreateASMExclusionFilter.go b/examples/v2/asm-exclusion-filters/CreateASMExclusionFilter.go new file mode 100644 index 00000000000..4742d7bc319 --- /dev/null +++ b/examples/v2/asm-exclusion-filters/CreateASMExclusionFilter.go @@ -0,0 +1,48 @@ +// Create a ASM 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.ASMExclusionFilterCreateRequest{ + Data: datadogV2.ASMExclusionFilterCreateData{ + Type: datadogV2.ASMEXCLUSIONFILTERTYPE_EXCLUSION_FILTER, + Attributes: datadogV2.ASMExclusionFilterCreateAttributes{ + Description: "my description", + Enabled: true, + PathGlob: "*", + RulesTarget: []datadogV2.ASMExclusionFilterRulesTarget{ + {}, + }, + Scope: []datadogV2.ASMExclusionFilterScope{ + { + Env: datadog.PtrString("staging"), + Service: datadog.PtrString("container-resolver"), + }, + }, + }, + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewASMExclusionFiltersApi(apiClient) + resp, r, err := api.CreateASMExclusionFilter(ctx, body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `ASMExclusionFiltersApi.CreateASMExclusionFilter`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `ASMExclusionFiltersApi.CreateASMExclusionFilter`:\n%s\n", responseContent) +} diff --git a/examples/v2/asm-exclusion-filters/DeleteASMExclusionFilter.go b/examples/v2/asm-exclusion-filters/DeleteASMExclusionFilter.go new file mode 100644 index 00000000000..92c248d2b33 --- /dev/null +++ b/examples/v2/asm-exclusion-filters/DeleteASMExclusionFilter.go @@ -0,0 +1,25 @@ +// Delete a ASM 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() { + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewASMExclusionFiltersApi(apiClient) + r, err := api.DeleteASMExclusionFilter(ctx, "exclusion_filter_id") + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `ASMExclusionFiltersApi.DeleteASMExclusionFilter`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } +} diff --git a/examples/v2/asm-exclusion-filters/GetASMExclusionFilters.go b/examples/v2/asm-exclusion-filters/GetASMExclusionFilters.go new file mode 100644 index 00000000000..558b558c943 --- /dev/null +++ b/examples/v2/asm-exclusion-filters/GetASMExclusionFilters.go @@ -0,0 +1,29 @@ +// Get a specific ASM 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() { + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewASMExclusionFiltersApi(apiClient) + resp, r, err := api.GetASMExclusionFilters(ctx, "exclusion_filter_id") + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `ASMExclusionFiltersApi.GetASMExclusionFilters`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `ASMExclusionFiltersApi.GetASMExclusionFilters`:\n%s\n", responseContent) +} diff --git a/examples/v2/asm-exclusion-filters/ListASMExclusionFilters.go b/examples/v2/asm-exclusion-filters/ListASMExclusionFilters.go new file mode 100644 index 00000000000..d55918a9ccb --- /dev/null +++ b/examples/v2/asm-exclusion-filters/ListASMExclusionFilters.go @@ -0,0 +1,29 @@ +// List ASM 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.NewASMExclusionFiltersApi(apiClient) + resp, r, err := api.ListASMExclusionFilters(ctx) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `ASMExclusionFiltersApi.ListASMExclusionFilters`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `ASMExclusionFiltersApi.ListASMExclusionFilters`:\n%s\n", responseContent) +} diff --git a/examples/v2/asm-exclusion-filters/UpdateASMExclusionFilter.go b/examples/v2/asm-exclusion-filters/UpdateASMExclusionFilter.go new file mode 100644 index 00000000000..3c21cf96da9 --- /dev/null +++ b/examples/v2/asm-exclusion-filters/UpdateASMExclusionFilter.go @@ -0,0 +1,57 @@ +// Update a ASM 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.ASMExclusionFilterUpdateRequest{ + Data: datadogV2.ASMExclusionFilterUpdateData{ + Attributes: datadogV2.ASMExclusionFilterUpdateAttributes{ + Description: "My Exclusion filter", + Enabled: true, + IpList: []string{ + "127.0.0.1", + }, + Parameters: []string{ + "list.search.query", + }, + PathGlob: "/lfi_include/*", + RulesTarget: []datadogV2.ASMExclusionFilterRulesTarget{ + { + RuleId: datadog.PtrString("dog-913-009"), + }, + }, + Scope: []datadogV2.ASMExclusionFilterScope{ + { + Env: datadog.PtrString("dd-appsec-php-support"), + Service: datadog.PtrString("anil-php-weblog"), + }, + }, + }, + Id: datadog.PtrString("3dd-0uc-h1s"), + Type: datadogV2.ASMEXCLUSIONFILTERTYPE_EXCLUSION_FILTER, + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewASMExclusionFiltersApi(apiClient) + resp, r, err := api.UpdateASMExclusionFilter(ctx, "exclusion_filter_id", body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `ASMExclusionFiltersApi.UpdateASMExclusionFilter`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `ASMExclusionFiltersApi.UpdateASMExclusionFilter`:\n%s\n", responseContent) +} diff --git a/tests/scenarios/api_mappings.go b/tests/scenarios/api_mappings.go index fcd6d96bcfa..705d1ba2a41 100644 --- a/tests/scenarios/api_mappings.go +++ b/tests/scenarios/api_mappings.go @@ -83,6 +83,7 @@ var apiMappings = map[string]map[string]reflect.Value{ "SecurityMonitoringApi": reflect.ValueOf(datadogV2.NewSecurityMonitoringApi), "PowerpackApi": reflect.ValueOf(datadogV2.NewPowerpackApi), "ProcessesApi": reflect.ValueOf(datadogV2.NewProcessesApi), + "ASMExclusionFiltersApi": reflect.ValueOf(datadogV2.NewASMExclusionFiltersApi), "CSMThreatsApi": reflect.ValueOf(datadogV2.NewCSMThreatsApi), "RestrictionPoliciesApi": reflect.ValueOf(datadogV2.NewRestrictionPoliciesApi), "RUMApi": reflect.ValueOf(datadogV2.NewRUMApi), diff --git a/tests/scenarios/features/v2/asm_exclusion_filters.feature b/tests/scenarios/features/v2/asm_exclusion_filters.feature new file mode 100644 index 00000000000..2269c6baa45 --- /dev/null +++ b/tests/scenarios/features/v2/asm_exclusion_filters.feature @@ -0,0 +1,89 @@ +@endpoint(asm-exclusion-filters) @endpoint(asm-exclusion-filters-v2) +Feature: ASM Exclusion Filters + Exclusion filters in ASM libraries are used to circumvent false positives + in protection. + + Background: + Given a valid "apiKeyAuth" key in the system + And a valid "appKeyAuth" key in the system + And an instance of "ASMExclusionFilters" API + + @generated @skip @team:DataDog/asm-respond-backend + Scenario: Create a ASM WAF Exclusion filter returns "Bad Request" response + Given new "CreateASMExclusionFilter" request + And body with value {"data": {"type": "exclusion_filter"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/asm-respond-backend + Scenario: Create a ASM WAF Exclusion filter returns "Conflict" response + Given new "CreateASMExclusionFilter" request + And body with value {"data": {"type": "exclusion_filter"}} + When the request is sent + Then the response status is 409 Conflict + + @skip @team:DataDog/asm-respond-backend + Scenario: Create a ASM WAF Exclusion filter returns "OK" response + Given new "CreateASMExclusionFilter" request + And body with value {"data": {"type": "exclusion_filter","attributes":{"description":"my description","enabled":true,"path_glob":"*","rules_target":[{"tags":{"category":"attack_attempt","type":"sql_injection"}}],"scope":[{"env":"staging","service":"container-resolver"}]}}} + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:DataDog/asm-respond-backend + Scenario: Delete a ASM Exclusion Filter returns "Not Found" response + Given new "DeleteASMExclusionFilter" request + And request contains "exclusion_filter_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/asm-respond-backend + Scenario: Delete a ASM Exclusion Filter returns "OK" response + Given new "DeleteASMExclusionFilter" request + And request contains "exclusion_filter_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 204 OK + + @generated @skip @team:DataDog/asm-respond-backend + Scenario: Get a specific ASM Exclusion Filter returns "OK" response + Given new "GetASMExclusionFilters" request + And request contains "exclusion_filter_id" parameter from "REPLACE.ME" + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:DataDog/asm-respond-backend + Scenario: List ASM Exclusion Filters returns "OK" response + Given new "ListASMExclusionFilters" request + When the request is sent + Then the response status is 200 OK + + @generated @skip @team:DataDog/asm-respond-backend + Scenario: Update a ASM Exclusion filter returns "Bad Request" response + Given new "UpdateASMExclusionFilter" request + And request contains "exclusion_filter_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"description": "My Exclusion filter", "enabled": true, "ip_list": ["127.0.0.1"], "parameters": ["list.search.query"], "path_glob": "/lfi_include/*", "rules_target": [{"rule_id": "dog-913-009"}], "scope": [{"env": "dd-appsec-php-support", "service": "anil-php-weblog"}]}, "id": "3dd-0uc-h1s", "type": "exclusion_filter"}} + When the request is sent + Then the response status is 400 Bad Request + + @generated @skip @team:DataDog/asm-respond-backend + Scenario: Update a ASM Exclusion filter returns "Concurrent Modification" response + Given new "UpdateASMExclusionFilter" request + And request contains "exclusion_filter_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"description": "My Exclusion filter", "enabled": true, "ip_list": ["127.0.0.1"], "parameters": ["list.search.query"], "path_glob": "/lfi_include/*", "rules_target": [{"rule_id": "dog-913-009"}], "scope": [{"env": "dd-appsec-php-support", "service": "anil-php-weblog"}]}, "id": "3dd-0uc-h1s", "type": "exclusion_filter"}} + When the request is sent + Then the response status is 409 Concurrent Modification + + @generated @skip @team:DataDog/asm-respond-backend + Scenario: Update a ASM Exclusion filter returns "Not Found" response + Given new "UpdateASMExclusionFilter" request + And request contains "exclusion_filter_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"description": "My Exclusion filter", "enabled": true, "ip_list": ["127.0.0.1"], "parameters": ["list.search.query"], "path_glob": "/lfi_include/*", "rules_target": [{"rule_id": "dog-913-009"}], "scope": [{"env": "dd-appsec-php-support", "service": "anil-php-weblog"}]}, "id": "3dd-0uc-h1s", "type": "exclusion_filter"}} + When the request is sent + Then the response status is 404 Not Found + + @generated @skip @team:DataDog/asm-respond-backend + Scenario: Update a ASM Exclusion filter returns "OK" response + Given new "UpdateASMExclusionFilter" request + And request contains "exclusion_filter_id" parameter from "REPLACE.ME" + And body with value {"data": {"attributes": {"description": "My Exclusion filter", "enabled": true, "ip_list": ["127.0.0.1"], "parameters": ["list.search.query"], "path_glob": "/lfi_include/*", "rules_target": [{"rule_id": "dog-913-009"}], "scope": [{"env": "dd-appsec-php-support", "service": "anil-php-weblog"}]}, "id": "3dd-0uc-h1s", "type": "exclusion_filter"}} + When the request is sent + Then the response status is 200 OK diff --git a/tests/scenarios/features/v2/given.json b/tests/scenarios/features/v2/given.json index efc7bed91b5..1a0fb80014b 100644 --- a/tests/scenarios/features/v2/given.json +++ b/tests/scenarios/features/v2/given.json @@ -391,6 +391,18 @@ "tag": "Powerpack", "operationId": "CreatePowerpack" }, + { + "parameters": [ + { + "name": "body", + "value": "{\n \"data\": {\n \"type\": \"exclusion_filter\",\n \"attributes\": {\n \"description\": \"My Exclusion Filter\",\n \"enabled\": true,\n \"path_glob\": \"*\",\n \"parameters\": [\n \"list.search.query\"\n ],\n \"rules_target\": [\n {\n \"tags\": {\n \"category\":\"attack_attempt\",\n \"type\":\"xss\"\n }\n }\n ],\n \"scope\": [\n {\n \"env\": \"staging\",\n \"service\": \"event-query\"\n }\n ]\n }\n }\n}" + } + ], + "step": "there is a valid \"exclusion_filter\" in the system", + "key": "exclusion_filter", + "tag": "ASM Exclusion Filters", + "operationId": "CreateASMExclusionFilter" + }, { "parameters": [ { diff --git a/tests/scenarios/features/v2/undo.json b/tests/scenarios/features/v2/undo.json index 62da7c99ef9..58802c864a6 100644 --- a/tests/scenarios/features/v2/undo.json +++ b/tests/scenarios/features/v2/undo.json @@ -1516,6 +1516,43 @@ "type": "idempotent" } }, + "ListASMExclusionFilters": { + "tag": "ASM Exclusion Filters", + "undo": { + "type": "safe" + } + }, + "CreateASMExclusionFilter": { + "tag": "ASM Exclusion Filters", + "undo": { + "operationId": "DeleteASMExclusionFilter", + "parameters": [ + { + "name": "exclusion_filter_id", + "source": "data.id" + } + ], + "type": "unsafe" + } + }, + "DeleteASMExclusionFilter": { + "tag": "ASM Exclusion Filters", + "undo": { + "type": "idempotent" + } + }, + "GetASMExclusionFilters": { + "tag": "ASM Exclusion Filters", + "undo": { + "type": "safe" + } + }, + "UpdateASMExclusionFilter": { + "tag": "ASM Exclusion Filters", + "undo": { + "type": "idempotent" + } + }, "ListCSMThreatsAgentRules": { "tag": "CSM Threats", "undo": {