import { toQueryString } from "../../utils" ; import { SdkClient } from "../common/sdk-client" ; import { SemanticDataInterconnectModels } from "./sdi-models" ; import { sdiTemplate } from "./sdi-template" ; export class extends SdkClient export class SemanticDataInterconnectClient extends SdkClient { private _baseUrl : string = "/api/sdi/v4" ; param { string } id returns { Promise < SemanticDataInterconnectModels . DataLakeResponse > } memberOf public async GetDataLake ( id ) { const result = await this . HttpAction ( { verb : "GET" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , baseUrl : `${ this . _baseUrl }/dataLakes/${ id }` , } ) ; return result as SemanticDataInterconnectModels . DataLakeResponse ; } param { string } id param { SemanticDataInterconnectModels . UpdateDataLakeRequest } updateDataLakeRequest returns { Promise < SemanticDataInterconnectModels . DataLakeResponse > } memberOf public async PatchDataLake ( id , updateDataLakeRequest ) { const result = await this . HttpAction ( { verb : "PATCH" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , body : updateDataLakeRequest , baseUrl : `${ this . _baseUrl }/dataLakes/${ id }` , } ) ; return result as SemanticDataInterconnectModels . DataLakeResponse ; } returns { Promise < SemanticDataInterconnectModels . DataLakeList > } memberOf public async GetDataLakes ( ) { const result = await this . HttpAction ( { verb : "GET" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , baseUrl : `${ this . _baseUrl }/dataLakes` , } ) ; return result as SemanticDataInterconnectModels . DataLakeList ; } param { SemanticDataInterconnectModels . CreateDataLakeRequest } createDataLakeRequest returns { Promise < SemanticDataInterconnectModels . CreateDataLakeResponse > } memberOf public async PostDataLake ( createDataLakeRequest ) { const result = await this . HttpAction ( { verb : "POST" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , body : createDataLakeRequest , baseUrl : `${ this . _baseUrl }/dataLakes` , } ) ; return result as SemanticDataInterconnectModels . CreateDataLakeRequest ; } param { string } id memberOf public async DeleteDataLake ( id ) { try { await this . HttpAction ( { verb : "DELETE" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , baseUrl : `${ this . _baseUrl }/dataLakes/${ id }` , } ) ; } catch ( error ) { console . error ( "At the time of creation of this client (April 2021), MindSphere didn't have any support for DELETE operation on data lakes." ) ; console . error ( "This was reported to mindsphere development team and should eventually start working." ) ; throw error ; } } param { string } id returns { Promise < SemanticDataInterconnectModels . DataRegistry > } memberOf public async GetDataRegistry ( id ) { const result = await this . HttpAction ( { verb : "GET" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , baseUrl : `${ this . _baseUrl }/dataRegistries/${ id }` , } ) ; return result as SemanticDataInterconnectModels . DataRegistry ; } param { string } id param { SemanticDataInterconnectModels . UpdateDataRegistryRequest } updateDataRegistryRequest returns { Promise < SemanticDataInterconnectModels . DataRegistry > } memberOf public async PatchDataRegistry ( id , updateDataRegistryRequest ) { const result = await this . HttpAction ( { verb : "PATCH" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , baseUrl : `${ this . _baseUrl }/dataRegistries/${ id }` , body : updateDataRegistryRequest , } ) ; return result as SemanticDataInterconnectModels . DataRegistry ; } param { { dataTag ? : string ; sourceName ? : string ; pageToken ? : string ; * } } params param params . datatag param params . sourceName param params . pageToken returns { Promise < SemanticDataInterconnectModels . ListOfRegistryResponse > } memberOf public async GetDataRegistries ( params ? ) { const parameters = params || { } ; const result = await this . HttpAction ( { verb : "GET" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , baseUrl : `${ this . _baseUrl }/dataRegistries?${ toQueryString ( parameters ) }` , } ) ; return result as SemanticDataInterconnectModels . ListOfRegistryResponse ; } param { SemanticDataInterconnectModels . CreateDataRegistryRequest } createDataRegistryRequest returns { Promise < SemanticDataInterconnectModels . DataRegistry > } memberOf public async PostDataRegistry ( createDataRegistryRequest ) { const result = await this . HttpAction ( { verb : "POST" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , baseUrl : `${ this . _baseUrl }/dataRegistries` , body : createDataRegistryRequest , } ) ; return result as SemanticDataInterconnectModels . DataRegistry ; } param { string } id memberOf public async DeleteDataRegistry ( id ) { try { await this . HttpAction ( { verb : "DELETE" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , baseUrl : `${ this . _baseUrl }/dataRegistries/${ id }` , } ) ; } catch ( error ) { console . error ( "At the time of creation of this client (April 2021), MindSphere didn't have any support for DELETE operation on data registries." ) ; console . error ( "This was reported to mindsphere development team and should eventually start working." ) ; throw error ; } } param { { filter ? : string ; pageToken ? : string ; * } } params param params . filter param params . pageToken returns { Promise < SemanticDataInterconnectModels . ListOfIoTRegistryResponse > } memberOf public async GetIotDataRegistries ( params ? ) { const parameters = params || { } ; const result = await this . HttpAction ( { verb : "GET" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , baseUrl : `${ this . _baseUrl }/iotDataRegistries?${ toQueryString ( parameters ) }` , } ) ; return result as SemanticDataInterconnectModels . ListOfIoTRegistryResponse ; } param { SemanticDataInterconnectModels . IotDataRegistry } iotDataRegistry returns { Promise < SemanticDataInterconnectModels . IotDataRegistryResponse > } memberOf public async PostIotDataRegistry ( iotDataRegistry ) { const result = await this . HttpAction ( { verb : "POST" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , baseUrl : `${ this . _baseUrl }/iotDataRegistries` , body : iotDataRegistry , } ) ; return result as SemanticDataInterconnectModels . IotDataRegistryResponse ; } param { string } registryId returns { Promise < SemanticDataInterconnectModels . IotDataRegistry > } memberOf public async GetIotDataRegistry ( registryId ) { let nextToken = undefined ; let registry = undefined ; do { const result = await this . GetIotDataRegistries ( ) ; result . iotDataRegistries ?. forEach ( ( x ) => { if ( x . registryId === registryId ) { registry = x ; } } ) ; nextToken = result . page ?. nextToken ; } while ( nextToken ) ; if ( ! registry ) { throw new Error ( `couldn't find iot data registry with id ${ registryId }` ) ; } return registry ; } param { string } id memberOf public async DeleteIotRegistry ( id ) { try { await this . HttpAction ( { verb : "DELETE" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , baseUrl : `${ this . _baseUrl }/iotDataRegistries/${ id }` , } ) ; } catch ( error ) { console . error ( "At the time of creation of this client (April 2021), MindSphere didn't have any support for DELETE operation on data registries." ) ; console . error ( "This was reported to mindsphere development team and should eventually start working." ) ; throw error ; } } param { string } name param { SemanticDataInterconnectModels . DataTypePattern } dataTypePattern returns { Promise < SemanticDataInterconnectModels . DataTypeDefinition > } memberOf public async AddPatternToDataType ( name , dataTypePattern ) { const result = await this . HttpAction ( { verb : "POST" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , baseUrl : `${ this . _baseUrl }/dataTypes/${ name }/addPatterns` , body : dataTypePattern , } ) ; return result as SemanticDataInterconnectModels . DataTypeDefinition ; } param { string } name returns { Promise < SemanticDataInterconnectModels . DataTypeDefinition > } memberOf public async GetDataType ( name ) { const result = await this . HttpAction ( { verb : "GET" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , baseUrl : `${ this . _baseUrl }/dataTypes/${ name }` , } ) ; return result as SemanticDataInterconnectModels . DataTypeDefinition ; } param { string } name memberOf public async DeleteDataType ( name ) { await this . HttpAction ( { verb : "DELETE" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , baseUrl : `${ this . _baseUrl }/dataTypes/${ name }` , noResponse : true , } ) ; } param { { pageToken ? : string ; * } } params returns { Promise < SemanticDataInterconnectModels . ListOfDataTypeDefinition > } memberOf public async GetDataTypes ( params ? ) { const parameters = params || { } ; const result = await this . HttpAction ( { verb : "GET" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , baseUrl : `${ this . _baseUrl }/dataTypes?${ toQueryString ( parameters ) }` , } ) ; return result as SemanticDataInterconnectModels . ListOfDataTypeDefinition ; } param { SemanticDataInterconnectModels . DataTypeDefinition } dataTypeDefinition returns { Promise < SemanticDataInterconnectModels . DataTypeDefinition > } memberOf public async PostDataType ( dataTypeDefinition ) { const result = await this . HttpAction ( { verb : "POST" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , baseUrl : `${ this . _baseUrl }/dataTypes` , body : dataTypeDefinition , } ) ; return result as SemanticDataInterconnectModels . DataTypeDefinition ; } param { SemanticDataInterconnectModels . SuggestPatternsRequest } request returns { Promise < SemanticDataInterconnectModels . ListOfPatterns > } memberOf public async SuggestPatterns ( request ) { let result = await this . HttpAction ( { verb : "POST" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , baseUrl : `${ this . _baseUrl }/suggestPatterns` , body : request , } ) ; const transformed = { suggestPatterns : [ ] } ; if ( Array . isArray ( result ) ) { ( result as Array < any > ) . forEach ( ( element ) => { const result = [ ] ; ( element . matches || [ ] ) . forEach ( ( t ) => { result . push ( t . toString ( ) ) ; } ) ; transformed . suggestPatterns . push ( { schema : element . schema , matches : result , schemaValid : element . schemaValid , } ) ; } ) ; result = transformed ; } return result as SemanticDataInterconnectModels . ListOfPatterns ; } param { string } fileName param { Buffer } buffer param { string } mimetype returns memberOf public async DataUpload ( fileName , buffer , mimetype ? ) { const body = sdiTemplate ( fileName , buffer , mimetype ) ; const result = await this . HttpAction ( { verb : "POST" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , baseUrl : `${ this . _baseUrl }/dataUpload` , body : body , multiPartFormData : true , } ) ; return result as SemanticDataInterconnectModels . SdiFileUploadResponse ; } param { SemanticDataInterconnectModels . SDIIngestData } ingestData returns { Promise < SemanticDataInterconnectModels . SdiJobStatusResponse > } memberOf public async PostIngestJob ( ingestData ) { const result = await this . HttpAction ( { verb : "POST" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , baseUrl : `${ this . _baseUrl }/ingestJobs` , body : ingestData , } ) ; return result as SemanticDataInterconnectModels . SdiJobStatusResponse ; } param { { pageToken ? : string ; * } } params param params . pageToken returns { Promise < SemanticDataInterconnectModels . ListOfJobIds > } memberOf public async GetIngestJobs ( params ? ) { const parameters = params || { } ; const result = await this . HttpAction ( { verb : "GET" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , baseUrl : `${ this . _baseUrl }/ingestJobStatus?${ toQueryString ( parameters ) }` , } ) ; return result as SemanticDataInterconnectModels . ListOfJobIds ; } param { string } id returns { Promise < SemanticDataInterconnectModels . SdiJobStatusResponse > } memberOf public async GetIngestJobStatus ( id ) { const result = await this . HttpAction ( { verb : "GET" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , baseUrl : `${ this . _baseUrl }/ingestJobStatus/${ id }` , } ) ; return result as SemanticDataInterconnectModels . SdiJobStatusResponse ; } param { SemanticDataInterconnectModels . SchemaSearchRequest } schemaSearchRequest param { { pageToken ? : string } } params param params . pageToken returns { Promise < SemanticDataInterconnectModels . ListOfSchemaRegistry > } memberOf public async SearchSchemas ( schemaSearchRequest , params ? ) { const parameters = params || { } ; const response = ( await this . HttpAction ( { verb : "POST" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , baseUrl : `${ this . _baseUrl }/searchSchemas?${ toQueryString ( parameters ) }` , body : schemaSearchRequest , rawResponse : true , } ) ) as Response ; let result ; if ( response . status === 204 ) { result = { schemas : [ ] } ; } else { result = response . json ( ) ; } return result as SemanticDataInterconnectModels . ListOfSchemaRegistry ; } param { { pageToken ? : string ; executable ? : boolean ; isDynamic ? : boolean ; ontologyId ? : string ; * } } params param params . pageToken param params . executable param params . isDynamic param params . ontologyId returns { Promise < SemanticDataInterconnectModels . ResponseAllDataSQLQuery > } memberOf public async GetQueries ( params ? ) { const parameters = params || { } ; const result = await this . HttpAction ( { verb : "GET" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , baseUrl : `${ this . _baseUrl }/queries?${ toQueryString ( parameters ) }` , } ) ; return result as SemanticDataInterconnectModels . ResponseAllDataSQLQuery ; } param { SemanticDataInterconnectModels . DataQuerySQLRequest } dataQuerySQLRequest returns { Promise < SemanticDataInterconnectModels . DataQuerySQLResponse > } memberOf public async PostQuery ( dataQuerySQLRequest ) { const result = await this . HttpAction ( { verb : "POST" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , baseUrl : `${ this . _baseUrl }/queries` , body : dataQuerySQLRequest , } ) ; return result as SemanticDataInterconnectModels . DataQuerySQLResponse ; } param { string } id returns { Promise < SemanticDataInterconnectModels . NativeQueryGetResponse > } memberOf public async GetQuery ( id ) { const result = await this . HttpAction ( { verb : "GET" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , baseUrl : `${ this . _baseUrl }/queries/${ id }` , } ) ; return result as SemanticDataInterconnectModels . NativeQueryGetResponse ; } param { string } id param { SemanticDataInterconnectModels . DataQuerySQLUpdateRequest } dataQuerySQLUpdateRequest returns { Promise < SemanticDataInterconnectModels . DataQuerySQLResponse > } memberOf public async PatchQuery ( id , dataQuerySQLUpdateRequest ) { const result = await this . HttpAction ( { verb : "PATCH" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , baseUrl : `${ this . _baseUrl }/queries/${ id }` , body : dataQuerySQLUpdateRequest , } ) ; return result as SemanticDataInterconnectModels . DataQuerySQLResponse ; } param { string } id memberOf public async DeleteQuery ( id ) { await this . HttpAction ( { verb : "DELETE" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , baseUrl : `${ this . _baseUrl }/queries/${ id }` , noResponse : true , } ) ; } param { string } id param { SemanticDataInterconnectModels . DataQueryExecuteQueryRequest } dataQueryExecuteRequest returns { Promise < SemanticDataInterconnectModels . DataQuerySQLResponse > } memberOf public async PostExecutionJob ( id , dataQueryExecuteRequest ) { const result = await this . HttpAction ( { verb : "POST" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , baseUrl : `${ this . _baseUrl }/queries/${ id }/executionJobs` , body : dataQueryExecuteRequest , } ) ; return result as SemanticDataInterconnectModels . DataQueryExecuteQueryResponse ; } param { string } id param { { Range ? : string } } params param params . Range returns { Promise < SemanticDataInterconnectModels . QueryResult > } memberOf public async GetQueryExecutionJobLatestResults ( id , params ? ) { const parameters = params || { } ; const result = await this . HttpAction ( { verb : "GET" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , baseUrl : `${ this . _baseUrl }/queries/${ id }/executionJobs/latestResults` , additionalHeaders : parameters , } ) ; return result as SemanticDataInterconnectModels . QueryResult ; } param { string } id param { { Range ? : string } } params param params . Range returns { Promise < SemanticDataInterconnectModels . QueryResult > } memberOf public async GetExecutionJobResults ( id , params ? ) { const parameters = params || { } ; const result = await this . HttpAction ( { verb : "GET" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , baseUrl : `${ this . _baseUrl }/executionJobs/${ id }/results` , additionalHeaders : parameters , } ) ; return result as SemanticDataInterconnectModels . QueryResult ; } param { string } id returns { Promise < SemanticDataInterconnectModels . DataQueryExecutionResponse > } memberOf public async GetExecutionJob ( id ) { const result = await this . HttpAction ( { verb : "GET" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , baseUrl : `${ this . _baseUrl }/executionJobs/${ id }` , } ) ; return result as SemanticDataInterconnectModels . DataQueryExecutionResponse ; } param { string } id memberOf public async DeleteExecutionJob ( id ) { await this . HttpAction ( { verb : "DELETE" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , baseUrl : `${ this . _baseUrl }/executionJobs/${ id }` , noResponse : true , } ) ; } param { { pageToken ? : string ; queryId ? : string ; status ? : string ; * } } params param params . pageToken param params . queryId param params . status returns { Promise < SemanticDataInterconnectModels . ResponseAllDataQueryExecutionResponse > } memberOf public async GetExecutionJobs ( params ? ) { const parameters = params || { } ; const result = await this . HttpAction ( { verb : "GET" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , baseUrl : `${ this . _baseUrl }/executionJobs?${ toQueryString ( parameters ) }` , } ) ; return result as SemanticDataInterconnectModels . ResponseAllDataQueryExecutionResponse ; } param { { pageToken ? : string ; * } } params param params . pageToken returns { Promise < SemanticDataInterconnectModels . ResponseAllOntologies > } memberOf public async GetOntologies ( params ? ) { const parameters = params || { } ; const result = await this . HttpAction ( { verb : "GET" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , baseUrl : `${ this . _baseUrl }/ontologies?${ toQueryString ( parameters ) }` , } ) ; return result as SemanticDataInterconnectModels . ResponseAllOntologies ; } param { string } id param { { Range ? : string } } params param params . Range returns { Promise < SemanticDataInterconnectModels . OntologyResponseData > } memberOf public async GetOntology ( id , params ? ) { const parameters = params || { } ; const result = await this . HttpAction ( { verb : "GET" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , baseUrl : `${ this . _baseUrl }/ontologies/${ id }` , additionalHeaders : parameters , } ) ; return result as SemanticDataInterconnectModels . OntologyResponseData ; } param { string } id memberOf public async DeleteOntology ( id ) { await this . HttpAction ( { verb : "DELETE" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , baseUrl : `${ this . _baseUrl }/ontologies/${ id }` , noResponse : true , } ) ; } param { SemanticDataInterconnectModels . InferSchemaSearchRequest } inferSchemaSearchRequest returns memberOf public async InferOntology ( inferSchemaSearchRequest ) { const result = await this . HttpAction ( { verb : "POST" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , baseUrl : `${ this . _baseUrl }/inferOntology` , body : inferSchemaSearchRequest , } ) ; return result ; } param { string } ontologyName param { Buffer } file param { string } ontologyId param { string } ontologyDescription param { string } keyMappingType returns { Promise < SemanticDataInterconnectModels . OntologyJob > } memberOf public async PostOntologyJob ( fileName , file , mimetype , ontologyName , ontologyId ? , ontologyDescription ? , keyMappingType ? ) { const body = sdiTemplate ( fileName , file , mimetype , { ontologyName , ontologyId , ontologyDescription , keyMappingType , } ) ; const result = await this . HttpAction ( { verb : "POST" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , baseUrl : `${ this . _baseUrl }/ontologyJobs` , body : body , multiPartFormData : true , } ) ; return result as SemanticDataInterconnectModels . OntologyJob ; } param { string } id returns { Promise < SemanticDataInterconnectModels . JobStatus > } memberOf public async GetOntologyJobStatus ( id ) { const result = await this . HttpAction ( { verb : "GET" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , baseUrl : `${ this . _baseUrl }/ontologyJobs/${ id }` , } ) ; return result as SemanticDataInterconnectModels . JobStatus ; } }