/
operations.ts
98 lines (90 loc) · 2.67 KB
/
operations.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/*
* Copyright (c) Microsoft Corporation.
* Licensed under the MIT License.
*
* Code generated by Microsoft (R) AutoRest Code Generator.
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
*/
import { PagedAsyncIterableIterator } from "@azure/core-paging";
import { Operations } from "../operationsInterfaces";
import * as coreClient from "@azure/core-client";
import * as Mappers from "../models/mappers";
import * as Parameters from "../models/parameters";
import { ContainerServiceClient } from "../containerServiceClient";
import {
OperationValue,
OperationsListOptionalParams,
OperationsListResponse
} from "../models";
/// <reference lib="esnext.asynciterable" />
/** Class containing Operations operations. */
export class OperationsImpl implements Operations {
private readonly client: ContainerServiceClient;
/**
* Initialize a new instance of the class Operations class.
* @param client Reference to the service client
*/
constructor(client: ContainerServiceClient) {
this.client = client;
}
/**
* Gets a list of operations.
* @param options The options parameters.
*/
public list(
options?: OperationsListOptionalParams
): PagedAsyncIterableIterator<OperationValue> {
const iter = this.listPagingAll(options);
return {
next() {
return iter.next();
},
[Symbol.asyncIterator]() {
return this;
},
byPage: () => {
return this.listPagingPage(options);
}
};
}
private async *listPagingPage(
options?: OperationsListOptionalParams
): AsyncIterableIterator<OperationValue[]> {
let result = await this._list(options);
yield result.value || [];
}
private async *listPagingAll(
options?: OperationsListOptionalParams
): AsyncIterableIterator<OperationValue> {
for await (const page of this.listPagingPage(options)) {
yield* page;
}
}
/**
* Gets a list of operations.
* @param options The options parameters.
*/
private _list(
options?: OperationsListOptionalParams
): Promise<OperationsListResponse> {
return this.client.sendOperationRequest({ options }, listOperationSpec);
}
}
// Operation Specifications
const serializer = coreClient.createSerializer(Mappers, /* isXml */ false);
const listOperationSpec: coreClient.OperationSpec = {
path: "/providers/Microsoft.ContainerService/operations",
httpMethod: "GET",
responses: {
200: {
bodyMapper: Mappers.OperationListResult
},
default: {
bodyMapper: Mappers.CloudError
}
},
queryParameters: [Parameters.apiVersion],
urlParameters: [Parameters.$host],
headerParameters: [Parameters.accept],
serializer
};