UNPKG

@datadog/datadog-api-client

Version:

OpenAPI client for Datadog APIs

837 lines 45.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.ConfluentCloudApi = exports.ConfluentCloudApiResponseProcessor = exports.ConfluentCloudApiRequestFactory = 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 ConfluentCloudApiRequestFactory extends baseapi_1.BaseAPIRequestFactory { createConfluentAccount(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", "createConfluentAccount"); } // Path Params const localVarPath = "/api/v2/integrations/confluent-cloud/accounts"; // Make Request Context const requestContext = _config .getServer("v2.ConfluentCloudApi.createConfluentAccount") .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, "ConfluentAccountCreateRequest", ""), contentType); requestContext.setBody(serializedBody); // Apply auth methods (0, configuration_1.applySecurityAuthentication)(_config, requestContext, [ "apiKeyAuth", "appKeyAuth", ]); return requestContext; }); } createConfluentResource(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", "createConfluentResource"); } // verify required parameter 'body' is not null or undefined if (body === null || body === undefined) { throw new baseapi_1.RequiredError("body", "createConfluentResource"); } // Path Params const localVarPath = "/api/v2/integrations/confluent-cloud/accounts/{account_id}/resources".replace("{account_id}", encodeURIComponent(String(accountId))); // Make Request Context const requestContext = _config .getServer("v2.ConfluentCloudApi.createConfluentResource") .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, "ConfluentResourceRequest", ""), contentType); requestContext.setBody(serializedBody); // Apply auth methods (0, configuration_1.applySecurityAuthentication)(_config, requestContext, [ "apiKeyAuth", "appKeyAuth", ]); return requestContext; }); } deleteConfluentAccount(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", "deleteConfluentAccount"); } // Path Params const localVarPath = "/api/v2/integrations/confluent-cloud/accounts/{account_id}".replace("{account_id}", encodeURIComponent(String(accountId))); // Make Request Context const requestContext = _config .getServer("v2.ConfluentCloudApi.deleteConfluentAccount") .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; }); } deleteConfluentResource(accountId, resourceId, _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", "deleteConfluentResource"); } // verify required parameter 'resourceId' is not null or undefined if (resourceId === null || resourceId === undefined) { throw new baseapi_1.RequiredError("resourceId", "deleteConfluentResource"); } // Path Params const localVarPath = "/api/v2/integrations/confluent-cloud/accounts/{account_id}/resources/{resource_id}" .replace("{account_id}", encodeURIComponent(String(accountId))) .replace("{resource_id}", encodeURIComponent(String(resourceId))); // Make Request Context const requestContext = _config .getServer("v2.ConfluentCloudApi.deleteConfluentResource") .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; }); } getConfluentAccount(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", "getConfluentAccount"); } // Path Params const localVarPath = "/api/v2/integrations/confluent-cloud/accounts/{account_id}".replace("{account_id}", encodeURIComponent(String(accountId))); // Make Request Context const requestContext = _config .getServer("v2.ConfluentCloudApi.getConfluentAccount") .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; }); } getConfluentResource(accountId, resourceId, _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", "getConfluentResource"); } // verify required parameter 'resourceId' is not null or undefined if (resourceId === null || resourceId === undefined) { throw new baseapi_1.RequiredError("resourceId", "getConfluentResource"); } // Path Params const localVarPath = "/api/v2/integrations/confluent-cloud/accounts/{account_id}/resources/{resource_id}" .replace("{account_id}", encodeURIComponent(String(accountId))) .replace("{resource_id}", encodeURIComponent(String(resourceId))); // Make Request Context const requestContext = _config .getServer("v2.ConfluentCloudApi.getConfluentResource") .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; }); } listConfluentAccount(_options) { return __awaiter(this, void 0, void 0, function* () { const _config = _options || this.configuration; // Path Params const localVarPath = "/api/v2/integrations/confluent-cloud/accounts"; // Make Request Context const requestContext = _config .getServer("v2.ConfluentCloudApi.listConfluentAccount") .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; }); } listConfluentResource(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", "listConfluentResource"); } // Path Params const localVarPath = "/api/v2/integrations/confluent-cloud/accounts/{account_id}/resources".replace("{account_id}", encodeURIComponent(String(accountId))); // Make Request Context const requestContext = _config .getServer("v2.ConfluentCloudApi.listConfluentResource") .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; }); } updateConfluentAccount(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", "updateConfluentAccount"); } // verify required parameter 'body' is not null or undefined if (body === null || body === undefined) { throw new baseapi_1.RequiredError("body", "updateConfluentAccount"); } // Path Params const localVarPath = "/api/v2/integrations/confluent-cloud/accounts/{account_id}".replace("{account_id}", encodeURIComponent(String(accountId))); // Make Request Context const requestContext = _config .getServer("v2.ConfluentCloudApi.updateConfluentAccount") .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, "ConfluentAccountUpdateRequest", ""), contentType); requestContext.setBody(serializedBody); // Apply auth methods (0, configuration_1.applySecurityAuthentication)(_config, requestContext, [ "apiKeyAuth", "appKeyAuth", ]); return requestContext; }); } updateConfluentResource(accountId, resourceId, 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", "updateConfluentResource"); } // verify required parameter 'resourceId' is not null or undefined if (resourceId === null || resourceId === undefined) { throw new baseapi_1.RequiredError("resourceId", "updateConfluentResource"); } // verify required parameter 'body' is not null or undefined if (body === null || body === undefined) { throw new baseapi_1.RequiredError("body", "updateConfluentResource"); } // Path Params const localVarPath = "/api/v2/integrations/confluent-cloud/accounts/{account_id}/resources/{resource_id}" .replace("{account_id}", encodeURIComponent(String(accountId))) .replace("{resource_id}", encodeURIComponent(String(resourceId))); // Make Request Context const requestContext = _config .getServer("v2.ConfluentCloudApi.updateConfluentResource") .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, "ConfluentResourceRequest", ""), contentType); requestContext.setBody(serializedBody); // Apply auth methods (0, configuration_1.applySecurityAuthentication)(_config, requestContext, [ "apiKeyAuth", "appKeyAuth", ]); return requestContext; }); } } exports.ConfluentCloudApiRequestFactory = ConfluentCloudApiRequestFactory; class ConfluentCloudApiResponseProcessor { /** * 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 createConfluentAccount * @throws ApiException if the response code was not in [200, 299] */ createConfluentAccount(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), "ConfluentAccountResponse"); 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), "ConfluentAccountResponse", ""); 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 createConfluentResource * @throws ApiException if the response code was not in [200, 299] */ createConfluentResource(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), "ConfluentResourceResponse"); 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), "ConfluentResourceResponse", ""); 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 deleteConfluentAccount * @throws ApiException if the response code was not in [200, 299] */ deleteConfluentAccount(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 deleteConfluentResource * @throws ApiException if the response code was not in [200, 299] */ deleteConfluentResource(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 getConfluentAccount * @throws ApiException if the response code was not in [200, 299] */ getConfluentAccount(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), "ConfluentAccountResponse"); 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), "ConfluentAccountResponse", ""); 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 getConfluentResource * @throws ApiException if the response code was not in [200, 299] */ getConfluentResource(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), "ConfluentResourceResponse"); 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), "ConfluentResourceResponse", ""); 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 listConfluentAccount * @throws ApiException if the response code was not in [200, 299] */ listConfluentAccount(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), "ConfluentAccountsResponse"); 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), "ConfluentAccountsResponse", ""); 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 listConfluentResource * @throws ApiException if the response code was not in [200, 299] */ listConfluentResource(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), "ConfluentResourcesResponse"); 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), "ConfluentResourcesResponse", ""); 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 updateConfluentAccount * @throws ApiException if the response code was not in [200, 299] */ updateConfluentAccount(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), "ConfluentAccountResponse"); 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), "ConfluentAccountResponse", ""); 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 updateConfluentResource * @throws ApiException if the response code was not in [200, 299] */ updateConfluentResource(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), "ConfluentResourceResponse"); 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), "ConfluentResourceResponse", ""); return body; } const body = (yield response.body.text()) || ""; throw new exception_1.ApiException(response.httpStatusCode, 'Unknown API Status Code!\nBody: "' + body + '"'); }); } } exports.ConfluentCloudApiResponseProcessor = ConfluentCloudApiResponseProcessor; class ConfluentCloudApi { constructor(configuration, requestFactory, responseProcessor) { this.configuration = configuration; this.requestFactory = requestFactory || new ConfluentCloudApiRequestFactory(configuration); this.responseProcessor = responseProcessor || new ConfluentCloudApiResponseProcessor(); } /** * Create a Confluent account. * @param param The request object */ createConfluentAccount(param, options) { const requestContextPromise = this.requestFactory.createConfluentAccount(param.body, options); return requestContextPromise.then((requestContext) => { return this.configuration.httpApi .send(requestContext) .then((responseContext) => { return this.responseProcessor.createConfluentAccount(responseContext); }); }); } /** * Create a Confluent resource for the account associated with the provided ID. * @param param The request object */ createConfluentResource(param, options) { const requestContextPromise = this.requestFactory.createConfluentResource(param.accountId, param.body, options); return requestContextPromise.then((requestContext) => { return this.configuration.httpApi .send(requestContext) .then((responseContext) => { return this.responseProcessor.createConfluentResource(responseContext); }); }); } /** * Delete a Confluent account with the provided account ID. * @param param The request object */ deleteConfluentAccount(param, options) { const requestContextPromise = this.requestFactory.deleteConfluentAccount(param.accountId, options); return requestContextPromise.then((requestContext) => { return this.configuration.httpApi .send(requestContext) .then((responseContext) => { return this.responseProcessor.deleteConfluentAccount(responseContext); }); }); } /** * Delete a Confluent resource with the provided resource id for the account associated with the provided account ID. * @param param The request object */ deleteConfluentResource(param, options) { const requestContextPromise = this.requestFactory.deleteConfluentResource(param.accountId, param.resourceId, options); return requestContextPromise.then((requestContext) => { return this.configuration.httpApi .send(requestContext) .then((responseContext) => { return this.responseProcessor.deleteConfluentResource(responseContext); }); }); } /** * Get the Confluent account with the provided account ID. * @param param The request object */ getConfluentAccount(param, options) { const requestContextPromise = this.requestFactory.getConfluentAccount(param.accountId, options); return requestContextPromise.then((requestContext) => { return this.configuration.httpApi .send(requestContext) .then((responseContext) => { return this.responseProcessor.getConfluentAccount(responseContext); }); }); } /** * Get a Confluent resource with the provided resource id for the account associated with the provided account ID. * @param param The request object */ getConfluentResource(param, options) { const requestContextPromise = this.requestFactory.getConfluentResource(param.accountId, param.resourceId, options); return requestContextPromise.then((requestContext) => { return this.configuration.httpApi .send(requestContext) .then((responseContext) => { return this.responseProcessor.getConfluentResource(responseContext); }); }); } /** * List Confluent accounts. * @param param The request object */ listConfluentAccount(options) { const requestContextPromise = this.requestFactory.listConfluentAccount(options); return requestContextPromise.then((requestContext) => { return this.configuration.httpApi .send(requestContext) .then((responseContext) => { return this.responseProcessor.listConfluentAccount(responseContext); }); }); } /** * Get a Confluent resource for the account associated with the provided ID. * @param param The request object */ listConfluentResource(param, options) { const requestContextPromise = this.requestFactory.listConfluentResource(param.accountId, options); return requestContextPromise.then((requestContext) => { return this.configuration.httpApi .send(requestContext) .then((responseContext) => { return this.responseProcessor.listConfluentResource(responseContext); }); }); } /** * Update the Confluent account with the provided account ID. * @param param The request object */ updateConfluentAccount(param, options) { const requestContextPromise = this.requestFactory.updateConfluentAccount(param.accountId, param.body, options); return requestContextPromise.then((requestContext) => { return this.configuration.httpApi .send(requestContext) .then((responseContext) => { return this.responseProcessor.updateConfluentAccount(responseContext); }); }); } /** * Update a Confluent resource with the provided resource id for the account associated with the provided account ID. * @param param The request object */ updateConfluentResource(param, options) { const requestContextPromise = this.requestFactory.updateConfluentResource(param.accountId, param.resourceId, param.body, options); return requestContextPromise.then((requestContext) => { return this.configuration.httpApi .send(requestContext) .then((responseContext) => { return this.responseProcessor.updateConfluentResource(responseContext); }); }); } } exports.ConfluentCloudApi = ConfluentCloudApi; //# sourceMappingURL=ConfluentCloudApi.js.map