Skip to content

Commit

Permalink
Add support for multi form parameter support (#2499)
Browse files Browse the repository at this point in the history
* Sort param list before comparing

* this

* Regenerate client from commit aeb956c4 of spec repo

---------

Co-authored-by: HantingZhang2 <[email protected]>
Co-authored-by: api-clients-generation-pipeline[bot] <54105614+api-clients-generation-pipeline[bot]@users.noreply.github.com>
Co-authored-by: ci.datadog-api-spec <[email protected]>
  • Loading branch information
3 people authored Nov 4, 2024
1 parent 6a24901 commit 88b75b8
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 6 deletions.
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

0 comments on commit 88b75b8

Please sign in to comment.