Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .apigentools-info
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
}
29 changes: 26 additions & 3 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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/).'
Expand Down
26 changes: 26 additions & 0 deletions examples/v2/security-monitoring/ListFindings_3865842421.java
Original file line number Diff line number Diff line change
@@ -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<Finding> 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();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -1709,7 +1710,7 @@ public ApiResponse<SecurityMonitoringSignal> 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;
Expand All @@ -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 &lt;= 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;
}

Expand Down Expand Up @@ -1920,9 +1922,104 @@ public CompletableFuture<ListFindingsResponse> listFindingsAsync(
});
}

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

/**
* List findings.
*
* <p>See {@link #listFindingsWithHttpInfo}.
*
* @return ListFindingsResponse
*/
public PaginationIterable<Finding> 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<String, Object> args = new LinkedHashMap<String, Object>();
args.put("optionalParams", parameters);

PaginationIterable iterator =
new PaginationIterable(
this,
"listFindings",
resultsPath,
valueGetterPath,
valueSetterPath,
valueSetterParamOptional,
limit,
args);

return iterator;
}

/**
* Get a list of CSPM findings.
*
* <h3>Filtering</h3>
*
* <p>Filters can be applied by appending query parameters to the URL.
*
* <ul>
* <li>Using a single filter: <code>?filter[attribute_key]=attribute_value</code>
* <li>Chaining filters: <code>
* ?filter[attribute_key]=attribute_value&amp;filter[attribute_key]=attribute_value...
* </code>
* <li>Filtering on tags: <code>
* ?filter[tags]=tag_key:tag_value&amp;filter[tags]=tag_key_2:tag_value_2</code>
* </ul>
*
* <p>Here, <code>attribute_key</code> can be any of the filter keys described further below.
*
* <p>Query parameters of type <code>integer</code> support comparison operators (<code>&gt;
* </code>, <code>&gt;=</code>, <code>&lt;</code>, <code>&lt;=</code>). This is particularly
* useful when filtering by <code>evaluation_changed_at</code> or <code>
* resource_discovery_timestamp</code>. For example: <code>
* ?filter[evaluation_changed_at]=&gt;20123123121</code>.
*
* <p>You can also use the negation operator on strings. For example, use <code>
* filter[resource_type]=-aws*</code> to filter for any non-AWS resources.
*
* <p>The operator must come after the equal sign. For example, to filter with the <code>&gt;=
* </code> operator, add the operator after the equal sign: <code>
* filter[evaluation_changed_at]=&gt;=1678809373257</code>.
*
* <h3>Response</h3>
*
* <p>The response includes an array of finding objects, pagination metadata, and a count of items
* that match the query.
*
* <p>Each finding object contains the following:
*
* <ul>
* <li>The finding ID that can be used in a <code>GetFinding</code> request to retrieve the full
* finding details.
* <li>Core attributes, including status, evaluation, high-level resource details, muted state,
* and rule details.
* <li><code>evaluation_changed_at</code> and <code>resource_discovery_date</code> time stamps.
* <li>An array of associated tags.
* </ul>
*
* @param parameters Optional parameters for the request.
* @return ApiResponse&lt;ListFindingsResponse&gt;
* @throws ApiException if fails to make API call
Expand All @@ -1947,7 +2044,7 @@ public ApiResponse<ListFindingsResponse> 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;
Expand All @@ -1965,7 +2062,7 @@ public ApiResponse<ListFindingsResponse> listFindingsWithHttpInfo(
List<Pair> localVarQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>();

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));
Expand Down Expand Up @@ -2024,7 +2121,7 @@ public CompletableFuture<ApiResponse<ListFindingsResponse>> 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;
Expand All @@ -2042,7 +2139,7 @@ public CompletableFuture<ApiResponse<ListFindingsResponse>> listFindingsWithHttp
List<Pair> localVarQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>();

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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down