Skip to content

Commit 2aff22c

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add GET /api/v2/apm/services endpoint to public documentation (#3099)
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
1 parent d30d4bd commit 2aff22c

File tree

16 files changed

+483
-31
lines changed

16 files changed

+483
-31
lines changed

.generator/schemas/v2/openapi.yaml

Lines changed: 66 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51360,6 +51360,49 @@ components:
5136051360
$ref: '#/components/schemas/ServiceDefinitionData'
5136151361
type: array
5136251362
type: object
51363+
ServiceList:
51364+
properties:
51365+
data:
51366+
$ref: '#/components/schemas/ServiceListData'
51367+
type: object
51368+
ServiceListData:
51369+
properties:
51370+
attributes:
51371+
$ref: '#/components/schemas/ServiceListDataAttributes'
51372+
id:
51373+
type: string
51374+
type:
51375+
$ref: '#/components/schemas/ServiceListDataType'
51376+
required:
51377+
- type
51378+
type: object
51379+
ServiceListDataAttributes:
51380+
properties:
51381+
metadata:
51382+
items:
51383+
$ref: '#/components/schemas/ServiceListDataAttributesMetadataItems'
51384+
type: array
51385+
services:
51386+
items:
51387+
type: string
51388+
type: array
51389+
type: object
51390+
ServiceListDataAttributesMetadataItems:
51391+
properties:
51392+
isTraced:
51393+
type: boolean
51394+
isUsm:
51395+
type: boolean
51396+
type: object
51397+
ServiceListDataType:
51398+
default: services_list
51399+
description: Services list resource type.
51400+
enum:
51401+
- services_list
51402+
example: services_list
51403+
type: string
51404+
x-enum-varnames:
51405+
- SERVICES_LIST
5136351406
ServiceNowBasicAuth:
5136451407
description: The definition of the `ServiceNowBasicAuth` object.
5136551408
properties:
@@ -61622,6 +61665,26 @@ paths:
6162261665
permissions:
6162361666
- apm_retention_filter_write
6162461667
- apm_pipelines_write
61668+
/api/v2/apm/services:
61669+
get:
61670+
operationId: GetServiceList
61671+
responses:
61672+
'200':
61673+
content:
61674+
application/json:
61675+
schema:
61676+
$ref: '#/components/schemas/ServiceList'
61677+
description: OK
61678+
'429':
61679+
$ref: '#/components/responses/TooManyRequestsResponse'
61680+
security:
61681+
- apiKeyAuth: []
61682+
appKeyAuth: []
61683+
- AuthZ:
61684+
- apm_read
61685+
summary: Get service list
61686+
tags:
61687+
- APM
6162561688
/api/v2/app-builder/apps:
6162661689
delete:
6162761690
description: Delete multiple apps in a single request from a list of app IDs.
@@ -69355,9 +69418,6 @@ paths:
6935569418
operator: OR
6935669419
permissions:
6935769420
- incident_read
69358-
x-unstable: '**Note**: This endpoint is in Preview.
69359-
69360-
If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).'
6936169421
post:
6936269422
description: Create an impact for an incident.
6936369423
operationId: CreateIncidentImpact
@@ -69401,9 +69461,6 @@ paths:
6940169461
operator: OR
6940269462
permissions:
6940369463
- incident_write
69404-
x-unstable: '**Note**: This endpoint is in Preview.
69405-
69406-
If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).'
6940769464
/api/v2/incidents/{incident_id}/impacts/{impact_id}:
6940869465
delete:
6940969466
description: Delete an incident impact.
@@ -69434,9 +69491,6 @@ paths:
6943469491
operator: OR
6943569492
permissions:
6943669493
- incident_write
69437-
x-unstable: '**Note**: This endpoint is in Preview.
69438-
69439-
If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).'
6944069494
/api/v2/incidents/{incident_id}/relationships/integrations:
6944169495
get:
6944269496
description: Get all integration metadata for an incident.
@@ -88607,6 +88661,9 @@ servers:
8860788661
tags:
8860888662
- description: Configure your API endpoints through the Datadog API.
8860988663
name: API Management
88664+
- description: Observe, troubleshoot, and improve cloud-scale applications with all
88665+
telemetry in context
88666+
name: APM
8861088667
- description: Manage configuration of [APM retention filters](https://app.datadoghq.com/apm/traces/retention-filters)
8861188668
for your organization. You need an API and application key with Admin rights to
8861288669
interact with this endpoint. See [retention filters](https://docs.datadoghq.com/tracing/trace_pipeline/trace_retention/#retention-filters)

examples/v2/apm/GetServiceList.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
* Get service list returns "OK" response
3+
*/
4+
5+
import { client, v2 } from "@datadog/datadog-api-client";
6+
7+
const configuration = client.createConfiguration();
8+
const apiInstance = new v2.APMApi(configuration);
9+
10+
apiInstance
11+
.getServiceList()
12+
.then((data: v2.ServiceList) => {
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
@@ -3092,6 +3092,9 @@ export const ScenariosModelMappings: {[key: string]: {[key: string]: any}} = {
30923092
},
30933093
"operationResponseType": "{}",
30943094
},
3095+
"v2.GetServiceList": {
3096+
"operationResponseType": "ServiceList",
3097+
},
30953098
"v2.ListApps": {
30963099
"limit": {
30973100
"type": "number",

features/v2/apm.feature

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
@endpoint(apm) @endpoint(apm-v2)
2+
Feature: APM
3+
Observe, troubleshoot, and improve cloud-scale applications with all
4+
telemetry in context
5+
6+
@generated @skip @team:DataDog/apm-aoe
7+
Scenario: Get service list returns "OK" response
8+
Given a valid "apiKeyAuth" key in the system
9+
And a valid "appKeyAuth" key in the system
10+
And an instance of "APM" API
11+
And new "GetServiceList" request
12+
When the request is sent
13+
Then the response status is 200 OK

features/v2/incidents.feature

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -806,16 +806,14 @@ Feature: Incidents
806806

807807
@generated @skip @team:DataDog/incident-app
808808
Scenario: List an incident's impacts returns "Bad Request" response
809-
Given operation "ListIncidentImpacts" enabled
810-
And new "ListIncidentImpacts" request
809+
Given new "ListIncidentImpacts" request
811810
And request contains "incident_id" parameter from "REPLACE.ME"
812811
When the request is sent
813812
Then the response status is 400 Bad Request
814813

815814
@generated @skip @team:DataDog/incident-app
816815
Scenario: List an incident's impacts returns "Not Found" response
817-
Given operation "ListIncidentImpacts" enabled
818-
And new "ListIncidentImpacts" request
816+
Given new "ListIncidentImpacts" request
819817
And request contains "incident_id" parameter from "REPLACE.ME"
820818
When the request is sent
821819
Then the response status is 404 Not Found

features/v2/undo.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,12 @@
516516
"type": "idempotent"
517517
}
518518
},
519+
"GetServiceList": {
520+
"tag": "APM",
521+
"undo": {
522+
"type": "safe"
523+
}
524+
},
519525
"DeleteApps": {
520526
"tag": "App Builder",
521527
"undo": {

packages/datadog-api-client-common/configuration.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -282,14 +282,12 @@ export function createConfiguration(
282282
"v2.updateDeploymentGate": false,
283283
"v2.updateDeploymentRule": false,
284284
"v2.createIncident": false,
285-
"v2.createIncidentImpact": false,
286285
"v2.createIncidentIntegration": false,
287286
"v2.createIncidentNotificationRule": false,
288287
"v2.createIncidentNotificationTemplate": false,
289288
"v2.createIncidentTodo": false,
290289
"v2.createIncidentType": false,
291290
"v2.deleteIncident": false,
292-
"v2.deleteIncidentImpact": false,
293291
"v2.deleteIncidentIntegration": false,
294292
"v2.deleteIncidentNotificationRule": false,
295293
"v2.deleteIncidentNotificationTemplate": false,
@@ -302,7 +300,6 @@ export function createConfiguration(
302300
"v2.getIncidentTodo": false,
303301
"v2.getIncidentType": false,
304302
"v2.listIncidentAttachments": false,
305-
"v2.listIncidentImpacts": false,
306303
"v2.listIncidentIntegrations": false,
307304
"v2.listIncidentNotificationRules": false,
308305
"v2.listIncidentNotificationTemplates": false,
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
import { BaseAPIRequestFactory } from "../../datadog-api-client-common/baseapi";
2+
import {
3+
Configuration,
4+
applySecurityAuthentication,
5+
} from "../../datadog-api-client-common/configuration";
6+
import {
7+
RequestContext,
8+
HttpMethod,
9+
ResponseContext,
10+
} from "../../datadog-api-client-common/http/http";
11+
12+
import { logger } from "../../../logger";
13+
import { ObjectSerializer } from "../models/ObjectSerializer";
14+
import { ApiException } from "../../datadog-api-client-common/exception";
15+
16+
import { APIErrorResponse } from "../models/APIErrorResponse";
17+
import { ServiceList } from "../models/ServiceList";
18+
19+
export class APMApiRequestFactory extends BaseAPIRequestFactory {
20+
public async getServiceList(
21+
_options?: Configuration
22+
): Promise<RequestContext> {
23+
const _config = _options || this.configuration;
24+
25+
// Path Params
26+
const localVarPath = "/api/v2/apm/services";
27+
28+
// Make Request Context
29+
const requestContext = _config
30+
.getServer("v2.APMApi.getServiceList")
31+
.makeRequestContext(localVarPath, HttpMethod.GET);
32+
requestContext.setHeaderParam("Accept", "application/json");
33+
requestContext.setHttpConfig(_config.httpConfig);
34+
35+
// Apply auth methods
36+
applySecurityAuthentication(_config, requestContext, [
37+
"apiKeyAuth",
38+
"appKeyAuth",
39+
"AuthZ",
40+
]);
41+
42+
return requestContext;
43+
}
44+
}
45+
46+
export class APMApiResponseProcessor {
47+
/**
48+
* Unwraps the actual response sent by the server from the response context and deserializes the response content
49+
* to the expected objects
50+
*
51+
* @params response Response returned by the server for a request to getServiceList
52+
* @throws ApiException if the response code was not in [200, 299]
53+
*/
54+
public async getServiceList(response: ResponseContext): Promise<ServiceList> {
55+
const contentType = ObjectSerializer.normalizeMediaType(
56+
response.headers["content-type"]
57+
);
58+
if (response.httpStatusCode === 200) {
59+
const body: ServiceList = ObjectSerializer.deserialize(
60+
ObjectSerializer.parse(await response.body.text(), contentType),
61+
"ServiceList"
62+
) as ServiceList;
63+
return body;
64+
}
65+
if (response.httpStatusCode === 429) {
66+
const bodyText = ObjectSerializer.parse(
67+
await response.body.text(),
68+
contentType
69+
);
70+
let body: APIErrorResponse;
71+
try {
72+
body = ObjectSerializer.deserialize(
73+
bodyText,
74+
"APIErrorResponse"
75+
) as APIErrorResponse;
76+
} catch (error) {
77+
logger.debug(`Got error deserializing error: ${error}`);
78+
throw new ApiException<APIErrorResponse>(
79+
response.httpStatusCode,
80+
bodyText
81+
);
82+
}
83+
throw new ApiException<APIErrorResponse>(response.httpStatusCode, body);
84+
}
85+
86+
// Work around for missing responses in specification, e.g. for petstore.yaml
87+
if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
88+
const body: ServiceList = ObjectSerializer.deserialize(
89+
ObjectSerializer.parse(await response.body.text(), contentType),
90+
"ServiceList",
91+
""
92+
) as ServiceList;
93+
return body;
94+
}
95+
96+
const body = (await response.body.text()) || "";
97+
throw new ApiException<string>(
98+
response.httpStatusCode,
99+
'Unknown API Status Code!\nBody: "' + body + '"'
100+
);
101+
}
102+
}
103+
104+
export class APMApi {
105+
private requestFactory: APMApiRequestFactory;
106+
private responseProcessor: APMApiResponseProcessor;
107+
private configuration: Configuration;
108+
109+
public constructor(
110+
configuration: Configuration,
111+
requestFactory?: APMApiRequestFactory,
112+
responseProcessor?: APMApiResponseProcessor
113+
) {
114+
this.configuration = configuration;
115+
this.requestFactory =
116+
requestFactory || new APMApiRequestFactory(configuration);
117+
this.responseProcessor = responseProcessor || new APMApiResponseProcessor();
118+
}
119+
120+
/**
121+
* @param param The request object
122+
*/
123+
public getServiceList(options?: Configuration): Promise<ServiceList> {
124+
const requestContextPromise = this.requestFactory.getServiceList(options);
125+
return requestContextPromise.then((requestContext) => {
126+
return this.configuration.httpApi
127+
.send(requestContext)
128+
.then((responseContext) => {
129+
return this.responseProcessor.getServiceList(responseContext);
130+
});
131+
});
132+
}
133+
}

packages/datadog-api-client-v2/apis/IncidentsApi.ts

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,6 @@ export class IncidentsApiRequestFactory extends BaseAPIRequestFactory {
112112
): Promise<RequestContext> {
113113
const _config = _options || this.configuration;
114114

115-
logger.warn("Using unstable operation 'createIncidentImpact'");
116-
if (!_config.unstableOperations["v2.createIncidentImpact"]) {
117-
throw new Error("Unstable operation 'createIncidentImpact' is disabled");
118-
}
119-
120115
// verify required parameter 'incidentId' is not null or undefined
121116
if (incidentId === null || incidentId === undefined) {
122117
throw new RequiredError("incidentId", "createIncidentImpact");
@@ -495,11 +490,6 @@ export class IncidentsApiRequestFactory extends BaseAPIRequestFactory {
495490
): Promise<RequestContext> {
496491
const _config = _options || this.configuration;
497492

498-
logger.warn("Using unstable operation 'deleteIncidentImpact'");
499-
if (!_config.unstableOperations["v2.deleteIncidentImpact"]) {
500-
throw new Error("Unstable operation 'deleteIncidentImpact' is disabled");
501-
}
502-
503493
// verify required parameter 'incidentId' is not null or undefined
504494
if (incidentId === null || incidentId === undefined) {
505495
throw new RequiredError("incidentId", "deleteIncidentImpact");
@@ -1140,11 +1130,6 @@ export class IncidentsApiRequestFactory extends BaseAPIRequestFactory {
11401130
): Promise<RequestContext> {
11411131
const _config = _options || this.configuration;
11421132

1143-
logger.warn("Using unstable operation 'listIncidentImpacts'");
1144-
if (!_config.unstableOperations["v2.listIncidentImpacts"]) {
1145-
throw new Error("Unstable operation 'listIncidentImpacts' is disabled");
1146-
}
1147-
11481133
// verify required parameter 'incidentId' is not null or undefined
11491134
if (incidentId === null || incidentId === undefined) {
11501135
throw new RequiredError("incidentId", "listIncidentImpacts");

0 commit comments

Comments
 (0)