UNPKG

@datadog/datadog-api-client

Version:

OpenAPI client for Datadog APIs

822 lines 43.9 kB
"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.LogsArchivesApi = exports.LogsArchivesApiResponseProcessor = exports.LogsArchivesApiRequestFactory = 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 LogsArchivesApiRequestFactory extends baseapi_1.BaseAPIRequestFactory { addReadRoleToArchive(archiveId, body, _options) { return __awaiter(this, void 0, void 0, function* () { const _config = _options || this.configuration; // verify required parameter 'archiveId' is not null or undefined if (archiveId === null || archiveId === undefined) { throw new baseapi_1.RequiredError("archiveId", "addReadRoleToArchive"); } // verify required parameter 'body' is not null or undefined if (body === null || body === undefined) { throw new baseapi_1.RequiredError("body", "addReadRoleToArchive"); } // Path Params const localVarPath = "/api/v2/logs/config/archives/{archive_id}/readers".replace("{archive_id}", encodeURIComponent(String(archiveId))); // Make Request Context const requestContext = _config .getServer("v2.LogsArchivesApi.addReadRoleToArchive") .makeRequestContext(localVarPath, http_1.HttpMethod.POST); requestContext.setHeaderParam("Accept", "*/*"); 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, "RelationshipToRole", ""), contentType); requestContext.setBody(serializedBody); // Apply auth methods (0, configuration_1.applySecurityAuthentication)(_config, requestContext, [ "apiKeyAuth", "appKeyAuth", ]); return requestContext; }); } createLogsArchive(body, _options) { return __awaiter(this, void 0, void 0, function* () { const _config = _options || this.configuration; // verify required parameter 'body' is not null or undefined if (body === null || body === undefined) { throw new baseapi_1.RequiredError("body", "createLogsArchive"); } // Path Params const localVarPath = "/api/v2/logs/config/archives"; // Make Request Context const requestContext = _config .getServer("v2.LogsArchivesApi.createLogsArchive") .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, "LogsArchiveCreateRequest", ""), contentType); requestContext.setBody(serializedBody); // Apply auth methods (0, configuration_1.applySecurityAuthentication)(_config, requestContext, [ "apiKeyAuth", "appKeyAuth", ]); return requestContext; }); } deleteLogsArchive(archiveId, _options) { return __awaiter(this, void 0, void 0, function* () { const _config = _options || this.configuration; // verify required parameter 'archiveId' is not null or undefined if (archiveId === null || archiveId === undefined) { throw new baseapi_1.RequiredError("archiveId", "deleteLogsArchive"); } // Path Params const localVarPath = "/api/v2/logs/config/archives/{archive_id}".replace("{archive_id}", encodeURIComponent(String(archiveId))); // Make Request Context const requestContext = _config .getServer("v2.LogsArchivesApi.deleteLogsArchive") .makeRequestContext(localVarPath, http_1.HttpMethod.DELETE); requestContext.setHeaderParam("Accept", "*/*"); requestContext.setHttpConfig(_config.httpConfig); // Apply auth methods (0, configuration_1.applySecurityAuthentication)(_config, requestContext, [ "apiKeyAuth", "appKeyAuth", ]); return requestContext; }); } getLogsArchive(archiveId, _options) { return __awaiter(this, void 0, void 0, function* () { const _config = _options || this.configuration; // verify required parameter 'archiveId' is not null or undefined if (archiveId === null || archiveId === undefined) { throw new baseapi_1.RequiredError("archiveId", "getLogsArchive"); } // Path Params const localVarPath = "/api/v2/logs/config/archives/{archive_id}".replace("{archive_id}", encodeURIComponent(String(archiveId))); // Make Request Context const requestContext = _config .getServer("v2.LogsArchivesApi.getLogsArchive") .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; }); } getLogsArchiveOrder(_options) { return __awaiter(this, void 0, void 0, function* () { const _config = _options || this.configuration; // Path Params const localVarPath = "/api/v2/logs/config/archive-order"; // Make Request Context const requestContext = _config .getServer("v2.LogsArchivesApi.getLogsArchiveOrder") .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; }); } listArchiveReadRoles(archiveId, _options) { return __awaiter(this, void 0, void 0, function* () { const _config = _options || this.configuration; // verify required parameter 'archiveId' is not null or undefined if (archiveId === null || archiveId === undefined) { throw new baseapi_1.RequiredError("archiveId", "listArchiveReadRoles"); } // Path Params const localVarPath = "/api/v2/logs/config/archives/{archive_id}/readers".replace("{archive_id}", encodeURIComponent(String(archiveId))); // Make Request Context const requestContext = _config .getServer("v2.LogsArchivesApi.listArchiveReadRoles") .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; }); } listLogsArchives(_options) { return __awaiter(this, void 0, void 0, function* () { const _config = _options || this.configuration; // Path Params const localVarPath = "/api/v2/logs/config/archives"; // Make Request Context const requestContext = _config .getServer("v2.LogsArchivesApi.listLogsArchives") .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; }); } removeRoleFromArchive(archiveId, body, _options) { return __awaiter(this, void 0, void 0, function* () { const _config = _options || this.configuration; // verify required parameter 'archiveId' is not null or undefined if (archiveId === null || archiveId === undefined) { throw new baseapi_1.RequiredError("archiveId", "removeRoleFromArchive"); } // verify required parameter 'body' is not null or undefined if (body === null || body === undefined) { throw new baseapi_1.RequiredError("body", "removeRoleFromArchive"); } // Path Params const localVarPath = "/api/v2/logs/config/archives/{archive_id}/readers".replace("{archive_id}", encodeURIComponent(String(archiveId))); // Make Request Context const requestContext = _config .getServer("v2.LogsArchivesApi.removeRoleFromArchive") .makeRequestContext(localVarPath, http_1.HttpMethod.DELETE); requestContext.setHeaderParam("Accept", "*/*"); 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, "RelationshipToRole", ""), contentType); requestContext.setBody(serializedBody); // Apply auth methods (0, configuration_1.applySecurityAuthentication)(_config, requestContext, [ "apiKeyAuth", "appKeyAuth", ]); return requestContext; }); } updateLogsArchive(archiveId, body, _options) { return __awaiter(this, void 0, void 0, function* () { const _config = _options || this.configuration; // verify required parameter 'archiveId' is not null or undefined if (archiveId === null || archiveId === undefined) { throw new baseapi_1.RequiredError("archiveId", "updateLogsArchive"); } // verify required parameter 'body' is not null or undefined if (body === null || body === undefined) { throw new baseapi_1.RequiredError("body", "updateLogsArchive"); } // Path Params const localVarPath = "/api/v2/logs/config/archives/{archive_id}".replace("{archive_id}", encodeURIComponent(String(archiveId))); // Make Request Context const requestContext = _config .getServer("v2.LogsArchivesApi.updateLogsArchive") .makeRequestContext(localVarPath, http_1.HttpMethod.PUT); 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, "LogsArchiveCreateRequest", ""), contentType); requestContext.setBody(serializedBody); // Apply auth methods (0, configuration_1.applySecurityAuthentication)(_config, requestContext, [ "apiKeyAuth", "appKeyAuth", ]); return requestContext; }); } updateLogsArchiveOrder(body, _options) { return __awaiter(this, void 0, void 0, function* () { const _config = _options || this.configuration; // verify required parameter 'body' is not null or undefined if (body === null || body === undefined) { throw new baseapi_1.RequiredError("body", "updateLogsArchiveOrder"); } // Path Params const localVarPath = "/api/v2/logs/config/archive-order"; // Make Request Context const requestContext = _config .getServer("v2.LogsArchivesApi.updateLogsArchiveOrder") .makeRequestContext(localVarPath, http_1.HttpMethod.PUT); 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, "LogsArchiveOrder", ""), contentType); requestContext.setBody(serializedBody); // Apply auth methods (0, configuration_1.applySecurityAuthentication)(_config, requestContext, [ "apiKeyAuth", "appKeyAuth", ]); return requestContext; }); } } exports.LogsArchivesApiRequestFactory = LogsArchivesApiRequestFactory; class LogsArchivesApiResponseProcessor { /** * 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 addReadRoleToArchive * @throws ApiException if the response code was not in [200, 299] */ addReadRoleToArchive(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 === 403 || response.httpStatusCode === 404 || 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), "void", ""); 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 createLogsArchive * @throws ApiException if the response code was not in [200, 299] */ createLogsArchive(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), "LogsArchive"); return body; } if (response.httpStatusCode === 400 || response.httpStatusCode === 403 || 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), "LogsArchive", ""); 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 deleteLogsArchive * @throws ApiException if the response code was not in [200, 299] */ deleteLogsArchive(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 === 403 || response.httpStatusCode === 404 || 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), "void", ""); 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 getLogsArchive * @throws ApiException if the response code was not in [200, 299] */ getLogsArchive(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), "LogsArchive"); return body; } if (response.httpStatusCode === 400 || response.httpStatusCode === 403 || response.httpStatusCode === 404 || 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), "LogsArchive", ""); 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 getLogsArchiveOrder * @throws ApiException if the response code was not in [200, 299] */ getLogsArchiveOrder(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), "LogsArchiveOrder"); return body; } if (response.httpStatusCode === 403 || 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), "LogsArchiveOrder", ""); 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 listArchiveReadRoles * @throws ApiException if the response code was not in [200, 299] */ listArchiveReadRoles(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), "RolesResponse"); return body; } if (response.httpStatusCode === 400 || response.httpStatusCode === 403 || response.httpStatusCode === 404 || 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), "RolesResponse", ""); 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 listLogsArchives * @throws ApiException if the response code was not in [200, 299] */ listLogsArchives(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), "LogsArchives"); return body; } if (response.httpStatusCode === 403 || 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), "LogsArchives", ""); 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 removeRoleFromArchive * @throws ApiException if the response code was not in [200, 299] */ removeRoleFromArchive(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 === 403 || response.httpStatusCode === 404 || 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), "void", ""); 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 updateLogsArchive * @throws ApiException if the response code was not in [200, 299] */ updateLogsArchive(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), "LogsArchive"); return body; } if (response.httpStatusCode === 400 || response.httpStatusCode === 403 || response.httpStatusCode === 404 || 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), "LogsArchive", ""); 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 updateLogsArchiveOrder * @throws ApiException if the response code was not in [200, 299] */ updateLogsArchiveOrder(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), "LogsArchiveOrder"); return body; } if (response.httpStatusCode === 400 || response.httpStatusCode === 403 || response.httpStatusCode === 422 || 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), "LogsArchiveOrder", ""); return body; } const body = (yield response.body.text()) || ""; throw new exception_1.ApiException(response.httpStatusCode, 'Unknown API Status Code!\nBody: "' + body + '"'); }); } } exports.LogsArchivesApiResponseProcessor = LogsArchivesApiResponseProcessor; class LogsArchivesApi { constructor(configuration, requestFactory, responseProcessor) { this.configuration = configuration; this.requestFactory = requestFactory || new LogsArchivesApiRequestFactory(configuration); this.responseProcessor = responseProcessor || new LogsArchivesApiResponseProcessor(); } /** * Adds a read role to an archive. ([Roles API](https://docs.datadoghq.com/api/v2/roles/)) * @param param The request object */ addReadRoleToArchive(param, options) { const requestContextPromise = this.requestFactory.addReadRoleToArchive(param.archiveId, param.body, options); return requestContextPromise.then((requestContext) => { return this.configuration.httpApi .send(requestContext) .then((responseContext) => { return this.responseProcessor.addReadRoleToArchive(responseContext); }); }); } /** * Create an archive in your organization. * @param param The request object */ createLogsArchive(param, options) { const requestContextPromise = this.requestFactory.createLogsArchive(param.body, options); return requestContextPromise.then((requestContext) => { return this.configuration.httpApi .send(requestContext) .then((responseContext) => { return this.responseProcessor.createLogsArchive(responseContext); }); }); } /** * Delete a given archive from your organization. * @param param The request object */ deleteLogsArchive(param, options) { const requestContextPromise = this.requestFactory.deleteLogsArchive(param.archiveId, options); return requestContextPromise.then((requestContext) => { return this.configuration.httpApi .send(requestContext) .then((responseContext) => { return this.responseProcessor.deleteLogsArchive(responseContext); }); }); } /** * Get a specific archive from your organization. * @param param The request object */ getLogsArchive(param, options) { const requestContextPromise = this.requestFactory.getLogsArchive(param.archiveId, options); return requestContextPromise.then((requestContext) => { return this.configuration.httpApi .send(requestContext) .then((responseContext) => { return this.responseProcessor.getLogsArchive(responseContext); }); }); } /** * Get the current order of your archives. * This endpoint takes no JSON arguments. * @param param The request object */ getLogsArchiveOrder(options) { const requestContextPromise = this.requestFactory.getLogsArchiveOrder(options); return requestContextPromise.then((requestContext) => { return this.configuration.httpApi .send(requestContext) .then((responseContext) => { return this.responseProcessor.getLogsArchiveOrder(responseContext); }); }); } /** * Returns all read roles a given archive is restricted to. * @param param The request object */ listArchiveReadRoles(param, options) { const requestContextPromise = this.requestFactory.listArchiveReadRoles(param.archiveId, options); return requestContextPromise.then((requestContext) => { return this.configuration.httpApi .send(requestContext) .then((responseContext) => { return this.responseProcessor.listArchiveReadRoles(responseContext); }); }); } /** * Get the list of configured logs archives with their definitions. * @param param The request object */ listLogsArchives(options) { const requestContextPromise = this.requestFactory.listLogsArchives(options); return requestContextPromise.then((requestContext) => { return this.configuration.httpApi .send(requestContext) .then((responseContext) => { return this.responseProcessor.listLogsArchives(responseContext); }); }); } /** * Removes a role from an archive. ([Roles API](https://docs.datadoghq.com/api/v2/roles/)) * @param param The request object */ removeRoleFromArchive(param, options) { const requestContextPromise = this.requestFactory.removeRoleFromArchive(param.archiveId, param.body, options); return requestContextPromise.then((requestContext) => { return this.configuration.httpApi .send(requestContext) .then((responseContext) => { return this.responseProcessor.removeRoleFromArchive(responseContext); }); }); } /** * Update a given archive configuration. * * **Note**: Using this method updates your archive configuration by **replacing** * your current configuration with the new one sent to your Datadog organization. * @param param The request object */ updateLogsArchive(param, options) { const requestContextPromise = this.requestFactory.updateLogsArchive(param.archiveId, param.body, options); return requestContextPromise.then((requestContext) => { return this.configuration.httpApi .send(requestContext) .then((responseContext) => { return this.responseProcessor.updateLogsArchive(responseContext); }); }); } /** * Update the order of your archives. Since logs are processed sequentially, reordering an archive may change * the structure and content of the data processed by other archives. * * **Note**: Using the `PUT` method updates your archive's order by replacing the current order * with the new one. * @param param The request object */ updateLogsArchiveOrder(param, options) { const requestContextPromise = this.requestFactory.updateLogsArchiveOrder(param.body, options); return requestContextPromise.then((requestContext) => { return this.configuration.httpApi .send(requestContext) .then((responseContext) => { return this.responseProcessor.updateLogsArchiveOrder(responseContext); }); }); } } exports.LogsArchivesApi = LogsArchivesApi; //# sourceMappingURL=LogsArchivesApi.js.map