/** * Sparks OpenAPI * Generated documentation for the Logicdrop Sparks API and OpenAPI clients. Logicdrop Sparks lets users build rules, analyze data, and automate documents. Use it to make decisions faster, generate documents better, and learn from your data. ### Documentation - [User Documentation](https://docs.logicdrop.com) ### Modules - [Sparks Compute](https://docs.logicdrop.com/rules/introduction) - [Sparks Decision Tables](https://docs.logicdrop.com/rules/authoring-decision-tables) - [Sparks Documents](https://docs.logicdrop.com/documents/introduction) ### Clients - [OpenAPI Clients](https://docs.logicdrop.com/development/sample-clients) ### Security - [Authorizing API Requests](https://docs.logicdrop.com/development/authorization) * * The version of the OpenAPI document: v_VERSION_, build# _BUILD_ * Contact: support@logicdrop.com * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ import localVarRequest = require('request'); import http = require('http'); /* tslint:disable:no-unused-locals */ import { ArtifactResponse } from '../model/artifactResponse'; import { DeleteArtifactRequest } from '../model/deleteArtifactRequest'; import { Schema } from '../model/schema'; import { UpdateArtifactRequest } from '../model/updateArtifactRequest'; import { ObjectSerializer, Authentication, VoidAuth } from '../model/models'; import { HttpBasicAuth, ApiKeyAuth, OAuth } from '../model/models'; import { HttpError, RequestFile } from './apis'; let defaultBasePath = 'https://api.staging.com'; // =============================================== // This file is autogenerated - Please do not edit // =============================================== export enum SchemaServicesApiApiKeys { api, } export class SchemaServicesApi { protected _basePath = defaultBasePath; protected defaultHeaders : any = {}; protected _useQuerystring : boolean = false; protected authentications = { 'default': new VoidAuth(), 'jwt': new HttpBasicAuth(), 'api': new ApiKeyAuth('header', 'X-Logicdrop-ApiKey'), 'oauth2': new OAuth(), } constructor(oAuth?: OAuth); constructor(oAuth: OAuth, basePath?: string) { if (oAuth) { this.oAuth = oAuth; } if (basePath) { this.basePath = basePath; } } set useQuerystring(value: boolean) { this._useQuerystring = value; } set basePath(basePath: string) { this._basePath = basePath; } get basePath() { return this._basePath; } public setDefaultAuthentication(auth: Authentication) { this.authentications.default = auth; } public setApiKey(key: SchemaServicesApiApiKeys, value: string) { (this.authentications as any)[SchemaServicesApiApiKeys[key]].apiKey = value; } set oAuth(oAuth: OAuth) { this.authentications.oauth2 = oAuth; } set tokenUrl(tokenUrl: string) { this.authentications.oauth2.tokenUrl = tokenUrl; } set clientId(clientId: string) { this.authentications.oauth2.clientId = clientId; } set clientSecret(clientSecret: string) { this.authentications.oauth2.clientSecret = clientSecret; } /** * * @summary Delete schema * @param client Client name * @param project Project name * @param artifact Schema name * @param v Schema version */ public async deleteSchema (client: string, project: string, artifact: string, v?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: ArtifactResponse; }> { const localVarPath = this.basePath + '/schemas/{client}/{project}/{artifact}' .replace('{' + 'client' + '}', encodeURIComponent(String(client))) .replace('{' + 'project' + '}', encodeURIComponent(String(project))) .replace('{' + 'artifact' + '}', encodeURIComponent(String(artifact))); let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); const produces = ['application/json']; // give precedence to 'application/json' if (produces.indexOf('application/json') >= 0) { localVarHeaderParams.Accept = 'application/json'; } else { localVarHeaderParams.Accept = produces.join(','); } let localVarFormParams: any = {}; // verify required parameter 'client' is not null or undefined if (client === null || client === undefined) { throw new Error('Required parameter client was null or undefined when calling deleteSchema.'); } // verify required parameter 'project' is not null or undefined if (project === null || project === undefined) { throw new Error('Required parameter project was null or undefined when calling deleteSchema.'); } // verify required parameter 'artifact' is not null or undefined if (artifact === null || artifact === undefined) { throw new Error('Required parameter artifact was null or undefined when calling deleteSchema.'); } if (v !== undefined) { localVarQueryParameters['v'] = ObjectSerializer.serialize(v, "string"); } (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; let localVarRequestOptions: localVarRequest.Options = { method: 'DELETE', qs: localVarQueryParameters, headers: localVarHeaderParams, uri: localVarPath, useQuerystring: this._useQuerystring, json: true, }; let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(async () => await this.authentications.oauth2.applyToRequest(localVarRequestOptions)); authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions)); return authenticationPromise.then(() => { if (Object.keys(localVarFormParams).length) { if (localVarUseFormData) { (localVarRequestOptions).formData = localVarFormParams; } else { localVarRequestOptions.form = localVarFormParams; } } return new Promise<{ response: http.ClientResponse; body: ArtifactResponse; }>((resolve, reject) => { localVarRequest(localVarRequestOptions, (error, response, body) => { if (error) { reject(error); } else { body = ObjectSerializer.deserialize(body, "ArtifactResponse"); if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { resolve({ response: response, body: body }); } else { reject(new HttpError(response, body, response.statusCode)); } } }); }); }); } /** * * @summary Delete schemas * @param client Client name * @param project Project name * @param deleteArtifactRequest Remove schemas by criteria */ public async deleteSchemas (client: string, project: string, deleteArtifactRequest: DeleteArtifactRequest, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: ArtifactResponse; }> { const localVarPath = this.basePath + '/schemas/{client}/{project}' .replace('{' + 'client' + '}', encodeURIComponent(String(client))) .replace('{' + 'project' + '}', encodeURIComponent(String(project))); let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); const produces = ['application/json']; // give precedence to 'application/json' if (produces.indexOf('application/json') >= 0) { localVarHeaderParams.Accept = 'application/json'; } else { localVarHeaderParams.Accept = produces.join(','); } let localVarFormParams: any = {}; // verify required parameter 'client' is not null or undefined if (client === null || client === undefined) { throw new Error('Required parameter client was null or undefined when calling deleteSchemas.'); } // verify required parameter 'project' is not null or undefined if (project === null || project === undefined) { throw new Error('Required parameter project was null or undefined when calling deleteSchemas.'); } // verify required parameter 'deleteArtifactRequest' is not null or undefined if (deleteArtifactRequest === null || deleteArtifactRequest === undefined) { throw new Error('Required parameter deleteArtifactRequest was null or undefined when calling deleteSchemas.'); } (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; let localVarRequestOptions: localVarRequest.Options = { method: 'DELETE', qs: localVarQueryParameters, headers: localVarHeaderParams, uri: localVarPath, useQuerystring: this._useQuerystring, json: true, body: ObjectSerializer.serialize(deleteArtifactRequest, "DeleteArtifactRequest") }; let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(async () => await this.authentications.oauth2.applyToRequest(localVarRequestOptions)); authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions)); return authenticationPromise.then(() => { if (Object.keys(localVarFormParams).length) { if (localVarUseFormData) { (localVarRequestOptions).formData = localVarFormParams; } else { localVarRequestOptions.form = localVarFormParams; } } return new Promise<{ response: http.ClientResponse; body: ArtifactResponse; }>((resolve, reject) => { localVarRequest(localVarRequestOptions, (error, response, body) => { if (error) { reject(error); } else { body = ObjectSerializer.deserialize(body, "ArtifactResponse"); if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { resolve({ response: response, body: body }); } else { reject(new HttpError(response, body, response.statusCode)); } } }); }); }); } /** * Get an schema * @summary Get schema * @param client Client name * @param project Project name * @param artifact Schema name * @param v Schema version * @param view Fields to return in the results */ public async getSchema (client: string, project: string, artifact: string, v?: string, view?: Array, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: Schema; }> { const localVarPath = this.basePath + '/schemas/{client}/{project}/{artifact}' .replace('{' + 'client' + '}', encodeURIComponent(String(client))) .replace('{' + 'project' + '}', encodeURIComponent(String(project))) .replace('{' + 'artifact' + '}', encodeURIComponent(String(artifact))); let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); const produces = ['application/json']; // give precedence to 'application/json' if (produces.indexOf('application/json') >= 0) { localVarHeaderParams.Accept = 'application/json'; } else { localVarHeaderParams.Accept = produces.join(','); } let localVarFormParams: any = {}; // verify required parameter 'client' is not null or undefined if (client === null || client === undefined) { throw new Error('Required parameter client was null or undefined when calling getSchema.'); } // verify required parameter 'project' is not null or undefined if (project === null || project === undefined) { throw new Error('Required parameter project was null or undefined when calling getSchema.'); } // verify required parameter 'artifact' is not null or undefined if (artifact === null || artifact === undefined) { throw new Error('Required parameter artifact was null or undefined when calling getSchema.'); } if (v !== undefined) { localVarQueryParameters['v'] = ObjectSerializer.serialize(v, "string"); } if (view !== undefined) { localVarQueryParameters['view'] = ObjectSerializer.serialize(view, "Array"); } (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; let localVarRequestOptions: localVarRequest.Options = { method: 'GET', qs: localVarQueryParameters, headers: localVarHeaderParams, uri: localVarPath, useQuerystring: this._useQuerystring, json: true, }; let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(async () => await this.authentications.oauth2.applyToRequest(localVarRequestOptions)); authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions)); return authenticationPromise.then(() => { if (Object.keys(localVarFormParams).length) { if (localVarUseFormData) { (localVarRequestOptions).formData = localVarFormParams; } else { localVarRequestOptions.form = localVarFormParams; } } return new Promise<{ response: http.ClientResponse; body: Schema; }>((resolve, reject) => { localVarRequest(localVarRequestOptions, (error, response, body) => { if (error) { reject(error); } else { body = ObjectSerializer.deserialize(body, "Schema"); if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { resolve({ response: response, body: body }); } else { reject(new HttpError(response, body, response.statusCode)); } } }); }); }); } /** * Get schemas using optional simple filters * @summary List schemas * @param client Client name * @param project Project name * @param view Comma separated fields to include */ public async listSchemas (client: string, project: string, view?: string, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: Array; }> { const localVarPath = this.basePath + '/schemas/{client}/{project}' .replace('{' + 'client' + '}', encodeURIComponent(String(client))) .replace('{' + 'project' + '}', encodeURIComponent(String(project))); let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); const produces = ['application/json']; // give precedence to 'application/json' if (produces.indexOf('application/json') >= 0) { localVarHeaderParams.Accept = 'application/json'; } else { localVarHeaderParams.Accept = produces.join(','); } let localVarFormParams: any = {}; // verify required parameter 'client' is not null or undefined if (client === null || client === undefined) { throw new Error('Required parameter client was null or undefined when calling listSchemas.'); } // verify required parameter 'project' is not null or undefined if (project === null || project === undefined) { throw new Error('Required parameter project was null or undefined when calling listSchemas.'); } if (view !== undefined) { localVarQueryParameters['view'] = ObjectSerializer.serialize(view, "string"); } (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; let localVarRequestOptions: localVarRequest.Options = { method: 'GET', qs: localVarQueryParameters, headers: localVarHeaderParams, uri: localVarPath, useQuerystring: this._useQuerystring, json: true, }; let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(async () => await this.authentications.oauth2.applyToRequest(localVarRequestOptions)); authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions)); return authenticationPromise.then(() => { if (Object.keys(localVarFormParams).length) { if (localVarUseFormData) { (localVarRequestOptions).formData = localVarFormParams; } else { localVarRequestOptions.form = localVarFormParams; } } return new Promise<{ response: http.ClientResponse; body: Array; }>((resolve, reject) => { localVarRequest(localVarRequestOptions, (error, response, body) => { if (error) { reject(error); } else { body = ObjectSerializer.deserialize(body, "Array"); if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { resolve({ response: response, body: body }); } else { reject(new HttpError(response, body, response.statusCode)); } } }); }); }); } /** * Saves or creates a schema (overwrite) * @summary Save schema * @param client Client name * @param project Project name * @param schema Schema to persist */ public async saveSchema (client: string, project: string, schema: Schema, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: Schema; }> { const localVarPath = this.basePath + '/schemas/{client}/{project}' .replace('{' + 'client' + '}', encodeURIComponent(String(client))) .replace('{' + 'project' + '}', encodeURIComponent(String(project))); let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); const produces = ['application/json']; // give precedence to 'application/json' if (produces.indexOf('application/json') >= 0) { localVarHeaderParams.Accept = 'application/json'; } else { localVarHeaderParams.Accept = produces.join(','); } let localVarFormParams: any = {}; // verify required parameter 'client' is not null or undefined if (client === null || client === undefined) { throw new Error('Required parameter client was null or undefined when calling saveSchema.'); } // verify required parameter 'project' is not null or undefined if (project === null || project === undefined) { throw new Error('Required parameter project was null or undefined when calling saveSchema.'); } // verify required parameter 'schema' is not null or undefined if (schema === null || schema === undefined) { throw new Error('Required parameter schema was null or undefined when calling saveSchema.'); } (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; let localVarRequestOptions: localVarRequest.Options = { method: 'PUT', qs: localVarQueryParameters, headers: localVarHeaderParams, uri: localVarPath, useQuerystring: this._useQuerystring, json: true, body: ObjectSerializer.serialize(schema, "Schema") }; let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(async () => await this.authentications.oauth2.applyToRequest(localVarRequestOptions)); authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions)); return authenticationPromise.then(() => { if (Object.keys(localVarFormParams).length) { if (localVarUseFormData) { (localVarRequestOptions).formData = localVarFormParams; } else { localVarRequestOptions.form = localVarFormParams; } } return new Promise<{ response: http.ClientResponse; body: Schema; }>((resolve, reject) => { localVarRequest(localVarRequestOptions, (error, response, body) => { if (error) { reject(error); } else { body = ObjectSerializer.deserialize(body, "Schema"); if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { resolve({ response: response, body: body }); } else { reject(new HttpError(response, body, response.statusCode)); } } }); }); }); } /** * Updates one schema * @summary Update schema * @param client Client name * @param project Project name * @param updateArtifactRequest Schemas to update */ public async updateSchema (client: string, project: string, updateArtifactRequest: UpdateArtifactRequest, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: ArtifactResponse; }> { const localVarPath = this.basePath + '/schemas/{client}/{project}' .replace('{' + 'client' + '}', encodeURIComponent(String(client))) .replace('{' + 'project' + '}', encodeURIComponent(String(project))); let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); const produces = ['application/json']; // give precedence to 'application/json' if (produces.indexOf('application/json') >= 0) { localVarHeaderParams.Accept = 'application/json'; } else { localVarHeaderParams.Accept = produces.join(','); } let localVarFormParams: any = {}; // verify required parameter 'client' is not null or undefined if (client === null || client === undefined) { throw new Error('Required parameter client was null or undefined when calling updateSchema.'); } // verify required parameter 'project' is not null or undefined if (project === null || project === undefined) { throw new Error('Required parameter project was null or undefined when calling updateSchema.'); } // verify required parameter 'updateArtifactRequest' is not null or undefined if (updateArtifactRequest === null || updateArtifactRequest === undefined) { throw new Error('Required parameter updateArtifactRequest was null or undefined when calling updateSchema.'); } (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; let localVarRequestOptions: localVarRequest.Options = { method: 'PATCH', qs: localVarQueryParameters, headers: localVarHeaderParams, uri: localVarPath, useQuerystring: this._useQuerystring, json: true, body: ObjectSerializer.serialize(updateArtifactRequest, "UpdateArtifactRequest") }; let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(async () => await this.authentications.oauth2.applyToRequest(localVarRequestOptions)); authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions)); return authenticationPromise.then(() => { if (Object.keys(localVarFormParams).length) { if (localVarUseFormData) { (localVarRequestOptions).formData = localVarFormParams; } else { localVarRequestOptions.form = localVarFormParams; } } return new Promise<{ response: http.ClientResponse; body: ArtifactResponse; }>((resolve, reject) => { localVarRequest(localVarRequestOptions, (error, response, body) => { if (error) { reject(error); } else { body = ObjectSerializer.deserialize(body, "ArtifactResponse"); if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { resolve({ response: response, body: body }); } else { reject(new HttpError(response, body, response.statusCode)); } } }); }); }); } /** * Updates multiple schemas * @summary Update schemas * @param client Client name * @param project Project name * @param updateArtifactRequest Schemas to update */ public async updateSchemas (client: string, project: string, updateArtifactRequest: UpdateArtifactRequest, options: {headers: {[name: string]: string}} = {headers: {}}) : Promise<{ response: http.ClientResponse; body: ArtifactResponse; }> { const localVarPath = this.basePath + '/schemas/{client}/{project}' .replace('{' + 'client' + '}', encodeURIComponent(String(client))) .replace('{' + 'project' + '}', encodeURIComponent(String(project))); let localVarQueryParameters: any = {}; let localVarHeaderParams: any = (Object).assign({}, this.defaultHeaders); const produces = ['application/json']; // give precedence to 'application/json' if (produces.indexOf('application/json') >= 0) { localVarHeaderParams.Accept = 'application/json'; } else { localVarHeaderParams.Accept = produces.join(','); } let localVarFormParams: any = {}; // verify required parameter 'client' is not null or undefined if (client === null || client === undefined) { throw new Error('Required parameter client was null or undefined when calling updateSchemas.'); } // verify required parameter 'project' is not null or undefined if (project === null || project === undefined) { throw new Error('Required parameter project was null or undefined when calling updateSchemas.'); } // verify required parameter 'updateArtifactRequest' is not null or undefined if (updateArtifactRequest === null || updateArtifactRequest === undefined) { throw new Error('Required parameter updateArtifactRequest was null or undefined when calling updateSchemas.'); } (Object).assign(localVarHeaderParams, options.headers); let localVarUseFormData = false; let localVarRequestOptions: localVarRequest.Options = { method: 'POST', qs: localVarQueryParameters, headers: localVarHeaderParams, uri: localVarPath, useQuerystring: this._useQuerystring, json: true, body: ObjectSerializer.serialize(updateArtifactRequest, "UpdateArtifactRequest") }; let authenticationPromise = Promise.resolve(); authenticationPromise = authenticationPromise.then(async () => await this.authentications.oauth2.applyToRequest(localVarRequestOptions)); authenticationPromise = authenticationPromise.then(() => this.authentications.default.applyToRequest(localVarRequestOptions)); return authenticationPromise.then(() => { if (Object.keys(localVarFormParams).length) { if (localVarUseFormData) { (localVarRequestOptions).formData = localVarFormParams; } else { localVarRequestOptions.form = localVarFormParams; } } return new Promise<{ response: http.ClientResponse; body: ArtifactResponse; }>((resolve, reject) => { localVarRequest(localVarRequestOptions, (error, response, body) => { if (error) { reject(error); } else { body = ObjectSerializer.deserialize(body, "ArtifactResponse"); if (response.statusCode && response.statusCode >= 200 && response.statusCode <= 299) { resolve({ response: response, body: body }); } else { reject(new HttpError(response, body, response.statusCode)); } } }); }); }); } }