Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for multi form parameter support #2499

Merged
merged 9 commits into from
Nov 4, 2024
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.6",
"regenerated": "2024-11-04 17:58:14.987631",
"spec_repo_commit": "6ffe013b"
"regenerated": "2024-11-04 18:34:35.476372",
"spec_repo_commit": "aeb956c4"
},
"v2": {
"apigentools_version": "1.6.6",
"regenerated": "2024-11-04 17:58:15.006297",
"spec_repo_commit": "6ffe013b"
"regenerated": "2024-11-04 18:34:35.495455",
"spec_repo_commit": "aeb956c4"
}
}
}
34 changes: 34 additions & 0 deletions examples/v2/security-monitoring/ListFindings_1668290866.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// List findings with detection_type query param returns "OK" response

import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.SecurityMonitoringApi;
import com.datadog.api.client.v2.api.SecurityMonitoringApi.ListFindingsOptionalParameters;
import com.datadog.api.client.v2.model.FindingVulnerabilityType;
import com.datadog.api.client.v2.model.ListFindingsResponse;
import java.util.Arrays;

public class Example {
public static void main(String[] args) {
ApiClient defaultClient = ApiClient.getDefaultApiClient();
defaultClient.setUnstableOperationEnabled("v2.listFindings", true);
SecurityMonitoringApi apiInstance = new SecurityMonitoringApi(defaultClient);

try {
ListFindingsResponse result =
apiInstance.listFindings(
new ListFindingsOptionalParameters()
.filterVulnerabilityType(
Arrays.asList(
FindingVulnerabilityType.MISCONFIGURATION,
FindingVulnerabilityType.ATTACK_PATH)));
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling SecurityMonitoringApi#listFindings");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
10 changes: 8 additions & 2 deletions src/test/java/com/datadog/api/TestClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -418,9 +418,15 @@ public Invocation.Builder request() {
if (params != null) {
Map expectedQueryParams = new HashMap<String, String>();
for (Map.Entry<String, List<String>> entry : params.entrySet()) {
expectedQueryParams.put(entry.getKey(), entry.getValue().get(0));
List<String> paramValueList = entry.getValue();
Collections.sort(paramValueList);
expectedQueryParams.put(entry.getKey(), paramValueList.get(0));
}
assertEquals(this.queryParams, expectedQueryParams);

List<String> actualQueryValue =
Arrays.asList(this.queryParams.entrySet().iterator().next().getValue());
Collections.sort(actualQueryValue);
assertEquals(expectedQueryParams, this.queryParams);
}
return new TestBuilder(this.client);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2024-10-21T20:05:58.636Z
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[
{
"httpRequest": {
"headers": {},
"method": "GET",
"path": "/api/v2/posture_management/findings",
"queryStringParameters": {
"filter[vulnerability_type]": [
"misconfiguration",
"attack_path"
]
},
"keepAlive": false,
"secure": true
},
"httpResponse": {
"body": "{\"data\":[],\"meta\":{\"page\":{\"total_filtered_count\":0},\"snapshot_timestamp\":1729541158755}}",
"headers": {
"Content-Type": [
"application/vnd.api+json"
]
},
"statusCode": 200,
"reasonPhrase": "OK"
},
"times": {
"remainingTimes": 1
},
"timeToLive": {
"unlimited": true
},
"id": "5f6fcc70-3704-b046-2fc3-3728fd9b12b2"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,14 @@ Feature: Security Monitoring
When the request with pagination is sent
Then the response status is 200 OK

@skip-terraform-config @team:DataDog/cloud-security-posture-management
Scenario: List findings with detection_type query param returns "OK" response
Given operation "ListFindings" enabled
And new "ListFindings" request
And request contains "filter[vulnerability_type]" parameter with value ["misconfiguration", "attack_path"]
When the request 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
Loading