@datadog/datadog-api-client
Version:
OpenAPI client for Datadog APIs
645 lines • 35.6 kB
JavaScript
"use strict";
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.TagPoliciesApi = exports.TagPoliciesApiResponseProcessor = exports.TagPoliciesApiRequestFactory = 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 TagPoliciesApiRequestFactory extends baseapi_1.BaseAPIRequestFactory {
createTagPolicy(body, _options) {
return __awaiter(this, void 0, void 0, function* () {
const _config = _options || this.configuration;
logger_1.logger.warn("Using unstable operation 'createTagPolicy'");
if (!_config.unstableOperations["v2.createTagPolicy"]) {
throw new Error("Unstable operation 'createTagPolicy' is disabled");
}
// verify required parameter 'body' is not null or undefined
if (body === null || body === undefined) {
throw new baseapi_1.RequiredError("body", "createTagPolicy");
}
// Path Params
const localVarPath = "/api/v2/tag-policies";
// Make Request Context
const requestContext = _config
.getServer("v2.TagPoliciesApi.createTagPolicy")
.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, "TagPolicyCreateRequest", ""), contentType);
requestContext.setBody(serializedBody);
// Apply auth methods
(0, configuration_1.applySecurityAuthentication)(_config, requestContext, [
"apiKeyAuth",
"appKeyAuth",
]);
return requestContext;
});
}
deleteTagPolicy(policyId, hardDelete, _options) {
return __awaiter(this, void 0, void 0, function* () {
const _config = _options || this.configuration;
logger_1.logger.warn("Using unstable operation 'deleteTagPolicy'");
if (!_config.unstableOperations["v2.deleteTagPolicy"]) {
throw new Error("Unstable operation 'deleteTagPolicy' is disabled");
}
// verify required parameter 'policyId' is not null or undefined
if (policyId === null || policyId === undefined) {
throw new baseapi_1.RequiredError("policyId", "deleteTagPolicy");
}
// Path Params
const localVarPath = "/api/v2/tag-policies/{policy_id}".replace("{policy_id}", encodeURIComponent(String(policyId)));
// Make Request Context
const requestContext = _config
.getServer("v2.TagPoliciesApi.deleteTagPolicy")
.makeRequestContext(localVarPath, http_1.HttpMethod.DELETE);
requestContext.setHeaderParam("Accept", "*/*");
requestContext.setHttpConfig(_config.httpConfig);
// Query Params
if (hardDelete !== undefined) {
requestContext.setQueryParam("hard_delete", ObjectSerializer_1.ObjectSerializer.serialize(hardDelete, "boolean", ""), "");
}
// Apply auth methods
(0, configuration_1.applySecurityAuthentication)(_config, requestContext, [
"apiKeyAuth",
"appKeyAuth",
]);
return requestContext;
});
}
getTagPolicy(policyId, include, tsStart, tsEnd, _options) {
return __awaiter(this, void 0, void 0, function* () {
const _config = _options || this.configuration;
logger_1.logger.warn("Using unstable operation 'getTagPolicy'");
if (!_config.unstableOperations["v2.getTagPolicy"]) {
throw new Error("Unstable operation 'getTagPolicy' is disabled");
}
// verify required parameter 'policyId' is not null or undefined
if (policyId === null || policyId === undefined) {
throw new baseapi_1.RequiredError("policyId", "getTagPolicy");
}
// Path Params
const localVarPath = "/api/v2/tag-policies/{policy_id}".replace("{policy_id}", encodeURIComponent(String(policyId)));
// Make Request Context
const requestContext = _config
.getServer("v2.TagPoliciesApi.getTagPolicy")
.makeRequestContext(localVarPath, http_1.HttpMethod.GET);
requestContext.setHeaderParam("Accept", "application/json");
requestContext.setHttpConfig(_config.httpConfig);
// Query Params
if (include !== undefined) {
requestContext.setQueryParam("include", ObjectSerializer_1.ObjectSerializer.serialize(include, "TagPolicyInclude", ""), "");
}
if (tsStart !== undefined) {
requestContext.setQueryParam("ts_start", ObjectSerializer_1.ObjectSerializer.serialize(tsStart, "number", "int64"), "");
}
if (tsEnd !== undefined) {
requestContext.setQueryParam("ts_end", ObjectSerializer_1.ObjectSerializer.serialize(tsEnd, "number", "int64"), "");
}
// Apply auth methods
(0, configuration_1.applySecurityAuthentication)(_config, requestContext, [
"apiKeyAuth",
"appKeyAuth",
]);
return requestContext;
});
}
getTagPolicyScore(policyId, tsStart, tsEnd, _options) {
return __awaiter(this, void 0, void 0, function* () {
const _config = _options || this.configuration;
logger_1.logger.warn("Using unstable operation 'getTagPolicyScore'");
if (!_config.unstableOperations["v2.getTagPolicyScore"]) {
throw new Error("Unstable operation 'getTagPolicyScore' is disabled");
}
// verify required parameter 'policyId' is not null or undefined
if (policyId === null || policyId === undefined) {
throw new baseapi_1.RequiredError("policyId", "getTagPolicyScore");
}
// Path Params
const localVarPath = "/api/v2/tag-policies/{policy_id}/score".replace("{policy_id}", encodeURIComponent(String(policyId)));
// Make Request Context
const requestContext = _config
.getServer("v2.TagPoliciesApi.getTagPolicyScore")
.makeRequestContext(localVarPath, http_1.HttpMethod.GET);
requestContext.setHeaderParam("Accept", "application/json");
requestContext.setHttpConfig(_config.httpConfig);
// Query Params
if (tsStart !== undefined) {
requestContext.setQueryParam("ts_start", ObjectSerializer_1.ObjectSerializer.serialize(tsStart, "number", "int64"), "");
}
if (tsEnd !== undefined) {
requestContext.setQueryParam("ts_end", ObjectSerializer_1.ObjectSerializer.serialize(tsEnd, "number", "int64"), "");
}
// Apply auth methods
(0, configuration_1.applySecurityAuthentication)(_config, requestContext, [
"apiKeyAuth",
"appKeyAuth",
]);
return requestContext;
});
}
listTagPolicies(includeDisabled, includeDeleted, include, filterSource, tsStart, tsEnd, _options) {
return __awaiter(this, void 0, void 0, function* () {
const _config = _options || this.configuration;
logger_1.logger.warn("Using unstable operation 'listTagPolicies'");
if (!_config.unstableOperations["v2.listTagPolicies"]) {
throw new Error("Unstable operation 'listTagPolicies' is disabled");
}
// Path Params
const localVarPath = "/api/v2/tag-policies";
// Make Request Context
const requestContext = _config
.getServer("v2.TagPoliciesApi.listTagPolicies")
.makeRequestContext(localVarPath, http_1.HttpMethod.GET);
requestContext.setHeaderParam("Accept", "application/json");
requestContext.setHttpConfig(_config.httpConfig);
// Query Params
if (includeDisabled !== undefined) {
requestContext.setQueryParam("include_disabled", ObjectSerializer_1.ObjectSerializer.serialize(includeDisabled, "boolean", ""), "");
}
if (includeDeleted !== undefined) {
requestContext.setQueryParam("include_deleted", ObjectSerializer_1.ObjectSerializer.serialize(includeDeleted, "boolean", ""), "");
}
if (include !== undefined) {
requestContext.setQueryParam("include", ObjectSerializer_1.ObjectSerializer.serialize(include, "TagPolicyInclude", ""), "");
}
if (filterSource !== undefined) {
requestContext.setQueryParam("filter[source]", ObjectSerializer_1.ObjectSerializer.serialize(filterSource, "TagPolicySource", ""), "");
}
if (tsStart !== undefined) {
requestContext.setQueryParam("ts_start", ObjectSerializer_1.ObjectSerializer.serialize(tsStart, "number", "int64"), "");
}
if (tsEnd !== undefined) {
requestContext.setQueryParam("ts_end", ObjectSerializer_1.ObjectSerializer.serialize(tsEnd, "number", "int64"), "");
}
// Apply auth methods
(0, configuration_1.applySecurityAuthentication)(_config, requestContext, [
"apiKeyAuth",
"appKeyAuth",
]);
return requestContext;
});
}
updateTagPolicy(policyId, body, _options) {
return __awaiter(this, void 0, void 0, function* () {
const _config = _options || this.configuration;
logger_1.logger.warn("Using unstable operation 'updateTagPolicy'");
if (!_config.unstableOperations["v2.updateTagPolicy"]) {
throw new Error("Unstable operation 'updateTagPolicy' is disabled");
}
// verify required parameter 'policyId' is not null or undefined
if (policyId === null || policyId === undefined) {
throw new baseapi_1.RequiredError("policyId", "updateTagPolicy");
}
// verify required parameter 'body' is not null or undefined
if (body === null || body === undefined) {
throw new baseapi_1.RequiredError("body", "updateTagPolicy");
}
// Path Params
const localVarPath = "/api/v2/tag-policies/{policy_id}".replace("{policy_id}", encodeURIComponent(String(policyId)));
// Make Request Context
const requestContext = _config
.getServer("v2.TagPoliciesApi.updateTagPolicy")
.makeRequestContext(localVarPath, http_1.HttpMethod.PATCH);
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, "TagPolicyUpdateRequest", ""), contentType);
requestContext.setBody(serializedBody);
// Apply auth methods
(0, configuration_1.applySecurityAuthentication)(_config, requestContext, [
"apiKeyAuth",
"appKeyAuth",
]);
return requestContext;
});
}
}
exports.TagPoliciesApiRequestFactory = TagPoliciesApiRequestFactory;
class TagPoliciesApiResponseProcessor {
/**
* 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 createTagPolicy
* @throws ApiException if the response code was not in [200, 299]
*/
createTagPolicy(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), "TagPolicyResponse");
return body;
}
if (response.httpStatusCode === 400 ||
response.httpStatusCode === 401 ||
response.httpStatusCode === 403 ||
response.httpStatusCode === 409) {
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), "TagPolicyResponse", "");
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 deleteTagPolicy
* @throws ApiException if the response code was not in [200, 299]
*/
deleteTagPolicy(response) {
return __awaiter(this, void 0, void 0, function* () {
const contentType = ObjectSerializer_1.ObjectSerializer.normalizeMediaType(response.headers["content-type"]);
if (response.httpStatusCode === 204) {
return;
}
if (response.httpStatusCode === 400 ||
response.httpStatusCode === 401 ||
response.httpStatusCode === 403 ||
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) {
return;
}
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 getTagPolicy
* @throws ApiException if the response code was not in [200, 299]
*/
getTagPolicy(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), "TagPolicyResponse");
return body;
}
if (response.httpStatusCode === 400 ||
response.httpStatusCode === 401 ||
response.httpStatusCode === 403 ||
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), "TagPolicyResponse", "");
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 getTagPolicyScore
* @throws ApiException if the response code was not in [200, 299]
*/
getTagPolicyScore(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), "TagPolicyScoreResponse");
return body;
}
if (response.httpStatusCode === 400 ||
response.httpStatusCode === 401 ||
response.httpStatusCode === 403 ||
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), "TagPolicyScoreResponse", "");
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 listTagPolicies
* @throws ApiException if the response code was not in [200, 299]
*/
listTagPolicies(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), "TagPoliciesListResponse");
return body;
}
if (response.httpStatusCode === 400 ||
response.httpStatusCode === 401 ||
response.httpStatusCode === 403) {
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), "TagPoliciesListResponse", "");
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 updateTagPolicy
* @throws ApiException if the response code was not in [200, 299]
*/
updateTagPolicy(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), "TagPolicyResponse");
return body;
}
if (response.httpStatusCode === 400 ||
response.httpStatusCode === 401 ||
response.httpStatusCode === 403 ||
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), "TagPolicyResponse", "");
return body;
}
const body = (yield response.body.text()) || "";
throw new exception_1.ApiException(response.httpStatusCode, 'Unknown API Status Code!\nBody: "' + body + '"');
});
}
}
exports.TagPoliciesApiResponseProcessor = TagPoliciesApiResponseProcessor;
class TagPoliciesApi {
constructor(configuration, requestFactory, responseProcessor) {
this.configuration = configuration;
this.requestFactory =
requestFactory || new TagPoliciesApiRequestFactory(configuration);
this.responseProcessor =
responseProcessor || new TagPoliciesApiResponseProcessor();
}
/**
* Create a new tag policy for the organization. The caller's organization is derived from
* the authenticated user; cross-organization creation is not supported. Fields such as
* `policy_id`, `version`, and the timestamp/audit fields are assigned by the server.
* @param param The request object
*/
createTagPolicy(param, options) {
const requestContextPromise = this.requestFactory.createTagPolicy(param.body, options);
return requestContextPromise.then((requestContext) => {
return this.configuration.httpApi
.send(requestContext)
.then((responseContext) => {
return this.responseProcessor.createTagPolicy(responseContext);
});
});
}
/**
* Delete a tag policy. By default the policy is soft-deleted so it can be recovered later
* and so that historical score data remains queryable. Pass `hard_delete=true` to remove
* the policy permanently.
* @param param The request object
*/
deleteTagPolicy(param, options) {
const requestContextPromise = this.requestFactory.deleteTagPolicy(param.policyId, param.hardDelete, options);
return requestContextPromise.then((requestContext) => {
return this.configuration.httpApi
.send(requestContext)
.then((responseContext) => {
return this.responseProcessor.deleteTagPolicy(responseContext);
});
});
}
/**
* Retrieve a single tag policy by ID. Optionally include the policy's current compliance
* score via the `include=score` query parameter. Policies belonging to other organizations
* cannot be retrieved.
* @param param The request object
*/
getTagPolicy(param, options) {
const requestContextPromise = this.requestFactory.getTagPolicy(param.policyId, param.include, param.tsStart, param.tsEnd, options);
return requestContextPromise.then((requestContext) => {
return this.configuration.httpApi
.send(requestContext)
.then((responseContext) => {
return this.responseProcessor.getTagPolicy(responseContext);
});
});
}
/**
* Retrieve the compliance score for a single tag policy. The score is computed over the
* requested time window (or a source-appropriate default) and represents the percentage of
* telemetry within that window that conforms to the policy. A `null` score indicates that
* no relevant telemetry was found.
* @param param The request object
*/
getTagPolicyScore(param, options) {
const requestContextPromise = this.requestFactory.getTagPolicyScore(param.policyId, param.tsStart, param.tsEnd, options);
return requestContextPromise.then((requestContext) => {
return this.configuration.httpApi
.send(requestContext)
.then((responseContext) => {
return this.responseProcessor.getTagPolicyScore(responseContext);
});
});
}
/**
* Retrieve all tag policies for the organization. Optionally include disabled or deleted
* policies, filter by telemetry source, and include each policy's current compliance score
* via the `include=score` query parameter.
* @param param The request object
*/
listTagPolicies(param = {}, options) {
const requestContextPromise = this.requestFactory.listTagPolicies(param.includeDisabled, param.includeDeleted, param.include, param.filterSource, param.tsStart, param.tsEnd, options);
return requestContextPromise.then((requestContext) => {
return this.configuration.httpApi
.send(requestContext)
.then((responseContext) => {
return this.responseProcessor.listTagPolicies(responseContext);
});
});
}
/**
* Update one or more attributes of an existing tag policy. Only the fields supplied in the
* request body are modified; omitted fields retain their current values. The policy's
* `source` cannot be changed after creation.
* @param param The request object
*/
updateTagPolicy(param, options) {
const requestContextPromise = this.requestFactory.updateTagPolicy(param.policyId, param.body, options);
return requestContextPromise.then((requestContext) => {
return this.configuration.httpApi
.send(requestContext)
.then((responseContext) => {
return this.responseProcessor.updateTagPolicy(responseContext);
});
});
}
}
exports.TagPoliciesApi = TagPoliciesApi;
//# sourceMappingURL=TagPoliciesApi.js.map