@datadog/datadog-api-client
Version:
OpenAPI client for Datadog APIs
648 lines • 37.1 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.CSMOwnershipApi = exports.CSMOwnershipApiResponseProcessor = exports.CSMOwnershipApiRequestFactory = void 0;
const baseapi_1 = require("../../datadog-api-client-common/baseapi");
const configuration_1 = require("../../datadog-api-client-common/configuration");
const http_1 = require("../../datadog-api-client-common/http/http");
const logger_1 = require("../../../logger");
const ObjectSerializer_1 = require("../models/ObjectSerializer");
const exception_1 = require("../../datadog-api-client-common/exception");
class CSMOwnershipApiRequestFactory extends baseapi_1.BaseAPIRequestFactory {
createOwnershipFeedback(resourceId, ownerType, body, _options) {
return __awaiter(this, void 0, void 0, function* () {
const _config = _options || this.configuration;
logger_1.logger.warn("Using unstable operation 'createOwnershipFeedback'");
if (!_config.unstableOperations["v2.createOwnershipFeedback"]) {
throw new Error("Unstable operation 'createOwnershipFeedback' is disabled");
}
// verify required parameter 'resourceId' is not null or undefined
if (resourceId === null || resourceId === undefined) {
throw new baseapi_1.RequiredError("resourceId", "createOwnershipFeedback");
}
// verify required parameter 'ownerType' is not null or undefined
if (ownerType === null || ownerType === undefined) {
throw new baseapi_1.RequiredError("ownerType", "createOwnershipFeedback");
}
// verify required parameter 'body' is not null or undefined
if (body === null || body === undefined) {
throw new baseapi_1.RequiredError("body", "createOwnershipFeedback");
}
// Path Params
const localVarPath = "/api/v2/csm/ownership/{resource_id}/{owner_type}/feedback"
.replace("{resource_id}", encodeURIComponent(String(resourceId)))
.replace("{owner_type}", encodeURIComponent(String(ownerType)));
// Make Request Context
const requestContext = _config
.getServer("v2.CSMOwnershipApi.createOwnershipFeedback")
.makeRequestContext(localVarPath, http_1.HttpMethod.POST);
requestContext.setHeaderParam("Accept", "application/json");
requestContext.setHttpConfig(_config.httpConfig);
// Body Params
const contentType = ObjectSerializer_1.ObjectSerializer.getPreferredMediaType([
"application/json",
]);
requestContext.setHeaderParam("Content-Type", contentType);
const serializedBody = ObjectSerializer_1.ObjectSerializer.stringify(ObjectSerializer_1.ObjectSerializer.serialize(body, "OwnershipFeedbackRequest", ""), contentType);
requestContext.setBody(serializedBody);
// Apply auth methods
(0, configuration_1.applySecurityAuthentication)(_config, requestContext, [
"apiKeyAuth",
"appKeyAuth",
]);
return requestContext;
});
}
getOwnershipEvidence(resourceId, ownerType, ifNoneMatch, _options) {
return __awaiter(this, void 0, void 0, function* () {
const _config = _options || this.configuration;
logger_1.logger.warn("Using unstable operation 'getOwnershipEvidence'");
if (!_config.unstableOperations["v2.getOwnershipEvidence"]) {
throw new Error("Unstable operation 'getOwnershipEvidence' is disabled");
}
// verify required parameter 'resourceId' is not null or undefined
if (resourceId === null || resourceId === undefined) {
throw new baseapi_1.RequiredError("resourceId", "getOwnershipEvidence");
}
// verify required parameter 'ownerType' is not null or undefined
if (ownerType === null || ownerType === undefined) {
throw new baseapi_1.RequiredError("ownerType", "getOwnershipEvidence");
}
// Path Params
const localVarPath = "/api/v2/csm/ownership/{resource_id}/{owner_type}/evidence"
.replace("{resource_id}", encodeURIComponent(String(resourceId)))
.replace("{owner_type}", encodeURIComponent(String(ownerType)));
// Make Request Context
const requestContext = _config
.getServer("v2.CSMOwnershipApi.getOwnershipEvidence")
.makeRequestContext(localVarPath, http_1.HttpMethod.GET);
requestContext.setHeaderParam("Accept", "application/json");
requestContext.setHttpConfig(_config.httpConfig);
// Header Params
if (ifNoneMatch !== undefined) {
requestContext.setHeaderParam("If-None-Match", ObjectSerializer_1.ObjectSerializer.serialize(ifNoneMatch, "string", ""));
}
// Apply auth methods
(0, configuration_1.applySecurityAuthentication)(_config, requestContext, [
"apiKeyAuth",
"appKeyAuth",
]);
return requestContext;
});
}
getOwnershipInference(resourceId, ownerType, ifNoneMatch, _options) {
return __awaiter(this, void 0, void 0, function* () {
const _config = _options || this.configuration;
logger_1.logger.warn("Using unstable operation 'getOwnershipInference'");
if (!_config.unstableOperations["v2.getOwnershipInference"]) {
throw new Error("Unstable operation 'getOwnershipInference' is disabled");
}
// verify required parameter 'resourceId' is not null or undefined
if (resourceId === null || resourceId === undefined) {
throw new baseapi_1.RequiredError("resourceId", "getOwnershipInference");
}
// verify required parameter 'ownerType' is not null or undefined
if (ownerType === null || ownerType === undefined) {
throw new baseapi_1.RequiredError("ownerType", "getOwnershipInference");
}
// Path Params
const localVarPath = "/api/v2/csm/ownership/{resource_id}/{owner_type}"
.replace("{resource_id}", encodeURIComponent(String(resourceId)))
.replace("{owner_type}", encodeURIComponent(String(ownerType)));
// Make Request Context
const requestContext = _config
.getServer("v2.CSMOwnershipApi.getOwnershipInference")
.makeRequestContext(localVarPath, http_1.HttpMethod.GET);
requestContext.setHeaderParam("Accept", "application/json");
requestContext.setHttpConfig(_config.httpConfig);
// Header Params
if (ifNoneMatch !== undefined) {
requestContext.setHeaderParam("If-None-Match", ObjectSerializer_1.ObjectSerializer.serialize(ifNoneMatch, "string", ""));
}
// Apply auth methods
(0, configuration_1.applySecurityAuthentication)(_config, requestContext, [
"apiKeyAuth",
"appKeyAuth",
]);
return requestContext;
});
}
listOwnershipHistory(resourceId, cursor, limit, _options) {
return __awaiter(this, void 0, void 0, function* () {
const _config = _options || this.configuration;
logger_1.logger.warn("Using unstable operation 'listOwnershipHistory'");
if (!_config.unstableOperations["v2.listOwnershipHistory"]) {
throw new Error("Unstable operation 'listOwnershipHistory' is disabled");
}
// verify required parameter 'resourceId' is not null or undefined
if (resourceId === null || resourceId === undefined) {
throw new baseapi_1.RequiredError("resourceId", "listOwnershipHistory");
}
// Path Params
const localVarPath = "/api/v2/csm/ownership/{resource_id}/history".replace("{resource_id}", encodeURIComponent(String(resourceId)));
// Make Request Context
const requestContext = _config
.getServer("v2.CSMOwnershipApi.listOwnershipHistory")
.makeRequestContext(localVarPath, http_1.HttpMethod.GET);
requestContext.setHeaderParam("Accept", "application/json");
requestContext.setHttpConfig(_config.httpConfig);
// Query Params
if (cursor !== undefined) {
requestContext.setQueryParam("cursor", ObjectSerializer_1.ObjectSerializer.serialize(cursor, "string", ""), "");
}
if (limit !== undefined) {
requestContext.setQueryParam("limit", ObjectSerializer_1.ObjectSerializer.serialize(limit, "number", "int32"), "");
}
// Apply auth methods
(0, configuration_1.applySecurityAuthentication)(_config, requestContext, [
"apiKeyAuth",
"appKeyAuth",
]);
return requestContext;
});
}
listOwnershipHistoryByOwnerType(resourceId, ownerType, cursor, limit, _options) {
return __awaiter(this, void 0, void 0, function* () {
const _config = _options || this.configuration;
logger_1.logger.warn("Using unstable operation 'listOwnershipHistoryByOwnerType'");
if (!_config.unstableOperations["v2.listOwnershipHistoryByOwnerType"]) {
throw new Error("Unstable operation 'listOwnershipHistoryByOwnerType' is disabled");
}
// verify required parameter 'resourceId' is not null or undefined
if (resourceId === null || resourceId === undefined) {
throw new baseapi_1.RequiredError("resourceId", "listOwnershipHistoryByOwnerType");
}
// verify required parameter 'ownerType' is not null or undefined
if (ownerType === null || ownerType === undefined) {
throw new baseapi_1.RequiredError("ownerType", "listOwnershipHistoryByOwnerType");
}
// Path Params
const localVarPath = "/api/v2/csm/ownership/{resource_id}/{owner_type}/history"
.replace("{resource_id}", encodeURIComponent(String(resourceId)))
.replace("{owner_type}", encodeURIComponent(String(ownerType)));
// Make Request Context
const requestContext = _config
.getServer("v2.CSMOwnershipApi.listOwnershipHistoryByOwnerType")
.makeRequestContext(localVarPath, http_1.HttpMethod.GET);
requestContext.setHeaderParam("Accept", "application/json");
requestContext.setHttpConfig(_config.httpConfig);
// Query Params
if (cursor !== undefined) {
requestContext.setQueryParam("cursor", ObjectSerializer_1.ObjectSerializer.serialize(cursor, "string", ""), "");
}
if (limit !== undefined) {
requestContext.setQueryParam("limit", ObjectSerializer_1.ObjectSerializer.serialize(limit, "number", "int32"), "");
}
// Apply auth methods
(0, configuration_1.applySecurityAuthentication)(_config, requestContext, [
"apiKeyAuth",
"appKeyAuth",
]);
return requestContext;
});
}
listOwnershipInferences(resourceId, _options) {
return __awaiter(this, void 0, void 0, function* () {
const _config = _options || this.configuration;
logger_1.logger.warn("Using unstable operation 'listOwnershipInferences'");
if (!_config.unstableOperations["v2.listOwnershipInferences"]) {
throw new Error("Unstable operation 'listOwnershipInferences' is disabled");
}
// verify required parameter 'resourceId' is not null or undefined
if (resourceId === null || resourceId === undefined) {
throw new baseapi_1.RequiredError("resourceId", "listOwnershipInferences");
}
// Path Params
const localVarPath = "/api/v2/csm/ownership/{resource_id}".replace("{resource_id}", encodeURIComponent(String(resourceId)));
// Make Request Context
const requestContext = _config
.getServer("v2.CSMOwnershipApi.listOwnershipInferences")
.makeRequestContext(localVarPath, http_1.HttpMethod.GET);
requestContext.setHeaderParam("Accept", "application/json");
requestContext.setHttpConfig(_config.httpConfig);
// Apply auth methods
(0, configuration_1.applySecurityAuthentication)(_config, requestContext, [
"apiKeyAuth",
"appKeyAuth",
]);
return requestContext;
});
}
}
exports.CSMOwnershipApiRequestFactory = CSMOwnershipApiRequestFactory;
class CSMOwnershipApiResponseProcessor {
/**
* 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 createOwnershipFeedback
* @throws ApiException if the response code was not in [200, 299]
*/
createOwnershipFeedback(response) {
return __awaiter(this, void 0, void 0, function* () {
const contentType = ObjectSerializer_1.ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
if (response.httpStatusCode === 201) {
const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(yield response.body.text(), contentType), "OwnershipFeedbackResponse");
return body;
}
if (response.httpStatusCode === 400 ||
response.httpStatusCode === 401 ||
response.httpStatusCode === 404) {
const bodyText = ObjectSerializer_1.ObjectSerializer.parse(yield response.body.text(), contentType);
let body;
try {
body = ObjectSerializer_1.ObjectSerializer.deserialize(bodyText, "JSONAPIErrorResponse");
}
catch (error) {
logger_1.logger.debug(`Got error deserializing error: ${error}`);
throw new exception_1.ApiException(response.httpStatusCode, bodyText);
}
throw new exception_1.ApiException(response.httpStatusCode, body);
}
if (response.httpStatusCode === 409) {
const bodyText = ObjectSerializer_1.ObjectSerializer.parse(yield response.body.text(), contentType);
let body;
try {
body = ObjectSerializer_1.ObjectSerializer.deserialize(bodyText, "OwnershipInferenceResponse");
}
catch (error) {
logger_1.logger.debug(`Got error deserializing error: ${error}`);
throw new exception_1.ApiException(response.httpStatusCode, bodyText);
}
throw new exception_1.ApiException(response.httpStatusCode, body);
}
if (response.httpStatusCode === 429) {
const bodyText = ObjectSerializer_1.ObjectSerializer.parse(yield response.body.text(), contentType);
let body;
try {
body = ObjectSerializer_1.ObjectSerializer.deserialize(bodyText, "APIErrorResponse");
}
catch (error) {
logger_1.logger.debug(`Got error deserializing error: ${error}`);
throw new exception_1.ApiException(response.httpStatusCode, bodyText);
}
throw new exception_1.ApiException(response.httpStatusCode, body);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(yield response.body.text(), contentType), "OwnershipFeedbackResponse", "");
return body;
}
const body = (yield response.body.text()) || "";
throw new exception_1.ApiException(response.httpStatusCode, 'Unknown API Status Code!\nBody: "' + body + '"');
});
}
/**
* 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 getOwnershipEvidence
* @throws ApiException if the response code was not in [200, 299]
*/
getOwnershipEvidence(response) {
return __awaiter(this, void 0, void 0, function* () {
const contentType = ObjectSerializer_1.ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
if (response.httpStatusCode === 200) {
const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(yield response.body.text(), contentType), "OwnershipEvidenceResponse");
return body;
}
if (response.httpStatusCode === 400 ||
response.httpStatusCode === 401 ||
response.httpStatusCode === 404) {
const bodyText = ObjectSerializer_1.ObjectSerializer.parse(yield response.body.text(), contentType);
let body;
try {
body = ObjectSerializer_1.ObjectSerializer.deserialize(bodyText, "JSONAPIErrorResponse");
}
catch (error) {
logger_1.logger.debug(`Got error deserializing error: ${error}`);
throw new exception_1.ApiException(response.httpStatusCode, bodyText);
}
throw new exception_1.ApiException(response.httpStatusCode, body);
}
if (response.httpStatusCode === 429) {
const bodyText = ObjectSerializer_1.ObjectSerializer.parse(yield response.body.text(), contentType);
let body;
try {
body = ObjectSerializer_1.ObjectSerializer.deserialize(bodyText, "APIErrorResponse");
}
catch (error) {
logger_1.logger.debug(`Got error deserializing error: ${error}`);
throw new exception_1.ApiException(response.httpStatusCode, bodyText);
}
throw new exception_1.ApiException(response.httpStatusCode, body);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(yield response.body.text(), contentType), "OwnershipEvidenceResponse", "");
return body;
}
const body = (yield response.body.text()) || "";
throw new exception_1.ApiException(response.httpStatusCode, 'Unknown API Status Code!\nBody: "' + body + '"');
});
}
/**
* 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 getOwnershipInference
* @throws ApiException if the response code was not in [200, 299]
*/
getOwnershipInference(response) {
return __awaiter(this, void 0, void 0, function* () {
const contentType = ObjectSerializer_1.ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
if (response.httpStatusCode === 200) {
const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(yield response.body.text(), contentType), "OwnershipInferenceResponse");
return body;
}
if (response.httpStatusCode === 400 ||
response.httpStatusCode === 401 ||
response.httpStatusCode === 404) {
const bodyText = ObjectSerializer_1.ObjectSerializer.parse(yield response.body.text(), contentType);
let body;
try {
body = ObjectSerializer_1.ObjectSerializer.deserialize(bodyText, "JSONAPIErrorResponse");
}
catch (error) {
logger_1.logger.debug(`Got error deserializing error: ${error}`);
throw new exception_1.ApiException(response.httpStatusCode, bodyText);
}
throw new exception_1.ApiException(response.httpStatusCode, body);
}
if (response.httpStatusCode === 429) {
const bodyText = ObjectSerializer_1.ObjectSerializer.parse(yield response.body.text(), contentType);
let body;
try {
body = ObjectSerializer_1.ObjectSerializer.deserialize(bodyText, "APIErrorResponse");
}
catch (error) {
logger_1.logger.debug(`Got error deserializing error: ${error}`);
throw new exception_1.ApiException(response.httpStatusCode, bodyText);
}
throw new exception_1.ApiException(response.httpStatusCode, body);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(yield response.body.text(), contentType), "OwnershipInferenceResponse", "");
return body;
}
const body = (yield response.body.text()) || "";
throw new exception_1.ApiException(response.httpStatusCode, 'Unknown API Status Code!\nBody: "' + body + '"');
});
}
/**
* 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 listOwnershipHistory
* @throws ApiException if the response code was not in [200, 299]
*/
listOwnershipHistory(response) {
return __awaiter(this, void 0, void 0, function* () {
const contentType = ObjectSerializer_1.ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
if (response.httpStatusCode === 200) {
const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(yield response.body.text(), contentType), "OwnershipHistoryResponse");
return body;
}
if (response.httpStatusCode === 400 || response.httpStatusCode === 401) {
const bodyText = ObjectSerializer_1.ObjectSerializer.parse(yield response.body.text(), contentType);
let body;
try {
body = ObjectSerializer_1.ObjectSerializer.deserialize(bodyText, "JSONAPIErrorResponse");
}
catch (error) {
logger_1.logger.debug(`Got error deserializing error: ${error}`);
throw new exception_1.ApiException(response.httpStatusCode, bodyText);
}
throw new exception_1.ApiException(response.httpStatusCode, body);
}
if (response.httpStatusCode === 429) {
const bodyText = ObjectSerializer_1.ObjectSerializer.parse(yield response.body.text(), contentType);
let body;
try {
body = ObjectSerializer_1.ObjectSerializer.deserialize(bodyText, "APIErrorResponse");
}
catch (error) {
logger_1.logger.debug(`Got error deserializing error: ${error}`);
throw new exception_1.ApiException(response.httpStatusCode, bodyText);
}
throw new exception_1.ApiException(response.httpStatusCode, body);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(yield response.body.text(), contentType), "OwnershipHistoryResponse", "");
return body;
}
const body = (yield response.body.text()) || "";
throw new exception_1.ApiException(response.httpStatusCode, 'Unknown API Status Code!\nBody: "' + body + '"');
});
}
/**
* 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 listOwnershipHistoryByOwnerType
* @throws ApiException if the response code was not in [200, 299]
*/
listOwnershipHistoryByOwnerType(response) {
return __awaiter(this, void 0, void 0, function* () {
const contentType = ObjectSerializer_1.ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
if (response.httpStatusCode === 200) {
const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(yield response.body.text(), contentType), "OwnershipHistoryResponse");
return body;
}
if (response.httpStatusCode === 400 || response.httpStatusCode === 401) {
const bodyText = ObjectSerializer_1.ObjectSerializer.parse(yield response.body.text(), contentType);
let body;
try {
body = ObjectSerializer_1.ObjectSerializer.deserialize(bodyText, "JSONAPIErrorResponse");
}
catch (error) {
logger_1.logger.debug(`Got error deserializing error: ${error}`);
throw new exception_1.ApiException(response.httpStatusCode, bodyText);
}
throw new exception_1.ApiException(response.httpStatusCode, body);
}
if (response.httpStatusCode === 429) {
const bodyText = ObjectSerializer_1.ObjectSerializer.parse(yield response.body.text(), contentType);
let body;
try {
body = ObjectSerializer_1.ObjectSerializer.deserialize(bodyText, "APIErrorResponse");
}
catch (error) {
logger_1.logger.debug(`Got error deserializing error: ${error}`);
throw new exception_1.ApiException(response.httpStatusCode, bodyText);
}
throw new exception_1.ApiException(response.httpStatusCode, body);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(yield response.body.text(), contentType), "OwnershipHistoryResponse", "");
return body;
}
const body = (yield response.body.text()) || "";
throw new exception_1.ApiException(response.httpStatusCode, 'Unknown API Status Code!\nBody: "' + body + '"');
});
}
/**
* 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 listOwnershipInferences
* @throws ApiException if the response code was not in [200, 299]
*/
listOwnershipInferences(response) {
return __awaiter(this, void 0, void 0, function* () {
const contentType = ObjectSerializer_1.ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
if (response.httpStatusCode === 200) {
const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(yield response.body.text(), contentType), "OwnershipInferenceListResponse");
return body;
}
if (response.httpStatusCode === 400 ||
response.httpStatusCode === 401 ||
response.httpStatusCode === 404) {
const bodyText = ObjectSerializer_1.ObjectSerializer.parse(yield response.body.text(), contentType);
let body;
try {
body = ObjectSerializer_1.ObjectSerializer.deserialize(bodyText, "JSONAPIErrorResponse");
}
catch (error) {
logger_1.logger.debug(`Got error deserializing error: ${error}`);
throw new exception_1.ApiException(response.httpStatusCode, bodyText);
}
throw new exception_1.ApiException(response.httpStatusCode, body);
}
if (response.httpStatusCode === 429) {
const bodyText = ObjectSerializer_1.ObjectSerializer.parse(yield response.body.text(), contentType);
let body;
try {
body = ObjectSerializer_1.ObjectSerializer.deserialize(bodyText, "APIErrorResponse");
}
catch (error) {
logger_1.logger.debug(`Got error deserializing error: ${error}`);
throw new exception_1.ApiException(response.httpStatusCode, bodyText);
}
throw new exception_1.ApiException(response.httpStatusCode, body);
}
// Work around for missing responses in specification, e.g. for petstore.yaml
if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
const body = ObjectSerializer_1.ObjectSerializer.deserialize(ObjectSerializer_1.ObjectSerializer.parse(yield response.body.text(), contentType), "OwnershipInferenceListResponse", "");
return body;
}
const body = (yield response.body.text()) || "";
throw new exception_1.ApiException(response.httpStatusCode, 'Unknown API Status Code!\nBody: "' + body + '"');
});
}
}
exports.CSMOwnershipApiResponseProcessor = CSMOwnershipApiResponseProcessor;
class CSMOwnershipApi {
constructor(configuration, requestFactory, responseProcessor) {
this.configuration = configuration;
this.requestFactory =
requestFactory || new CSMOwnershipApiRequestFactory(configuration);
this.responseProcessor =
responseProcessor || new CSMOwnershipApiResponseProcessor();
}
/**
* Submit feedback on the current ownership inference for a resource and owner type. Valid actions are `confirm`, `reject`, `correct`, and `persist`.
*
* The request must include the current inference `checksum` in `inference_checksum`. If the checksum does not match the current inference state, the endpoint returns `409 Conflict`.
*
* When `action` is `correct`, `corrected_owner_handle` and `corrected_owner_type` are required.
* @param param The request object
*/
createOwnershipFeedback(param, options) {
const requestContextPromise = this.requestFactory.createOwnershipFeedback(param.resourceId, param.ownerType, param.body, options);
return requestContextPromise.then((requestContext) => {
return this.configuration.httpApi
.send(requestContext)
.then((responseContext) => {
return this.responseProcessor.createOwnershipFeedback(responseContext);
});
});
}
/**
* Get the evidence versions backing the current ownership inference for a resource and owner type.
*
* This endpoint supports weak ETag caching. Pass the previously returned `ETag` value in the `If-None-Match` request header to receive a `304 Not Modified` response when the evidence has not changed.
* @param param The request object
*/
getOwnershipEvidence(param, options) {
const requestContextPromise = this.requestFactory.getOwnershipEvidence(param.resourceId, param.ownerType, param.ifNoneMatch, options);
return requestContextPromise.then((requestContext) => {
return this.configuration.httpApi
.send(requestContext)
.then((responseContext) => {
return this.responseProcessor.getOwnershipEvidence(responseContext);
});
});
}
/**
* Get the current ownership inference for a resource for a specific owner type.
*
* This endpoint supports ETag-based caching. Pass the previously returned `ETag` value in the `If-None-Match` request header to receive a `304 Not Modified` response when the inference has not changed.
* @param param The request object
*/
getOwnershipInference(param, options) {
const requestContextPromise = this.requestFactory.getOwnershipInference(param.resourceId, param.ownerType, param.ifNoneMatch, options);
return requestContextPromise.then((requestContext) => {
return this.configuration.httpApi
.send(requestContext)
.then((responseContext) => {
return this.responseProcessor.getOwnershipInference(responseContext);
});
});
}
/**
* List inference history entries for a resource across all owner types, ordered from most recent to oldest. Uses cursor-based pagination.
* @param param The request object
*/
listOwnershipHistory(param, options) {
const requestContextPromise = this.requestFactory.listOwnershipHistory(param.resourceId, param.cursor, param.limit, options);
return requestContextPromise.then((requestContext) => {
return this.configuration.httpApi
.send(requestContext)
.then((responseContext) => {
return this.responseProcessor.listOwnershipHistory(responseContext);
});
});
}
/**
* List inference history entries for a resource filtered by owner type, ordered from most recent to oldest. Uses cursor-based pagination.
* @param param The request object
*/
listOwnershipHistoryByOwnerType(param, options) {
const requestContextPromise = this.requestFactory.listOwnershipHistoryByOwnerType(param.resourceId, param.ownerType, param.cursor, param.limit, options);
return requestContextPromise.then((requestContext) => {
return this.configuration.httpApi
.send(requestContext)
.then((responseContext) => {
return this.responseProcessor.listOwnershipHistoryByOwnerType(responseContext);
});
});
}
/**
* Get all current ownership inferences for a resource, one per owner type (`user`, `team`, `service`, `unknown`).
* @param param The request object
*/
listOwnershipInferences(param, options) {
const requestContextPromise = this.requestFactory.listOwnershipInferences(param.resourceId, options);
return requestContextPromise.then((requestContext) => {
return this.configuration.httpApi
.send(requestContext)
.then((responseContext) => {
return this.responseProcessor.listOwnershipInferences(responseContext);
});
});
}
}
exports.CSMOwnershipApi = CSMOwnershipApi;
//# sourceMappingURL=CSMOwnershipApi.js.map