Skip to content

Commit 3270c36

Browse files
author
ci.datadog-api-spec
committed
Regenerate client from commit af0cd40 of spec repo
1 parent 2f4a7ce commit 3270c36

File tree

11 files changed

+528
-0
lines changed

11 files changed

+528
-0
lines changed

.generator/schemas/v2/openapi.yaml

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17289,6 +17289,76 @@ components:
1728917289
- score
1729017290
- severity
1729117291
type: object
17292+
Email:
17293+
description: On-Call User Email.
17294+
example:
17295+
data:
17296+
attributes:
17297+
active: true
17298+
address: john.doe@datadoghq.com
17299+
alias: ''
17300+
blocked: false
17301+
created_at: '2024-04-16T23:38:50.388642Z'
17302+
formats:
17303+
- html
17304+
modified_at: '2024-04-16T23:38:50.388642Z'
17305+
id: 45cd9fe5-dd96-42ad-83de-2242ea9f6efd
17306+
type: emails
17307+
properties:
17308+
data:
17309+
$ref: '#/components/schemas/EmailData'
17310+
type: object
17311+
EmailAttributes:
17312+
description: Attributes for an on-call email.
17313+
properties:
17314+
active:
17315+
description: Whether the email is currently active.
17316+
type: boolean
17317+
address:
17318+
description: Email address.
17319+
type: string
17320+
alias:
17321+
description: Optional display alias for the email.
17322+
type: string
17323+
blocked:
17324+
description: Whether the email is blocked.
17325+
type: boolean
17326+
created_at:
17327+
description: Creation time of the email resource.
17328+
format: date-time
17329+
type: string
17330+
formats:
17331+
description: Preferred content formats for notifications.
17332+
items:
17333+
type: string
17334+
type: array
17335+
modified_at:
17336+
description: Last modification time of the email resource.
17337+
format: date-time
17338+
type: string
17339+
type: object
17340+
EmailData:
17341+
description: Data for an on-call email resource.
17342+
properties:
17343+
attributes:
17344+
$ref: '#/components/schemas/EmailAttributes'
17345+
id:
17346+
description: The email's unique identifier.
17347+
type: string
17348+
type:
17349+
$ref: '#/components/schemas/EmailType'
17350+
required:
17351+
- type
17352+
type: object
17353+
EmailType:
17354+
default: emails
17355+
description: Indicates that the resource is of type 'emails'.
17356+
enum:
17357+
- emails
17358+
example: emails
17359+
type: string
17360+
x-enum-varnames:
17361+
- EMAILS
1729217362
Enabled:
1729317363
description: Field used to enable or disable the rule.
1729417364
example: true
@@ -70837,6 +70907,48 @@ paths:
7083770907
operator: AND
7083870908
permissions:
7083970909
- on_call_write
70910+
/api/v2/on-call/users/{user_id}/notification-channels/emails:
70911+
post:
70912+
description: Create a new email notification channel for an on-call user
70913+
operationId: CreateUserEmailNotificationChannel
70914+
parameters:
70915+
- description: The user ID
70916+
in: path
70917+
name: user_id
70918+
required: true
70919+
schema:
70920+
example: 00000000-0000-0000-0000-000000000000
70921+
type: string
70922+
requestBody:
70923+
content:
70924+
application/json:
70925+
schema:
70926+
$ref: '#/components/schemas/Email'
70927+
required: true
70928+
responses:
70929+
'201':
70930+
description: Created
70931+
'400':
70932+
$ref: '#/components/responses/BadRequestResponse'
70933+
'401':
70934+
$ref: '#/components/responses/UnauthorizedResponse'
70935+
'403':
70936+
$ref: '#/components/responses/ForbiddenResponse'
70937+
'404':
70938+
$ref: '#/components/responses/NotFoundResponse'
70939+
'429':
70940+
$ref: '#/components/responses/TooManyRequestsResponse'
70941+
security:
70942+
- apiKeyAuth: []
70943+
appKeyAuth: []
70944+
- AuthZ: []
70945+
summary: Create email notification channel for user
70946+
tags:
70947+
- On-Call
70948+
x-permission:
70949+
operator: AND
70950+
permissions:
70951+
- on_call_admin
7084070952
/api/v2/org_configs:
7084170953
get:
7084270954
description: Returns all Org Configs (name, description, and value).

features/v2/on-call.feature

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,30 @@ Feature: On-Call
4343
When the request is sent
4444
Then the response status is 201 Created
4545

46+
@generated @skip @team:DataDog/on-call
47+
Scenario: Create email notification channel for user returns "Bad Request" response
48+
Given new "CreateUserEmailNotificationChannel" request
49+
And request contains "user_id" parameter from "REPLACE.ME"
50+
And body with value {"data": {"attributes": {"active": true, "address": "john.doe@datadoghq.com", "alias": "", "blocked": false, "created_at": "2024-04-16T23:38:50.388642Z", "formats": ["html"], "modified_at": "2024-04-16T23:38:50.388642Z"}, "id": "45cd9fe5-dd96-42ad-83de-2242ea9f6efd", "type": "emails"}}
51+
When the request is sent
52+
Then the response status is 400 Bad Request
53+
54+
@generated @skip @team:DataDog/on-call
55+
Scenario: Create email notification channel for user returns "Created" response
56+
Given new "CreateUserEmailNotificationChannel" request
57+
And request contains "user_id" parameter from "REPLACE.ME"
58+
And body with value {"data": {"attributes": {"active": true, "address": "john.doe@datadoghq.com", "alias": "", "blocked": false, "created_at": "2024-04-16T23:38:50.388642Z", "formats": ["html"], "modified_at": "2024-04-16T23:38:50.388642Z"}, "id": "45cd9fe5-dd96-42ad-83de-2242ea9f6efd", "type": "emails"}}
59+
When the request is sent
60+
Then the response status is 201 Created
61+
62+
@generated @skip @team:DataDog/on-call
63+
Scenario: Create email notification channel for user returns "Not Found" response
64+
Given new "CreateUserEmailNotificationChannel" request
65+
And request contains "user_id" parameter from "REPLACE.ME"
66+
And body with value {"data": {"attributes": {"active": true, "address": "john.doe@datadoghq.com", "alias": "", "blocked": false, "created_at": "2024-04-16T23:38:50.388642Z", "formats": ["html"], "modified_at": "2024-04-16T23:38:50.388642Z"}, "id": "45cd9fe5-dd96-42ad-83de-2242ea9f6efd", "type": "emails"}}
67+
When the request is sent
68+
Then the response status is 404 Not Found
69+
4670
@team:DataDog/on-call
4771
Scenario: Delete On-Call escalation policy returns "No Content" response
4872
Given new "DeleteOnCallEscalationPolicy" request

features/v2/undo.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2697,6 +2697,14 @@
26972697
"type": "idempotent"
26982698
}
26992699
},
2700+
"CreateUserEmailNotificationChannel": {
2701+
"tag": "On-Call",
2702+
"undo": {
2703+
"operationId": "TODO",
2704+
"parameters": [],
2705+
"type": "unsafe"
2706+
}
2707+
},
27002708
"ListOrgConfigs": {
27012709
"tag": "Organizations",
27022710
"undo": {

private/bdd_runner/src/support/scenarios_model_mapping.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7193,6 +7193,17 @@ export const ScenariosModelMappings: { [key: string]: OperationMapping } = {
71937193
},
71947194
operationResponseType: "TeamRoutingRules",
71957195
},
7196+
"OnCallApi.V2.CreateUserEmailNotificationChannel": {
7197+
userId: {
7198+
type: "string",
7199+
format: "",
7200+
},
7201+
body: {
7202+
type: "Email",
7203+
format: "",
7204+
},
7205+
operationResponseType: "{}",
7206+
},
71967207
"OnCallPagingApi.V2.CreateOnCallPage": {
71977208
body: {
71987209
type: "CreatePageRequest",

services/on_call/src/v2/OnCallApi.ts

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import {
2323

2424
import { TypingInfo } from "./models/TypingInfo";
2525
import { APIErrorResponse } from "./models/APIErrorResponse";
26+
import { Email } from "./models/Email";
2627
import { EscalationPolicy } from "./models/EscalationPolicy";
2728
import { EscalationPolicyCreateRequest } from "./models/EscalationPolicyCreateRequest";
2829
import { EscalationPolicyUpdateRequest } from "./models/EscalationPolicyUpdateRequest";
@@ -166,6 +167,67 @@ export class OnCallApiRequestFactory extends BaseAPIRequestFactory {
166167
return requestContext;
167168
}
168169

170+
public async createUserEmailNotificationChannel(
171+
userId: string,
172+
body: Email,
173+
_options?: Configuration,
174+
): Promise<RequestContext> {
175+
const _config = _options || this.configuration;
176+
177+
// verify required parameter 'userId' is not null or undefined
178+
if (userId === null || userId === undefined) {
179+
throw new RequiredError("userId", "createUserEmailNotificationChannel");
180+
}
181+
182+
// verify required parameter 'body' is not null or undefined
183+
if (body === null || body === undefined) {
184+
throw new RequiredError("body", "createUserEmailNotificationChannel");
185+
}
186+
187+
// Path Params
188+
const localVarPath =
189+
"/api/v2/on-call/users/{user_id}/notification-channels/emails".replace(
190+
"{user_id}",
191+
encodeURIComponent(String(userId)),
192+
);
193+
194+
// Make Request Context
195+
const { server, overrides } = _config.getServerAndOverrides(
196+
"OnCallApi.v2.createUserEmailNotificationChannel",
197+
OnCallApi.operationServers,
198+
);
199+
const requestContext = server.makeRequestContext(
200+
localVarPath,
201+
HttpMethod.POST,
202+
overrides,
203+
);
204+
requestContext.setHeaderParam("Accept", "*/*");
205+
requestContext.setHttpConfig(_config.httpConfig);
206+
207+
// Set User-Agent
208+
if (this.userAgent) {
209+
requestContext.setHeaderParam("User-Agent", this.userAgent);
210+
}
211+
212+
// Body Params
213+
const contentType = getPreferredMediaType(["application/json"]);
214+
requestContext.setHeaderParam("Content-Type", contentType);
215+
const serializedBody = stringify(
216+
serialize(body, TypingInfo, "Email", ""),
217+
contentType,
218+
);
219+
requestContext.setBody(serializedBody);
220+
221+
// Apply auth methods
222+
applySecurityAuthentication(_config, requestContext, [
223+
"apiKeyAuth",
224+
"appKeyAuth",
225+
"AuthZ",
226+
]);
227+
228+
return requestContext;
229+
}
230+
169231
public async deleteOnCallEscalationPolicy(
170232
policyId: string,
171233
_options?: Configuration,
@@ -879,6 +941,57 @@ export class OnCallApiResponseProcessor {
879941
);
880942
}
881943

944+
/**
945+
* Unwraps the actual response sent by the server from the response context and deserializes the response content
946+
* to the expected objects
947+
*
948+
* @params response Response returned by the server for a request to createUserEmailNotificationChannel
949+
* @throws ApiException if the response code was not in [200, 299]
950+
*/
951+
public async createUserEmailNotificationChannel(
952+
response: ResponseContext,
953+
): Promise<void> {
954+
const contentType = normalizeMediaType(response.headers["content-type"]);
955+
if (response.httpStatusCode === 201) {
956+
return;
957+
}
958+
if (
959+
response.httpStatusCode === 400 ||
960+
response.httpStatusCode === 401 ||
961+
response.httpStatusCode === 403 ||
962+
response.httpStatusCode === 404 ||
963+
response.httpStatusCode === 429
964+
) {
965+
const bodyText = parse(await response.body.text(), contentType);
966+
let body: APIErrorResponse;
967+
try {
968+
body = deserialize(
969+
bodyText,
970+
TypingInfo,
971+
"APIErrorResponse",
972+
) as APIErrorResponse;
973+
} catch (error) {
974+
logger.debug(`Got error deserializing error: ${error}`);
975+
throw new ApiException<APIErrorResponse>(
976+
response.httpStatusCode,
977+
bodyText,
978+
);
979+
}
980+
throw new ApiException<APIErrorResponse>(response.httpStatusCode, body);
981+
}
982+
983+
// Work around for missing responses in specification, e.g. for petstore.yaml
984+
if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
985+
return;
986+
}
987+
988+
const body = (await response.body.text()) || "";
989+
throw new ApiException<string>(
990+
response.httpStatusCode,
991+
'Unknown API Status Code!\nBody: "' + body + '"',
992+
);
993+
}
994+
882995
/**
883996
* Unwraps the actual response sent by the server from the response context and deserializes the response content
884997
* to the expected objects
@@ -1483,6 +1596,18 @@ export interface OnCallApiCreateOnCallScheduleRequest {
14831596
include?: string;
14841597
}
14851598

1599+
export interface OnCallApiCreateUserEmailNotificationChannelRequest {
1600+
/**
1601+
* The user ID
1602+
* @type string
1603+
*/
1604+
userId: string;
1605+
/**
1606+
* @type Email
1607+
*/
1608+
body: Email;
1609+
}
1610+
14861611
export interface OnCallApiDeleteOnCallEscalationPolicyRequest {
14871612
/**
14881613
* The ID of the escalation policy
@@ -1686,6 +1811,31 @@ export class OnCallApi {
16861811
});
16871812
}
16881813

1814+
/**
1815+
* Create a new email notification channel for an on-call user
1816+
* @param param The request object
1817+
*/
1818+
public createUserEmailNotificationChannel(
1819+
param: OnCallApiCreateUserEmailNotificationChannelRequest,
1820+
options?: Configuration,
1821+
): Promise<void> {
1822+
const requestContextPromise =
1823+
this.requestFactory.createUserEmailNotificationChannel(
1824+
param.userId,
1825+
param.body,
1826+
options,
1827+
);
1828+
return requestContextPromise.then((requestContext) => {
1829+
return this.configuration.httpApi
1830+
.send(requestContext)
1831+
.then((responseContext) => {
1832+
return this.responseProcessor.createUserEmailNotificationChannel(
1833+
responseContext,
1834+
);
1835+
});
1836+
});
1837+
}
1838+
16891839
/**
16901840
* Delete an On-Call escalation policy
16911841
* @param param The request object

services/on_call/src/v2/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
export {
22
OnCallApiCreateOnCallEscalationPolicyRequest,
33
OnCallApiCreateOnCallScheduleRequest,
4+
OnCallApiCreateUserEmailNotificationChannelRequest,
45
OnCallApiDeleteOnCallEscalationPolicyRequest,
56
OnCallApiDeleteOnCallScheduleRequest,
67
OnCallApiGetOnCallEscalationPolicyRequest,
@@ -18,6 +19,10 @@ export { APIErrorResponse } from "./models/APIErrorResponse";
1819
export { DataRelationshipsTeams } from "./models/DataRelationshipsTeams";
1920
export { DataRelationshipsTeamsDataItems } from "./models/DataRelationshipsTeamsDataItems";
2021
export { DataRelationshipsTeamsDataItemsType } from "./models/DataRelationshipsTeamsDataItemsType";
22+
export { Email } from "./models/Email";
23+
export { EmailAttributes } from "./models/EmailAttributes";
24+
export { EmailData } from "./models/EmailData";
25+
export { EmailType } from "./models/EmailType";
2126
export { Escalation } from "./models/Escalation";
2227
export { EscalationPolicy } from "./models/EscalationPolicy";
2328
export { EscalationPolicyCreateRequest } from "./models/EscalationPolicyCreateRequest";

0 commit comments

Comments
 (0)