diff --git a/.apigentools-info b/.apigentools-info index e2b3ecfce17..594ecdafaf5 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.6.5", - "regenerated": "2023-08-30 08:43:00.573454", - "spec_repo_commit": "fee86b40" + "regenerated": "2023-08-30 11:45:15.156195", + "spec_repo_commit": "2f2fd804" }, "v2": { "apigentools_version": "1.6.5", - "regenerated": "2023-08-30 08:43:00.591173", - "spec_repo_commit": "fee86b40" + "regenerated": "2023-08-30 11:45:15.170455", + "spec_repo_commit": "2f2fd804" } } } \ No newline at end of file diff --git a/.generator/schemas/v1/openapi.yaml b/.generator/schemas/v1/openapi.yaml index 3ed657399ef..68301444636 100644 --- a/.generator/schemas/v1/openapi.yaml +++ b/.generator/schemas/v1/openapi.yaml @@ -27990,14 +27990,19 @@ paths: - description: Used for pagination. The number of tests returned in the page. in: query name: page_size + required: false schema: - type: string + default: 100 + format: int64 + type: integer - description: Used for pagination. Which page you want to retrieve. Starts at zero. in: query name: page_number + required: false schema: - type: string + format: int64 + type: integer responses: '200': content: @@ -28027,6 +28032,10 @@ paths: summary: Get the list of all Synthetic tests tags: - Synthetics + x-pagination: + limitParam: page_size + pageParam: page_number + resultsPath: tests /api/v1/synthetics/tests/api: post: description: Create a Synthetic API test. diff --git a/examples/v1/synthetics/ListTests_1938827783.java b/examples/v1/synthetics/ListTests_1938827783.java new file mode 100644 index 00000000000..839ee0f1798 --- /dev/null +++ b/examples/v1/synthetics/ListTests_1938827783.java @@ -0,0 +1,28 @@ +// Get the list of all Synthetic tests returns "OK - Returns the list of all Synthetic tests." +// response with pagination + +import com.datadog.api.client.ApiClient; +import com.datadog.api.client.PaginationIterable; +import com.datadog.api.client.v1.api.SyntheticsApi; +import com.datadog.api.client.v1.api.SyntheticsApi.ListTestsOptionalParameters; +import com.datadog.api.client.v1.model.SyntheticsTestDetails; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = ApiClient.getDefaultApiClient(); + SyntheticsApi apiInstance = new SyntheticsApi(defaultClient); + + try { + PaginationIterable iterable = + apiInstance.listTestsWithPagination(new ListTestsOptionalParameters().pageSize(2L)); + + for (SyntheticsTestDetails item : iterable) { + System.out.println(item); + } + } catch (RuntimeException e) { + System.err.println("Exception when calling SyntheticsApi#listTestsWithPagination"); + System.err.println("Reason: " + e.getMessage()); + e.printStackTrace(); + } + } +} diff --git a/src/main/java/com/datadog/api/client/v1/api/SyntheticsApi.java b/src/main/java/com/datadog/api/client/v1/api/SyntheticsApi.java index 18c6937cdea..501344a104a 100644 --- a/src/main/java/com/datadog/api/client/v1/api/SyntheticsApi.java +++ b/src/main/java/com/datadog/api/client/v1/api/SyntheticsApi.java @@ -3,6 +3,7 @@ import com.datadog.api.client.ApiClient; import com.datadog.api.client.ApiException; import com.datadog.api.client.ApiResponse; +import com.datadog.api.client.PaginationIterable; import com.datadog.api.client.Pair; import com.datadog.api.client.v1.model.SyntheticsAPITest; import com.datadog.api.client.v1.model.SyntheticsAPITestResultFull; @@ -28,6 +29,7 @@ import jakarta.ws.rs.core.GenericType; import java.util.ArrayList; import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.concurrent.CompletableFuture; @@ -3108,16 +3110,17 @@ public CompletableFuture> listLocationsWithHttp /** Manage optional parameters to listTests. */ public static class ListTestsOptionalParameters { - private String pageSize; - private String pageNumber; + private Long pageSize; + private Long pageNumber; /** * Set pageSize. * - * @param pageSize Used for pagination. The number of tests returned in the page. (optional) + * @param pageSize Used for pagination. The number of tests returned in the page. (optional, + * default to 100) * @return ListTestsOptionalParameters */ - public ListTestsOptionalParameters pageSize(String pageSize) { + public ListTestsOptionalParameters pageSize(Long pageSize) { this.pageSize = pageSize; return this; } @@ -3129,7 +3132,7 @@ public ListTestsOptionalParameters pageSize(String pageSize) { * (optional) * @return ListTestsOptionalParameters */ - public ListTestsOptionalParameters pageNumber(String pageNumber) { + public ListTestsOptionalParameters pageNumber(Long pageNumber) { this.pageNumber = pageNumber; return this; } @@ -3193,6 +3196,59 @@ public CompletableFuture listTestsAsync( }); } + /** + * Get the list of all Synthetic tests. + * + *

See {@link #listTestsWithHttpInfo}. + * + * @return PaginationIterable<SyntheticsTestDetails> + */ + public PaginationIterable listTestsWithPagination() { + ListTestsOptionalParameters parameters = new ListTestsOptionalParameters(); + return listTestsWithPagination(parameters); + } + + /** + * Get the list of all Synthetic tests. + * + *

See {@link #listTestsWithHttpInfo}. + * + * @return SyntheticsListTestsResponse + */ + public PaginationIterable listTestsWithPagination( + ListTestsOptionalParameters parameters) { + String resultsPath = "getTests"; + String valueGetterPath = ""; + String valueSetterPath = "pageNumber"; + Boolean valueSetterParamOptional = true; + parameters.pageNumber(0l); + Long limit; + + if (parameters.pageSize == null) { + limit = 100l; + parameters.pageSize(limit); + } else { + limit = parameters.pageSize; + } + + LinkedHashMap args = new LinkedHashMap(); + args.put("optionalParams", parameters); + + PaginationIterable iterator = + new PaginationIterable( + this, + "listTests", + resultsPath, + valueGetterPath, + valueSetterPath, + valueSetterParamOptional, + false, + limit, + args); + + return iterator; + } + /** * Get the list of all Synthetic tests. * @@ -3212,8 +3268,8 @@ public CompletableFuture listTestsAsync( public ApiResponse listTestsWithHttpInfo( ListTestsOptionalParameters parameters) throws ApiException { Object localVarPostBody = null; - String pageSize = parameters.pageSize; - String pageNumber = parameters.pageNumber; + Long pageSize = parameters.pageSize; + Long pageNumber = parameters.pageNumber; // create path and map variables String localVarPath = "/api/v1/synthetics/tests"; @@ -3254,8 +3310,8 @@ public ApiResponse listTestsWithHttpInfo( public CompletableFuture> listTestsWithHttpInfoAsync( ListTestsOptionalParameters parameters) { Object localVarPostBody = null; - String pageSize = parameters.pageSize; - String pageNumber = parameters.pageNumber; + Long pageSize = parameters.pageSize; + Long pageNumber = parameters.pageNumber; // create path and map variables String localVarPath = "/api/v1/synthetics/tests"; diff --git a/src/test/resources/cassettes/features/v1/Get_the_list_of_all_Synthetic_tests_returns_OK_Returns_the_list_of_all_Synthetic_tests_response_with_pagination.freeze b/src/test/resources/cassettes/features/v1/Get_the_list_of_all_Synthetic_tests_returns_OK_Returns_the_list_of_all_Synthetic_tests_response_with_pagination.freeze new file mode 100644 index 00000000000..1c77d3c7d8e --- /dev/null +++ b/src/test/resources/cassettes/features/v1/Get_the_list_of_all_Synthetic_tests_returns_OK_Returns_the_list_of_all_Synthetic_tests_response_with_pagination.freeze @@ -0,0 +1 @@ +2023-08-30T09:42:25.568Z \ No newline at end of file diff --git a/src/test/resources/cassettes/features/v1/Get_the_list_of_all_Synthetic_tests_returns_OK_Returns_the_list_of_all_Synthetic_tests_response_with_pagination.json b/src/test/resources/cassettes/features/v1/Get_the_list_of_all_Synthetic_tests_returns_OK_Returns_the_list_of_all_Synthetic_tests_response_with_pagination.json new file mode 100644 index 00000000000..04450f1fb73 --- /dev/null +++ b/src/test/resources/cassettes/features/v1/Get_the_list_of_all_Synthetic_tests_returns_OK_Returns_the_list_of_all_Synthetic_tests_response_with_pagination.json @@ -0,0 +1,70 @@ +[ + { + "httpRequest": { + "headers": {}, + "method": "GET", + "path": "/api/v1/synthetics/tests", + "queryStringParameters": { + "page_size": [ + "2" + ], + "page_number": [ + "0" + ] + }, + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"tests\":[{\"public_id\":\"888-nvp-kbw\",\"name\":\"tf-TestAccDatadogSyntheticsTestBrowserMML_Basic-local-1689951468-updated\",\"status\":\"paused\",\"type\":\"browser\",\"tags\":[\"foo:bar\",\"baz\"],\"created_at\":\"2023-07-21T14:57:51.688079+00:00\",\"modified_at\":\"2023-07-21T14:58:21.332326+00:00\",\"config\":{\"assertions\":[],\"configVariables\":[],\"request\":{\"method\":\"GET\",\"timeout\":60,\"url\":\"https://www.datadoghq.com\"},\"variables\":[]},\"message\":\"Notify @datadog.user\",\"options\":{\"device_ids\":[\"laptop_large\"],\"min_location_failed\":1,\"tick_every\":900},\"locations\":[\"aws:eu-central-1\"],\"monitor_id\":126283369,\"creator\":{\"name\":null,\"handle\":\"frog@datadoghq.com\",\"email\":\"frog@datadoghq.com\"}},{\"public_id\":\"i9r-v4f-v3u\",\"name\":\"tf-TestAccDatadogSyntheticsBrowserTest_Updated_RumSettings-local-1689951491-updated-rumsettings\",\"status\":\"live\",\"type\":\"browser\",\"tags\":[\"foo:bar\",\"buz\"],\"created_at\":\"2023-07-21T14:58:17.635359+00:00\",\"modified_at\":\"2023-08-28T14:37:49.734465+00:00\",\"config\":{\"assertions\":[],\"configVariables\":[],\"request\":{\"method\":\"GET\",\"headers\":{\"Accept\":\"application/xml\",\"X-Datadog-Trace-ID\":\"987654321\"},\"url\":\"https://docs.datadoghq.com\"},\"setCookie\":\"\",\"variables\":[{\"example\":\"7956\",\"name\":\"MY_PATTERN_VAR\",\"pattern\":\"{{numeric(4)}}\",\"secure\":false,\"type\":\"text\"}]},\"message\":\"Notify @pagerduty\",\"options\":{\"device_ids\":[\"chrome.laptop_large\",\"chrome.tablet\"],\"ignoreServerCertificateError\":false,\"disableCors\":false,\"disableCsp\":false,\"noScreenshot\":false,\"tick_every\":1800,\"min_failure_duration\":10,\"min_location_failed\":1,\"retry\":{\"count\":3,\"interval\":500},\"monitor_options\":{\"renotify_interval\":120},\"ci\":{\"executionRule\":\"skipped\"},\"rumSettings\":{\"isEnabled\":false},\"enableProfiling\":false,\"enableSecurityTesting\":false},\"locations\":[\"aws:eu-central-1\"],\"monitor_id\":126283421,\"creator\":{\"name\":null,\"handle\":\"frog@datadoghq.com\",\"email\":\"frog@datadoghq.com\"}}],\"total\":3}", + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "statusCode": 200, + "reasonPhrase": "OK" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "8bd3539f-e2a3-d4f5-897f-5d75b0a8fdce" + }, + { + "httpRequest": { + "headers": {}, + "method": "GET", + "path": "/api/v1/synthetics/tests", + "queryStringParameters": { + "page_size": [ + "2" + ], + "page_number": [ + "1" + ] + }, + "keepAlive": false, + "secure": true + }, + "httpResponse": { + "body": "{\"tests\":[{\"public_id\":\"p34-3up-y6p\",\"name\":\"Example-Create_an_API_HTTP_test_returns_OK_Returns_the_created_test_details_response_1692944481\",\"status\":\"live\",\"type\":\"api\",\"tags\":[\"testing:api\"],\"created_at\":\"2023-08-25T06:21:21.640836+00:00\",\"modified_at\":\"2023-08-25T06:21:21.640836+00:00\",\"config\":{\"assertions\":[{\"operator\":\"is\",\"property\":\"{{ PROPERTY }}\",\"target\":\"text/html\",\"type\":\"header\"},{\"operator\":\"lessThan\",\"target\":2000,\"type\":\"responseTime\"},{\"operator\":\"validatesJSONPath\",\"target\":{\"jsonPath\":\"topKey\",\"operator\":\"isNot\",\"targetValue\":\"0\"},\"type\":\"body\"},{\"operator\":\"validatesXPath\",\"target\":{\"xPath\":\"target-xpath\",\"targetValue\":\"0\",\"operator\":\"contains\"},\"type\":\"body\"}],\"configVariables\":[{\"example\":\"content-type\",\"name\":\"PROPERTY\",\"pattern\":\"content-type\",\"type\":\"text\"}],\"request\":{\"certificate\":{\"cert\":{\"filename\":\"cert-filename\",\"updatedAt\":\"2020-10-16T09:23:24.857Z\"},\"key\":{\"filename\":\"key-filename\",\"updatedAt\":\"2020-10-16T09:23:24.857Z\"}},\"headers\":{\"unique\":\"examplecreateanapihttptestreturnsokreturnsthecreatedtestdetailsresponse1692944481\"},\"method\":\"GET\",\"timeout\":10,\"url\":\"https://datadoghq.com\",\"proxy\":{\"url\":\"https://datadoghq.com\",\"headers\":{}},\"basicAuth\":{\"accessTokenUrl\":\"https://datadog-token.com\",\"audience\":\"audience\",\"clientId\":\"client-id\",\"clientSecret\":\"client-secret\",\"resource\":\"resource\",\"scope\":\"yoyo\",\"tokenApiAuthentication\":\"header\",\"type\":\"oauth-client\"},\"persistCookies\":true}},\"message\":\"BDD test payload: synthetics_api_http_test_payload.json\",\"options\":{\"accept_self_signed\":false,\"allow_insecure\":true,\"follow_redirects\":true,\"min_failure_duration\":10,\"min_location_failed\":1,\"monitor_name\":\"Example-Create_an_API_HTTP_test_returns_OK_Returns_the_created_test_details_response_1692944481\",\"monitor_priority\":5,\"retry\":{\"count\":3,\"interval\":10},\"tick_every\":60,\"httpVersion\":\"http2\"},\"locations\":[\"aws:us-east-2\"],\"subtype\":\"http\",\"monitor_id\":130283608,\"creator\":{\"name\":null,\"handle\":\"frog@datadoghq.com\",\"email\":\"frog@datadoghq.com\"}}],\"total\":3}", + "headers": { + "Content-Type": [ + "application/json" + ] + }, + "statusCode": 200, + "reasonPhrase": "OK" + }, + "times": { + "remainingTimes": 1 + }, + "timeToLive": { + "unlimited": true + }, + "id": "7ec174e7-0c2c-2725-d1fa-011cd87e22f9" + } +] \ No newline at end of file diff --git a/src/test/resources/com/datadog/api/client/v1/api/synthetics.feature b/src/test/resources/com/datadog/api/client/v1/api/synthetics.feature index f35f990c844..2a081e01c1e 100644 --- a/src/test/resources/com/datadog/api/client/v1/api/synthetics.feature +++ b/src/test/resources/com/datadog/api/client/v1/api/synthetics.feature @@ -534,6 +534,14 @@ Feature: Synthetics When the request is sent Then the response status is 200 OK - Returns the list of all Synthetic tests. + @replay-only @skip-validation @team:DataDog/synthetics-app @with-pagination + Scenario: Get the list of all Synthetic tests returns "OK - Returns the list of all Synthetic tests." response with pagination + Given new "ListTests" request + And request contains "page_size" parameter with value 2 + When the request with pagination is sent + Then the response status is 200 OK - Returns the list of all Synthetic tests. + And the response has 3 items + @generated @skip @team:DataDog/synthetics-app Scenario: Get the list of all Synthetic tests returns "Synthetic Monitoring is not activated for the user." response Given new "ListTests" request