Skip to content

Commit 03407f6

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add endpoint to get Synthetics default locations (#1182)
Co-authored-by: ci.datadog-api-spec <[email protected]>
1 parent b101f76 commit 03407f6

File tree

10 files changed

+250
-4
lines changed

10 files changed

+250
-4
lines changed

.apigentools-info

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
"spec_versions": {
55
"v1": {
66
"apigentools_version": "1.6.4",
7-
"regenerated": "2023-06-09 14:55:30.884395",
8-
"spec_repo_commit": "b6c7aa0b"
7+
"regenerated": "2023-06-12 13:40:04.293838",
8+
"spec_repo_commit": "2c47742f"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.4",
12-
"regenerated": "2023-06-09 14:55:30.900828",
13-
"spec_repo_commit": "b6c7aa0b"
12+
"regenerated": "2023-06-12 13:40:04.312292",
13+
"spec_repo_commit": "2c47742f"
1414
}
1515
}
1616
}

.generator/schemas/v1/openapi.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13436,6 +13436,14 @@ components:
1343613436
description: URL attached to the metrics.
1343713437
type: string
1343813438
type: object
13439+
SyntheticsDefaultLocations:
13440+
description: List of Synthetics default locations settings.
13441+
example:
13442+
- aws:eu-west-3
13443+
items:
13444+
description: Name of the location.
13445+
type: string
13446+
type: array
1343913447
SyntheticsDeleteTestsPayload:
1344013448
description: 'A JSON list of the ID or IDs of the Synthetic tests that you want
1344113449

@@ -27640,6 +27648,27 @@ paths:
2764027648
tags:
2764127649
- Synthetics
2764227650
x-codegen-request-body-name: body
27651+
/api/v1/synthetics/settings/default_locations:
27652+
get:
27653+
description: Get the default locations settings.
27654+
operationId: GetSyntheticsDefaultLocations
27655+
responses:
27656+
'200':
27657+
content:
27658+
application/json:
27659+
schema:
27660+
$ref: '#/components/schemas/SyntheticsDefaultLocations'
27661+
description: OK
27662+
'429':
27663+
$ref: '#/components/responses/TooManyRequestsResponse'
27664+
security:
27665+
- apiKeyAuth: []
27666+
appKeyAuth: []
27667+
- AuthZ:
27668+
- synthetics_default_settings_read
27669+
summary: Get the default locations
27670+
tags:
27671+
- Synthetics
2764327672
/api/v1/synthetics/tests:
2764427673
get:
2764527674
description: Get the list of all Synthetic tests.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"2023-06-08T19:13:18.175Z"
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
{
2+
"log": {
3+
"_recordingName": "Synthetics/Get the list of default locations returns \"OK\" response",
4+
"creator": {
5+
"comment": "persister:fs",
6+
"name": "Polly.JS",
7+
"version": "6.0.5"
8+
},
9+
"entries": [
10+
{
11+
"_id": "b9dc107e62814944ce79b8f4922edb4b",
12+
"_order": 0,
13+
"cache": {},
14+
"request": {
15+
"bodySize": 0,
16+
"cookies": [],
17+
"headers": [
18+
{
19+
"_fromType": "array",
20+
"name": "accept",
21+
"value": "application/json"
22+
}
23+
],
24+
"headersSize": 546,
25+
"httpVersion": "HTTP/1.1",
26+
"method": "GET",
27+
"queryString": [],
28+
"url": "https://api.datadoghq.com/api/v1/synthetics/settings/default_locations"
29+
},
30+
"response": {
31+
"bodySize": 469,
32+
"content": {
33+
"mimeType": "application/json",
34+
"size": 469,
35+
"text": "[\"aws:af-south-1\",\"aws:ap-east-1\",\"aws:ap-northeast-1\",\"aws:ap-northeast-2\",\"aws:ap-northeast-3\",\"aws:ap-south-1\",\"aws:ap-southeast-1\",\"aws:ap-southeast-2\",\"aws:ap-southeast-3\",\"aws:ca-central-1\",\"aws:eu-central-1\",\"aws:eu-north-1\",\"aws:eu-south-1\",\"aws:eu-west-1\",\"aws:eu-west-2\",\"aws:eu-west-3\",\"aws:me-south-1\",\"aws:sa-east-1\",\"aws:us-east-1\",\"aws:us-east-2\",\"aws:us-west-1\",\"aws:us-west-2\",\"azure:eastus\",\"pl:gcp-integrations-lab-527d63de5764c9fdad65fd1a5ac64a8e\"]\n"
36+
},
37+
"cookies": [],
38+
"headers": [
39+
{
40+
"name": "content-type",
41+
"value": "application/json"
42+
}
43+
],
44+
"headersSize": 672,
45+
"httpVersion": "HTTP/1.1",
46+
"redirectURL": "",
47+
"status": 200,
48+
"statusText": "OK"
49+
},
50+
"startedDateTime": "2023-06-08T19:13:18.191Z",
51+
"time": 271
52+
}
53+
],
54+
"pages": [],
55+
"version": "1.2"
56+
}
57+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
* Get the default locations returns "OK" response
3+
*/
4+
5+
import { client, v1 } from "@datadog/datadog-api-client";
6+
7+
const configuration = client.createConfiguration();
8+
const apiInstance = new v1.SyntheticsApi(configuration);
9+
10+
apiInstance
11+
.getSyntheticsDefaultLocations()
12+
.then((data: string[]) => {
13+
console.log(
14+
"API called successfully. Returned data: " + JSON.stringify(data)
15+
);
16+
})
17+
.catch((error: any) => console.error(error));
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
* Get the list of default locations returns "OK" response
3+
*/
4+
5+
import { client, v1 } from "@datadog/datadog-api-client";
6+
7+
const configuration = client.createConfiguration();
8+
const apiInstance = new v1.SyntheticsApi(configuration);
9+
10+
apiInstance
11+
.getSyntheticsDefaultLocations()
12+
.then((data: string[]) => {
13+
console.log(
14+
"API called successfully. Returned data: " + JSON.stringify(data)
15+
);
16+
})
17+
.catch((error: any) => console.error(error));

features/support/scenarios_model_mapping.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1970,6 +1970,9 @@ export const ScenariosModelMappings: {[key: string]: {[key: string]: any}} = {
19701970
},
19711971
"operationResponseType": "SyntheticsPrivateLocation",
19721972
},
1973+
"v1.GetSyntheticsDefaultLocations": {
1974+
"operationResponseType": "Array<string>",
1975+
},
19731976
"v1.ListTests": {
19741977
"pageSize": {
19751978
"type": "string",

features/v1/synthetics.feature

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,12 @@ Feature: Synthetics
522522
When the request is sent
523523
Then the response status is 200 OK
524524

525+
@generated @skip @team:DataDog/synthetics-app
526+
Scenario: Get the default locations returns "OK" response
527+
Given new "GetSyntheticsDefaultLocations" request
528+
When the request is sent
529+
Then the response status is 200 OK
530+
525531
@generated @skip @team:DataDog/synthetics-app
526532
Scenario: Get the list of all Synthetic tests returns "OK - Returns the list of all Synthetic tests." response
527533
Given new "ListTests" request
@@ -534,6 +540,12 @@ Feature: Synthetics
534540
When the request is sent
535541
Then the response status is 404 Synthetic Monitoring is not activated for the user.
536542

543+
@team:DataDog/synthetics-app
544+
Scenario: Get the list of default locations returns "OK" response
545+
Given new "GetSyntheticsDefaultLocations" request
546+
When the request is sent
547+
Then the response status is 200 OK
548+
537549
@generated @skip @team:DataDog/synthetics-app
538550
Scenario: Pause or start a test returns "- Synthetic Monitoring is not activated for the user" response
539551
Given new "UpdateTestPauseStatus" request

features/v1/undo.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1078,6 +1078,12 @@
10781078
"type": "idempotent"
10791079
}
10801080
},
1081+
"GetSyntheticsDefaultLocations": {
1082+
"tag": "Synthetics",
1083+
"undo": {
1084+
"type": "safe"
1085+
}
1086+
},
10811087
"ListTests": {
10821088
"tag": "Synthetics",
10831089
"undo": {

packages/datadog-api-client-v1/apis/SyntheticsApi.ts

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -753,6 +753,32 @@ export class SyntheticsApiRequestFactory extends BaseAPIRequestFactory {
753753
return requestContext;
754754
}
755755

756+
public async getSyntheticsDefaultLocations(
757+
_options?: Configuration
758+
): Promise<RequestContext> {
759+
const _config = _options || this.configuration;
760+
761+
// Path Params
762+
const localVarPath = "/api/v1/synthetics/settings/default_locations";
763+
764+
// Make Request Context
765+
const requestContext = getServer(
766+
_config,
767+
"v1.SyntheticsApi.getSyntheticsDefaultLocations"
768+
).makeRequestContext(localVarPath, HttpMethod.GET);
769+
requestContext.setHeaderParam("Accept", "application/json");
770+
requestContext.setHttpConfig(_config.httpConfig);
771+
772+
// Apply auth methods
773+
applySecurityAuthentication(_config, requestContext, [
774+
"AuthZ",
775+
"apiKeyAuth",
776+
"appKeyAuth",
777+
]);
778+
779+
return requestContext;
780+
}
781+
756782
public async getTest(
757783
publicId: string,
758784
_options?: Configuration
@@ -2225,6 +2251,64 @@ export class SyntheticsApiResponseProcessor {
22252251
);
22262252
}
22272253

2254+
/**
2255+
* Unwraps the actual response sent by the server from the response context and deserializes the response content
2256+
* to the expected objects
2257+
*
2258+
* @params response Response returned by the server for a request to getSyntheticsDefaultLocations
2259+
* @throws ApiException if the response code was not in [200, 299]
2260+
*/
2261+
public async getSyntheticsDefaultLocations(
2262+
response: ResponseContext
2263+
): Promise<Array<string>> {
2264+
const contentType = ObjectSerializer.normalizeMediaType(
2265+
response.headers["content-type"]
2266+
);
2267+
if (response.httpStatusCode == 200) {
2268+
const body: Array<string> = ObjectSerializer.deserialize(
2269+
ObjectSerializer.parse(await response.body.text(), contentType),
2270+
"Array<string>"
2271+
) as Array<string>;
2272+
return body;
2273+
}
2274+
if (response.httpStatusCode == 429) {
2275+
const bodyText = ObjectSerializer.parse(
2276+
await response.body.text(),
2277+
contentType
2278+
);
2279+
let body: APIErrorResponse;
2280+
try {
2281+
body = ObjectSerializer.deserialize(
2282+
bodyText,
2283+
"APIErrorResponse"
2284+
) as APIErrorResponse;
2285+
} catch (error) {
2286+
logger.info(`Got error deserializing error: ${error}`);
2287+
throw new ApiException<APIErrorResponse>(
2288+
response.httpStatusCode,
2289+
bodyText
2290+
);
2291+
}
2292+
throw new ApiException<APIErrorResponse>(response.httpStatusCode, body);
2293+
}
2294+
2295+
// Work around for missing responses in specification, e.g. for petstore.yaml
2296+
if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
2297+
const body: Array<string> = ObjectSerializer.deserialize(
2298+
ObjectSerializer.parse(await response.body.text(), contentType),
2299+
"Array<string>",
2300+
""
2301+
) as Array<string>;
2302+
return body;
2303+
}
2304+
2305+
const body = (await response.body.text()) || "";
2306+
throw new ApiException<string>(
2307+
response.httpStatusCode,
2308+
'Unknown API Status Code!\nBody: "' + body + '"'
2309+
);
2310+
}
2311+
22282312
/**
22292313
* Unwraps the actual response sent by the server from the response context and deserializes the response content
22302314
* to the expected objects
@@ -3499,6 +3583,26 @@ export class SyntheticsApi {
34993583
});
35003584
}
35013585

3586+
/**
3587+
* Get the default locations settings.
3588+
* @param param The request object
3589+
*/
3590+
public getSyntheticsDefaultLocations(
3591+
options?: Configuration
3592+
): Promise<Array<string>> {
3593+
const requestContextPromise =
3594+
this.requestFactory.getSyntheticsDefaultLocations(options);
3595+
return requestContextPromise.then((requestContext) => {
3596+
return this.configuration.httpApi
3597+
.send(requestContext)
3598+
.then((responseContext) => {
3599+
return this.responseProcessor.getSyntheticsDefaultLocations(
3600+
responseContext
3601+
);
3602+
});
3603+
});
3604+
}
3605+
35023606
/**
35033607
* Get the detailed configuration associated with a Synthetic test.
35043608
* @param param The request object

0 commit comments

Comments
 (0)