From c101ba0d2eefe3bc02fdf4f7ed199582be3e4806 Mon Sep 17 00:00:00 2001 From: "ci.datadog-api-spec" Date: Mon, 24 Apr 2023 09:05:51 +0000 Subject: [PATCH] Regenerate client from commit 6be43f02 of spec repo --- .apigentools-info | 8 +- .generator/schemas/v2/openapi.yaml | 29 ++++- .../ListFindings_3865842421.java | 26 ++++ .../client/v2/api/SecurityMonitoringApi.java | 115 ++++++++++++++++-- .../client/v2/api/security_monitoring.feature | 7 ++ 5 files changed, 169 insertions(+), 16 deletions(-) create mode 100644 examples/v2/security-monitoring/ListFindings_3865842421.java diff --git a/.apigentools-info b/.apigentools-info index e4839b6ff79..e67d61d37d7 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.6.4", - "regenerated": "2023-04-21 15:12:12.583053", - "spec_repo_commit": "7fa27269" + "regenerated": "2023-04-24 09:04:27.702528", + "spec_repo_commit": "6be43f02" }, "v2": { "apigentools_version": "1.6.4", - "regenerated": "2023-04-21 15:12:12.599199", - "spec_repo_commit": "7fa27269" + "regenerated": "2023-04-24 09:04:27.716387", + "spec_repo_commit": "6be43f02" } } } \ No newline at end of file diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 4ab88039845..c09ac7267a7 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -19455,15 +19455,33 @@ paths: - Roles /api/v2/posture_management/findings: get: - description: Get a list of CSPM findings. + description: "Get a list of CSPM findings.\n\n### Filtering\n\nFilters can be + applied by appending query parameters to the URL.\n\n - Using a single filter: + `?filter[attribute_key]=attribute_value`\n - Chaining filters: `?filter[attribute_key]=attribute_value&filter[attribute_key]=attribute_value...`\n + \ - Filtering on tags: `?filter[tags]=tag_key:tag_value&filter[tags]=tag_key_2:tag_value_2`\n\nHere, + `attribute_key` can be any of the filter keys described further below.\n\nQuery + parameters of type `integer` support comparison operators (`>`, `>=`, `<`, + `<=`). This is particularly useful when filtering by `evaluation_changed_at` + or `resource_discovery_timestamp`. For example: `?filter[evaluation_changed_at]=>20123123121`.\n\nYou + 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" operationId: ListFindings parameters: - - description: Limit the number of findings returned. + - description: Limit the number of findings returned. Must be <= 1000. example: 50 in: query - name: limit + name: page[limit] required: false schema: + default: 100 format: int64 maximum: 1000 minimum: 1 @@ -19573,6 +19591,11 @@ paths: summary: List findings tags: - Security Monitoring + x-pagination: + cursorParam: page[cursor] + cursorPath: meta.page.cursor + limitParam: page[limit] + resultsPath: data x-unstable: '**Note**: This endpoint is in public beta. If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' diff --git a/examples/v2/security-monitoring/ListFindings_3865842421.java b/examples/v2/security-monitoring/ListFindings_3865842421.java new file mode 100644 index 00000000000..8f06feff6d8 --- /dev/null +++ b/examples/v2/security-monitoring/ListFindings_3865842421.java @@ -0,0 +1,26 @@ +// List findings returns "OK" response with pagination + +import com.datadog.api.client.ApiClient; +import com.datadog.api.client.PaginationIterable; +import com.datadog.api.client.v2.api.SecurityMonitoringApi; +import com.datadog.api.client.v2.model.Finding; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + defaultClient.setUnstableOperationEnabled("v2.listFindings", true); + SecurityMonitoringApi apiInstance = new SecurityMonitoringApi(defaultClient); + + try { + PaginationIterable iterable = apiInstance.listFindingsWithPagination(); + + for (Finding item : iterable) { + System.out.println(item); + } + } catch (RuntimeException e) { + System.err.println("Exception when calling SecurityMonitoringApi#listFindingsWithPagination"); + System.err.println("Reason: " + e.getMessage()); + e.printStackTrace(); + } + } +} diff --git a/src/main/java/com/datadog/api/client/v2/api/SecurityMonitoringApi.java b/src/main/java/com/datadog/api/client/v2/api/SecurityMonitoringApi.java index 16d439968af..00b971c6fbb 100644 --- a/src/main/java/com/datadog/api/client/v2/api/SecurityMonitoringApi.java +++ b/src/main/java/com/datadog/api/client/v2/api/SecurityMonitoringApi.java @@ -5,6 +5,7 @@ import com.datadog.api.client.ApiResponse; import com.datadog.api.client.PaginationIterable; import com.datadog.api.client.Pair; +import com.datadog.api.client.v2.model.Finding; import com.datadog.api.client.v2.model.FindingEvaluation; import com.datadog.api.client.v2.model.FindingStatus; import com.datadog.api.client.v2.model.GetFindingResponse; @@ -1709,7 +1710,7 @@ public ApiResponse getSecurityMonitoringSignalWithHttp /** Manage optional parameters to listFindings. */ public static class ListFindingsOptionalParameters { - private Long limit; + private Long pageLimit; private Long snapshotTimestamp; private String pageCursor; private String filterTags; @@ -1723,13 +1724,14 @@ public static class ListFindingsOptionalParameters { private FindingStatus filterStatus; /** - * Set limit. + * Set pageLimit. * - * @param limit Limit the number of findings returned. (optional) + * @param pageLimit Limit the number of findings returned. Must be <= 1000. (optional, + * default to 100) * @return ListFindingsOptionalParameters */ - public ListFindingsOptionalParameters limit(Long limit) { - this.limit = limit; + public ListFindingsOptionalParameters pageLimit(Long pageLimit) { + this.pageLimit = pageLimit; return this; } @@ -1920,9 +1922,104 @@ public CompletableFuture listFindingsAsync( }); } + /** + * List findings. + * + *

See {@link #listFindingsWithHttpInfo}. + * + * @return PaginationIterable<Finding> + */ + public PaginationIterable listFindingsWithPagination() { + ListFindingsOptionalParameters parameters = new ListFindingsOptionalParameters(); + return listFindingsWithPagination(parameters); + } + + /** + * List findings. + * + *

See {@link #listFindingsWithHttpInfo}. + * + * @return ListFindingsResponse + */ + public PaginationIterable listFindingsWithPagination( + ListFindingsOptionalParameters parameters) { + String resultsPath = "getData"; + String valueGetterPath = "getMeta.getPage.getCursor"; + String valueSetterPath = "pageCursor"; + Boolean valueSetterParamOptional = true; + Long limit; + + if (parameters.pageLimit == null) { + limit = 100l; + parameters.pageLimit(limit); + } else { + limit = parameters.pageLimit; + } + + LinkedHashMap args = new LinkedHashMap(); + args.put("optionalParams", parameters); + + PaginationIterable iterator = + new PaginationIterable( + this, + "listFindings", + resultsPath, + valueGetterPath, + valueSetterPath, + valueSetterParamOptional, + limit, + args); + + return iterator; + } + /** * Get a list of CSPM findings. * + *

Filtering

+ * + *

Filters can be applied by appending query parameters to the URL. + * + *

    + *
  • Using a single filter: ?filter[attribute_key]=attribute_value + *
  • Chaining filters: + * ?filter[attribute_key]=attribute_value&filter[attribute_key]=attribute_value... + * + *
  • Filtering on tags: + * ?filter[tags]=tag_key:tag_value&filter[tags]=tag_key_2:tag_value_2 + *
+ * + *

Here, attribute_key can be any of the filter keys described further below. + * + *

Query parameters of type integer support comparison operators (> + * , >=, <, <=). This is particularly + * useful when filtering by evaluation_changed_at or + * resource_discovery_timestamp. For example: + * ?filter[evaluation_changed_at]=>20123123121. + * + *

You can also use the negation operator on strings. For example, use + * filter[resource_type]=-aws* to filter for any non-AWS resources. + * + *

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. + * + *

Response

+ * + *

The response includes an array of finding objects, pagination metadata, and a count of items + * that match the query. + * + *

Each finding object contains the following: + * + *

    + *
  • The finding ID that can be used in a GetFinding request to retrieve the full + * finding details. + *
  • Core attributes, including status, evaluation, high-level resource details, muted state, + * and rule details. + *
  • evaluation_changed_at and resource_discovery_date time stamps. + *
  • An array of associated tags. + *
+ * * @param parameters Optional parameters for the request. * @return ApiResponse<ListFindingsResponse> * @throws ApiException if fails to make API call @@ -1947,7 +2044,7 @@ public ApiResponse listFindingsWithHttpInfo( throw new ApiException(0, String.format("Unstable operation '%s' is disabled", operationId)); } Object localVarPostBody = null; - Long limit = parameters.limit; + Long pageLimit = parameters.pageLimit; Long snapshotTimestamp = parameters.snapshotTimestamp; String pageCursor = parameters.pageCursor; String filterTags = parameters.filterTags; @@ -1965,7 +2062,7 @@ public ApiResponse listFindingsWithHttpInfo( List localVarQueryParams = new ArrayList(); Map localVarHeaderParams = new HashMap(); - localVarQueryParams.addAll(apiClient.parameterToPairs("", "limit", limit)); + localVarQueryParams.addAll(apiClient.parameterToPairs("", "page[limit]", pageLimit)); localVarQueryParams.addAll( apiClient.parameterToPairs("", "snapshot_timestamp", snapshotTimestamp)); localVarQueryParams.addAll(apiClient.parameterToPairs("", "page[cursor]", pageCursor)); @@ -2024,7 +2121,7 @@ public CompletableFuture> listFindingsWithHttp return result; } Object localVarPostBody = null; - Long limit = parameters.limit; + Long pageLimit = parameters.pageLimit; Long snapshotTimestamp = parameters.snapshotTimestamp; String pageCursor = parameters.pageCursor; String filterTags = parameters.filterTags; @@ -2042,7 +2139,7 @@ public CompletableFuture> listFindingsWithHttp List localVarQueryParams = new ArrayList(); Map localVarHeaderParams = new HashMap(); - localVarQueryParams.addAll(apiClient.parameterToPairs("", "limit", limit)); + localVarQueryParams.addAll(apiClient.parameterToPairs("", "page[limit]", pageLimit)); localVarQueryParams.addAll( apiClient.parameterToPairs("", "snapshot_timestamp", snapshotTimestamp)); localVarQueryParams.addAll(apiClient.parameterToPairs("", "page[cursor]", pageCursor)); diff --git a/src/test/resources/com/datadog/api/client/v2/api/security_monitoring.feature b/src/test/resources/com/datadog/api/client/v2/api/security_monitoring.feature index b5800de3117..4b01fcbe876 100644 --- a/src/test/resources/com/datadog/api/client/v2/api/security_monitoring.feature +++ b/src/test/resources/com/datadog/api/client/v2/api/security_monitoring.feature @@ -344,6 +344,13 @@ Feature: Security Monitoring Then the response status is 200 OK And the response "data[0].type" is equal to "finding" + @generated @skip @team:DataDog/cloud-security-posture-management @with-pagination + Scenario: List findings returns "OK" response with pagination + Given operation "ListFindings" enabled + And new "ListFindings" request + When the request with pagination is sent + Then the response status is 200 OK + @generated @skip @team:DataDog/k9-cloud-security-platform Scenario: List rules returns "Bad Request" response Given new "ListSecurityMonitoringRules" request