From 24521eee1462849a8b1611bd56bf23f4c6615722 Mon Sep 17 00:00:00 2001 From: "ci.datadog-api-spec" Date: Fri, 12 Nov 2021 17:42:45 +0000 Subject: [PATCH] Regenerate client from commit 2b850b7 of spec repo --- .apigentools-info | 8 +- .generator/schemas/v1/openapi.yaml | 53 ++ .../frozen.json | 1 + .../recording.har | 463 ++++++++++++++++++ docs/v1/SyntheticsApi.md | 79 +++ features/v1/synthetics.feature | 14 + features/v1/undo.json | 6 + .../.openapi-generator/FILES | 2 + .../apis/SyntheticsApi.ts | 111 +++++ packages/datadog-api-client-v1/index.ts | 1 + .../models/ObjectSerializer.ts | 4 + .../models/SyntheticsTriggerBody.ts | 41 ++ .../models/SyntheticsTriggerTest.ts | 46 ++ .../types/ObjectParamAPI.ts | 22 + .../types/ObservableAPI.ts | 43 ++ .../datadog-api-client-v1/types/PromiseAPI.ts | 14 + 16 files changed, 904 insertions(+), 4 deletions(-) create mode 100644 cassettes/v1/Synthetics_2658572017/Trigger-some-Synthetics-tests-returns-OK-response_3057428528/frozen.json create mode 100644 cassettes/v1/Synthetics_2658572017/Trigger-some-Synthetics-tests-returns-OK-response_3057428528/recording.har create mode 100644 packages/datadog-api-client-v1/models/SyntheticsTriggerBody.ts create mode 100644 packages/datadog-api-client-v1/models/SyntheticsTriggerTest.ts diff --git a/.apigentools-info b/.apigentools-info index c6648ec6424..ba27cdfe18b 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.5.1.dev2", - "regenerated": "2021-11-12 16:34:44.905327", - "spec_repo_commit": "cbb6f12" + "regenerated": "2021-11-12 17:41:04.911019", + "spec_repo_commit": "2b850b7" }, "v2": { "apigentools_version": "1.5.1.dev2", - "regenerated": "2021-11-12 16:34:44.931401", - "spec_repo_commit": "cbb6f12" + "regenerated": "2021-11-12 17:41:04.934476", + "spec_repo_commit": "2b850b7" } } } \ No newline at end of file diff --git a/.generator/schemas/v1/openapi.yaml b/.generator/schemas/v1/openapi.yaml index 09d066e7d61..816e06cdd70 100644 --- a/.generator/schemas/v1/openapi.yaml +++ b/.generator/schemas/v1/openapi.yaml @@ -11075,6 +11075,17 @@ components: format: double type: number type: object + SyntheticsTriggerBody: + description: Object describing the synthetics tests to trigger. + properties: + tests: + description: Individual synthetics test. + items: + $ref: '#/components/schemas/SyntheticsTriggerTest' + type: array + required: + - tests + type: object SyntheticsTriggerCITestLocation: description: Synthetics location. properties: @@ -11125,6 +11136,18 @@ components: type: string type: array type: object + SyntheticsTriggerTest: + description: Test configuration for Synthetics + properties: + metadata: + $ref: '#/components/schemas/SyntheticsCIBatchMetadata' + public_id: + description: The public ID of the Synthetics test to trigger. + example: aaa-aaa-aaa + type: string + required: + - public_id + type: object SyntheticsUpdateTestPauseStatusPayload: description: Object to start or pause an existing Synthetic test. properties: @@ -22683,6 +22706,36 @@ paths: x-menu-order: 14 x-undo: type: idempotent + /api/v1/synthetics/tests/trigger: + post: + description: Trigger a set of Synthetics tests. + operationId: TriggerTests + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/SyntheticsTriggerBody' + description: The identifiers of the tests to trigger. + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/SyntheticsTriggerCITestsResponse' + description: OK + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Bad Request + summary: Trigger some Synthetics tests + tags: + - Synthetics + x-codegen-request-body-name: body + x-undo: + type: safe /api/v1/synthetics/tests/trigger/ci: post: description: Trigger a set of Synthetics tests for continuous integration. diff --git a/cassettes/v1/Synthetics_2658572017/Trigger-some-Synthetics-tests-returns-OK-response_3057428528/frozen.json b/cassettes/v1/Synthetics_2658572017/Trigger-some-Synthetics-tests-returns-OK-response_3057428528/frozen.json new file mode 100644 index 00000000000..640768d588d --- /dev/null +++ b/cassettes/v1/Synthetics_2658572017/Trigger-some-Synthetics-tests-returns-OK-response_3057428528/frozen.json @@ -0,0 +1 @@ +"2021-11-12T17:35:35.435Z" diff --git a/cassettes/v1/Synthetics_2658572017/Trigger-some-Synthetics-tests-returns-OK-response_3057428528/recording.har b/cassettes/v1/Synthetics_2658572017/Trigger-some-Synthetics-tests-returns-OK-response_3057428528/recording.har new file mode 100644 index 00000000000..814af6e68e4 --- /dev/null +++ b/cassettes/v1/Synthetics_2658572017/Trigger-some-Synthetics-tests-returns-OK-response_3057428528/recording.har @@ -0,0 +1,463 @@ +{ + "log": { + "_recordingName": "Synthetics/Trigger some Synthetics tests returns \"OK\" response", + "creator": { + "comment": "persister:fs", + "name": "Polly.JS", + "version": "5.1.0" + }, + "entries": [ + { + "_id": "9a9c6ff51f20a80c0595e45ea99f1c77", + "_order": 0, + "cache": {}, + "request": { + "bodySize": 1263, + "cookies": [], + "headers": [ + { + "_fromType": "array", + "name": "user-agent", + "value": "datadog-api-client-typescript/1.0.0-beta.6 (node 14.18.1; os Linux; arch x64)" + }, + { + "_fromType": "array", + "name": "accept", + "value": "application/json, */*;q=0.8" + }, + { + "_fromType": "array", + "name": "content-type", + "value": "application/json" + }, + { + "_fromType": "array", + "name": "x-datadog-parent-id", + "value": "654830376920344774" + }, + { + "_fromType": "array", + "name": "x-datadog-trace-id", + "value": "2492155518930022279" + }, + { + "_fromType": "array", + "name": "content-length", + "value": "1263" + }, + { + "_fromType": "array", + "name": "connection", + "value": "close" + }, + { + "name": "host", + "value": "api.datadoghq.com" + } + ], + "headersSize": 487, + "httpVersion": "HTTP/1.1", + "method": "POST", + "postData": { + "mimeType": "application/json", + "params": [], + "text": "{\"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\"}],\"configVariables\":[{\"example\":\"content-type\",\"name\":\"PROPERTY\",\"pattern\":\"content-type\",\"type\":\"text\"}],\"request\":{\"certificate\":{\"cert\":{\"content\":\"cert-content\",\"filename\":\"cert-filename\",\"updatedAt\":\"2020-10-16T09:23:24.857Z\"},\"key\":{\"content\":\"key-content\",\"filename\":\"key-filename\",\"updatedAt\":\"2020-10-16T09:23:24.857Z\"}},\"headers\":{\"unique\":\"testtriggersomesyntheticstestsreturnsokresponse1636738535\"},\"method\":\"GET\",\"timeout\":10,\"url\":\"https://datadoghq.com\"}},\"locations\":[\"aws:us-east-2\"],\"message\":\"BDD test payload: synthetics_api_test_payload.json\",\"name\":\"Test-Trigger_some_Synthetics_tests_returns_OK_response-1636738535\",\"options\":{\"accept_self_signed\":false,\"allow_insecure\":true,\"follow_redirects\":true,\"min_failure_duration\":10,\"min_location_failed\":1,\"monitor_name\":\"Test-Trigger_some_Synthetics_tests_returns_OK_response-1636738535\",\"monitor_priority\":5,\"retry\":{\"count\":3,\"interval\":10},\"tick_every\":60},\"subtype\":\"http\",\"tags\":[\"testing:api\"],\"type\":\"api\"}" + }, + "queryString": [], + "url": "https://api.datadoghq.com/api/v1/synthetics/tests/api" + }, + "response": { + "bodySize": 1409, + "content": { + "mimeType": "application/json", + "size": 1409, + "text": "{\"status\":\"live\",\"public_id\":\"jqf-wxg-5xc\",\"tags\":[\"testing:api\"],\"org_id\":321813,\"locations\":[\"aws:us-east-2\"],\"message\":\"BDD test payload: synthetics_api_test_payload.json\",\"deleted_at\":null,\"name\":\"Test-Trigger_some_Synthetics_tests_returns_OK_response-1636738535\",\"monitor_id\":54284080,\"type\":\"api\",\"created_at\":\"2021-11-12T17:35:35.988611+00:00\",\"modified_at\":\"2021-11-12T17:35:35.988611+00:00\",\"subtype\":\"http\",\"config\":{\"request\":{\"url\":\"https://datadoghq.com\",\"headers\":{\"unique\":\"testtriggersomesyntheticstestsreturnsokresponse1636738535\"},\"certificate\":{\"cert\":{\"filename\":\"cert-filename\",\"updatedAt\":\"2020-10-16T09:23:24.857Z\"},\"key\":{\"filename\":\"key-filename\",\"updatedAt\":\"2020-10-16T09:23:24.857Z\"}},\"method\":\"GET\",\"timeout\":10},\"assertions\":[{\"operator\":\"is\",\"property\":\"{{ PROPERTY }}\",\"type\":\"header\",\"target\":\"text/html\"},{\"operator\":\"lessThan\",\"type\":\"responseTime\",\"target\":2000},{\"operator\":\"validatesJSONPath\",\"type\":\"body\",\"target\":{\"operator\":\"isNot\",\"targetValue\":\"0\",\"jsonPath\":\"topKey\"}}],\"configVariables\":[{\"pattern\":\"content-type\",\"type\":\"text\",\"example\":\"content-type\",\"name\":\"PROPERTY\"}]},\"options\":{\"accept_self_signed\":false,\"retry\":{\"count\":3,\"interval\":10},\"min_location_failed\":1,\"allow_insecure\":true,\"follow_redirects\":true,\"min_failure_duration\":10,\"monitor_priority\":5,\"monitor_name\":\"Test-Trigger_some_Synthetics_tests_returns_OK_response-1636738535\",\"tick_every\":60}}" + }, + "cookies": [], + "headers": [ + { + "name": "date", + "value": "Fri, 12 Nov 2021 17:35:36 GMT" + }, + { + "name": "content-type", + "value": "application/json" + }, + { + "name": "content-length", + "value": "1409" + }, + { + "name": "connection", + "value": "close" + }, + { + "name": "pragma", + "value": "no-cache" + }, + { + "name": "cache-control", + "value": "no-cache" + }, + { + "name": "x-ratelimit-limit", + "value": "12000" + }, + { + "name": "x-ratelimit-period", + "value": "60" + }, + { + "name": "x-ratelimit-reset", + "value": "25" + }, + { + "name": "x-ratelimit-remaining", + "value": "11999" + }, + { + "name": "x-envoy-upstream-service-time", + "value": "549" + }, + { + "name": "vary", + "value": "Accept-Encoding" + }, + { + "name": "x-content-type-options", + "value": "nosniff" + }, + { + "name": "strict-transport-security", + "value": "max-age=15724800;" + }, + { + "name": "content-security-policy", + "value": "frame-ancestors 'self'; report-uri https://api.datadoghq.com/csp-report" + }, + { + "name": "x-frame-options", + "value": "SAMEORIGIN" + } + ], + "headersSize": 523, + "httpVersion": "HTTP/1.1", + "redirectURL": "", + "status": 200, + "statusText": "OK" + }, + "startedDateTime": "2021-11-12T17:35:35.458Z", + "time": 589, + "timings": { + "blocked": -1, + "connect": -1, + "dns": -1, + "receive": 0, + "send": 0, + "ssl": -1, + "wait": 589 + } + }, + { + "_id": "53fac4401e6fdb08df5691018a6dbb21", + "_order": 0, + "cache": {}, + "request": { + "bodySize": 39, + "cookies": [], + "headers": [ + { + "_fromType": "array", + "name": "user-agent", + "value": "datadog-api-client-typescript/1.0.0-beta.6 (node 14.18.1; os Linux; arch x64)" + }, + { + "_fromType": "array", + "name": "accept", + "value": "application/json, */*;q=0.8" + }, + { + "_fromType": "array", + "name": "content-type", + "value": "application/json" + }, + { + "_fromType": "array", + "name": "x-datadog-parent-id", + "value": "5482693785226029008" + }, + { + "_fromType": "array", + "name": "x-datadog-trace-id", + "value": "2492155518930022279" + }, + { + "_fromType": "array", + "name": "content-length", + "value": "39" + }, + { + "_fromType": "array", + "name": "connection", + "value": "close" + }, + { + "name": "host", + "value": "api.datadoghq.com" + } + ], + "headersSize": 490, + "httpVersion": "HTTP/1.1", + "method": "POST", + "postData": { + "mimeType": "application/json", + "params": [], + "text": "{\"tests\":[{\"public_id\":\"jqf-wxg-5xc\"}]}" + }, + "queryString": [], + "url": "https://api.datadoghq.com/api/v1/synthetics/tests/trigger" + }, + "response": { + "bodySize": 278, + "content": { + "mimeType": "application/json", + "size": 278, + "text": "{\"batch_id\":null,\"results\":[{\"result_id\":\"7545278083435118828\",\"public_id\":\"jqf-wxg-5xc\",\"location\":30005}],\"triggered_check_ids\":[\"jqf-wxg-5xc\"],\"locations\":[{\"display_name\":\"Ohio (AWS)\",\"name\":\"aws:us-east-2\",\"region\":\"Americas\",\"is_active\":true,\"is_public\":true,\"id\":30005}]}" + }, + "cookies": [], + "headers": [ + { + "name": "date", + "value": "Fri, 12 Nov 2021 17:35:36 GMT" + }, + { + "name": "content-type", + "value": "application/json" + }, + { + "name": "content-length", + "value": "278" + }, + { + "name": "connection", + "value": "close" + }, + { + "name": "vary", + "value": "Accept-Encoding" + }, + { + "name": "pragma", + "value": "no-cache" + }, + { + "name": "cache-control", + "value": "no-cache" + }, + { + "name": "x-ratelimit-limit", + "value": "4" + }, + { + "name": "x-ratelimit-period", + "value": "300" + }, + { + "name": "x-ratelimit-reset", + "value": "264" + }, + { + "name": "x-ratelimit-remaining", + "value": "3" + }, + { + "name": "x-content-type-options", + "value": "nosniff" + }, + { + "name": "strict-transport-security", + "value": "max-age=15724800;" + }, + { + "name": "content-security-policy", + "value": "frame-ancestors 'self'; report-uri https://api.datadoghq.com/csp-report" + }, + { + "name": "x-frame-options", + "value": "SAMEORIGIN" + } + ], + "headersSize": 480, + "httpVersion": "HTTP/1.1", + "redirectURL": "", + "status": 200, + "statusText": "OK" + }, + "startedDateTime": "2021-11-12T17:35:36.059Z", + "time": 128, + "timings": { + "blocked": -1, + "connect": -1, + "dns": -1, + "receive": 0, + "send": 0, + "ssl": -1, + "wait": 128 + } + }, + { + "_id": "5c59f6c6fe311c0af25f3604f422b85d", + "_order": 0, + "cache": {}, + "request": { + "bodySize": 30, + "cookies": [], + "headers": [ + { + "_fromType": "array", + "name": "user-agent", + "value": "datadog-api-client-typescript/1.0.0-beta.6 (node 14.18.1; os Linux; arch x64)" + }, + { + "_fromType": "array", + "name": "accept", + "value": "application/json, */*;q=0.8" + }, + { + "_fromType": "array", + "name": "content-type", + "value": "application/json" + }, + { + "_fromType": "array", + "name": "x-datadog-parent-id", + "value": "8736598278305049725" + }, + { + "_fromType": "array", + "name": "x-datadog-trace-id", + "value": "2492155518930022279" + }, + { + "_fromType": "array", + "name": "content-length", + "value": "30" + }, + { + "_fromType": "array", + "name": "connection", + "value": "close" + }, + { + "name": "host", + "value": "api.datadoghq.com" + } + ], + "headersSize": 489, + "httpVersion": "HTTP/1.1", + "method": "POST", + "postData": { + "mimeType": "application/json", + "params": [], + "text": "{\"public_ids\":[\"jqf-wxg-5xc\"]}" + }, + "queryString": [], + "url": "https://api.datadoghq.com/api/v1/synthetics/tests/delete" + }, + "response": { + "bodySize": 95, + "content": { + "mimeType": "application/json", + "size": 95, + "text": "{\"deleted_tests\":[{\"deleted_at\":\"2021-11-12T17:35:36.412774+00:00\",\"public_id\":\"jqf-wxg-5xc\"}]}" + }, + "cookies": [], + "headers": [ + { + "name": "date", + "value": "Fri, 12 Nov 2021 17:35:36 GMT" + }, + { + "name": "content-type", + "value": "application/json" + }, + { + "name": "content-length", + "value": "95" + }, + { + "name": "connection", + "value": "close" + }, + { + "name": "pragma", + "value": "no-cache" + }, + { + "name": "cache-control", + "value": "no-cache" + }, + { + "name": "x-ratelimit-limit", + "value": "12000" + }, + { + "name": "x-ratelimit-period", + "value": "60" + }, + { + "name": "x-ratelimit-reset", + "value": "24" + }, + { + "name": "x-ratelimit-remaining", + "value": "11999" + }, + { + "name": "x-envoy-upstream-service-time", + "value": "287" + }, + { + "name": "vary", + "value": "Accept-Encoding" + }, + { + "name": "x-content-type-options", + "value": "nosniff" + }, + { + "name": "strict-transport-security", + "value": "max-age=15724800;" + }, + { + "name": "content-security-policy", + "value": "frame-ancestors 'self'; report-uri https://api.datadoghq.com/csp-report" + }, + { + "name": "x-frame-options", + "value": "SAMEORIGIN" + } + ], + "headersSize": 521, + "httpVersion": "HTTP/1.1", + "redirectURL": "", + "status": 200, + "statusText": "OK" + }, + "startedDateTime": "2021-11-12T17:35:36.194Z", + "time": 360, + "timings": { + "blocked": -1, + "connect": -1, + "dns": -1, + "receive": 0, + "send": 0, + "ssl": -1, + "wait": 360 + } + } + ], + "pages": [], + "version": "1.2" + } +} diff --git a/docs/v1/SyntheticsApi.md b/docs/v1/SyntheticsApi.md index 2634d1b7ca2..b74c52b86f6 100644 --- a/docs/v1/SyntheticsApi.md +++ b/docs/v1/SyntheticsApi.md @@ -26,6 +26,7 @@ All URIs are relative to *https://api.datadoghq.com* | [**listLocations**](SyntheticsApi.md#listLocations) | **GET** /api/v1/synthetics/locations | Get all locations (public and private) | | [**listTests**](SyntheticsApi.md#listTests) | **GET** /api/v1/synthetics/tests | Get the list of all tests | | [**triggerCITests**](SyntheticsApi.md#triggerCITests) | **POST** /api/v1/synthetics/tests/trigger/ci | Trigger tests from CI/CD pipelines | +| [**triggerTests**](SyntheticsApi.md#triggerTests) | **POST** /api/v1/synthetics/tests/trigger | Trigger some Synthetics tests | | [**updateAPITest**](SyntheticsApi.md#updateAPITest) | **PUT** /api/v1/synthetics/tests/api/{public_id} | Edit an API test | | [**updateBrowserTest**](SyntheticsApi.md#updateBrowserTest) | **PUT** /api/v1/synthetics/tests/browser/{public_id} | Edit a browser test | | [**updatePrivateLocation**](SyntheticsApi.md#updatePrivateLocation) | **PUT** /api/v1/synthetics/private-locations/{location_id} | Edit a private location | @@ -1656,6 +1657,84 @@ apiInstance [[Back to top]](#) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to Model list]](README.md#documentation-for-models) [[Back to README]](README.md) +## **triggerTests** + +> SyntheticsTriggerCITestsResponse triggerTests(body) + +Trigger a set of Synthetics tests. + +### Example + +```typescript +import { v1 } from "@datadog/datadog-api-client"; +import * as fs from "fs"; + +const configuration = v1.createConfiguration(); +const apiInstance = new v1.SyntheticsApi(configuration); + +let params: v1.SyntheticsApiTriggerTestsRequest = { + // SyntheticsTriggerBody | The identifiers of the tests to trigger. + body: { + tests: [ + { + metadata: { + ci: { + pipeline: { + url: "url_example", + }, + provider: { + name: "name_example", + }, + }, + git: { + branch: "branch_example", + commitSha: "commitSha_example", + }, + }, + publicId: "aaa-aaa-aaa", + }, + ], + }, +}; + +apiInstance + .triggerTests(params) + .then((data: any) => { + console.log( + "API called successfully. Returned data: " + JSON.stringify(data) + ); + }) + .catch((error: any) => console.error(error)); +``` + +### Parameters + +| Name | Type | Description | Notes | +| -------- | ------------------------- | ---------------------------------------- | ----- | +| **body** | **SyntheticsTriggerBody** | The identifiers of the tests to trigger. | + +### Return type + +**SyntheticsTriggerCITestsResponse** + +### Authorization + +[apiKeyAuth](README.md#apiKeyAuth), [appKeyAuth](README.md#appKeyAuth) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +### HTTP response details + +| Status code | Description | Response headers | +| ----------- | ----------- | ---------------- | +| **200** | OK | - | +| **400** | Bad Request | - | + +[[Back to top]](#) [[Back to API list]](README.md#documentation-for-api-endpoints) [[Back to Model list]](README.md#documentation-for-models) [[Back to README]](README.md) + ## **updateAPITest** > SyntheticsAPITest updateAPITest(body) diff --git a/features/v1/synthetics.feature b/features/v1/synthetics.feature index f8e513531dd..49b78012aa8 100644 --- a/features/v1/synthetics.feature +++ b/features/v1/synthetics.feature @@ -439,6 +439,20 @@ Feature: Synthetics When the request is sent Then the response status is 200 OK - Returns a boolean indicating if the update was successful. + @generated @skip + Scenario: Trigger some Synthetics tests returns "Bad Request" response + Given new "TriggerTests" request + And body with value {"tests": [{"metadata": {"ci": {"pipeline": {"url": null}, "provider": {"name": null}}, "git": {"branch": null, "commitSha": null}}, "public_id": "aaa-aaa-aaa"}]} + When the request is sent + Then the response status is 400 Bad Request + + Scenario: Trigger some Synthetics tests returns "OK" response + Given there is a valid "synthetics_api_test" in the system + And new "TriggerTests" request + And body with value {"tests": [{"public_id": "{{ synthetics_api_test.public_id }}"}]} + When the request is sent + Then the response status is 200 OK + @generated @skip Scenario: Trigger tests from CI/CD pipelines returns "JSON format is wrong" response Given new "TriggerCITests" request diff --git a/features/v1/undo.json b/features/v1/undo.json index 350be838950..df9febaedcb 100644 --- a/features/v1/undo.json +++ b/features/v1/undo.json @@ -1039,6 +1039,12 @@ "type": "idempotent" } }, + "TriggerTests": { + "tag": "Synthetics", + "undo": { + "type": "safe" + } + }, "TriggerCITests": { "tag": "Synthetics", "undo": { diff --git a/packages/datadog-api-client-v1/.openapi-generator/FILES b/packages/datadog-api-client-v1/.openapi-generator/FILES index 668737b743c..ca4bc63673d 100644 --- a/packages/datadog-api-client-v1/.openapi-generator/FILES +++ b/packages/datadog-api-client-v1/.openapi-generator/FILES @@ -540,9 +540,11 @@ models/SyntheticsTestRequest.ts models/SyntheticsTestRequestCertificate.ts models/SyntheticsTestRequestCertificateItem.ts models/SyntheticsTiming.ts +models/SyntheticsTriggerBody.ts models/SyntheticsTriggerCITestLocation.ts models/SyntheticsTriggerCITestRunResult.ts models/SyntheticsTriggerCITestsResponse.ts +models/SyntheticsTriggerTest.ts models/SyntheticsUpdateTestPauseStatusPayload.ts models/SyntheticsVariableParser.ts models/SyntheticsWarningType.ts diff --git a/packages/datadog-api-client-v1/apis/SyntheticsApi.ts b/packages/datadog-api-client-v1/apis/SyntheticsApi.ts index e015ccdaf6b..6a96ebc30a7 100644 --- a/packages/datadog-api-client-v1/apis/SyntheticsApi.ts +++ b/packages/datadog-api-client-v1/apis/SyntheticsApi.ts @@ -24,6 +24,7 @@ import { SyntheticsLocations } from "../models/SyntheticsLocations"; import { SyntheticsPrivateLocation } from "../models/SyntheticsPrivateLocation"; import { SyntheticsPrivateLocationCreationResponse } from "../models/SyntheticsPrivateLocationCreationResponse"; import { SyntheticsTestDetails } from "../models/SyntheticsTestDetails"; +import { SyntheticsTriggerBody } from "../models/SyntheticsTriggerBody"; import { SyntheticsTriggerCITestsResponse } from "../models/SyntheticsTriggerCITestsResponse"; import { SyntheticsUpdateTestPauseStatusPayload } from "../models/SyntheticsUpdateTestPauseStatusPayload"; @@ -1396,6 +1397,67 @@ export class SyntheticsApiRequestFactory extends BaseAPIRequestFactory { return requestContext; } + /** + * Trigger a set of Synthetics tests. + * Trigger some Synthetics tests + * @param body The identifiers of the tests to trigger. + */ + public async triggerTests( + body: SyntheticsTriggerBody, + _options?: Configuration + ): Promise { + const _config = _options || this.configuration; + + // verify required parameter 'body' is not null or undefined + if (body === null || body === undefined) { + throw new RequiredError( + "Required parameter body was null or undefined when calling triggerTests." + ); + } + + // Path Params + const localVarPath = "/api/v1/synthetics/tests/trigger"; + + // Make Request Context + const requestContext = getServer( + _config, + "SyntheticsApi.triggerTests" + ).makeRequestContext(localVarPath, HttpMethod.POST); + requestContext.setHeaderParam("Accept", "application/json, */*;q=0.8"); + requestContext.setHttpConfig(_config.httpConfig); + + // Query Params + + // Header Params + + // Form Params + + // Body Params + const contentType = ObjectSerializer.getPreferredMediaType([ + "application/json", + ]); + requestContext.setHeaderParam("Content-Type", contentType); + const serializedBody = ObjectSerializer.stringify( + ObjectSerializer.serialize(body, "SyntheticsTriggerBody", ""), + contentType + ); + requestContext.setBody(serializedBody); + + let authMethod = null; + // Apply auth methods + authMethod = _config.authMethods["apiKeyAuth"]; + if (authMethod) { + await authMethod.applySecurityAuthentication(requestContext); + } + // Apply auth methods + authMethod = _config.authMethods["appKeyAuth"]; + if (authMethod) { + await authMethod.applySecurityAuthentication(requestContext); + } + + return requestContext; + } + /** * Edit the configuration of a Synthetic API test. * Edit an API test @@ -2894,6 +2956,55 @@ export class SyntheticsApiResponseProcessor { ); } + /** + * Unwraps the actual response sent by the server from the response context and deserializes the response content + * to the expected objects + * + * @params response Response returned by the server for a request to triggerTests + * @throws ApiException if the response code was not in [200, 299] + */ + public async triggerTests( + response: ResponseContext + ): Promise { + const contentType = ObjectSerializer.normalizeMediaType( + response.headers["content-type"] + ); + if (isCodeInRange("200", response.httpStatusCode)) { + const body: SyntheticsTriggerCITestsResponse = + ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "SyntheticsTriggerCITestsResponse", + "" + ) as SyntheticsTriggerCITestsResponse; + return body; + } + if (isCodeInRange("400", response.httpStatusCode)) { + const body: APIErrorResponse = ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "APIErrorResponse", + "" + ) as APIErrorResponse; + throw new ApiException(400, body); + } + + // Work around for missing responses in specification, e.g. for petstore.yaml + if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) { + const body: SyntheticsTriggerCITestsResponse = + ObjectSerializer.deserialize( + ObjectSerializer.parse(await response.body.text(), contentType), + "SyntheticsTriggerCITestsResponse", + "" + ) as SyntheticsTriggerCITestsResponse; + return body; + } + + const body = (await response.body.text()) || ""; + throw new ApiException( + response.httpStatusCode, + 'Unknown API Status Code!\nBody: "' + body + '"' + ); + } + /** * Unwraps the actual response sent by the server from the response context and deserializes the response content * to the expected objects diff --git a/packages/datadog-api-client-v1/index.ts b/packages/datadog-api-client-v1/index.ts index 438ef21e71c..29964c6d66c 100644 --- a/packages/datadog-api-client-v1/index.ts +++ b/packages/datadog-api-client-v1/index.ts @@ -164,6 +164,7 @@ export { SyntheticsApiGetSyntheticsCIBatchRequest, SyntheticsApiGetTestRequest, SyntheticsApiTriggerCITestsRequest, + SyntheticsApiTriggerTestsRequest, SyntheticsApiUpdateAPITestRequest, SyntheticsApiUpdateBrowserTestRequest, SyntheticsApiUpdatePrivateLocationRequest, diff --git a/packages/datadog-api-client-v1/models/ObjectSerializer.ts b/packages/datadog-api-client-v1/models/ObjectSerializer.ts index b60438e628f..700d5ee9258 100644 --- a/packages/datadog-api-client-v1/models/ObjectSerializer.ts +++ b/packages/datadog-api-client-v1/models/ObjectSerializer.ts @@ -352,9 +352,11 @@ import { SyntheticsTestRequest } from "./SyntheticsTestRequest"; import { SyntheticsTestRequestCertificate } from "./SyntheticsTestRequestCertificate"; import { SyntheticsTestRequestCertificateItem } from "./SyntheticsTestRequestCertificateItem"; import { SyntheticsTiming } from "./SyntheticsTiming"; +import { SyntheticsTriggerBody } from "./SyntheticsTriggerBody"; import { SyntheticsTriggerCITestLocation } from "./SyntheticsTriggerCITestLocation"; import { SyntheticsTriggerCITestRunResult } from "./SyntheticsTriggerCITestRunResult"; import { SyntheticsTriggerCITestsResponse } from "./SyntheticsTriggerCITestsResponse"; +import { SyntheticsTriggerTest } from "./SyntheticsTriggerTest"; import { SyntheticsUpdateTestPauseStatusPayload } from "./SyntheticsUpdateTestPauseStatusPayload"; import { SyntheticsVariableParser } from "./SyntheticsVariableParser"; import { TableWidgetDefinition } from "./TableWidgetDefinition"; @@ -1367,9 +1369,11 @@ const typeMap: { [index: string]: any } = { SyntheticsTestRequestCertificate: SyntheticsTestRequestCertificate, SyntheticsTestRequestCertificateItem: SyntheticsTestRequestCertificateItem, SyntheticsTiming: SyntheticsTiming, + SyntheticsTriggerBody: SyntheticsTriggerBody, SyntheticsTriggerCITestLocation: SyntheticsTriggerCITestLocation, SyntheticsTriggerCITestRunResult: SyntheticsTriggerCITestRunResult, SyntheticsTriggerCITestsResponse: SyntheticsTriggerCITestsResponse, + SyntheticsTriggerTest: SyntheticsTriggerTest, SyntheticsUpdateTestPauseStatusPayload: SyntheticsUpdateTestPauseStatusPayload, SyntheticsVariableParser: SyntheticsVariableParser, diff --git a/packages/datadog-api-client-v1/models/SyntheticsTriggerBody.ts b/packages/datadog-api-client-v1/models/SyntheticsTriggerBody.ts new file mode 100644 index 00000000000..740f8260c2b --- /dev/null +++ b/packages/datadog-api-client-v1/models/SyntheticsTriggerBody.ts @@ -0,0 +1,41 @@ +/** + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2020-Present Datadog, Inc. + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { SyntheticsTriggerTest } from "./SyntheticsTriggerTest"; + +export class SyntheticsTriggerBody { + /** + * Individual synthetics test. + */ + "tests": Array; + + "unparsedObject"?: any; + + static readonly attributeTypeMap: { + [key: string]: { + baseName: string; + type: string; + required?: boolean; + format?: string; + }; + } = { + tests: { + baseName: "tests", + type: "Array", + required: true, + }, + }; + + static getAttributeTypeMap() { + return SyntheticsTriggerBody.attributeTypeMap; + } + + public constructor() {} +} diff --git a/packages/datadog-api-client-v1/models/SyntheticsTriggerTest.ts b/packages/datadog-api-client-v1/models/SyntheticsTriggerTest.ts new file mode 100644 index 00000000000..4e8acfa920c --- /dev/null +++ b/packages/datadog-api-client-v1/models/SyntheticsTriggerTest.ts @@ -0,0 +1,46 @@ +/** + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + * This product includes software developed at Datadog (https://www.datadoghq.com/). + * Copyright 2020-Present Datadog, Inc. + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +import { SyntheticsCIBatchMetadata } from "./SyntheticsCIBatchMetadata"; + +export class SyntheticsTriggerTest { + "metadata"?: SyntheticsCIBatchMetadata; + /** + * The public ID of the Synthetics test to trigger. + */ + "publicId": string; + + "unparsedObject"?: any; + + static readonly attributeTypeMap: { + [key: string]: { + baseName: string; + type: string; + required?: boolean; + format?: string; + }; + } = { + metadata: { + baseName: "metadata", + type: "SyntheticsCIBatchMetadata", + }, + publicId: { + baseName: "public_id", + type: "string", + required: true, + }, + }; + + static getAttributeTypeMap() { + return SyntheticsTriggerTest.attributeTypeMap; + } + + public constructor() {} +} diff --git a/packages/datadog-api-client-v1/types/ObjectParamAPI.ts b/packages/datadog-api-client-v1/types/ObjectParamAPI.ts index 9f0c57f6448..652178f1498 100644 --- a/packages/datadog-api-client-v1/types/ObjectParamAPI.ts +++ b/packages/datadog-api-client-v1/types/ObjectParamAPI.ts @@ -113,6 +113,7 @@ import { SyntheticsLocations } from "../models/SyntheticsLocations"; import { SyntheticsPrivateLocation } from "../models/SyntheticsPrivateLocation"; import { SyntheticsPrivateLocationCreationResponse } from "../models/SyntheticsPrivateLocationCreationResponse"; import { SyntheticsTestDetails } from "../models/SyntheticsTestDetails"; +import { SyntheticsTriggerBody } from "../models/SyntheticsTriggerBody"; import { SyntheticsTriggerCITestsResponse } from "../models/SyntheticsTriggerCITestsResponse"; import { SyntheticsUpdateTestPauseStatusPayload } from "../models/SyntheticsUpdateTestPauseStatusPayload"; import { TagToHosts } from "../models/TagToHosts"; @@ -4136,6 +4137,15 @@ export interface SyntheticsApiTriggerCITestsRequest { body: SyntheticsCITestBody; } +export interface SyntheticsApiTriggerTestsRequest { + /** + * The identifiers of the tests to trigger. + * @type SyntheticsTriggerBody + * @memberof SyntheticsApitriggerTests + */ + body: SyntheticsTriggerBody; +} + export interface SyntheticsApiUpdateAPITestRequest { /** * The public ID of the test to get details from. @@ -4496,6 +4506,18 @@ export class ObjectSyntheticsApi { return this.api.triggerCITests(param.body, options).toPromise(); } + /** + * Trigger a set of Synthetics tests. + * Trigger some Synthetics tests + * @param param the request object + */ + public triggerTests( + param: SyntheticsApiTriggerTestsRequest, + options?: Configuration + ): Promise { + return this.api.triggerTests(param.body, options).toPromise(); + } + /** * Edit the configuration of a Synthetic API test. * Edit an API test diff --git a/packages/datadog-api-client-v1/types/ObservableAPI.ts b/packages/datadog-api-client-v1/types/ObservableAPI.ts index fdf4817d370..56137315cb8 100644 --- a/packages/datadog-api-client-v1/types/ObservableAPI.ts +++ b/packages/datadog-api-client-v1/types/ObservableAPI.ts @@ -114,6 +114,7 @@ import { SyntheticsLocations } from "../models/SyntheticsLocations"; import { SyntheticsPrivateLocation } from "../models/SyntheticsPrivateLocation"; import { SyntheticsPrivateLocationCreationResponse } from "../models/SyntheticsPrivateLocationCreationResponse"; import { SyntheticsTestDetails } from "../models/SyntheticsTestDetails"; +import { SyntheticsTriggerBody } from "../models/SyntheticsTriggerBody"; import { SyntheticsTriggerCITestsResponse } from "../models/SyntheticsTriggerCITestsResponse"; import { SyntheticsUpdateTestPauseStatusPayload } from "../models/SyntheticsUpdateTestPauseStatusPayload"; import { TagToHosts } from "../models/TagToHosts"; @@ -7172,6 +7173,48 @@ export class ObservableSyntheticsApi { }) ); } + /** + * Trigger a set of Synthetics tests. + * Trigger some Synthetics tests + * @param body The identifiers of the tests to trigger. + */ + public triggerTests( + body: SyntheticsTriggerBody, + _options?: Configuration + ): Observable { + const requestContextPromise = this.requestFactory.triggerTests( + body, + _options + ); + + // build promise chain + let middlewarePreObservable = from_(requestContextPromise); + for (const middleware of this.configuration.middleware) { + middlewarePreObservable = middlewarePreObservable.pipe( + mergeMap((ctx: RequestContext) => middleware.pre(ctx)) + ); + } + + return middlewarePreObservable + .pipe( + mergeMap((ctx: RequestContext) => this.configuration.httpApi.send(ctx)) + ) + .pipe( + mergeMap((response: ResponseContext) => { + let middlewarePostObservable = of(response); + for (const middleware of this.configuration.middleware) { + middlewarePostObservable = middlewarePostObservable.pipe( + mergeMap((rsp: ResponseContext) => middleware.post(rsp)) + ); + } + return middlewarePostObservable.pipe( + map((rsp: ResponseContext) => + this.responseProcessor.triggerTests(rsp) + ) + ); + }) + ); + } /** * Edit the configuration of a Synthetic API test. * Edit an API test diff --git a/packages/datadog-api-client-v1/types/PromiseAPI.ts b/packages/datadog-api-client-v1/types/PromiseAPI.ts index cbb7dff40fd..506eef6f723 100644 --- a/packages/datadog-api-client-v1/types/PromiseAPI.ts +++ b/packages/datadog-api-client-v1/types/PromiseAPI.ts @@ -113,6 +113,7 @@ import { SyntheticsLocations } from "../models/SyntheticsLocations"; import { SyntheticsPrivateLocation } from "../models/SyntheticsPrivateLocation"; import { SyntheticsPrivateLocationCreationResponse } from "../models/SyntheticsPrivateLocationCreationResponse"; import { SyntheticsTestDetails } from "../models/SyntheticsTestDetails"; +import { SyntheticsTriggerBody } from "../models/SyntheticsTriggerBody"; import { SyntheticsTriggerCITestsResponse } from "../models/SyntheticsTriggerCITestsResponse"; import { SyntheticsUpdateTestPauseStatusPayload } from "../models/SyntheticsUpdateTestPauseStatusPayload"; import { TagToHosts } from "../models/TagToHosts"; @@ -2943,6 +2944,19 @@ export class PromiseSyntheticsApi { return result.toPromise(); } + /** + * Trigger a set of Synthetics tests. + * Trigger some Synthetics tests + * @param body The identifiers of the tests to trigger. + */ + public triggerTests( + body: SyntheticsTriggerBody, + _options?: Configuration + ): Promise { + const result = this.api.triggerTests(body, _options); + return result.toPromise(); + } + /** * Edit the configuration of a Synthetic API test. * Edit an API test