UNPKG

auth0

Version:

Auth0 Node.js SDK for the Management API v2.

696 lines (695 loc) 33.7 kB
"use strict"; // This file was auto-generated by Fern from our API Definition. var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || (function () { var ownKeys = function(o) { ownKeys = Object.getOwnPropertyNames || function (o) { var ar = []; for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; return ar; }; return ownKeys(o); }; return function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); __setModuleDefault(result, mod); return result; }; })(); 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.LogStreamsClient = void 0; const BaseClient_js_1 = require("../../../../BaseClient.js"); const core = __importStar(require("../../../../core/index.js")); const headers_js_1 = require("../../../../core/headers.js"); const environments = __importStar(require("../../../../environments.js")); const handleNonStatusCodeError_js_1 = require("../../../../errors/handleNonStatusCodeError.js"); const errors = __importStar(require("../../../../errors/index.js")); const Management = __importStar(require("../../../index.js")); class LogStreamsClient { constructor(options) { this._options = (0, BaseClient_js_1.normalizeClientOptionsWithAuth)(options); } /** * Retrieve details on <a href="https://auth0.com/docs/logs/streams">log streams</a>. * <h5>Sample Response</h5><pre><code>[{ * "id": "string", * "name": "string", * "type": "eventbridge", * "status": "active|paused|suspended", * "sink": { * "awsAccountId": "string", * "awsRegion": "string", * "awsPartnerEventSource": "string" * } * }, { * "id": "string", * "name": "string", * "type": "http", * "status": "active|paused|suspended", * "sink": { * "httpContentFormat": "JSONLINES|JSONARRAY", * "httpContentType": "string", * "httpEndpoint": "string", * "httpAuthorization": "string" * } * }, * { * "id": "string", * "name": "string", * "type": "eventgrid", * "status": "active|paused|suspended", * "sink": { * "azureSubscriptionId": "string", * "azureResourceGroup": "string", * "azureRegion": "string", * "azurePartnerTopic": "string" * } * }, * { * "id": "string", * "name": "string", * "type": "splunk", * "status": "active|paused|suspended", * "sink": { * "splunkDomain": "string", * "splunkToken": "string", * "splunkPort": "string", * "splunkSecure": "boolean" * } * }, * { * "id": "string", * "name": "string", * "type": "sumo", * "status": "active|paused|suspended", * "sink": { * "sumoSourceAddress": "string", * } * }, * { * "id": "string", * "name": "string", * "type": "datadog", * "status": "active|paused|suspended", * "sink": { * "datadogRegion": "string", * "datadogApiKey": "string" * } * }]</code></pre> * * @param {LogStreamsClient.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} * * @example * await client.logStreams.list() */ list(requestOptions) { return core.HttpResponsePromise.fromPromise(this.__list(requestOptions)); } __list(requestOptions) { return __awaiter(this, void 0, void 0, function* () { var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k; const _authRequest = yield this._options.authProvider.getAuthRequest(); let _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers); const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({ url: core.url.join((_d = (_c = (yield core.Supplier.get(this._options.baseUrl))) !== null && _c !== void 0 ? _c : (yield core.Supplier.get(this._options.environment))) !== null && _d !== void 0 ? _d : environments.ManagementEnvironment.Default, "log-streams"), method: "GET", headers: _headers, queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams, timeoutMs: ((_g = (_e = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _e !== void 0 ? _e : (_f = this._options) === null || _f === void 0 ? void 0 : _f.timeoutInSeconds) !== null && _g !== void 0 ? _g : 60) * 1000, maxRetries: (_h = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _h !== void 0 ? _h : (_j = this._options) === null || _j === void 0 ? void 0 : _j.maxRetries, abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal, fetchFn: (_k = this._options) === null || _k === void 0 ? void 0 : _k.fetch, logging: this._options.logging, }); if (_response.ok) { return { data: _response.body, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: throw new Management.UnauthorizedError(_response.error.body, _response.rawResponse); case 403: throw new Management.ForbiddenError(_response.error.body, _response.rawResponse); case 404: throw new Management.NotFoundError(_response.error.body, _response.rawResponse); case 429: throw new Management.TooManyRequestsError(_response.error.body, _response.rawResponse); default: throw new errors.ManagementError({ statusCode: _response.error.statusCode, body: _response.error.body, rawResponse: _response.rawResponse, }); } } return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "GET", "/log-streams"); }); } /** * Create a log stream. * <h5>Log Stream Types</h5> The <code>type</code> of log stream being created determines the properties required in the <code>sink</code> payload. * <h5>HTTP Stream</h5> For an <code>http</code> Stream, the <code>sink</code> properties are listed in the payload below * Request: <pre><code>{ * "name": "string", * "type": "http", * "sink": { * "httpEndpoint": "string", * "httpContentType": "string", * "httpContentFormat": "JSONLINES|JSONARRAY", * "httpAuthorization": "string" * } * }</code></pre> * Response: <pre><code>{ * "id": "string", * "name": "string", * "type": "http", * "status": "active", * "sink": { * "httpEndpoint": "string", * "httpContentType": "string", * "httpContentFormat": "JSONLINES|JSONARRAY", * "httpAuthorization": "string" * } * }</code></pre> * <h5>Amazon EventBridge Stream</h5> For an <code>eventbridge</code> Stream, the <code>sink</code> properties are listed in the payload below * Request: <pre><code>{ * "name": "string", * "type": "eventbridge", * "sink": { * "awsRegion": "string", * "awsAccountId": "string" * } * }</code></pre> * The response will include an additional field <code>awsPartnerEventSource</code> in the <code>sink</code>: <pre><code>{ * "id": "string", * "name": "string", * "type": "eventbridge", * "status": "active", * "sink": { * "awsAccountId": "string", * "awsRegion": "string", * "awsPartnerEventSource": "string" * } * }</code></pre> * <h5>Azure Event Grid Stream</h5> For an <code>Azure Event Grid</code> Stream, the <code>sink</code> properties are listed in the payload below * Request: <pre><code>{ * "name": "string", * "type": "eventgrid", * "sink": { * "azureSubscriptionId": "string", * "azureResourceGroup": "string", * "azureRegion": "string" * } * }</code></pre> * Response: <pre><code>{ * "id": "string", * "name": "string", * "type": "http", * "status": "active", * "sink": { * "azureSubscriptionId": "string", * "azureResourceGroup": "string", * "azureRegion": "string", * "azurePartnerTopic": "string" * } * }</code></pre> * <h5>Datadog Stream</h5> For a <code>Datadog</code> Stream, the <code>sink</code> properties are listed in the payload below * Request: <pre><code>{ * "name": "string", * "type": "datadog", * "sink": { * "datadogRegion": "string", * "datadogApiKey": "string" * } * }</code></pre> * Response: <pre><code>{ * "id": "string", * "name": "string", * "type": "datadog", * "status": "active", * "sink": { * "datadogRegion": "string", * "datadogApiKey": "string" * } * }</code></pre> * <h5>Splunk Stream</h5> For a <code>Splunk</code> Stream, the <code>sink</code> properties are listed in the payload below * Request: <pre><code>{ * "name": "string", * "type": "splunk", * "sink": { * "splunkDomain": "string", * "splunkToken": "string", * "splunkPort": "string", * "splunkSecure": "boolean" * } * }</code></pre> * Response: <pre><code>{ * "id": "string", * "name": "string", * "type": "splunk", * "status": "active", * "sink": { * "splunkDomain": "string", * "splunkToken": "string", * "splunkPort": "string", * "splunkSecure": "boolean" * } * }</code></pre> * <h5>Sumo Logic Stream</h5> For a <code>Sumo Logic</code> Stream, the <code>sink</code> properties are listed in the payload below * Request: <pre><code>{ * "name": "string", * "type": "sumo", * "sink": { * "sumoSourceAddress": "string", * } * }</code></pre> * Response: <pre><code>{ * "id": "string", * "name": "string", * "type": "sumo", * "status": "active", * "sink": { * "sumoSourceAddress": "string", * } * }</code></pre> * * @param {Management.CreateLogStreamRequestContent} request * @param {LogStreamsClient.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link Management.BadRequestError} * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.ConflictError} * @throws {@link Management.TooManyRequestsError} * * @example * await client.logStreams.create({ * type: "http", * sink: { * httpEndpoint: "httpEndpoint" * } * }) */ create(request, requestOptions) { return core.HttpResponsePromise.fromPromise(this.__create(request, requestOptions)); } __create(request, requestOptions) { return __awaiter(this, void 0, void 0, function* () { var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k; const _authRequest = yield this._options.authProvider.getAuthRequest(); let _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers); const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({ url: core.url.join((_d = (_c = (yield core.Supplier.get(this._options.baseUrl))) !== null && _c !== void 0 ? _c : (yield core.Supplier.get(this._options.environment))) !== null && _d !== void 0 ? _d : environments.ManagementEnvironment.Default, "log-streams"), method: "POST", headers: _headers, contentType: "application/json", queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams, requestType: "json", body: request, timeoutMs: ((_g = (_e = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _e !== void 0 ? _e : (_f = this._options) === null || _f === void 0 ? void 0 : _f.timeoutInSeconds) !== null && _g !== void 0 ? _g : 60) * 1000, maxRetries: (_h = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _h !== void 0 ? _h : (_j = this._options) === null || _j === void 0 ? void 0 : _j.maxRetries, abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal, fetchFn: (_k = this._options) === null || _k === void 0 ? void 0 : _k.fetch, logging: this._options.logging, }); if (_response.ok) { return { data: _response.body, rawResponse: _response.rawResponse, }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 400: throw new Management.BadRequestError(_response.error.body, _response.rawResponse); case 401: throw new Management.UnauthorizedError(_response.error.body, _response.rawResponse); case 403: throw new Management.ForbiddenError(_response.error.body, _response.rawResponse); case 409: throw new Management.ConflictError(_response.error.body, _response.rawResponse); case 429: throw new Management.TooManyRequestsError(_response.error.body, _response.rawResponse); default: throw new errors.ManagementError({ statusCode: _response.error.statusCode, body: _response.error.body, rawResponse: _response.rawResponse, }); } } return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "POST", "/log-streams"); }); } /** * Retrieve a log stream configuration and status. * <h5>Sample responses</h5><h5>Amazon EventBridge Log Stream</h5><pre><code>{ * "id": "string", * "name": "string", * "type": "eventbridge", * "status": "active|paused|suspended", * "sink": { * "awsAccountId": "string", * "awsRegion": "string", * "awsPartnerEventSource": "string" * } * }</code></pre> <h5>HTTP Log Stream</h5><pre><code>{ * "id": "string", * "name": "string", * "type": "http", * "status": "active|paused|suspended", * "sink": { * "httpContentFormat": "JSONLINES|JSONARRAY", * "httpContentType": "string", * "httpEndpoint": "string", * "httpAuthorization": "string" * } * }</code></pre> <h5>Datadog Log Stream</h5><pre><code>{ * "id": "string", * "name": "string", * "type": "datadog", * "status": "active|paused|suspended", * "sink": { * "datadogRegion": "string", * "datadogApiKey": "string" * } * * }</code></pre><h5>Mixpanel</h5> * * Request: <pre><code>{ * "name": "string", * "type": "mixpanel", * "sink": { * "mixpanelRegion": "string", // "us" | "eu", * "mixpanelProjectId": "string", * "mixpanelServiceAccountUsername": "string", * "mixpanelServiceAccountPassword": "string" * } * } </code></pre> * * * Response: <pre><code>{ * "id": "string", * "name": "string", * "type": "mixpanel", * "status": "active", * "sink": { * "mixpanelRegion": "string", // "us" | "eu", * "mixpanelProjectId": "string", * "mixpanelServiceAccountUsername": "string", * "mixpanelServiceAccountPassword": "string" // the following is redacted on return * } * } </code></pre> * * <h5>Segment</h5> * * Request: <pre><code> { * "name": "string", * "type": "segment", * "sink": { * "segmentWriteKey": "string" * } * }</code></pre> * * Response: <pre><code>{ * "id": "string", * "name": "string", * "type": "segment", * "status": "active", * "sink": { * "segmentWriteKey": "string" * } * } </code></pre> * * <h5>Splunk Log Stream</h5><pre><code>{ * "id": "string", * "name": "string", * "type": "splunk", * "status": "active|paused|suspended", * "sink": { * "splunkDomain": "string", * "splunkToken": "string", * "splunkPort": "string", * "splunkSecure": "boolean" * } * }</code></pre> <h5>Sumo Logic Log Stream</h5><pre><code>{ * "id": "string", * "name": "string", * "type": "sumo", * "status": "active|paused|suspended", * "sink": { * "sumoSourceAddress": "string", * } * }</code></pre> <h5>Status</h5> The <code>status</code> of a log stream maybe any of the following: * 1. <code>active</code> - Stream is currently enabled. * 2. <code>paused</code> - Stream is currently user disabled and will not attempt log delivery. * 3. <code>suspended</code> - Stream is currently disabled because of errors and will not attempt log delivery. * * @param {string} id - The id of the log stream to get * @param {LogStreamsClient.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} * * @example * await client.logStreams.get("id") */ get(id, requestOptions) { return core.HttpResponsePromise.fromPromise(this.__get(id, requestOptions)); } __get(id, requestOptions) { return __awaiter(this, void 0, void 0, function* () { var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k; const _authRequest = yield this._options.authProvider.getAuthRequest(); let _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers); const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({ url: core.url.join((_d = (_c = (yield core.Supplier.get(this._options.baseUrl))) !== null && _c !== void 0 ? _c : (yield core.Supplier.get(this._options.environment))) !== null && _d !== void 0 ? _d : environments.ManagementEnvironment.Default, `log-streams/${core.url.encodePathParam(id)}`), method: "GET", headers: _headers, queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams, timeoutMs: ((_g = (_e = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _e !== void 0 ? _e : (_f = this._options) === null || _f === void 0 ? void 0 : _f.timeoutInSeconds) !== null && _g !== void 0 ? _g : 60) * 1000, maxRetries: (_h = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _h !== void 0 ? _h : (_j = this._options) === null || _j === void 0 ? void 0 : _j.maxRetries, abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal, fetchFn: (_k = this._options) === null || _k === void 0 ? void 0 : _k.fetch, logging: this._options.logging, }); if (_response.ok) { return { data: _response.body, rawResponse: _response.rawResponse, }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 401: throw new Management.UnauthorizedError(_response.error.body, _response.rawResponse); case 403: throw new Management.ForbiddenError(_response.error.body, _response.rawResponse); case 404: throw new Management.NotFoundError(_response.error.body, _response.rawResponse); case 429: throw new Management.TooManyRequestsError(_response.error.body, _response.rawResponse); default: throw new errors.ManagementError({ statusCode: _response.error.statusCode, body: _response.error.body, rawResponse: _response.rawResponse, }); } } return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "GET", "/log-streams/{id}"); }); } /** * Delete a log stream. * * @param {string} id - The id of the log stream to delete * @param {LogStreamsClient.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link Management.BadRequestError} * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.NotFoundError} * @throws {@link Management.TooManyRequestsError} * * @example * await client.logStreams.delete("id") */ delete(id, requestOptions) { return core.HttpResponsePromise.fromPromise(this.__delete(id, requestOptions)); } __delete(id, requestOptions) { return __awaiter(this, void 0, void 0, function* () { var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k; const _authRequest = yield this._options.authProvider.getAuthRequest(); let _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers); const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({ url: core.url.join((_d = (_c = (yield core.Supplier.get(this._options.baseUrl))) !== null && _c !== void 0 ? _c : (yield core.Supplier.get(this._options.environment))) !== null && _d !== void 0 ? _d : environments.ManagementEnvironment.Default, `log-streams/${core.url.encodePathParam(id)}`), method: "DELETE", headers: _headers, queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams, timeoutMs: ((_g = (_e = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _e !== void 0 ? _e : (_f = this._options) === null || _f === void 0 ? void 0 : _f.timeoutInSeconds) !== null && _g !== void 0 ? _g : 60) * 1000, maxRetries: (_h = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _h !== void 0 ? _h : (_j = this._options) === null || _j === void 0 ? void 0 : _j.maxRetries, abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal, fetchFn: (_k = this._options) === null || _k === void 0 ? void 0 : _k.fetch, logging: this._options.logging, }); if (_response.ok) { return { data: undefined, rawResponse: _response.rawResponse }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 400: throw new Management.BadRequestError(_response.error.body, _response.rawResponse); case 401: throw new Management.UnauthorizedError(_response.error.body, _response.rawResponse); case 403: throw new Management.ForbiddenError(_response.error.body, _response.rawResponse); case 404: throw new Management.NotFoundError(_response.error.body, _response.rawResponse); case 429: throw new Management.TooManyRequestsError(_response.error.body, _response.rawResponse); default: throw new errors.ManagementError({ statusCode: _response.error.statusCode, body: _response.error.body, rawResponse: _response.rawResponse, }); } } return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "DELETE", "/log-streams/{id}"); }); } /** * Update a log stream. * <h4>Examples of how to use the PATCH endpoint.</h4> The following fields may be updated in a PATCH operation: <ul><li>name</li><li>status</li><li>sink</li></ul> Note: For log streams of type <code>eventbridge</code> and <code>eventgrid</code>, updating the <code>sink</code> is not permitted. * <h5>Update the status of a log stream</h5><pre><code>{ * "status": "active|paused" * }</code></pre> * <h5>Update the name of a log stream</h5><pre><code>{ * "name": "string" * }</code></pre> * <h5>Update the sink properties of a stream of type <code>http</code></h5><pre><code>{ * "sink": { * "httpEndpoint": "string", * "httpContentType": "string", * "httpContentFormat": "JSONARRAY|JSONLINES", * "httpAuthorization": "string" * } * }</code></pre> * <h5>Update the sink properties of a stream of type <code>datadog</code></h5><pre><code>{ * "sink": { * "datadogRegion": "string", * "datadogApiKey": "string" * } * }</code></pre> * <h5>Update the sink properties of a stream of type <code>splunk</code></h5><pre><code>{ * "sink": { * "splunkDomain": "string", * "splunkToken": "string", * "splunkPort": "string", * "splunkSecure": "boolean" * } * }</code></pre> * <h5>Update the sink properties of a stream of type <code>sumo</code></h5><pre><code>{ * "sink": { * "sumoSourceAddress": "string" * } * }</code></pre> * * @param {string} id - The id of the log stream to get * @param {Management.UpdateLogStreamRequestContent} request * @param {LogStreamsClient.RequestOptions} requestOptions - Request-specific configuration. * * @throws {@link Management.BadRequestError} * @throws {@link Management.UnauthorizedError} * @throws {@link Management.ForbiddenError} * @throws {@link Management.TooManyRequestsError} * * @example * await client.logStreams.update("id") */ update(id, request = {}, requestOptions) { return core.HttpResponsePromise.fromPromise(this.__update(id, request, requestOptions)); } __update(id_1) { return __awaiter(this, arguments, void 0, function* (id, request = {}, requestOptions) { var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k; const _authRequest = yield this._options.authProvider.getAuthRequest(); let _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers); const _response = yield ((_b = this._options.fetcher) !== null && _b !== void 0 ? _b : core.fetcher)({ url: core.url.join((_d = (_c = (yield core.Supplier.get(this._options.baseUrl))) !== null && _c !== void 0 ? _c : (yield core.Supplier.get(this._options.environment))) !== null && _d !== void 0 ? _d : environments.ManagementEnvironment.Default, `log-streams/${core.url.encodePathParam(id)}`), method: "PATCH", headers: _headers, contentType: "application/json", queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams, requestType: "json", body: request, timeoutMs: ((_g = (_e = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _e !== void 0 ? _e : (_f = this._options) === null || _f === void 0 ? void 0 : _f.timeoutInSeconds) !== null && _g !== void 0 ? _g : 60) * 1000, maxRetries: (_h = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _h !== void 0 ? _h : (_j = this._options) === null || _j === void 0 ? void 0 : _j.maxRetries, abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal, fetchFn: (_k = this._options) === null || _k === void 0 ? void 0 : _k.fetch, logging: this._options.logging, }); if (_response.ok) { return { data: _response.body, rawResponse: _response.rawResponse, }; } if (_response.error.reason === "status-code") { switch (_response.error.statusCode) { case 400: throw new Management.BadRequestError(_response.error.body, _response.rawResponse); case 401: throw new Management.UnauthorizedError(_response.error.body, _response.rawResponse); case 403: throw new Management.ForbiddenError(_response.error.body, _response.rawResponse); case 429: throw new Management.TooManyRequestsError(_response.error.body, _response.rawResponse); default: throw new errors.ManagementError({ statusCode: _response.error.statusCode, body: _response.error.body, rawResponse: _response.rawResponse, }); } } return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "PATCH", "/log-streams/{id}"); }); } } exports.LogStreamsClient = LogStreamsClient;