diff --git a/.apigentools-info b/.apigentools-info index f56f5f89534..0a2fcd81c64 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.6.4", - "regenerated": "2023-06-14 07:20:56.714030", - "spec_repo_commit": "87ef2d8d" + "regenerated": "2023-06-14 09:15:58.253200", + "spec_repo_commit": "aa4abfb0" }, "v2": { "apigentools_version": "1.6.4", - "regenerated": "2023-06-14 07:20:56.729433", - "spec_repo_commit": "87ef2d8d" + "regenerated": "2023-06-14 09:15:58.265879", + "spec_repo_commit": "aa4abfb0" } } } \ No newline at end of file diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 6f7ec021e7e..e3022cf1f86 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -477,6 +477,31 @@ components: schema: $ref: '#/components/schemas/APIErrorResponse' description: Conflict + FindingsBadRequestResponse: + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: 'Bad Request: The server cannot process the request due to invalid + syntax in the request.' + FindingsForbiddenResponse: + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: 'Forbidden: Access denied' + FindingsNotFoundResponse: + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: 'Not Found: The requested finding cannot be found.' + FindingsTooManyRequestsResponse: + content: + application/json: + schema: + $ref: '#/components/schemas/JSONAPIErrorResponse' + description: 'Too many requests: The rate limit set by the API has been exceeded.' ForbiddenResponse: content: application/json: @@ -4520,34 +4545,6 @@ components: type: string x-enum-varnames: - FINDING - FindingsErrorItem: - description: API error response body - properties: - detail: - description: A human-readable explanation specific to this occurrence of - the error. - example: attribute "muted" is required - type: string - status: - description: Status code of the response. - example: '400' - type: string - title: - description: Short human-readable summary of the error. - example: Bad Request - type: string - type: object - FindingsErrorResponse: - description: API error response. - properties: - errors: - description: A list of errors. - items: - $ref: '#/components/schemas/FindingsErrorItem' - type: array - required: - - errors - type: object FormulaLimit: description: Message for specifying limits to the number of values returned by a query. @@ -6839,6 +6836,34 @@ components: type: string type: array type: object + JSONAPIErrorItem: + description: API error response body + properties: + detail: + description: A human-readable explanation specific to this occurrence of + the error. + example: Missing required attribute in body + type: string + status: + description: Status code of the response. + example: '400' + type: string + title: + description: Short human-readable summary of the error. + example: Bad Request + type: string + type: object + JSONAPIErrorResponse: + description: Rapid API error response. + properties: + errors: + description: A list of errors. + items: + $ref: '#/components/schemas/JSONAPIErrorItem' + type: array + required: + - errors + type: object JiraIntegrationMetadata: description: Incident integration metadata for the Jira integration. properties: @@ -20715,13 +20740,16 @@ paths: can also use the negation operator on strings. For example, use `filter[resource_type]=-aws*` to filter for any non-AWS resources.\n\nThe operator must come after the equal sign. For example, to filter with the `>=` operator, add the operator after - the equal sign: `filter[evaluation_changed_at]=>=1678809373257`.\n\n### Response\n\nThe - response includes an array of finding objects, pagination metadata, and a - count of items that match the query.\n\nEach finding object contains the following:\n\n- - The finding ID that can be used in a `GetFinding` request to retrieve the - full finding details.\n- Core attributes, including status, evaluation, high-level - resource details, muted state, and rule details.\n- `evaluation_changed_at` - and `resource_discovery_date` time stamps.\n- An array of associated tags.\n" + the equal sign: `filter[evaluation_changed_at]=>=1678809373257`.\n\nQuery + parameters must be only among the documented ones and with values of correct + types. Duplicated query parameters (e.g. `filter[status]=low&filter[status]=info`) + are not allowed.\n\n### Response\n\nThe response includes an array of finding + objects, pagination metadata, and a count of items that match the query.\n\nEach + finding object contains the following:\n\n- The finding ID that can be used + in a `GetFinding` request to retrieve the full finding details.\n- Core attributes, + including status, evaluation, high-level resource details, muted state, and + rule details.\n- `evaluation_changed_at` and `resource_discovery_date` time + stamps.\n- An array of associated tags.\n" operationId: ListFindings parameters: - description: Limit the number of findings returned. Must be <= 1000. @@ -20821,17 +20849,13 @@ paths: $ref: '#/components/schemas/ListFindingsResponse' description: OK '400': - content: - application/json: - schema: - $ref: '#/components/schemas/APIErrorResponse' - description: Bad Request + $ref: '#/components/responses/FindingsBadRequestResponse' '403': - $ref: '#/components/responses/ForbiddenResponse' + $ref: '#/components/responses/FindingsForbiddenResponse' '404': - $ref: '#/components/responses/NotFoundResponse' + $ref: '#/components/responses/FindingsNotFoundResponse' '429': - $ref: '#/components/responses/TooManyRequestsResponse' + $ref: '#/components/responses/FindingsTooManyRequestsResponse' security: - apiKeyAuth: [] appKeyAuth: [] @@ -20876,17 +20900,13 @@ paths: $ref: '#/components/schemas/GetFindingResponse' description: OK '400': - content: - application/json: - schema: - $ref: '#/components/schemas/APIErrorResponse' - description: Bad Request + $ref: '#/components/responses/FindingsBadRequestResponse' '403': - $ref: '#/components/responses/ForbiddenResponse' + $ref: '#/components/responses/FindingsForbiddenResponse' '404': - $ref: '#/components/responses/NotFoundResponse' + $ref: '#/components/responses/FindingsNotFoundResponse' '429': - $ref: '#/components/responses/TooManyRequestsResponse' + $ref: '#/components/responses/FindingsTooManyRequestsResponse' security: - apiKeyAuth: [] appKeyAuth: [] @@ -20934,39 +20954,27 @@ paths: $ref: '#/components/schemas/MuteFindingResponse' description: OK '400': - content: - application/json: - schema: - $ref: '#/components/schemas/FindingsErrorResponse' - description: 'Bad Request: The server cannot process the request due to - invalid syntax in the request.' + $ref: '#/components/responses/FindingsBadRequestResponse' + '403': + $ref: '#/components/responses/FindingsForbiddenResponse' '404': - content: - application/json: - schema: - $ref: '#/components/schemas/FindingsErrorResponse' - description: 'Not Found: The requested finding cannot be found.' + $ref: '#/components/responses/FindingsNotFoundResponse' '409': content: application/json: schema: - $ref: '#/components/schemas/FindingsErrorResponse' + $ref: '#/components/schemas/JSONAPIErrorResponse' description: 'Resource Conflict: The finding has already been muted or unmuted within the last 60 seconds.' '422': content: application/json: schema: - $ref: '#/components/schemas/FindingsErrorResponse' + $ref: '#/components/schemas/JSONAPIErrorResponse' description: 'Invalid Request: The server understands the request syntax but cannot process it due to invalid data.' '429': - content: - application/json: - schema: - $ref: '#/components/schemas/FindingsErrorResponse' - description: 'Too many requests: The rate limit set by the API has been - exceeded.' + $ref: '#/components/responses/FindingsTooManyRequestsResponse' security: - apiKeyAuth: [] appKeyAuth: [] diff --git a/api/datadogV2/api_security_monitoring.go b/api/datadogV2/api_security_monitoring.go index 66adb4f315e..ee7357b765b 100644 --- a/api/datadogV2/api_security_monitoring.go +++ b/api/datadogV2/api_security_monitoring.go @@ -596,7 +596,7 @@ func (a *SecurityMonitoringApi) GetFinding(ctx _context.Context, findingId strin ErrorMessage: localVarHTTPResponse.Status, } if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 404 || localVarHTTPResponse.StatusCode == 429 { - var v APIErrorResponse + var v JSONAPIErrorResponse err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) if err != nil { return localVarReturnValue, localVarHTTPResponse, newErr @@ -947,6 +947,8 @@ func (r *ListFindingsOptionalParameters) WithFilterStatus(filterStatus FindingSt // // The operator must come after the equal sign. For example, to filter with the `>=` operator, add the operator after the equal sign: `filter[evaluation_changed_at]=>=1678809373257`. // +// Query parameters must be only among the documented ones and with values of correct types. Duplicated query parameters (e.g. `filter[status]=low&filter[status]=info`) are not allowed. +// // ### Response // // The response includes an array of finding objects, pagination metadata, and a count of items that match the query. @@ -1055,7 +1057,7 @@ func (a *SecurityMonitoringApi) ListFindings(ctx _context.Context, o ...ListFind ErrorMessage: localVarHTTPResponse.Status, } if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 404 || localVarHTTPResponse.StatusCode == 429 { - var v APIErrorResponse + var v JSONAPIErrorResponse err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) if err != nil { return localVarReturnValue, localVarHTTPResponse, newErr @@ -1746,8 +1748,8 @@ func (a *SecurityMonitoringApi) UpdateFinding(ctx _context.Context, findingId st ErrorBody: localVarBody, ErrorMessage: localVarHTTPResponse.Status, } - if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 404 || localVarHTTPResponse.StatusCode == 409 || localVarHTTPResponse.StatusCode == 422 || localVarHTTPResponse.StatusCode == 429 { - var v FindingsErrorResponse + if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 404 || localVarHTTPResponse.StatusCode == 409 || localVarHTTPResponse.StatusCode == 422 || localVarHTTPResponse.StatusCode == 429 { + var v JSONAPIErrorResponse err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) if err != nil { return localVarReturnValue, localVarHTTPResponse, newErr diff --git a/api/datadogV2/model_findings_error_item.go b/api/datadogV2/model_jsonapi_error_item.go similarity index 78% rename from api/datadogV2/model_findings_error_item.go rename to api/datadogV2/model_jsonapi_error_item.go index 48261f6b149..4dabfd82747 100644 --- a/api/datadogV2/model_findings_error_item.go +++ b/api/datadogV2/model_jsonapi_error_item.go @@ -10,8 +10,8 @@ import ( "github.com/DataDog/datadog-api-client-go/v2/api/datadog" ) -// FindingsErrorItem API error response body -type FindingsErrorItem struct { +// JSONAPIErrorItem API error response body +type JSONAPIErrorItem struct { // A human-readable explanation specific to this occurrence of the error. Detail *string `json:"detail,omitempty"` // Status code of the response. @@ -23,25 +23,25 @@ type FindingsErrorItem struct { AdditionalProperties map[string]interface{} } -// NewFindingsErrorItem instantiates a new FindingsErrorItem object. +// NewJSONAPIErrorItem instantiates a new JSONAPIErrorItem 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 NewFindingsErrorItem() *FindingsErrorItem { - this := FindingsErrorItem{} +func NewJSONAPIErrorItem() *JSONAPIErrorItem { + this := JSONAPIErrorItem{} return &this } -// NewFindingsErrorItemWithDefaults instantiates a new FindingsErrorItem object. +// NewJSONAPIErrorItemWithDefaults instantiates a new JSONAPIErrorItem 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 NewFindingsErrorItemWithDefaults() *FindingsErrorItem { - this := FindingsErrorItem{} +func NewJSONAPIErrorItemWithDefaults() *JSONAPIErrorItem { + this := JSONAPIErrorItem{} return &this } // GetDetail returns the Detail field value if set, zero value otherwise. -func (o *FindingsErrorItem) GetDetail() string { +func (o *JSONAPIErrorItem) GetDetail() string { if o == nil || o.Detail == nil { var ret string return ret @@ -51,7 +51,7 @@ func (o *FindingsErrorItem) GetDetail() string { // GetDetailOk returns a tuple with the Detail field value if set, nil otherwise // and a boolean to check if the value has been set. -func (o *FindingsErrorItem) GetDetailOk() (*string, bool) { +func (o *JSONAPIErrorItem) GetDetailOk() (*string, bool) { if o == nil || o.Detail == nil { return nil, false } @@ -59,17 +59,17 @@ func (o *FindingsErrorItem) GetDetailOk() (*string, bool) { } // HasDetail returns a boolean if a field has been set. -func (o *FindingsErrorItem) HasDetail() bool { +func (o *JSONAPIErrorItem) HasDetail() bool { return o != nil && o.Detail != nil } // SetDetail gets a reference to the given string and assigns it to the Detail field. -func (o *FindingsErrorItem) SetDetail(v string) { +func (o *JSONAPIErrorItem) SetDetail(v string) { o.Detail = &v } // GetStatus returns the Status field value if set, zero value otherwise. -func (o *FindingsErrorItem) GetStatus() string { +func (o *JSONAPIErrorItem) GetStatus() string { if o == nil || o.Status == nil { var ret string return ret @@ -79,7 +79,7 @@ func (o *FindingsErrorItem) GetStatus() string { // GetStatusOk returns a tuple with the Status field value if set, nil otherwise // and a boolean to check if the value has been set. -func (o *FindingsErrorItem) GetStatusOk() (*string, bool) { +func (o *JSONAPIErrorItem) GetStatusOk() (*string, bool) { if o == nil || o.Status == nil { return nil, false } @@ -87,17 +87,17 @@ func (o *FindingsErrorItem) GetStatusOk() (*string, bool) { } // HasStatus returns a boolean if a field has been set. -func (o *FindingsErrorItem) HasStatus() bool { +func (o *JSONAPIErrorItem) HasStatus() bool { return o != nil && o.Status != nil } // SetStatus gets a reference to the given string and assigns it to the Status field. -func (o *FindingsErrorItem) SetStatus(v string) { +func (o *JSONAPIErrorItem) SetStatus(v string) { o.Status = &v } // GetTitle returns the Title field value if set, zero value otherwise. -func (o *FindingsErrorItem) GetTitle() string { +func (o *JSONAPIErrorItem) GetTitle() string { if o == nil || o.Title == nil { var ret string return ret @@ -107,7 +107,7 @@ func (o *FindingsErrorItem) GetTitle() string { // GetTitleOk returns a tuple with the Title field value if set, nil otherwise // and a boolean to check if the value has been set. -func (o *FindingsErrorItem) GetTitleOk() (*string, bool) { +func (o *JSONAPIErrorItem) GetTitleOk() (*string, bool) { if o == nil || o.Title == nil { return nil, false } @@ -115,17 +115,17 @@ func (o *FindingsErrorItem) GetTitleOk() (*string, bool) { } // HasTitle returns a boolean if a field has been set. -func (o *FindingsErrorItem) HasTitle() bool { +func (o *JSONAPIErrorItem) HasTitle() bool { return o != nil && o.Title != nil } // SetTitle gets a reference to the given string and assigns it to the Title field. -func (o *FindingsErrorItem) SetTitle(v string) { +func (o *JSONAPIErrorItem) SetTitle(v string) { o.Title = &v } // MarshalJSON serializes the struct using spec logic. -func (o FindingsErrorItem) MarshalJSON() ([]byte, error) { +func (o JSONAPIErrorItem) MarshalJSON() ([]byte, error) { toSerialize := map[string]interface{}{} if o.UnparsedObject != nil { return json.Marshal(o.UnparsedObject) @@ -147,7 +147,7 @@ func (o FindingsErrorItem) MarshalJSON() ([]byte, error) { } // UnmarshalJSON deserializes the given payload. -func (o *FindingsErrorItem) UnmarshalJSON(bytes []byte) (err error) { +func (o *JSONAPIErrorItem) UnmarshalJSON(bytes []byte) (err error) { raw := map[string]interface{}{} all := struct { Detail *string `json:"detail,omitempty"` diff --git a/api/datadogV2/model_findings_error_response.go b/api/datadogV2/model_jsonapi_error_response.go similarity index 71% rename from api/datadogV2/model_findings_error_response.go rename to api/datadogV2/model_jsonapi_error_response.go index 01e53d680c4..d162aaaec5b 100644 --- a/api/datadogV2/model_findings_error_response.go +++ b/api/datadogV2/model_jsonapi_error_response.go @@ -11,37 +11,37 @@ import ( "github.com/DataDog/datadog-api-client-go/v2/api/datadog" ) -// FindingsErrorResponse API error response. -type FindingsErrorResponse struct { +// JSONAPIErrorResponse Rapid API error response. +type JSONAPIErrorResponse struct { // A list of errors. - Errors []FindingsErrorItem `json:"errors"` + Errors []JSONAPIErrorItem `json:"errors"` // 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{} } -// NewFindingsErrorResponse instantiates a new FindingsErrorResponse object. +// NewJSONAPIErrorResponse instantiates a new JSONAPIErrorResponse 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 NewFindingsErrorResponse(errors []FindingsErrorItem) *FindingsErrorResponse { - this := FindingsErrorResponse{} +func NewJSONAPIErrorResponse(errors []JSONAPIErrorItem) *JSONAPIErrorResponse { + this := JSONAPIErrorResponse{} this.Errors = errors return &this } -// NewFindingsErrorResponseWithDefaults instantiates a new FindingsErrorResponse object. +// NewJSONAPIErrorResponseWithDefaults instantiates a new JSONAPIErrorResponse 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 NewFindingsErrorResponseWithDefaults() *FindingsErrorResponse { - this := FindingsErrorResponse{} +func NewJSONAPIErrorResponseWithDefaults() *JSONAPIErrorResponse { + this := JSONAPIErrorResponse{} return &this } // GetErrors returns the Errors field value. -func (o *FindingsErrorResponse) GetErrors() []FindingsErrorItem { +func (o *JSONAPIErrorResponse) GetErrors() []JSONAPIErrorItem { if o == nil { - var ret []FindingsErrorItem + var ret []JSONAPIErrorItem return ret } return o.Errors @@ -49,7 +49,7 @@ func (o *FindingsErrorResponse) GetErrors() []FindingsErrorItem { // GetErrorsOk returns a tuple with the Errors field value // and a boolean to check if the value has been set. -func (o *FindingsErrorResponse) GetErrorsOk() (*[]FindingsErrorItem, bool) { +func (o *JSONAPIErrorResponse) GetErrorsOk() (*[]JSONAPIErrorItem, bool) { if o == nil { return nil, false } @@ -57,12 +57,12 @@ func (o *FindingsErrorResponse) GetErrorsOk() (*[]FindingsErrorItem, bool) { } // SetErrors sets field value. -func (o *FindingsErrorResponse) SetErrors(v []FindingsErrorItem) { +func (o *JSONAPIErrorResponse) SetErrors(v []JSONAPIErrorItem) { o.Errors = v } // MarshalJSON serializes the struct using spec logic. -func (o FindingsErrorResponse) MarshalJSON() ([]byte, error) { +func (o JSONAPIErrorResponse) MarshalJSON() ([]byte, error) { toSerialize := map[string]interface{}{} if o.UnparsedObject != nil { return json.Marshal(o.UnparsedObject) @@ -76,13 +76,13 @@ func (o FindingsErrorResponse) MarshalJSON() ([]byte, error) { } // UnmarshalJSON deserializes the given payload. -func (o *FindingsErrorResponse) UnmarshalJSON(bytes []byte) (err error) { +func (o *JSONAPIErrorResponse) UnmarshalJSON(bytes []byte) (err error) { raw := map[string]interface{}{} required := struct { - Errors *[]FindingsErrorItem `json:"errors"` + Errors *[]JSONAPIErrorItem `json:"errors"` }{} all := struct { - Errors []FindingsErrorItem `json:"errors"` + Errors []JSONAPIErrorItem `json:"errors"` }{} err = json.Unmarshal(bytes, &required) if err != nil { diff --git a/tests/scenarios/features/v2/security_monitoring.feature b/tests/scenarios/features/v2/security_monitoring.feature index cdbcb18dffc..c8c8357f4eb 100644 --- a/tests/scenarios/features/v2/security_monitoring.feature +++ b/tests/scenarios/features/v2/security_monitoring.feature @@ -199,20 +199,20 @@ Feature: Security Monitoring And the response "id" has the same value as "cloud_configuration_rule.id" @generated @skip @team:DataDog/cloud-security-posture-management - Scenario: Get a finding returns "Bad Request" response + Scenario: Get a finding returns "Bad Request: The server cannot process the request due to invalid syntax in the request." response Given operation "GetFinding" enabled And new "GetFinding" request And request contains "finding_id" parameter from "REPLACE.ME" When the request is sent - Then the response status is 400 Bad Request + Then the response status is 400 Bad Request: The server cannot process the request due to invalid syntax in the request. @generated @skip @team:DataDog/cloud-security-posture-management - Scenario: Get a finding returns "Not Found" response + Scenario: Get a finding returns "Not Found: The requested finding cannot be found." response Given operation "GetFinding" enabled And new "GetFinding" request And request contains "finding_id" parameter from "REPLACE.ME" When the request is sent - Then the response status is 404 Not Found + Then the response status is 404 Not Found: The requested finding cannot be found. @replay-only @team:DataDog/cloud-security-posture-management Scenario: Get a finding returns "OK" response @@ -325,18 +325,18 @@ Feature: Security Monitoring And the response "data" has item with field "attributes.is_builtin" with value true @generated @skip @team:DataDog/cloud-security-posture-management - Scenario: List findings returns "Bad Request" response + Scenario: List findings returns "Bad Request: The server cannot process the request due to invalid syntax in the request." response Given operation "ListFindings" enabled And new "ListFindings" request When the request is sent - Then the response status is 400 Bad Request + Then the response status is 400 Bad Request: The server cannot process the request due to invalid syntax in the request. @generated @skip @team:DataDog/cloud-security-posture-management - Scenario: List findings returns "Not Found" response + Scenario: List findings returns "Not Found: The requested finding cannot be found." response Given operation "ListFindings" enabled And new "ListFindings" request When the request is sent - Then the response status is 404 Not Found + Then the response status is 404 Not Found: The requested finding cannot be found. @replay-only @team:DataDog/cloud-security-posture-management Scenario: List findings returns "OK" response