11import { AbstractHttpService , OperationOptions } from "@azure/bonito-core" ;
22import { BatchNodeOutput , BatchNodeVMExtensionOutput } from "./node-models" ;
3- import { NodeService } from "./node-service" ;
4- import { createBatchClient , isUnexpected } from "../internal/batch-rest" ;
3+ import { ListNodesOptions , NodeService } from "./node-service" ;
4+ import {
5+ createBatchClient ,
6+ isUnexpected ,
7+ paginate ,
8+ } from "../internal/batch-rest" ;
59import { createBatchUnexpectedStatusCodeError } from "../utils" ;
10+ import { PagedAsyncIterableIterator } from "@azure/core-paging" ;
611
712export class LiveNodeService
813 extends AbstractHttpService
@@ -16,43 +21,68 @@ export class LiveNodeService
1621 return accountEndpoint ;
1722 }
1823
19- async listBatchNodes (
24+ async getNode (
2025 accountEndpoint : string ,
21- poolId : string ,
22- opts ?: OperationOptions | undefined
23- ) : Promise < BatchNodeOutput [ ] | undefined > {
26+ poolName : string ,
27+ nodeId : string ,
28+ opts ?: OperationOptions
29+ ) : Promise < BatchNodeOutput > {
30+ const batchClient = createBatchClient (
31+ this . _ensureHttpsEndpoint ( accountEndpoint )
32+ ) ;
33+
34+ const res = await batchClient
35+ . path ( "/pools/{poolId}/nodes/{nodeId}" , poolName , nodeId )
36+ . get ( ) ;
37+
38+ if ( isUnexpected ( res ) ) {
39+ throw createBatchUnexpectedStatusCodeError ( res ) ;
40+ }
41+
42+ return res . body ;
43+ }
44+
45+ async listNodes (
46+ accountEndpoint : string ,
47+ poolName : string ,
48+ opts ?: ListNodesOptions
49+ ) : Promise < PagedAsyncIterableIterator < BatchNodeOutput > > {
2450 const listNodePath = "/pools/{poolId}/nodes" ;
2551 const batchClient = createBatchClient (
2652 this . _ensureHttpsEndpoint ( accountEndpoint )
2753 ) ;
28- const res = await batchClient . path ( listNodePath , poolId ) . get ( ) ;
54+ const res = await batchClient . path ( listNodePath , poolName ) . get ( {
55+ queryParameters : {
56+ $filter : opts ?. filter ,
57+ } ,
58+ } ) ;
2959
3060 if ( isUnexpected ( res ) ) {
3161 throw createBatchUnexpectedStatusCodeError ( res ) ;
3262 }
3363
34- return res . body . value ;
64+ return paginate ( batchClient , res ) ;
3565 }
3666
37- async listBatchNodeExtensions (
67+ async listVmExtensions (
3868 accountEndpoint : string ,
39- poolId : string ,
69+ poolName : string ,
4070 nodeId : string ,
41- opts ?: OperationOptions | undefined
42- ) : Promise < BatchNodeVMExtensionOutput [ ] | undefined > {
71+ opts ?: OperationOptions
72+ ) : Promise < BatchNodeVMExtensionOutput [ ] > {
4373 const listNodeExtensionPath =
4474 "/pools/{poolId}/nodes/{nodeId}/extensions" ;
4575 const batchClient = createBatchClient (
4676 this . _ensureHttpsEndpoint ( accountEndpoint )
4777 ) ;
4878 const res = await batchClient
49- . path ( listNodeExtensionPath , poolId , nodeId )
79+ . path ( listNodeExtensionPath , poolName , nodeId )
5080 . get ( ) ;
5181
5282 if ( isUnexpected ( res ) ) {
5383 throw createBatchUnexpectedStatusCodeError ( res ) ;
5484 }
5585
56- return res . body . value ;
86+ return res . body . value ?? [ ] ;
5787 }
5888}
0 commit comments