Skip to content
Merged
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
379 changes: 379 additions & 0 deletions .generator/schemas/v2/openapi.yaml

Large diffs are not rendered by default.

22 changes: 22 additions & 0 deletions examples/v2/product-catalog/ListProductCatalogSKUs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* List SKUs returns "OK" response
*/

import { client, v2 } from "@datadog/datadog-api-client";

const configuration = client.createConfiguration();
configuration.unstableOperations["v2.listProductCatalogSKUs"] = true;
const apiInstance = new v2.ProductCatalogApi(configuration);

const params: v2.ProductCatalogApiListProductCatalogSKUsRequest = {
version: "v1",
};

apiInstance
.listProductCatalogSKUs(params)
.then((data: v2.ProductCatalogSKUsResponse) => {
console.log(
"API called successfully. Returned data: " + JSON.stringify(data)
);
})
.catch((error: any) => console.error(error));
11 changes: 11 additions & 0 deletions features/support/scenarios_model_mapping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14641,6 +14641,17 @@ export const ScenariosModelMappings: {[key: string]: {[key: string]: any}} = {
},
"operationResponseType": "ListConnectionsResponse",
},
"v2.ListProductCatalogSKUs": {
"version": {
"type": "ProductCatalogSKUsAPIVersion",
"format": "",
},
"asOfDate": {
"type": "Date",
"format": "date",
},
"operationResponseType": "ProductCatalogSKUsResponse",
},
"v2.GetPrunedTraceByID": {
"traceId": {
"type": "string",
Expand Down
30 changes: 30 additions & 0 deletions features/v2/product_catalog.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
@endpoint(product-catalog) @endpoint(product-catalog-v2)
Feature: Product Catalog
Look up the Datadog SKUs that are generally available, together with the
public list prices, allotments, and tiered pricing that apply to them on a
given date.

Background:
Given a valid "apiKeyAuth" key in the system
And a valid "appKeyAuth" key in the system
And an instance of "ProductCatalog" API
And operation "ListProductCatalogSKUs" enabled
And new "ListProductCatalogSKUs" request

@generated @skip @team:DataDog/red-zone-product-catalog
Scenario: List SKUs returns "Bad Request - version is missing or invalid, or as_of_date is malformed or in the future" response
Given request contains "version" parameter from "REPLACE.ME"
When the request is sent
Then the response status is 400 Bad Request - version is missing or invalid, or as_of_date is malformed or in the future

@generated @skip @team:DataDog/red-zone-product-catalog
Scenario: List SKUs returns "Not Found - the requested catalog version is not supported" response
Given request contains "version" parameter from "REPLACE.ME"
When the request is sent
Then the response status is 404 Not Found - the requested catalog version is not supported

@generated @skip @team:DataDog/red-zone-product-catalog
Scenario: List SKUs returns "OK" response
Given request contains "version" parameter from "REPLACE.ME"
When the request is sent
Then the response status is 200 OK
6 changes: 6 additions & 0 deletions features/v2/undo.json
Original file line number Diff line number Diff line change
Expand Up @@ -6611,6 +6611,12 @@
"type": "safe"
}
},
"ListProductCatalogSKUs": {
"tag": "Product Catalog",
"undo": {
"type": "safe"
}
},
"GetPrunedTraceByID": {
"tag": "APM Trace",
"undo": {
Expand Down
1 change: 1 addition & 0 deletions packages/datadog-api-client-common/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,7 @@ export function createConfiguration(
"v2.queryEventFilteredUsers": false,
"v2.queryUsers": false,
"v2.updateConnection": false,
"v2.listProductCatalogSKUs": false,
"v2.getPrunedTraceByID": false,
"v2.getTraceByID": false,
"v2.getAsmServiceByName": false,
Expand Down
237 changes: 237 additions & 0 deletions packages/datadog-api-client-v2/apis/ProductCatalogApi.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,237 @@
import {
BaseAPIRequestFactory,
RequiredError,
} from "../../datadog-api-client-common/baseapi";
import {
Configuration,
applySecurityAuthentication,
} from "../../datadog-api-client-common/configuration";
import {
RequestContext,
HttpMethod,
ResponseContext,
} from "../../datadog-api-client-common/http/http";

import { logger } from "../../../logger";
import { ObjectSerializer } from "../models/ObjectSerializer";
import { ApiException } from "../../datadog-api-client-common/exception";

import { APIErrorResponse } from "../models/APIErrorResponse";
import { JSONAPIErrorResponse } from "../models/JSONAPIErrorResponse";
import { ProductCatalogSKUsAPIVersion } from "../models/ProductCatalogSKUsAPIVersion";
import { ProductCatalogSKUsResponse } from "../models/ProductCatalogSKUsResponse";

export class ProductCatalogApiRequestFactory extends BaseAPIRequestFactory {
public async listProductCatalogSKUs(
version: ProductCatalogSKUsAPIVersion,
asOfDate?: Date,
_options?: Configuration
): Promise<RequestContext> {
const _config = _options || this.configuration;

logger.warn("Using unstable operation 'listProductCatalogSKUs'");
if (!_config.unstableOperations["v2.listProductCatalogSKUs"]) {
throw new Error(
"Unstable operation 'listProductCatalogSKUs' is disabled"
);
}

// verify required parameter 'version' is not null or undefined
if (version === null || version === undefined) {
throw new RequiredError("version", "listProductCatalogSKUs");
}

// Path Params
const localVarPath = "/api/v2/product-catalog/skus";

// Make Request Context
const requestContext = _config
.getServer("v2.ProductCatalogApi.listProductCatalogSKUs")
.makeRequestContext(localVarPath, HttpMethod.GET);
requestContext.setHeaderParam("Accept", "application/json");
requestContext.setHttpConfig(_config.httpConfig);

// Set IaC header
if (_config.isIaC) {
requestContext.setHeaderParam("X-Datadog-Managed-By", "iac");
}

// Query Params
if (version !== undefined) {
requestContext.setQueryParam(
"version",
ObjectSerializer.serialize(version, "ProductCatalogSKUsAPIVersion", ""),
""
);
}
if (asOfDate !== undefined) {
requestContext.setQueryParam(
"as_of_date",
ObjectSerializer.serialize(asOfDate, "Date", "date"),
""
);
}

// Apply auth methods
applySecurityAuthentication(_config, requestContext, [
"apiKeyAuth",
"appKeyAuth",
"AuthZ",
]);

return requestContext;
}
}

export class ProductCatalogApiResponseProcessor {
/**
* 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 listProductCatalogSKUs
* @throws ApiException if the response code was not in [200, 299]
*/
public async listProductCatalogSKUs(
response: ResponseContext
): Promise<ProductCatalogSKUsResponse> {
const contentType = ObjectSerializer.normalizeMediaType(
response.headers["content-type"]
);
if (response.httpStatusCode === 200) {
const body: ProductCatalogSKUsResponse = ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"ProductCatalogSKUsResponse"
) as ProductCatalogSKUsResponse;
return body;
}
if (
response.httpStatusCode === 400 ||
response.httpStatusCode === 403 ||
response.httpStatusCode === 404
) {
const bodyText = ObjectSerializer.parse(
await response.body.text(),
contentType
);
let body: JSONAPIErrorResponse;
try {
body = ObjectSerializer.deserialize(
bodyText,
"JSONAPIErrorResponse"
) as JSONAPIErrorResponse;
} catch (error) {
logger.debug(`Got error deserializing error: ${error}`);
throw new ApiException<JSONAPIErrorResponse>(
response.httpStatusCode,
bodyText
);
}
throw new ApiException<JSONAPIErrorResponse>(
response.httpStatusCode,
body
);
}
if (response.httpStatusCode === 429) {
const bodyText = ObjectSerializer.parse(
await response.body.text(),
contentType
);
let body: APIErrorResponse;
try {
body = ObjectSerializer.deserialize(
bodyText,
"APIErrorResponse"
) as APIErrorResponse;
} catch (error) {
logger.debug(`Got error deserializing error: ${error}`);
throw new ApiException<APIErrorResponse>(
response.httpStatusCode,
bodyText
);
}
throw new ApiException<APIErrorResponse>(response.httpStatusCode, body);
}

// Work around for missing responses in specification, e.g. for petstore.yaml
if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
const body: ProductCatalogSKUsResponse = ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"ProductCatalogSKUsResponse",
""
) as ProductCatalogSKUsResponse;
return body;
}

const body = (await response.body.text()) || "";
throw new ApiException<string>(
response.httpStatusCode,
'Unknown API Status Code!\nBody: "' + body + '"'
);
}
}

export interface ProductCatalogApiListProductCatalogSKUsRequest {
/**
* The version of the product catalog contract to return. `v1` is the latest.
* @type ProductCatalogSKUsAPIVersion
*/
version: ProductCatalogSKUsAPIVersion;
/**
* The date the returned prices, allotments, and pricing tiers are effective as of, in
* `YYYY-MM-DD` format. Defaults to the date of the request, and must not be later
* than it.
* @type Date
*/
asOfDate?: Date;
}

export class ProductCatalogApi {
private requestFactory: ProductCatalogApiRequestFactory;
private responseProcessor: ProductCatalogApiResponseProcessor;
private configuration: Configuration;

public constructor(
configuration: Configuration,
requestFactory?: ProductCatalogApiRequestFactory,
responseProcessor?: ProductCatalogApiResponseProcessor
) {
this.configuration = configuration;
this.requestFactory =
requestFactory || new ProductCatalogApiRequestFactory(configuration);
this.responseProcessor =
responseProcessor || new ProductCatalogApiResponseProcessor();
}

/**
* Get every generally available Datadog SKU, with the pricing and allotment metadata that
* applies to it, for the Datadog site serving the request. A SKU is generally available
* when it is billed through a metered commitment or through automatic billing; SKUs in any
* other phase are not returned.
*
* Prices, allotments, and pricing tiers are returned as they were in effect on
* `as_of_date`, which defaults to the date of the request. Prices are public list prices:
* they do not reflect discounts, commitments, or negotiated rates on an account.
*
* Each SKU is a separate resource in `data`, identified by its SKU code, and sorted by
* that code in ascending order. The whole catalog is returned in a single response, so
* this endpoint is not paginated.
* @param param The request object
*/
public listProductCatalogSKUs(
param: ProductCatalogApiListProductCatalogSKUsRequest,
options?: Configuration
): Promise<ProductCatalogSKUsResponse> {
const requestContextPromise = this.requestFactory.listProductCatalogSKUs(
param.version,
param.asOfDate,
options
);
return requestContextPromise.then((requestContext) => {
return this.configuration.httpApi
.send(requestContext)
.then((responseContext) => {
return this.responseProcessor.listProductCatalogSKUs(responseContext);
});
});
}
}
16 changes: 16 additions & 0 deletions packages/datadog-api-client-v2/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1235,6 +1235,11 @@ export {
ProductAnalyticsApi,
} from "./apis/ProductAnalyticsApi";

export {
ProductCatalogApiListProductCatalogSKUsRequest,
ProductCatalogApi,
} from "./apis/ProductCatalogApi";

export {
RUMApiAggregateRUMEventsRequest,
RUMApiCreateRUMApplicationRequest,
Expand Down Expand Up @@ -7229,6 +7234,17 @@ export { ProductAnalyticsTimeseriesResponseAttributes } from "./models/ProductAn
export { ProductAnalyticsTimeseriesResponseData } from "./models/ProductAnalyticsTimeseriesResponseData";
export { ProductAnalyticsTimeseriesResponseType } from "./models/ProductAnalyticsTimeseriesResponseType";
export { ProductAnalyticsUnit } from "./models/ProductAnalyticsUnit";
export { ProductCatalogSKUAllotment } from "./models/ProductCatalogSKUAllotment";
export { ProductCatalogSKUDataAttributesResponse } from "./models/ProductCatalogSKUDataAttributesResponse";
export { ProductCatalogSKUDataResponse } from "./models/ProductCatalogSKUDataResponse";
export { ProductCatalogSKUOnDemandOption } from "./models/ProductCatalogSKUOnDemandOption";
export { ProductCatalogSKUPricingTier } from "./models/ProductCatalogSKUPricingTier";
export { ProductCatalogSKUPricingType } from "./models/ProductCatalogSKUPricingType";
export { ProductCatalogSKUPricingUnitType } from "./models/ProductCatalogSKUPricingUnitType";
export { ProductCatalogSKUsAPIVersion } from "./models/ProductCatalogSKUsAPIVersion";
export { ProductCatalogSKUsResponse } from "./models/ProductCatalogSKUsResponse";
export { ProductCatalogSKUTieredPricing } from "./models/ProductCatalogSKUTieredPricing";
export { ProductCatalogSKUType } from "./models/ProductCatalogSKUType";
export { Project } from "./models/Project";
export { ProjectAttributes } from "./models/ProjectAttributes";
export { ProjectColumnsConfig } from "./models/ProjectColumnsConfig";
Expand Down
18 changes: 18 additions & 0 deletions packages/datadog-api-client-v2/models/ObjectSerializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4040,6 +4040,12 @@ import { ProductAnalyticsTimeseriesResponse } from "./ProductAnalyticsTimeseries
import { ProductAnalyticsTimeseriesResponseAttributes } from "./ProductAnalyticsTimeseriesResponseAttributes";
import { ProductAnalyticsTimeseriesResponseData } from "./ProductAnalyticsTimeseriesResponseData";
import { ProductAnalyticsUnit } from "./ProductAnalyticsUnit";
import { ProductCatalogSKUAllotment } from "./ProductCatalogSKUAllotment";
import { ProductCatalogSKUDataAttributesResponse } from "./ProductCatalogSKUDataAttributesResponse";
import { ProductCatalogSKUDataResponse } from "./ProductCatalogSKUDataResponse";
import { ProductCatalogSKUPricingTier } from "./ProductCatalogSKUPricingTier";
import { ProductCatalogSKUTieredPricing } from "./ProductCatalogSKUTieredPricing";
import { ProductCatalogSKUsResponse } from "./ProductCatalogSKUsResponse";
import { Project } from "./Project";
import { ProjectAttributes } from "./ProjectAttributes";
import { ProjectColumnsConfig } from "./ProjectColumnsConfig";
Expand Down Expand Up @@ -8064,6 +8070,11 @@ const enumsMap: { [key: string]: any[] } = {
ProductAnalyticsScalarResponseType: ["scalar_response"],
ProductAnalyticsServerSideEventItemType: ["server"],
ProductAnalyticsTimeseriesResponseType: ["timeseries_response"],
ProductCatalogSKUOnDemandOption: ["hourly", "monthly"],
ProductCatalogSKUPricingType: ["usage", "percent"],
ProductCatalogSKUPricingUnitType: ["block", "unit"],
ProductCatalogSKUType: ["Sku"],
ProductCatalogSKUsAPIVersion: ["v1"],
ProjectFavoriteResourceType: ["project_favorite"],
ProjectResourceType: ["project"],
ProjectedCostType: ["projected_cost"],
Expand Down Expand Up @@ -14140,6 +14151,13 @@ const typeMap: { [index: string]: any } = {
ProductAnalyticsTimeseriesResponseData:
ProductAnalyticsTimeseriesResponseData,
ProductAnalyticsUnit: ProductAnalyticsUnit,
ProductCatalogSKUAllotment: ProductCatalogSKUAllotment,
ProductCatalogSKUDataAttributesResponse:
ProductCatalogSKUDataAttributesResponse,
ProductCatalogSKUDataResponse: ProductCatalogSKUDataResponse,
ProductCatalogSKUPricingTier: ProductCatalogSKUPricingTier,
ProductCatalogSKUTieredPricing: ProductCatalogSKUTieredPricing,
ProductCatalogSKUsResponse: ProductCatalogSKUsResponse,
Project: Project,
ProjectAttributes: ProjectAttributes,
ProjectColumnsConfig: ProjectColumnsConfig,
Expand Down
Loading
Loading