UNPKG

@datadog/datadog-api-client

Version:
704 lines 39.6 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.ReportSchedulesApi = exports.ReportSchedulesApiResponseProcessor = exports.ReportSchedulesApiRequestFactory = 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 ReportSchedulesApiRequestFactory extends baseapi_1.BaseAPIRequestFactory { createReportSchedule(body, _options) { return __awaiter(this, void 0, void 0, function* () { const _config = _options || this.configuration; logger_1.logger.warn("Using unstable operation 'createReportSchedule'"); if (!_config.unstableOperations["v2.createReportSchedule"]) { throw new Error("Unstable operation 'createReportSchedule' is disabled"); } // verify required parameter 'body' is not null or undefined if (body === null || body === undefined) { throw new baseapi_1.RequiredError("body", "createReportSchedule"); } // Path Params const localVarPath = "/api/v2/reporting/schedule"; // Make Request Context const requestContext = _config .getServer("v2.ReportSchedulesApi.createReportSchedule") .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, "ReportScheduleCreateRequest", ""), contentType); requestContext.setBody(serializedBody); // Apply auth methods (0, configuration_1.applySecurityAuthentication)(_config, requestContext, [ "apiKeyAuth", "appKeyAuth", ]); return requestContext; }); } deleteReportSchedule(scheduleUuid, _options) { return __awaiter(this, void 0, void 0, function* () { const _config = _options || this.configuration; // verify required parameter 'scheduleUuid' is not null or undefined if (scheduleUuid === null || scheduleUuid === undefined) { throw new baseapi_1.RequiredError("scheduleUuid", "deleteReportSchedule"); } // Path Params const localVarPath = "/api/v2/reporting/schedule/{schedule_uuid}".replace("{schedule_uuid}", encodeURIComponent(String(scheduleUuid))); // Make Request Context const requestContext = _config .getServer("v2.ReportSchedulesApi.deleteReportSchedule") .makeRequestContext(localVarPath, http_1.HttpMethod.DELETE); requestContext.setHeaderParam("Accept", "application/json"); requestContext.setHttpConfig(_config.httpConfig); // Apply auth methods (0, configuration_1.applySecurityAuthentication)(_config, requestContext, [ "apiKeyAuth", "appKeyAuth", ]); return requestContext; }); } getReportSchedule(scheduleUuid, _options) { return __awaiter(this, void 0, void 0, function* () { const _config = _options || this.configuration; // verify required parameter 'scheduleUuid' is not null or undefined if (scheduleUuid === null || scheduleUuid === undefined) { throw new baseapi_1.RequiredError("scheduleUuid", "getReportSchedule"); } // Path Params const localVarPath = "/api/v2/reporting/schedule/{schedule_uuid}".replace("{schedule_uuid}", encodeURIComponent(String(scheduleUuid))); // Make Request Context const requestContext = _config .getServer("v2.ReportSchedulesApi.getReportSchedule") .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; }); } getReportSchedulesForResource(resourceType, resourceId, _options) { return __awaiter(this, void 0, void 0, function* () { const _config = _options || this.configuration; // verify required parameter 'resourceType' is not null or undefined if (resourceType === null || resourceType === undefined) { throw new baseapi_1.RequiredError("resourceType", "getReportSchedulesForResource"); } // verify required parameter 'resourceId' is not null or undefined if (resourceId === null || resourceId === undefined) { throw new baseapi_1.RequiredError("resourceId", "getReportSchedulesForResource"); } // Path Params const localVarPath = "/api/v2/reporting/schedule/{resource_type}/{resource_id}" .replace("{resource_type}", encodeURIComponent(String(resourceType))) .replace("{resource_id}", encodeURIComponent(String(resourceId))); // Make Request Context const requestContext = _config .getServer("v2.ReportSchedulesApi.getReportSchedulesForResource") .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; }); } listReportSchedules(pageLimit, pageOffset, filterTitle, filterAuthorUuid, filterRecipients, _options) { return __awaiter(this, void 0, void 0, function* () { const _config = _options || this.configuration; // Path Params const localVarPath = "/api/v2/reporting/schedule/list"; // Make Request Context const requestContext = _config .getServer("v2.ReportSchedulesApi.listReportSchedules") .makeRequestContext(localVarPath, http_1.HttpMethod.GET); requestContext.setHeaderParam("Accept", "application/json"); requestContext.setHttpConfig(_config.httpConfig); // Query Params if (pageLimit !== undefined) { requestContext.setQueryParam("page[limit]", ObjectSerializer_1.ObjectSerializer.serialize(pageLimit, "number", "int64"), ""); } if (pageOffset !== undefined) { requestContext.setQueryParam("page[offset]", ObjectSerializer_1.ObjectSerializer.serialize(pageOffset, "number", "int64"), ""); } if (filterTitle !== undefined) { requestContext.setQueryParam("filter[title]", ObjectSerializer_1.ObjectSerializer.serialize(filterTitle, "string", ""), ""); } if (filterAuthorUuid !== undefined) { requestContext.setQueryParam("filter[author_uuid]", ObjectSerializer_1.ObjectSerializer.serialize(filterAuthorUuid, "string", "uuid"), ""); } if (filterRecipients !== undefined) { requestContext.setQueryParam("filter[recipients]", ObjectSerializer_1.ObjectSerializer.serialize(filterRecipients, "string", ""), ""); } // Apply auth methods (0, configuration_1.applySecurityAuthentication)(_config, requestContext, [ "apiKeyAuth", "appKeyAuth", ]); return requestContext; }); } patchReportSchedule(scheduleUuid, body, _options) { return __awaiter(this, void 0, void 0, function* () { const _config = _options || this.configuration; logger_1.logger.warn("Using unstable operation 'patchReportSchedule'"); if (!_config.unstableOperations["v2.patchReportSchedule"]) { throw new Error("Unstable operation 'patchReportSchedule' is disabled"); } // verify required parameter 'scheduleUuid' is not null or undefined if (scheduleUuid === null || scheduleUuid === undefined) { throw new baseapi_1.RequiredError("scheduleUuid", "patchReportSchedule"); } // verify required parameter 'body' is not null or undefined if (body === null || body === undefined) { throw new baseapi_1.RequiredError("body", "patchReportSchedule"); } // Path Params const localVarPath = "/api/v2/reporting/schedule/{schedule_uuid}".replace("{schedule_uuid}", encodeURIComponent(String(scheduleUuid))); // Make Request Context const requestContext = _config .getServer("v2.ReportSchedulesApi.patchReportSchedule") .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, "ReportSchedulePatchRequest", ""), contentType); requestContext.setBody(serializedBody); // Apply auth methods (0, configuration_1.applySecurityAuthentication)(_config, requestContext, [ "apiKeyAuth", "appKeyAuth", ]); return requestContext; }); } toggleReportSchedule(scheduleUuid, body, _options) { return __awaiter(this, void 0, void 0, function* () { const _config = _options || this.configuration; // verify required parameter 'scheduleUuid' is not null or undefined if (scheduleUuid === null || scheduleUuid === undefined) { throw new baseapi_1.RequiredError("scheduleUuid", "toggleReportSchedule"); } // verify required parameter 'body' is not null or undefined if (body === null || body === undefined) { throw new baseapi_1.RequiredError("body", "toggleReportSchedule"); } // Path Params const localVarPath = "/api/v2/reporting/schedule/{schedule_uuid}/toggle".replace("{schedule_uuid}", encodeURIComponent(String(scheduleUuid))); // Make Request Context const requestContext = _config .getServer("v2.ReportSchedulesApi.toggleReportSchedule") .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, "ReportScheduleToggleRequest", ""), contentType); requestContext.setBody(serializedBody); // Apply auth methods (0, configuration_1.applySecurityAuthentication)(_config, requestContext, [ "apiKeyAuth", "appKeyAuth", ]); return requestContext; }); } } exports.ReportSchedulesApiRequestFactory = ReportSchedulesApiRequestFactory; class ReportSchedulesApiResponseProcessor { /** * 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 createReportSchedule * @throws ApiException if the response code was not in [200, 299] */ createReportSchedule(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), "ReportScheduleResponse"); return body; } if (response.httpStatusCode === 400 || 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), "ReportScheduleResponse", ""); 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 deleteReportSchedule * @throws ApiException if the response code was not in [200, 299] */ deleteReportSchedule(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), "ReportScheduleResponse"); return body; } if (response.httpStatusCode === 400 || 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), "ReportScheduleResponse", ""); 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 getReportSchedule * @throws ApiException if the response code was not in [200, 299] */ getReportSchedule(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), "ReportScheduleResponse"); return body; } if (response.httpStatusCode === 400 || 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), "ReportScheduleResponse", ""); 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 getReportSchedulesForResource * @throws ApiException if the response code was not in [200, 299] */ getReportSchedulesForResource(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), "ReportScheduleListResponse"); return body; } if (response.httpStatusCode === 400 || 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), "ReportScheduleListResponse", ""); 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 listReportSchedules * @throws ApiException if the response code was not in [200, 299] */ listReportSchedules(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), "ReportScheduleListResponse"); return body; } if (response.httpStatusCode === 400 || 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), "ReportScheduleListResponse", ""); 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 patchReportSchedule * @throws ApiException if the response code was not in [200, 299] */ patchReportSchedule(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), "ReportScheduleResponse"); return body; } if (response.httpStatusCode === 400 || 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), "ReportScheduleResponse", ""); 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 toggleReportSchedule * @throws ApiException if the response code was not in [200, 299] */ toggleReportSchedule(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), "ReportScheduleResponse"); return body; } if (response.httpStatusCode === 400 || 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), "ReportScheduleResponse", ""); return body; } const body = (yield response.body.text()) || ""; throw new exception_1.ApiException(response.httpStatusCode, 'Unknown API Status Code!\nBody: "' + body + '"'); }); } } exports.ReportSchedulesApiResponseProcessor = ReportSchedulesApiResponseProcessor; class ReportSchedulesApi { constructor(configuration, requestFactory, responseProcessor) { this.configuration = configuration; this.requestFactory = requestFactory || new ReportSchedulesApiRequestFactory(configuration); this.responseProcessor = responseProcessor || new ReportSchedulesApiResponseProcessor(); } /** * Create a new scheduled report. A schedule renders a dashboard or integration dashboard * on a recurring cadence and delivers it to the configured recipients over email, Slack, * or Microsoft Teams. * Requires the `generate_dashboard_reports` permission. * @param param The request object */ createReportSchedule(param, options) { const requestContextPromise = this.requestFactory.createReportSchedule(param.body, options); return requestContextPromise.then((requestContext) => { return this.configuration.httpApi .send(requestContext) .then((responseContext) => { return this.responseProcessor.createReportSchedule(responseContext); }); }); } /** * Delete a report schedule by its unique identifier. The response returns the deleted schedule. * Requires a reporting write permission appropriate to the targeted resource type and schedule ownership. * @param param The request object */ deleteReportSchedule(param, options) { const requestContextPromise = this.requestFactory.deleteReportSchedule(param.scheduleUuid, options); return requestContextPromise.then((requestContext) => { return this.configuration.httpApi .send(requestContext) .then((responseContext) => { return this.responseProcessor.deleteReportSchedule(responseContext); }); }); } /** * Get a report schedule by its unique identifier. * Requires a reporting read permission appropriate to the targeted resource type. * @param param The request object */ getReportSchedule(param, options) { const requestContextPromise = this.requestFactory.getReportSchedule(param.scheduleUuid, options); return requestContextPromise.then((requestContext) => { return this.configuration.httpApi .send(requestContext) .then((responseContext) => { return this.responseProcessor.getReportSchedule(responseContext); }); }); } /** * Get all report schedules that target a dashboard or integration dashboard resource. * Requires a reporting read permission appropriate to the targeted resource type. * @param param The request object */ getReportSchedulesForResource(param, options) { const requestContextPromise = this.requestFactory.getReportSchedulesForResource(param.resourceType, param.resourceId, options); return requestContextPromise.then((requestContext) => { return this.configuration.httpApi .send(requestContext) .then((responseContext) => { return this.responseProcessor.getReportSchedulesForResource(responseContext); }); }); } /** * List dashboard and integration dashboard report schedules for the organization. * The response is paginated and can be filtered by title, author UUID, or recipients. * Requires the `generate_dashboard_reports` permission. * @param param The request object */ listReportSchedules(param = {}, options) { const requestContextPromise = this.requestFactory.listReportSchedules(param.pageLimit, param.pageOffset, param.filterTitle, param.filterAuthorUuid, param.filterRecipients, options); return requestContextPromise.then((requestContext) => { return this.configuration.httpApi .send(requestContext) .then((responseContext) => { return this.responseProcessor.listReportSchedules(responseContext); }); }); } /** * Update an existing scheduled report by its identifier. The editable attributes * are replaced with the supplied values; the targeted resource (`resource_id` and * `resource_type`) cannot be changed after creation. * Requires the `generate_dashboard_reports` permission and schedule ownership. * @param param The request object */ patchReportSchedule(param, options) { const requestContextPromise = this.requestFactory.patchReportSchedule(param.scheduleUuid, param.body, options); return requestContextPromise.then((requestContext) => { return this.configuration.httpApi .send(requestContext) .then((responseContext) => { return this.responseProcessor.patchReportSchedule(responseContext); }); }); } /** * Activate or pause a report schedule by setting its status to `active` or `inactive`. * Requires a reporting write permission appropriate to the targeted resource type and schedule ownership. * @param param The request object */ toggleReportSchedule(param, options) { const requestContextPromise = this.requestFactory.toggleReportSchedule(param.scheduleUuid, param.body, options); return requestContextPromise.then((requestContext) => { return this.configuration.httpApi .send(requestContext) .then((responseContext) => { return this.responseProcessor.toggleReportSchedule(responseContext); }); }); } } exports.ReportSchedulesApi = ReportSchedulesApi; //# sourceMappingURL=ReportSchedulesApi.js.map