import fetch from "cross-fetch" ; import * as fs from "fs" ; import { toQueryString } from "../../utils" ; import { SdkClient } from "../common/sdk-client" ; import { DataLakeModels } from "./data-lake.models" ; const HttpsProxyAgent = require ( "https-proxy-agent" ) ; export class DataLakeClient extends SdkClient { private _baseUrl : string = "/api/datalake/v3" ; param { string } path param { { subtenantid ? : string } } optional returns { Promise < DataLakeModels . ObjectMetaDataResponse > } memberOf public async GetObjectMetaData ( path , optional ? ) { return ( await this . HttpAction ( { verb : "GET" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , baseUrl : `${ this . _baseUrl }/objectMetadata/${ path }?${ toQueryString ( optional ) }` , } ) ) as DataLakeModels . ObjectMetaDataResponse ; } param { string } path param { { filter : string ; subtenantid ? : string ; size ? : number ; page ? : number } } params returns { Promise < DataLakeModels . SearchResponse > } memberOf public async GetObjectMetaDatas ( path , params ) { return ( await this . HttpAction ( { verb : "GET" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , baseUrl : `${ this . _baseUrl }/objectMetadata/${ path }?${ toQueryString ( params ) }` , } ) ) as DataLakeModels . SearchResponse ; } param { string } path param { DataLakeModels . Metadata } Metadata param { { subtenantid ? : string } } optional returns memberOf public async PutObjectMetaData ( path , metadata , optional ? ) { return await this . HttpAction ( { verb : "PUT" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , body : metadata , baseUrl : `${ this . _baseUrl }/objectMetadata/${ path }?${ toQueryString ( optional ) }` , } ) ; } param { DataLakeModels . GenerateUrlPayload } generateUrlPayload returns memberOf public async GenerateUploadObjectUrls ( generateUrlPayload ) { return ( await this . HttpAction ( { verb : "POST" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , baseUrl : `${ this . _baseUrl }/generateUploadObjectUrls` , body : generateUrlPayload , } ) ) as DataLakeModels . SignedUrlResponse ; } param { DataLakeModels . GenerateUrlPayload } generateUrlPayload returns { Promise < DataLakeModels . SignedUrlResponse > } memberOf public async GenerateDownloadObjectUrls ( generateUrlPayload ) { return ( await this . HttpAction ( { verb : "POST" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , baseUrl : `${ this . _baseUrl }/generateDownloadObjectUrls` , body : generateUrlPayload , } ) ) as DataLakeModels . SignedUrlResponse ; } param { ( string | Buffer ) } file param { string } signedUrl returns { Promise < Headers > } memberOf public async PutFile ( file , signedUrl ) { const myBuffer = typeof file === "string" ? fs . readFileSync ( file ) : ( file as Buffer ) ; const proxy = process . env . http_proxy || process . env . HTTP_PROXY ; const proxyHttpAgent = proxy ? new HttpsProxyAgent ( proxy ) : null ; const request = { method : "PUT" , headers : { "x-ms-blob-type" : "BlockBlob" } , agent : proxyHttpAgent } ; request . body = myBuffer ; const response = await fetch ( signedUrl , request ) ; return response . headers ; } param { DataLakeModels . CrossAccountRequest } crossAccountRequest returns { Promise < DataLakeModels . CrossAccount > } memberOf public async PostCrossAccount ( crossAccountRequest ) { return ( await this . HttpAction ( { verb : "POST" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , baseUrl : `${ this . _baseUrl }/crossAccounts` , body : crossAccountRequest , } ) ) as DataLakeModels . CrossAccount ; } param { { page ? : number ; size ? : number ; filter ? : string ; * } } params returns { Promise < DataLakeModels . CrossAccountListResource > } memberOf public async GetCrossAccounts ( params ? ) { return ( await this . HttpAction ( { verb : "GET" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , baseUrl : `${ this . _baseUrl }/crossAccounts?${ toQueryString ( params ) }` , } ) ) as DataLakeModels . CrossAccountListResource ; } param { string } id returns { Promise < DataLakeModels . CrossAccount > } memberOf public async GetCrossAccount ( id ) { return ( await this . HttpAction ( { verb : "GET" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , baseUrl : `${ this . _baseUrl }/crossAccounts/${ id }` , } ) ) as DataLakeModels . CrossAccount ; } param { string } id param { DataLakeModels . CrossAccountUpdateRequest } crossAccountUpdateRequest param { { ifMatch : number } } params returns { Promise < DataLakeModels . CrossAccount > } memberOf public async PatchCrossAccount ( id , crossAccountUpdateRequest , params ) { return ( await this . HttpAction ( { verb : "PATCH" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , baseUrl : `${ this . _baseUrl }/crossAccounts/${ id }` , additionalHeaders : { "If-Match" : params . ifMatch } , body : crossAccountUpdateRequest , } ) ) as DataLakeModels . CrossAccount ; } param { string } id param { { ifMatch : number } } params returns memberOf public async DeleteCrossAccount ( id , params ) { return await this . HttpAction ( { verb : "DELETE" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , baseUrl : `${ this . _baseUrl }/crossAccounts/${ id }` , additionalHeaders : { "If-Match" : params . ifMatch } , noResponse : true , } ) ; } param { string } id param { DataLakeModels . CrossAccountAccessRequest } crossAccountAccessRequest returns { Promise < DataLakeModels . CrossAccountAccess > } memberOf public async PostCrossAccountAccess ( id , crossAccountAccessRequest ) { return ( await this . HttpAction ( { verb : "POST" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , baseUrl : `${ this . _baseUrl }/crossAccounts${ id }/accesses` , body : crossAccountAccessRequest , } ) ) as DataLakeModels . CrossAccountAccess ; } param { string } id param { { page ? : number ; size ? : number ; * } } params returns { Promise < DataLakeModels . CrossAccountAccessListResource > } memberOf public async GetCrossAccountAccesses ( id , params ? ) { return ( await this . HttpAction ( { verb : "GET" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , baseUrl : `${ this . _baseUrl }/crossAccounts/${ id }/accesses?${ toQueryString ( params ) }` , } ) ) as DataLakeModels . CrossAccountAccessListResource ; } param { string } id param { string } accessId returns { Promise < DataLakeModels . CrossAccountAccess > } memberOf public async GetCrossAccountAccess ( id , accessId ) { return ( await this . HttpAction ( { verb : "GET" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , baseUrl : `${ this . _baseUrl }/crossAccounts/${ id }/accesses/${ accessId }` , } ) ) as DataLakeModels . CrossAccountAccess ; } param { string } id param { string } accessId param { DataLakeModels . CrossAccountAccessRequest } crossAcccountAccessRequest param { { ifMatch : number } } params returns { Promise < DataLakeModels . CrossAccountAccess > } memberOf public async PatchCrossAccountAccess ( id , accessId , crossAcccountAccessRequest , params ) { return ( await this . HttpAction ( { verb : "PATCH" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , baseUrl : `${ this . _baseUrl }/crossAccounts/${ id }/accesses/${ accessId }` , body : crossAcccountAccessRequest , additionalHeaders : { "If-Match" : params . ifMatch } , } ) ) as DataLakeModels . CrossAccountAccess ; } param { string } id param { string } accessId param { { ifMatch : number } } params returns memberOf public async DeleteCrossAccountAccess ( id , accessId , params ) { return await this . HttpAction ( { verb : "DELETE" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , baseUrl : `${ this . _baseUrl }/crossAccounts/${ id }/accesses/${ accessId }` , additionalHeaders : { "If-Match" : params . ifMatch } , noResponse : true , } ) ; } param { DataLakeModels . Subscription } subscription returns { Promise < DataLakeModels . Subscription > } memberOf public async PostObjectEventSubscriptions ( subscription ) { return ( await this . HttpAction ( { verb : "POST" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , baseUrl : `${ this . _baseUrl }/objectEventSubscriptions` , body : subscription , } ) ) as DataLakeModels . Subscription ; } param { { page ? : number ; size ? : number ; filter ? : string ; * } } params param params . filter example returns { Promise < DataLakeModels . SubscriptionListResource > } memberOf public async GetObjectEventSubscriptions ( params ? ) { return ( await this . HttpAction ( { verb : "GET" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , baseUrl : `${ this . _baseUrl }/objectEventSubscriptions?${ toQueryString ( params ) }` , } ) ) as DataLakeModels . SubscriptionListResource ; } param { string } id returns { Promise < DataLakeModels . SubscriptionResponse > } memberOf public async GetObjectEventSubscription ( id ) { return ( await this . HttpAction ( { verb : "GET" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , baseUrl : `${ this . _baseUrl }/objectEventSubscriptions/${ id }` , } ) ) as DataLakeModels . SubscriptionResponse ; } param { string } id param { DataLakeModels . SubscriptionUpdate } subscriptionUpdate param { { ifMatch : number } } params returns { Promise < DataLakeModels . SubscriptionResponse > } memberOf public async PatchObjectEventSubscription ( id , subscriptionUpdate , params ) { return ( await this . HttpAction ( { verb : "PATCH" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , baseUrl : `${ this . _baseUrl }/objectEventSubscriptions/${ id }` , additionalHeaders : { "If-Match" : params . ifMatch } , body : subscriptionUpdate , } ) ) as DataLakeModels . SubscriptionResponse ; } param { string } id param { { ifMatch : number } } params returns memberOf public async DeleteObjectEventSubscription ( id , params ) { return await this . HttpAction ( { verb : "DELETE" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , baseUrl : `${ this . _baseUrl }/objectEventSubscriptions/${ id }` , additionalHeaders : { "If-Match" : params . ifMatch } , noResponse : true , } ) ; } param { DataLakeModels . ImportJobRequest } importJob returns { Promise < DataLakeModels . ImportJobResponse > } memberOf public async PostTimeSeriesImportJob ( importJob ) { return ( await this . HttpAction ( { verb : "POST" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , baseUrl : `${ this . _baseUrl }/timeSeriesImportJobs` , body : importJob , } ) ) as DataLakeModels . ImportJobResponse ; } param { { page ? : number ; size ? : number ; filter ? : string ; * } } params param params . filter example returns { Promise < DataLakeModels . ImportJobListResource > } memberOf public async GetTimeSeriesImportJobs ( params ? ) { return ( await this . HttpAction ( { verb : "GET" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , baseUrl : `${ this . _baseUrl }/timeSeriesImportJobs?${ toQueryString ( params ) }` , } ) ) as DataLakeModels . ImportJobListResource ; } param { string } id returns { Promise < DataLakeModels . ImportJobResponse > } memberOf public async GetTimeSeriesImportJob ( id ) { return ( await this . HttpAction ( { verb : "GET" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , baseUrl : `${ this . _baseUrl }/timeSeriesImportJobs/${ id }` , } ) ) as DataLakeModels . ImportJobResponse ; } param { string } id returns memberOf public async DeleteTimeSeriesImportJob ( id ) { return await this . HttpAction ( { verb : "DELETE" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , baseUrl : `${ this . _baseUrl }/timeSeriesImportJobs/${ id }` , noResponse : true , } ) ; } param { string } id returns { Promise < DataLakeModels . ImportJobDetails > } memberOf public async GetTimeSeriesImportJobDetails ( id ) { return ( await this . HttpAction ( { verb : "GET" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , baseUrl : `${ this . _baseUrl }/timeSeriesImportJobs/${ id }/details` , } ) ) as DataLakeModels . ImportJobDetails ; } param { DataLakeModels . GenerateSTSPayload } stsPayload returns { Promise < DataLakeModels . AccessTokens > } memberOf public async GenerateAccessToken ( stsPayload ) { return ( await this . HttpAction ( { verb : "POST" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , baseUrl : `${ this . _baseUrl }/generateAccessToken` , body : stsPayload , } ) ) as DataLakeModels . AccessTokens ; } param { { page ? : number ; size ? : number ; * } } optional returns { Promise < DataLakeModels . AccessTokenPermissionResources > } memberOf public async GetAccessTokenPermissions ( optional ? ) { const qs = toQueryString ( optional ) ; return ( await this . HttpAction ( { verb : "GET" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , baseUrl : `${ this . _baseUrl }/accessTokenPermissions?${ qs }` , } ) ) as DataLakeModels . AccessTokenPermissionResources ; } param { string } id returns { Promise < DataLakeModels . AccessTokenPermissionResource > } memberOf public async GetAccessTokenPermission ( id ) { return ( await this . HttpAction ( { verb : "GET" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , baseUrl : `${ this . _baseUrl }/accessTokenPermissions/${ id }` , } ) ) as DataLakeModels . AccessTokenPermissionResource ; } param { string } id returns { Promise < DataLakeModels . AccessTokenPermissionResource > } memberOf public async DeleteAccessTokenPermission ( id ) { return await this . HttpAction ( { verb : "DELETE" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , baseUrl : `${ this . _baseUrl }/accessTokenPermissions/${ id }` , noResponse : true , } ) ; } param { DataLakeModels . AccessTokenPermissionRequest } writePathPayload returns { Promise < DataLakeModels . AccessTokenPermissionResource > } memberOf public async PostAccessTokenPermissions ( writePathPayload ) { return ( await this . HttpAction ( { verb : "POST" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , baseUrl : `${ this . _baseUrl }/accessTokenPermissions` , body : writePathPayload , } ) ) as DataLakeModels . AccessTokenPermissionResource ; } }