@datadog/datadog-api-client
Version:
OpenAPI client for Datadog APIs
837 lines • 45.1 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.FastlyIntegrationApi = exports.FastlyIntegrationApiResponseProcessor = exports.FastlyIntegrationApiRequestFactory = 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 FastlyIntegrationApiRequestFactory extends baseapi_1.BaseAPIRequestFactory {
createFastlyAccount(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", "createFastlyAccount");
}
// Path Params
const localVarPath = "/api/v2/integrations/fastly/accounts";
// Make Request Context
const requestContext = _config
.getServer("v2.FastlyIntegrationApi.createFastlyAccount")
.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, "FastlyAccountCreateRequest", ""), contentType);
requestContext.setBody(serializedBody);
// Apply auth methods
(0, configuration_1.applySecurityAuthentication)(_config, requestContext, [
"apiKeyAuth",
"appKeyAuth",
]);
return requestContext;
});
}
createFastlyService(accountId, body, _options) {
return __awaiter(this, void 0, void 0, function* () {
const _config = _options || this.configuration;
// verify required parameter 'accountId' is not null or undefined
if (accountId === null || accountId === undefined) {
throw new baseapi_1.RequiredError("accountId", "createFastlyService");
}
// verify required parameter 'body' is not null or undefined
if (body === null || body === undefined) {
throw new baseapi_1.RequiredError("body", "createFastlyService");
}
// Path Params
const localVarPath = "/api/v2/integrations/fastly/accounts/{account_id}/services".replace("{account_id}", encodeURIComponent(String(accountId)));
// Make Request Context
const requestContext = _config
.getServer("v2.FastlyIntegrationApi.createFastlyService")
.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, "FastlyServiceRequest", ""), contentType);
requestContext.setBody(serializedBody);
// Apply auth methods
(0, configuration_1.applySecurityAuthentication)(_config, requestContext, [
"apiKeyAuth",
"appKeyAuth",
]);
return requestContext;
});
}
deleteFastlyAccount(accountId, _options) {
return __awaiter(this, void 0, void 0, function* () {
const _config = _options || this.configuration;
// verify required parameter 'accountId' is not null or undefined
if (accountId === null || accountId === undefined) {
throw new baseapi_1.RequiredError("accountId", "deleteFastlyAccount");
}
// Path Params
const localVarPath = "/api/v2/integrations/fastly/accounts/{account_id}".replace("{account_id}", encodeURIComponent(String(accountId)));
// Make Request Context
const requestContext = _config
.getServer("v2.FastlyIntegrationApi.deleteFastlyAccount")
.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;
});
}
deleteFastlyService(accountId, serviceId, _options) {
return __awaiter(this, void 0, void 0, function* () {
const _config = _options || this.configuration;
// verify required parameter 'accountId' is not null or undefined
if (accountId === null || accountId === undefined) {
throw new baseapi_1.RequiredError("accountId", "deleteFastlyService");
}
// verify required parameter 'serviceId' is not null or undefined
if (serviceId === null || serviceId === undefined) {
throw new baseapi_1.RequiredError("serviceId", "deleteFastlyService");
}
// Path Params
const localVarPath = "/api/v2/integrations/fastly/accounts/{account_id}/services/{service_id}"
.replace("{account_id}", encodeURIComponent(String(accountId)))
.replace("{service_id}", encodeURIComponent(String(serviceId)));
// Make Request Context
const requestContext = _config
.getServer("v2.FastlyIntegrationApi.deleteFastlyService")
.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;
});
}
getFastlyAccount(accountId, _options) {
return __awaiter(this, void 0, void 0, function* () {
const _config = _options || this.configuration;
// verify required parameter 'accountId' is not null or undefined
if (accountId === null || accountId === undefined) {
throw new baseapi_1.RequiredError("accountId", "getFastlyAccount");
}
// Path Params
const localVarPath = "/api/v2/integrations/fastly/accounts/{account_id}".replace("{account_id}", encodeURIComponent(String(accountId)));
// Make Request Context
const requestContext = _config
.getServer("v2.FastlyIntegrationApi.getFastlyAccount")
.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;
});
}
getFastlyService(accountId, serviceId, _options) {
return __awaiter(this, void 0, void 0, function* () {
const _config = _options || this.configuration;
// verify required parameter 'accountId' is not null or undefined
if (accountId === null || accountId === undefined) {
throw new baseapi_1.RequiredError("accountId", "getFastlyService");
}
// verify required parameter 'serviceId' is not null or undefined
if (serviceId === null || serviceId === undefined) {
throw new baseapi_1.RequiredError("serviceId", "getFastlyService");
}
// Path Params
const localVarPath = "/api/v2/integrations/fastly/accounts/{account_id}/services/{service_id}"
.replace("{account_id}", encodeURIComponent(String(accountId)))
.replace("{service_id}", encodeURIComponent(String(serviceId)));
// Make Request Context
const requestContext = _config
.getServer("v2.FastlyIntegrationApi.getFastlyService")
.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;
});
}
listFastlyAccounts(_options) {
return __awaiter(this, void 0, void 0, function* () {
const _config = _options || this.configuration;
// Path Params
const localVarPath = "/api/v2/integrations/fastly/accounts";
// Make Request Context
const requestContext = _config
.getServer("v2.FastlyIntegrationApi.listFastlyAccounts")
.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;
});
}
listFastlyServices(accountId, _options) {
return __awaiter(this, void 0, void 0, function* () {
const _config = _options || this.configuration;
// verify required parameter 'accountId' is not null or undefined
if (accountId === null || accountId === undefined) {
throw new baseapi_1.RequiredError("accountId", "listFastlyServices");
}
// Path Params
const localVarPath = "/api/v2/integrations/fastly/accounts/{account_id}/services".replace("{account_id}", encodeURIComponent(String(accountId)));
// Make Request Context
const requestContext = _config
.getServer("v2.FastlyIntegrationApi.listFastlyServices")
.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;
});
}
updateFastlyAccount(accountId, body, _options) {
return __awaiter(this, void 0, void 0, function* () {
const _config = _options || this.configuration;
// verify required parameter 'accountId' is not null or undefined
if (accountId === null || accountId === undefined) {
throw new baseapi_1.RequiredError("accountId", "updateFastlyAccount");
}
// verify required parameter 'body' is not null or undefined
if (body === null || body === undefined) {
throw new baseapi_1.RequiredError("body", "updateFastlyAccount");
}
// Path Params
const localVarPath = "/api/v2/integrations/fastly/accounts/{account_id}".replace("{account_id}", encodeURIComponent(String(accountId)));
// Make Request Context
const requestContext = _config
.getServer("v2.FastlyIntegrationApi.updateFastlyAccount")
.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, "FastlyAccountUpdateRequest", ""), contentType);
requestContext.setBody(serializedBody);
// Apply auth methods
(0, configuration_1.applySecurityAuthentication)(_config, requestContext, [
"apiKeyAuth",
"appKeyAuth",
]);
return requestContext;
});
}
updateFastlyService(accountId, serviceId, body, _options) {
return __awaiter(this, void 0, void 0, function* () {
const _config = _options || this.configuration;
// verify required parameter 'accountId' is not null or undefined
if (accountId === null || accountId === undefined) {
throw new baseapi_1.RequiredError("accountId", "updateFastlyService");
}
// verify required parameter 'serviceId' is not null or undefined
if (serviceId === null || serviceId === undefined) {
throw new baseapi_1.RequiredError("serviceId", "updateFastlyService");
}
// verify required parameter 'body' is not null or undefined
if (body === null || body === undefined) {
throw new baseapi_1.RequiredError("body", "updateFastlyService");
}
// Path Params
const localVarPath = "/api/v2/integrations/fastly/accounts/{account_id}/services/{service_id}"
.replace("{account_id}", encodeURIComponent(String(accountId)))
.replace("{service_id}", encodeURIComponent(String(serviceId)));
// Make Request Context
const requestContext = _config
.getServer("v2.FastlyIntegrationApi.updateFastlyService")
.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, "FastlyServiceRequest", ""), contentType);
requestContext.setBody(serializedBody);
// Apply auth methods
(0, configuration_1.applySecurityAuthentication)(_config, requestContext, [
"apiKeyAuth",
"appKeyAuth",
]);
return requestContext;
});
}
}
exports.FastlyIntegrationApiRequestFactory = FastlyIntegrationApiRequestFactory;
class FastlyIntegrationApiResponseProcessor {
/**
* 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 createFastlyAccount
* @throws ApiException if the response code was not in [200, 299]
*/
createFastlyAccount(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), "FastlyAccountResponse");
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), "FastlyAccountResponse", "");
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 createFastlyService
* @throws ApiException if the response code was not in [200, 299]
*/
createFastlyService(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), "FastlyServiceResponse");
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), "FastlyServiceResponse", "");
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 deleteFastlyAccount
* @throws ApiException if the response code was not in [200, 299]
*/
deleteFastlyAccount(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 deleteFastlyService
* @throws ApiException if the response code was not in [200, 299]
*/
deleteFastlyService(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 getFastlyAccount
* @throws ApiException if the response code was not in [200, 299]
*/
getFastlyAccount(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), "FastlyAccountResponse");
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), "FastlyAccountResponse", "");
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 getFastlyService
* @throws ApiException if the response code was not in [200, 299]
*/
getFastlyService(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), "FastlyServiceResponse");
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), "FastlyServiceResponse", "");
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 listFastlyAccounts
* @throws ApiException if the response code was not in [200, 299]
*/
listFastlyAccounts(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), "FastlyAccountsResponse");
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), "FastlyAccountsResponse", "");
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 listFastlyServices
* @throws ApiException if the response code was not in [200, 299]
*/
listFastlyServices(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), "FastlyServicesResponse");
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), "FastlyServicesResponse", "");
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 updateFastlyAccount
* @throws ApiException if the response code was not in [200, 299]
*/
updateFastlyAccount(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), "FastlyAccountResponse");
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), "FastlyAccountResponse", "");
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 updateFastlyService
* @throws ApiException if the response code was not in [200, 299]
*/
updateFastlyService(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), "FastlyServiceResponse");
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), "FastlyServiceResponse", "");
return body;
}
const body = (yield response.body.text()) || "";
throw new exception_1.ApiException(response.httpStatusCode, 'Unknown API Status Code!\nBody: "' + body + '"');
});
}
}
exports.FastlyIntegrationApiResponseProcessor = FastlyIntegrationApiResponseProcessor;
class FastlyIntegrationApi {
constructor(configuration, requestFactory, responseProcessor) {
this.configuration = configuration;
this.requestFactory =
requestFactory || new FastlyIntegrationApiRequestFactory(configuration);
this.responseProcessor =
responseProcessor || new FastlyIntegrationApiResponseProcessor();
}
/**
* Create a Fastly account.
* @param param The request object
*/
createFastlyAccount(param, options) {
const requestContextPromise = this.requestFactory.createFastlyAccount(param.body, options);
return requestContextPromise.then((requestContext) => {
return this.configuration.httpApi
.send(requestContext)
.then((responseContext) => {
return this.responseProcessor.createFastlyAccount(responseContext);
});
});
}
/**
* Create a Fastly service for an account.
* @param param The request object
*/
createFastlyService(param, options) {
const requestContextPromise = this.requestFactory.createFastlyService(param.accountId, param.body, options);
return requestContextPromise.then((requestContext) => {
return this.configuration.httpApi
.send(requestContext)
.then((responseContext) => {
return this.responseProcessor.createFastlyService(responseContext);
});
});
}
/**
* Delete a Fastly account.
* @param param The request object
*/
deleteFastlyAccount(param, options) {
const requestContextPromise = this.requestFactory.deleteFastlyAccount(param.accountId, options);
return requestContextPromise.then((requestContext) => {
return this.configuration.httpApi
.send(requestContext)
.then((responseContext) => {
return this.responseProcessor.deleteFastlyAccount(responseContext);
});
});
}
/**
* Delete a Fastly service for an account.
* @param param The request object
*/
deleteFastlyService(param, options) {
const requestContextPromise = this.requestFactory.deleteFastlyService(param.accountId, param.serviceId, options);
return requestContextPromise.then((requestContext) => {
return this.configuration.httpApi
.send(requestContext)
.then((responseContext) => {
return this.responseProcessor.deleteFastlyService(responseContext);
});
});
}
/**
* Get a Fastly account.
* @param param The request object
*/
getFastlyAccount(param, options) {
const requestContextPromise = this.requestFactory.getFastlyAccount(param.accountId, options);
return requestContextPromise.then((requestContext) => {
return this.configuration.httpApi
.send(requestContext)
.then((responseContext) => {
return this.responseProcessor.getFastlyAccount(responseContext);
});
});
}
/**
* Get a Fastly service for an account.
* @param param The request object
*/
getFastlyService(param, options) {
const requestContextPromise = this.requestFactory.getFastlyService(param.accountId, param.serviceId, options);
return requestContextPromise.then((requestContext) => {
return this.configuration.httpApi
.send(requestContext)
.then((responseContext) => {
return this.responseProcessor.getFastlyService(responseContext);
});
});
}
/**
* List Fastly accounts.
* @param param The request object
*/
listFastlyAccounts(options) {
const requestContextPromise = this.requestFactory.listFastlyAccounts(options);
return requestContextPromise.then((requestContext) => {
return this.configuration.httpApi
.send(requestContext)
.then((responseContext) => {
return this.responseProcessor.listFastlyAccounts(responseContext);
});
});
}
/**
* List Fastly services for an account.
* @param param The request object
*/
listFastlyServices(param, options) {
const requestContextPromise = this.requestFactory.listFastlyServices(param.accountId, options);
return requestContextPromise.then((requestContext) => {
return this.configuration.httpApi
.send(requestContext)
.then((responseContext) => {
return this.responseProcessor.listFastlyServices(responseContext);
});
});
}
/**
* Update a Fastly account.
* @param param The request object
*/
updateFastlyAccount(param, options) {
const requestContextPromise = this.requestFactory.updateFastlyAccount(param.accountId, param.body, options);
return requestContextPromise.then((requestContext) => {
return this.configuration.httpApi
.send(requestContext)
.then((responseContext) => {
return this.responseProcessor.updateFastlyAccount(responseContext);
});
});
}
/**
* Update a Fastly service for an account.
* @param param The request object
*/
updateFastlyService(param, options) {
const requestContextPromise = this.requestFactory.updateFastlyService(param.accountId, param.serviceId, param.body, options);
return requestContextPromise.then((requestContext) => {
return this.configuration.httpApi
.send(requestContext)
.then((responseContext) => {
return this.responseProcessor.updateFastlyService(responseContext);
});
});
}
}
exports.FastlyIntegrationApi = FastlyIntegrationApi;
//# sourceMappingURL=FastlyIntegrationApi.js.map