Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
274 changes: 239 additions & 35 deletions .generator/schemas/v2/openapi.yaml

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions features/v2/incidents.feature
Original file line number Diff line number Diff line change
Expand Up @@ -334,15 +334,15 @@ Feature: Incidents
Scenario: Create postmortem template returns "Bad Request" response
Given operation "CreateIncidentPostmortemTemplate" enabled
And new "CreateIncidentPostmortemTemplate" request
And body with value {"data": {"attributes": {"name": "Standard Postmortem Template"}, "type": "postmortem_template"}}
And body with value {"data": {"attributes": {"confluence_postmortem_settings": {"account_id": "123456", "parent_id": "345678", "space_id": "789012"}, "content": "# Overview\n\n# What Happened\n\n# Timeline\n\n# Action Items", "google_docs_postmortem_settings": {"account_id": "123456", "parent_folder_id": "789012"}, "is_default": "2024-01-01T00:00:00+00:00", "location": "datadog_notebooks", "name": "Standard Postmortem Template"}, "id": "00000000-0000-0000-0000-000000000000", "relationships": {"incident_type": {"data": {"id": "00000000-0000-0000-0000-000000000009", "type": "incident_types"}}}, "type": "postmortem_templates"}}
When the request is sent
Then the response status is 400 Bad Request

@generated @skip @team:DataDog/incident-app
Scenario: Create postmortem template returns "Created" response
Given operation "CreateIncidentPostmortemTemplate" enabled
And new "CreateIncidentPostmortemTemplate" request
And body with value {"data": {"attributes": {"name": "Standard Postmortem Template"}, "type": "postmortem_template"}}
And body with value {"data": {"attributes": {"confluence_postmortem_settings": {"account_id": "123456", "parent_id": "345678", "space_id": "789012"}, "content": "# Overview\n\n# What Happened\n\n# Timeline\n\n# Action Items", "google_docs_postmortem_settings": {"account_id": "123456", "parent_folder_id": "789012"}, "is_default": "2024-01-01T00:00:00+00:00", "location": "datadog_notebooks", "name": "Standard Postmortem Template"}, "id": "00000000-0000-0000-0000-000000000000", "relationships": {"incident_type": {"data": {"id": "00000000-0000-0000-0000-000000000009", "type": "incident_types"}}}, "type": "postmortem_templates"}}
When the request is sent
Then the response status is 201 Created

Expand Down Expand Up @@ -1590,7 +1590,7 @@ Feature: Incidents
Given operation "UpdateIncidentPostmortemTemplate" enabled
And new "UpdateIncidentPostmortemTemplate" request
And request contains "template_id" parameter from "REPLACE.ME"
And body with value {"data": {"attributes": {"name": "Standard Postmortem Template"}, "type": "postmortem_template"}}
And body with value {"data": {"attributes": {"confluence_postmortem_settings": {"account_id": "123456", "parent_id": "345678", "space_id": "789012"}, "content": "# Overview\n\n# What Happened\n\n# Timeline\n\n# Action Items", "google_docs_postmortem_settings": {"account_id": "123456", "parent_folder_id": "789012"}, "is_default": "2024-01-01T00:00:00+00:00", "location": "datadog_notebooks", "name": "Standard Postmortem Template"}, "id": "00000000-0000-0000-0000-000000000000", "relationships": {"incident_type": {"data": {"id": "00000000-0000-0000-0000-000000000009", "type": "incident_types"}}}, "type": "postmortem_templates"}}
When the request is sent
Then the response status is 400 Bad Request

Expand All @@ -1599,7 +1599,7 @@ Feature: Incidents
Given operation "UpdateIncidentPostmortemTemplate" enabled
And new "UpdateIncidentPostmortemTemplate" request
And request contains "template_id" parameter from "REPLACE.ME"
And body with value {"data": {"attributes": {"name": "Standard Postmortem Template"}, "type": "postmortem_template"}}
And body with value {"data": {"attributes": {"confluence_postmortem_settings": {"account_id": "123456", "parent_id": "345678", "space_id": "789012"}, "content": "# Overview\n\n# What Happened\n\n# Timeline\n\n# Action Items", "google_docs_postmortem_settings": {"account_id": "123456", "parent_folder_id": "789012"}, "is_default": "2024-01-01T00:00:00+00:00", "location": "datadog_notebooks", "name": "Standard Postmortem Template"}, "id": "00000000-0000-0000-0000-000000000000", "relationships": {"incident_type": {"data": {"id": "00000000-0000-0000-0000-000000000009", "type": "incident_types"}}}, "type": "postmortem_templates"}}
When the request is sent
Then the response status is 404 Not Found

Expand All @@ -1608,6 +1608,6 @@ Feature: Incidents
Given operation "UpdateIncidentPostmortemTemplate" enabled
And new "UpdateIncidentPostmortemTemplate" request
And request contains "template_id" parameter from "REPLACE.ME"
And body with value {"data": {"attributes": {"name": "Standard Postmortem Template"}, "type": "postmortem_template"}}
And body with value {"data": {"attributes": {"confluence_postmortem_settings": {"account_id": "123456", "parent_id": "345678", "space_id": "789012"}, "content": "# Overview\n\n# What Happened\n\n# Timeline\n\n# Action Items", "google_docs_postmortem_settings": {"account_id": "123456", "parent_folder_id": "789012"}, "is_default": "2024-01-01T00:00:00+00:00", "location": "datadog_notebooks", "name": "Standard Postmortem Template"}, "id": "00000000-0000-0000-0000-000000000000", "relationships": {"incident_type": {"data": {"id": "00000000-0000-0000-0000-000000000009", "type": "incident_types"}}}, "type": "postmortem_templates"}}
When the request is sent
Then the response status is 200 OK
2 changes: 1 addition & 1 deletion features/v2/undo.json
Original file line number Diff line number Diff line change
Expand Up @@ -3029,7 +3029,7 @@
"parameters": [
{
"name": "template_id",
"source": "<RESPONSE_PATH>"
"source": "data.id"
}
],
"type": "unsafe"
Expand Down
19 changes: 4 additions & 15 deletions packages/datadog-api-client/src/ObjectSerializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,12 +249,7 @@ export function serialize(
}
}

export function deserialize(
data: any,
typingInfo: ModelTypingInfo,
type: string,
format: string = "",
): any {
export function deserialize(data: any, typingInfo: ModelTypingInfo, type: string, format: string = ""): any {
if (data == undefined || type === "any") {
return data;
} else if (
Expand Down Expand Up @@ -292,12 +287,7 @@ export function deserialize(
const subType: string = type.substring(MAP_PREFIX.length, type.length - 3);
const transformedData: { [key: string]: any } = {};
for (const key in data) {
transformedData[key] = deserialize(
data[key],
typingInfo,
subType,
format,
);
transformedData[key] = deserialize(data[key], typingInfo, subType, format);
}
return transformedData;
} else if (type === "Date") {
Expand Down Expand Up @@ -339,8 +329,7 @@ export function deserialize(
const instance = new typingInfo.typeMap[type]();
const attributesMap = typingInfo.typeMap[type].getAttributeTypeMap();
const keepAllInAdditional =
(typingInfo.typeMap[type] as any)._keepTypedInAdditionalProperties ===
true;
(typingInfo.typeMap[type] as any)._keepTypedInAdditionalProperties === true;
// Single pass: build attributesBaseNames (for extra-key detection) and, when needed,
// baseNameToAttr (for per-field typed deserialization preserving int64 precision).
const attributesBaseNames: { [key: string]: string } = {};
Expand Down Expand Up @@ -431,4 +420,4 @@ export function deserialize(

return instance;
}
}
}
32 changes: 15 additions & 17 deletions packages/datadog-api-client/src/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,52 +82,50 @@ export class AppKeyAuthAuthentication implements SecurityAuthentication {
}

export type AuthMethods = {
AuthZ?: SecurityAuthentication;
apiKeyAuth?: SecurityAuthentication;
appKeyAuth?: SecurityAuthentication;
};
"AuthZ"?: SecurityAuthentication,
"apiKeyAuth"?: SecurityAuthentication,
"appKeyAuth"?: SecurityAuthentication
}

export type ApiKeyConfiguration = string;
export type HttpBasicConfiguration = { username: string; password: string };
export type HttpBasicConfiguration = { "username": string, "password": string };
export type HttpBearerConfiguration = { tokenProvider: TokenProvider };
export type OAuth2Configuration = { accessToken: string };

export type AuthMethodsConfiguration = {
AuthZ?: OAuth2Configuration;
apiKeyAuth?: ApiKeyConfiguration;
appKeyAuth?: ApiKeyConfiguration;
};
"AuthZ"?: OAuth2Configuration,
"apiKeyAuth"?: ApiKeyConfiguration,
"appKeyAuth"?: ApiKeyConfiguration
}

/**
* Creates the authentication methods from a swagger description.
*
*/
export function configureAuthMethods(
config: AuthMethodsConfiguration | undefined,
): AuthMethods {
let authMethods: AuthMethods = {};
export function configureAuthMethods(config: AuthMethodsConfiguration | undefined): AuthMethods {
let authMethods: AuthMethods = {}

if (!config) {
return authMethods;
}

if (config["AuthZ"]) {
authMethods["AuthZ"] = new AuthZAuthentication(
config["AuthZ"]["accessToken"],
config["AuthZ"]["accessToken"]
);
}

if (config["apiKeyAuth"]) {
authMethods["apiKeyAuth"] = new ApiKeyAuthAuthentication(
config["apiKeyAuth"],
config["apiKeyAuth"]
);
}

if (config["appKeyAuth"]) {
authMethods["appKeyAuth"] = new AppKeyAuthAuthentication(
config["appKeyAuth"],
config["appKeyAuth"]
);
}

return authMethods;
}
}
11 changes: 3 additions & 8 deletions packages/datadog-api-client/src/baseapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,8 @@ export class BaseAPIRequestFactory {
* @extends {Error}
*/
export class RequiredError extends Error {
constructor(
public field: string,
operation: string,
) {
super(
`Required parameter ${field} was null or undefined when calling ${operation}.`,
);
constructor(public field: string, operation: string) {
super(`Required parameter ${field} was null or undefined when calling ${operation}.`);
this.name = "RequiredError";
}
}
}
51 changes: 14 additions & 37 deletions packages/datadog-api-client/src/configuration.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,15 @@
import {
HttpLibrary,
HttpConfiguration,
RequestContext,
ZstdCompressorCallback,
} from "./http/http";
import { HttpLibrary, HttpConfiguration, RequestContext, ZstdCompressorCallback } from "./http/http";
import { IsomorphicFetchHttpLibrary as DefaultHttpLibrary } from "./http/isomorphic-fetch";
import { BaseServerConfiguration, server1, servers } from "./servers";
import {
configureAuthMethods,
AuthMethods,
AuthMethodsConfiguration,
} from "./auth";
import { configureAuthMethods, AuthMethods, AuthMethodsConfiguration } from "./auth";
import { logger } from "./logger";

export class Configuration {
readonly baseServer?: BaseServerConfiguration;
readonly serverIndex: number;
readonly serverVariables: { [key: string]: string };
readonly operationServerIndices: { [name: string]: number };
readonly operationServerVariables: {
[name: string]: { [key: string]: string };
};
readonly operationServerVariables: { [name: string]: { [key: string]: string } };
readonly httpApi: HttpLibrary;
readonly authMethods: AuthMethods;
readonly httpConfig: HttpConfiguration;
Expand Down Expand Up @@ -75,8 +64,8 @@ export class Configuration {
key: string,
operationServers?: { [key: string]: BaseServerConfiguration[] },
): {
server: BaseServerConfiguration;
overrides?: { [key: string]: string };
server: BaseServerConfiguration,
overrides?: { [key: string]: string },
} {
if (this.baseServer !== undefined) {
return { server: this.baseServer, overrides: this.serverVariables };
Expand Down Expand Up @@ -151,15 +140,15 @@ export interface ConfigurationParameters {
/**
* Configuration for HTTP transport
*/
httpConfig?: HttpConfiguration;
httpConfig?: HttpConfiguration
/**
* Flag to enable requests tracing
*/
debug?: boolean;
debug?: boolean
/**
* Callback method to compress string body with zstd
*/
zstdCompressorCallback?: ZstdCompressorCallback;
zstdCompressorCallback?: ZstdCompressorCallback
/**
* Maximum of retry attempts allowed
*/
Expand Down Expand Up @@ -194,28 +183,16 @@ export interface ConfigurationParameters {
*
* @param conf partial configuration
*/
export function createConfiguration(
conf: ConfigurationParameters = {},
): Configuration {
export function createConfiguration(conf: ConfigurationParameters = {}): Configuration {
if (typeof process !== "undefined" && process.env && process.env.DD_SITE) {
const serverConf = server1.getConfiguration();
server1.setVariables({ site: process.env.DD_SITE } as typeof serverConf);
server1.setVariables({ "site": process.env.DD_SITE } as (typeof serverConf));
}
const authMethods = conf.authMethods || {};
if (
!("apiKeyAuth" in authMethods) &&
typeof process !== "undefined" &&
process.env &&
process.env.DD_API_KEY
) {
if (!("apiKeyAuth" in authMethods) && typeof process !== "undefined" && process.env && process.env.DD_API_KEY) {
authMethods["apiKeyAuth"] = process.env.DD_API_KEY;
}
if (
!("appKeyAuth" in authMethods) &&
typeof process !== "undefined" &&
process.env &&
process.env.DD_APP_KEY
) {
if (!("appKeyAuth" in authMethods) && typeof process !== "undefined" && process.env && process.env.DD_APP_KEY) {
authMethods["appKeyAuth"] = process.env.DD_APP_KEY;
}

Expand All @@ -235,7 +212,7 @@ export function createConfiguration(
conf.backoffMultiplier || 2,
{},
);
configuration.httpApi.zstdCompressorCallback = conf.zstdCompressorCallback;
configuration.httpApi.zstdCompressorCallback = conf.zstdCompressorCallback
configuration.httpApi.debug = configuration.debug;
configuration.httpApi.enableRetry = configuration.enableRetry;
configuration.httpApi.maxRetries = configuration.maxRetries;
Expand All @@ -260,4 +237,4 @@ export function applySecurityAuthentication<
authMethod.applySecurityAuthentication(requestContext);
}
}
}
}
7 changes: 2 additions & 5 deletions packages/datadog-api-client/src/exception.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,10 @@
*
*/
export class ApiException<T> extends Error {
public constructor(
public code: number,
public body: T,
) {
public constructor(public code: number, public body: T) {
super("HTTP-Code: " + code + "\nMessage: " + JSON.stringify(body));
Object.setPrototypeOf(this, ApiException.prototype);
this.code = code;
this.body = body;
}
}
}
28 changes: 11 additions & 17 deletions packages/datadog-api-client/src/http/http.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@


// TODO: evaluate if we can easily get rid of this library
import FormData from "form-data";
import { isBrowser } from "../util";
Expand All @@ -19,7 +21,7 @@ export interface AbortSignal {
capture?: boolean;
once?: boolean;
passive?: boolean;
},
}
) => void;

removeEventListener: (
Expand All @@ -29,7 +31,7 @@ export interface AbortSignal {
| boolean
| {
capture?: boolean;
},
}
) => void;

dispatchEvent: (event: any) => boolean;
Expand Down Expand Up @@ -96,12 +98,9 @@ export class RequestContext {
* @param url url of the requested resource
* @param httpMethod http method
*/
public constructor(
url: string,
public httpMethod: HttpMethod,
) {
public constructor(url: string, public httpMethod: HttpMethod) {
this.url = new URL(url);
}
}

/*
* Returns the url set in the constructor including the query string
Expand Down Expand Up @@ -150,12 +149,8 @@ export class RequestContext {
* @param name the name of the query parameter
* @param value the value of the query parameter
* @param collectionFormat the format of the query parameter See https://spec.openapis.org/oas/v3.0.2#style-values
*/
public setQueryParam(
name: string,
value: string | string[],
collectionFormat: string,
): void {
*/
public setQueryParam(name: string, value: string | string[], collectionFormat: string): void {
if (collectionFormat === "multi") {
for (const val of value) {
this.url.searchParams.append(name, val);
Expand All @@ -164,8 +159,7 @@ export class RequestContext {
}

if (Array.isArray(value)) {
const delimiter =
COLLECTION_FORMATS[collectionFormat as keyof typeof COLLECTION_FORMATS];
const delimiter = COLLECTION_FORMATS[collectionFormat as keyof typeof COLLECTION_FORMATS];
value = value.join(delimiter);
}

Expand Down Expand Up @@ -221,7 +215,7 @@ export class ResponseContext {
public constructor(
public httpStatusCode: number,
public headers: { [key: string]: string },
public body: ResponseBody,
public body: ResponseBody
) {}

/**
Expand Down Expand Up @@ -273,4 +267,4 @@ export interface HttpLibrary {
fetch?: any;
zstdCompressorCallback?: ZstdCompressorCallback;
send(request: RequestContext): Promise<ResponseContext>;
}
}
Loading
Loading