import { sleep } from "../../../../test/test-utils" ; import { toQueryString } from "../../utils" ; import { SdkClient } from "../common/sdk-client" ; import { AgentManagementModels } from "./agent-models" ; export class extends SdkClient export class AgentManagementClient extends SdkClient { private _baseUrl : string = "/api/agentmanagement/v3" ; param { AgentManagementModels . Agent } agent returns memberOf public async PostAgent ( agent ) { const result = await this . HttpAction ( { verb : "POST" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , baseUrl : `${ this . _baseUrl }/agents` , body : agent , } ) ; return result as AgentManagementModels . Agent ; } param { { page ? : number ; size ? : number ; sort ? : string ; filter ? : string ; * } } params returns { Promise < AgentManagementModels . PagedAgent > } memberOf public async GetAgents ( params ? ) { const parameters = params || { } ; const { page , size , sort , filter } = parameters ; const result = await this . HttpAction ( { verb : "GET" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , baseUrl : `${ this . _baseUrl }/agents?${ toQueryString ( { page , size , sort , filter } ) }` , } ) ; return result as AgentManagementModels . PagedAgent ; } param { string } id returns { Promise < AgentManagementModels . Agent > } memberOf public async GetAgent ( id ) { const result = await this . HttpAction ( { verb : "GET" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , baseUrl : `${ this . _baseUrl }/agents/${ id }` , } ) ; return result as AgentManagementModels . Agent ; } param { string } id param { AgentManagementModels . AgentUpdate } agent param { { ifMatch : string } } params returns { Promise < AgentManagementModels . Agent > } memberOf public async PutAgent ( id , agent , params ) { const parameters = params || { } ; const { ifMatch } = parameters ; const result = await this . HttpAction ( { verb : "PUT" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , baseUrl : `${ this . _baseUrl }/agents/${ id }` , body : agent , additionalHeaders : { "If-Match" : ifMatch } , } ) ; return result as AgentManagementModels . Agent ; } param { string } id param { { ifMatch : string } } params returns { Promise < AgentManagementModels . Agent > } memberOf public async DeleteAgent ( id , params ) { const parameters = params || { } ; const { ifMatch } = parameters ; const result = await this . HttpAction ( { verb : "DELETE" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , baseUrl : `${ this . _baseUrl }/agents/${ id }` , additionalHeaders : { "If-Match" : ifMatch } , noResponse : true , } ) ; return result as AgentManagementModels . Agent ; } param { string } id returns { Promise < AgentManagementModels . OnlineStatus > } memberOf public async GetAgentOnlineStatus ( id ) { const result = await this . HttpAction ( { verb : "GET" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , baseUrl : `${ this . _baseUrl }/agents/${ id }/status` , } ) ; return result as AgentManagementModels . OnlineStatus ; } param { string } id returns { Promise < AgentManagementModels . DataSourceConfiguration > } memberOf public async GetDataSourceConfiguration ( id ) { const result = await this . HttpAction ( { verb : "GET" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , baseUrl : `${ this . _baseUrl }/agents/${ id }/dataSourceConfiguration` , } ) ; return result as AgentManagementModels . DataSourceConfiguration ; } param { string } id param { AgentManagementModels . DataSourceConfiguration } dataSourceConfiguration param { { ifMatch : string } } params returns { Promise < AgentManagementModels . DataSourceConfiguration > } memberOf public async PutDataSourceConfiguration ( id , dataSourceConfiguration , params ) { const parameters = params || { } ; const { ifMatch } = parameters ; const result = await this . HttpAction ( { verb : "PUT" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , baseUrl : `${ this . _baseUrl }/agents/${ id }/dataSourceConfiguration` , body : dataSourceConfiguration , additionalHeaders : { "If-Match" : ifMatch } , } ) ; return result as AgentManagementModels . DataSourceConfiguration ; } param { string } id returns { Promise < AgentManagementModels . Configuration > } memberOf public async GetBoardingConfiguration ( id , params ? ) { const parameters = params || { } ; let { retry } = parameters ; retry = retry || 1 ; let result ; for ( let index = 0 ; index < retry ; index ++ ) { result = ( await this . HttpAction ( { verb : "GET" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , baseUrl : `${ this . _baseUrl }/agents/${ id }/boarding/configuration` , } ) ) as AgentManagementModels . Configuration ; if ( ! result . content ) { await sleep ( 500 * index ) ; continue ; } else { break ; } } return result as AgentManagementModels . Configuration ; } param { string } id returns { Promise < AgentManagementModels . OnboardingStatus > } memberOf public async OffboardAgent ( id ) { const result = await this . HttpAction ( { verb : "POST" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , baseUrl : `${ this . _baseUrl }/agents/${ id }/boarding/offboard` , } ) ; return result as AgentManagementModels . OnboardingStatus ; } param { string } id returns { Promise < AgentManagementModels . OnboardingStatus > } memberOf public async GetOnboardingStatus ( id ) { const result = await this . HttpAction ( { verb : "GET" , gateway : this . GetGateway ( ) , authorization : await this . GetToken ( ) , baseUrl : `${ this . _baseUrl }/agents/${ id }/boarding/status` , } ) ; return result as AgentManagementModels . OnboardingStatus ; } }