UNPKG

@contiva/sap-integration-suite-client

Version:
279 lines (278 loc) 12.2 kB
"use strict"; /* eslint-disable */ /* tslint:disable */ // @ts-nocheck /* * --------------------------------------------------------------- * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ## * ## ## * ## AUTHOR: acacode ## * ## SOURCE: https://github.com/acacode/swagger-typescript-api ## * --------------------------------------------------------------- */ Object.defineProperty(exports, "__esModule", { value: true }); exports.Api = exports.HttpClient = exports.ContentType = void 0; var ContentType; (function (ContentType) { ContentType["Json"] = "application/json"; ContentType["FormData"] = "multipart/form-data"; ContentType["UrlEncoded"] = "application/x-www-form-urlencoded"; ContentType["Text"] = "text/plain"; })(ContentType || (exports.ContentType = ContentType = {})); class HttpClient { constructor(apiConfig = {}) { this.baseUrl = "https://{Account Short Name}-tmn.{SSL Host}.{landscapehost}/api/v1"; this.securityData = null; this.abortControllers = new Map(); this.customFetch = (...fetchParams) => fetch(...fetchParams); this.baseApiParams = { credentials: "same-origin", headers: {}, redirect: "follow", referrerPolicy: "no-referrer", }; this.setSecurityData = (data) => { this.securityData = data; }; this.contentFormatters = { [ContentType.Json]: (input) => input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input, [ContentType.Text]: (input) => (input !== null && typeof input !== "string" ? JSON.stringify(input) : input), [ContentType.FormData]: (input) => Object.keys(input || {}).reduce((formData, key) => { const property = input[key]; formData.append(key, property instanceof Blob ? property : typeof property === "object" && property !== null ? JSON.stringify(property) : `${property}`); return formData; }, new FormData()), [ContentType.UrlEncoded]: (input) => this.toQueryString(input), }; this.createAbortSignal = (cancelToken) => { if (this.abortControllers.has(cancelToken)) { const abortController = this.abortControllers.get(cancelToken); if (abortController) { return abortController.signal; } return void 0; } const abortController = new AbortController(); this.abortControllers.set(cancelToken, abortController); return abortController.signal; }; this.abortRequest = (cancelToken) => { const abortController = this.abortControllers.get(cancelToken); if (abortController) { abortController.abort(); this.abortControllers.delete(cancelToken); } }; this.request = async ({ body, secure, path, type, query, format, baseUrl, cancelToken, ...params }) => { const secureParams = ((typeof secure === "boolean" ? secure : this.baseApiParams.secure) && this.securityWorker && (await this.securityWorker(this.securityData))) || {}; const requestParams = this.mergeRequestParams(params, secureParams); const queryString = query && this.toQueryString(query); const payloadFormatter = this.contentFormatters[type || ContentType.Json]; const responseFormat = format || requestParams.format; return this.customFetch(`${baseUrl || this.baseUrl || ""}${path}${queryString ? `?${queryString}` : ""}`, { ...requestParams, headers: { ...(requestParams.headers || {}), ...(type && type !== ContentType.FormData ? { "Content-Type": type } : {}), }, signal: (cancelToken ? this.createAbortSignal(cancelToken) : requestParams.signal) || null, body: typeof body === "undefined" || body === null ? null : payloadFormatter(body), }).then(async (response) => { const r = response.clone(); r.data = null; r.error = null; const data = !responseFormat ? r : await response[responseFormat]() .then((data) => { if (r.ok) { r.data = data; } else { r.error = data; } return r; }) .catch((e) => { r.error = e; return r; }); if (cancelToken) { this.abortControllers.delete(cancelToken); } if (!response.ok) throw data; return data; }); }; Object.assign(this, apiConfig); } encodeQueryParam(key, value) { const encodedKey = encodeURIComponent(key); return `${encodedKey}=${encodeURIComponent(typeof value === "number" ? value : `${value}`)}`; } addQueryParam(query, key) { return this.encodeQueryParam(key, query[key]); } addArrayQueryParam(query, key) { const value = query[key]; return value.map((v) => this.encodeQueryParam(key, v)).join("&"); } toQueryString(rawQuery) { const query = rawQuery || {}; const keys = Object.keys(query).filter((key) => "undefined" !== typeof query[key]); return keys .map((key) => (Array.isArray(query[key]) ? this.addArrayQueryParam(query, key) : this.addQueryParam(query, key))) .join("&"); } addQueryParams(rawQuery) { const queryString = this.toQueryString(rawQuery); return queryString ? `?${queryString}` : ""; } mergeRequestParams(params1, params2) { return { ...this.baseApiParams, ...params1, ...(params2 || {}), headers: { ...(this.baseApiParams.headers || {}), ...(params1.headers || {}), ...((params2 && params2.headers) || {}), }, }; } } exports.HttpClient = HttpClient; /** * @title Log Files * @version 1.0.0 * @baseUrl https://{Account Short Name}-tmn.{SSL Host}.{landscapehost}/api/v1 * @externalDocs https://help.sap.com/viewer/368c481cd6954bdfa5d0435479fd4eaf/Cloud/en-US/93bc3722533741c7a48eec6a8352f060.html * * HTTP log files enables you to access technical system logs written during message processing on the runtime node. HTTP log files contain information on authentication and authorization errors for inbound HTTP communication. The trace log files contain processing information including message payload data. * This API is implemented based on OData version 2 specification. */ class Api extends HttpClient { constructor() { super(...arguments); this.logFileArchives = { /** * @description You can use the following request to get all log file collections. * * @tags Log File Archives * @name LogFileArchivesList * @summary Get all log file collections. * @request GET:/LogFileArchives * @secure */ logFileArchivesList: (params = {}) => this.request({ path: `/LogFileArchives`, method: "GET", secure: true, type: ContentType.Json, format: "json", ...params, }), }; this.logFileArchivesScopeScopeLogFileTypeLogFileTypeNodeScopeWorker = { /** * @description You can use the following request to get log file collections for a scope and type in a compressed file (zip format), which could be downloaded via OData $value option. * * @tags Log File Archives * @name LogFileArchivesScopeLogFileTypeNodeScopeWorkerList * @summary Get log file collections by scope and type in a compressed file. * @request GET:/LogFileArchives(Scope='{Scope}',LogFileType='{LogFileType}',NodeScope='worker') * @secure */ logFileArchivesScopeLogFileTypeNodeScopeWorkerList: (scope, logFileType, query, params = {}) => this.request({ path: `/LogFileArchives(Scope='${scope}',LogFileType='${logFileType}',NodeScope='worker')`, method: "GET", query: query, secure: true, type: ContentType.Json, format: "json", ...params, }), /** * @description You can use the following request to download log file collections for a scope and type in a compressed file (zip format). * * @tags Log File Archives * @name ValueList * @summary Download log file collections. * @request GET:/LogFileArchives(Scope='{Scope}',LogFileType='{LogFileType}',NodeScope='worker')/$value * @secure */ valueList: (scope, logFileType, query, params = {}) => this.request({ path: `/LogFileArchives(Scope='${scope}',LogFileType='${logFileType}',NodeScope='worker')/$value`, method: "GET", query: query, secure: true, type: ContentType.Json, ...params, }), }; this.logFiles = { /** * @description You can use the following request to get all log files. * * @tags Log Files * @name LogFilesList * @summary Get all log files. * @request GET:/LogFiles * @secure */ logFilesList: (query, params = {}) => this.request({ path: `/LogFiles`, method: "GET", query: query, secure: true, type: ContentType.Json, format: "json", ...params, }), }; this.logFilesNameNameApplicationApplication = { /** * @description You can use the following request to get log file by name and application, which could be downloaded via OData $value option. * * @tags Log Files * @name LogFilesNameApplicationList * @summary Get log files by name and application. * @request GET:/LogFiles(Name='{Name}',Application='{Application}') * @secure */ logFilesNameApplicationList: (name, application, params = {}) => this.request({ path: `/LogFiles(Name='${name}',Application='${application}')`, method: "GET", secure: true, type: ContentType.Json, format: "json", ...params, }), /** * @description You can use the following request to download log file by name and application. * * @tags Log Files * @name ValueList * @summary Download log file. * @request GET:/LogFiles(Name='{Name}',Application='{Application}')/$value * @secure */ valueList: (name, application, params = {}) => this.request({ path: `/LogFiles(Name='${name}',Application='${application}')/$value`, method: "GET", secure: true, type: ContentType.Json, ...params, }), }; } } exports.Api = Api;