/* tslint:disable */ /* eslint-disable */ /** * Faraday REST API * The [Faraday](https://faraday.ai) API makes it easy to predict customer behavior programmatically. See our [API change policy](https://faraday.ai/legal). * * The version of the OpenAPI document: 1.0.0 * Contact: support@faraday.ai * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. */ import * as runtime from '../runtime'; import { ArchiveConfig, Connection, ConnectionMergePatch, ConnectionPost, Dataset, RotateCredentialsRequest, Target, } from '../models'; export interface ArchiveConnectionRequest { connectionId: string; archiveConfig: ArchiveConfig; } export interface CreateConnectionRequest { connectionFields: ConnectionPost; } export interface DeleteConnectionRequest { connectionId: string; } export interface ForceUpdateConnectionRequest { connectionId: string; } export interface GetConnectionRequest { connectionId: string; } export interface GetConnectionDatasetsRequest { connectionId: string; } export interface GetConnectionTargetsRequest { connectionId: string; } export interface GetConnectionsRequest { ids?: Array; } export interface RotateConnectionCredentialsRequest { connectionId: string; rotateCredentialsRequest: RotateCredentialsRequest; } export interface UnarchiveConnectionRequest { connectionId: string; archiveConfig: ArchiveConfig; } export interface UpdateConnectionRequest { connectionId: string; connectionMergePatch: ConnectionMergePatch; } /** * */ export class ConnectionsApi extends runtime.BaseAPI { /** * Archive a connection * Archive a connection */ async archiveConnectionRaw(requestParameters: ArchiveConnectionRequest, ): Promise> { if (requestParameters.connectionId === null || requestParameters.connectionId === undefined) { throw new runtime.RequiredError('connectionId','Required parameter requestParameters.connectionId was null or undefined when calling archiveConnection.'); } if (requestParameters.archiveConfig === null || requestParameters.archiveConfig === undefined) { throw new runtime.RequiredError('archiveConfig','Required parameter requestParameters.archiveConfig was null or undefined when calling archiveConnection.'); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; headerParameters['Content-Type'] = 'application/json'; if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = await token("bearer", []); if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } const response = await this.request({ path: `/connections/{connection_id}/archive`.replace(`{${"connection_id"}}`, encodeURIComponent(String(requestParameters.connectionId))), method: 'POST', headers: headerParameters, query: queryParameters, body: requestParameters.archiveConfig, }); return new runtime.VoidApiResponse(response); } /** * Archive a connection * Archive a connection */ async archiveConnection(connectionId: string, archiveConfig: ArchiveConfig, ): Promise { await this.archiveConnectionRaw({ connectionId: connectionId, archiveConfig: archiveConfig }, ); } /** * Add a new connection. Connections are configuration for connecting data between Faraday and an external location. They are required when working with **replication targets**. All connections have a `type` that determines which options may be specified. Connection `type` is specified in the `options` object. * Create connection */ async createConnectionRaw(requestParameters: CreateConnectionRequest, ): Promise> { if (requestParameters.connectionFields === null || requestParameters.connectionFields === undefined) { throw new runtime.RequiredError('connectionFields','Required parameter requestParameters.connectionFields was null or undefined when calling createConnection.'); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; headerParameters['Content-Type'] = 'application/json'; if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = await token("bearer", []); if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } const response = await this.request({ path: `/connections`, method: 'POST', headers: headerParameters, query: queryParameters, body: requestParameters.connectionFields, }); return new runtime.JSONApiResponse(response); } /** * Add a new connection. Connections are configuration for connecting data between Faraday and an external location. They are required when working with **replication targets**. All connections have a `type` that determines which options may be specified. Connection `type` is specified in the `options` object. * Create connection */ async createConnection(connectionFields: ConnectionPost, ): Promise { const response = await this.createConnectionRaw({ connectionFields: connectionFields }, ); return await response.value(); } /** * Delete a connection * Delete a connection */ async deleteConnectionRaw(requestParameters: DeleteConnectionRequest, ): Promise> { if (requestParameters.connectionId === null || requestParameters.connectionId === undefined) { throw new runtime.RequiredError('connectionId','Required parameter requestParameters.connectionId was null or undefined when calling deleteConnection.'); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = await token("bearer", []); if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } const response = await this.request({ path: `/connections/{connection_id}`.replace(`{${"connection_id"}}`, encodeURIComponent(String(requestParameters.connectionId))), method: 'DELETE', headers: headerParameters, query: queryParameters, }); return new runtime.VoidApiResponse(response); } /** * Delete a connection * Delete a connection */ async deleteConnection(connectionId: string, ): Promise { await this.deleteConnectionRaw({ connectionId: connectionId }, ); } /** * Trigger a rerun for this resource. Faraday automatically updates resources when their config changes, but this option is available in case of transient errors. * Trigger a rerun for this resource. */ async forceUpdateConnectionRaw(requestParameters: ForceUpdateConnectionRequest, ): Promise> { if (requestParameters.connectionId === null || requestParameters.connectionId === undefined) { throw new runtime.RequiredError('connectionId','Required parameter requestParameters.connectionId was null or undefined when calling forceUpdateConnection.'); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = await token("bearer", []); if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } const response = await this.request({ path: `/connections/{connection_id}/force_update`.replace(`{${"connection_id"}}`, encodeURIComponent(String(requestParameters.connectionId))), method: 'POST', headers: headerParameters, query: queryParameters, }); return new runtime.VoidApiResponse(response); } /** * Trigger a rerun for this resource. Faraday automatically updates resources when their config changes, but this option is available in case of transient errors. * Trigger a rerun for this resource. */ async forceUpdateConnection(connectionId: string, ): Promise { await this.forceUpdateConnectionRaw({ connectionId: connectionId }, ); } /** * Get details on a specific connection * Retrieve a connection */ async getConnectionRaw(requestParameters: GetConnectionRequest, ): Promise> { if (requestParameters.connectionId === null || requestParameters.connectionId === undefined) { throw new runtime.RequiredError('connectionId','Required parameter requestParameters.connectionId was null or undefined when calling getConnection.'); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = await token("bearer", []); if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } const response = await this.request({ path: `/connections/{connection_id}`.replace(`{${"connection_id"}}`, encodeURIComponent(String(requestParameters.connectionId))), method: 'GET', headers: headerParameters, query: queryParameters, }); return new runtime.JSONApiResponse(response); } /** * Get details on a specific connection * Retrieve a connection */ async getConnection(connectionId: string, ): Promise { const response = await this.getConnectionRaw({ connectionId: connectionId }, ); return await response.value(); } /** * Get all datasets that use this connection * Retrieve all datasets that use this connection */ async getConnectionDatasetsRaw(requestParameters: GetConnectionDatasetsRequest, ): Promise>> { if (requestParameters.connectionId === null || requestParameters.connectionId === undefined) { throw new runtime.RequiredError('connectionId','Required parameter requestParameters.connectionId was null or undefined when calling getConnectionDatasets.'); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = await token("bearer", []); if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } const response = await this.request({ path: `/connections/{connection_id}/datasets`.replace(`{${"connection_id"}}`, encodeURIComponent(String(requestParameters.connectionId))), method: 'GET', headers: headerParameters, query: queryParameters, }); return new runtime.JSONApiResponse(response); } /** * Get all datasets that use this connection * Retrieve all datasets that use this connection */ async getConnectionDatasets(connectionId: string, ): Promise> { const response = await this.getConnectionDatasetsRaw({ connectionId: connectionId }, ); return await response.value(); } /** * Get all targets that use this connection * Retrieve all targets that use this connection */ async getConnectionTargetsRaw(requestParameters: GetConnectionTargetsRequest, ): Promise>> { if (requestParameters.connectionId === null || requestParameters.connectionId === undefined) { throw new runtime.RequiredError('connectionId','Required parameter requestParameters.connectionId was null or undefined when calling getConnectionTargets.'); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = await token("bearer", []); if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } const response = await this.request({ path: `/connections/{connection_id}/targets`.replace(`{${"connection_id"}}`, encodeURIComponent(String(requestParameters.connectionId))), method: 'GET', headers: headerParameters, query: queryParameters, }); return new runtime.JSONApiResponse(response); } /** * Get all targets that use this connection * Retrieve all targets that use this connection */ async getConnectionTargets(connectionId: string, ): Promise> { const response = await this.getConnectionTargetsRaw({ connectionId: connectionId }, ); return await response.value(); } /** * Get a list of connections defined on the account * List connections */ async getConnectionsRaw(requestParameters: GetConnectionsRequest, ): Promise>> { const queryParameters: any = {}; if (requestParameters.ids) { queryParameters['ids'] = requestParameters.ids; } const headerParameters: runtime.HTTPHeaders = {}; if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = await token("bearer", []); if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } const response = await this.request({ path: `/connections`, method: 'GET', headers: headerParameters, query: queryParameters, }); return new runtime.JSONApiResponse(response); } /** * Get a list of connections defined on the account * List connections */ async getConnections(ids?: Array, ): Promise> { const response = await this.getConnectionsRaw({ ids: ids }, ); return await response.value(); } /** * Rotate credentials for a connection. Currently only supported for Snowflake connections. This will regenerate the RSA keypair for the connection. * Rotate credentials for a connection */ async rotateConnectionCredentialsRaw(requestParameters: RotateConnectionCredentialsRequest, ): Promise> { if (requestParameters.connectionId === null || requestParameters.connectionId === undefined) { throw new runtime.RequiredError('connectionId','Required parameter requestParameters.connectionId was null or undefined when calling rotateConnectionCredentials.'); } if (requestParameters.rotateCredentialsRequest === null || requestParameters.rotateCredentialsRequest === undefined) { throw new runtime.RequiredError('rotateCredentialsRequest','Required parameter requestParameters.rotateCredentialsRequest was null or undefined when calling rotateConnectionCredentials.'); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; headerParameters['Content-Type'] = 'application/json'; if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = await token("bearer", []); if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } const response = await this.request({ path: `/connections/{connection_id}/rotate_credentials`.replace(`{${"connection_id"}}`, encodeURIComponent(String(requestParameters.connectionId))), method: 'POST', headers: headerParameters, query: queryParameters, body: requestParameters.rotateCredentialsRequest, }); return new runtime.JSONApiResponse(response); } /** * Rotate credentials for a connection. Currently only supported for Snowflake connections. This will regenerate the RSA keypair for the connection. * Rotate credentials for a connection */ async rotateConnectionCredentials(connectionId: string, rotateCredentialsRequest: RotateCredentialsRequest, ): Promise { const response = await this.rotateConnectionCredentialsRaw({ connectionId: connectionId, rotateCredentialsRequest: rotateCredentialsRequest }, ); return await response.value(); } /** * Unarchive a connection * Unarchive a connection */ async unarchiveConnectionRaw(requestParameters: UnarchiveConnectionRequest, ): Promise> { if (requestParameters.connectionId === null || requestParameters.connectionId === undefined) { throw new runtime.RequiredError('connectionId','Required parameter requestParameters.connectionId was null or undefined when calling unarchiveConnection.'); } if (requestParameters.archiveConfig === null || requestParameters.archiveConfig === undefined) { throw new runtime.RequiredError('archiveConfig','Required parameter requestParameters.archiveConfig was null or undefined when calling unarchiveConnection.'); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; headerParameters['Content-Type'] = 'application/json'; if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = await token("bearer", []); if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } const response = await this.request({ path: `/connections/{connection_id}/unarchive`.replace(`{${"connection_id"}}`, encodeURIComponent(String(requestParameters.connectionId))), method: 'POST', headers: headerParameters, query: queryParameters, body: requestParameters.archiveConfig, }); return new runtime.VoidApiResponse(response); } /** * Unarchive a connection * Unarchive a connection */ async unarchiveConnection(connectionId: string, archiveConfig: ArchiveConfig, ): Promise { await this.unarchiveConnectionRaw({ connectionId: connectionId, archiveConfig: archiveConfig }, ); } /** * Update the configuration of a connection. * Update a connection */ async updateConnectionRaw(requestParameters: UpdateConnectionRequest, ): Promise> { if (requestParameters.connectionId === null || requestParameters.connectionId === undefined) { throw new runtime.RequiredError('connectionId','Required parameter requestParameters.connectionId was null or undefined when calling updateConnection.'); } if (requestParameters.connectionMergePatch === null || requestParameters.connectionMergePatch === undefined) { throw new runtime.RequiredError('connectionMergePatch','Required parameter requestParameters.connectionMergePatch was null or undefined when calling updateConnection.'); } const queryParameters: any = {}; const headerParameters: runtime.HTTPHeaders = {}; headerParameters['Content-Type'] = 'application/merge-patch+json'; if (this.configuration && this.configuration.accessToken) { const token = this.configuration.accessToken; const tokenString = await token("bearer", []); if (tokenString) { headerParameters["Authorization"] = `Bearer ${tokenString}`; } } const response = await this.request({ path: `/connections/{connection_id}`.replace(`{${"connection_id"}}`, encodeURIComponent(String(requestParameters.connectionId))), method: 'PATCH', headers: headerParameters, query: queryParameters, body: requestParameters.connectionMergePatch, }); return new runtime.JSONApiResponse(response); } /** * Update the configuration of a connection. * Update a connection */ async updateConnection(connectionId: string, connectionMergePatch: ConnectionMergePatch, ): Promise { const response = await this.updateConnectionRaw({ connectionId: connectionId, connectionMergePatch: connectionMergePatch }, ); return await response.value(); } }