@azure/arm-machinelearningexperimentation 2.0.0-beta.2 → 2.0.0-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. package/CHANGELOG.md +2 -2
  2. package/LICENSE +1 -1
  3. package/README.md +1 -1
  4. package/dist/index.js +162 -55
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.min.js +1 -1
  7. package/dist/index.min.js.map +1 -1
  8. package/dist-esm/samples-dev/accountsCreateOrUpdateSample.js +12 -3
  9. package/dist-esm/samples-dev/accountsCreateOrUpdateSample.js.map +1 -1
  10. package/dist-esm/samples-dev/accountsDeleteSample.js +13 -4
  11. package/dist-esm/samples-dev/accountsDeleteSample.js.map +1 -1
  12. package/dist-esm/samples-dev/accountsGetSample.js +12 -3
  13. package/dist-esm/samples-dev/accountsGetSample.js.map +1 -1
  14. package/dist-esm/samples-dev/accountsListByResourceGroupSample.js +13 -4
  15. package/dist-esm/samples-dev/accountsListByResourceGroupSample.js.map +1 -1
  16. package/dist-esm/samples-dev/accountsListSample.js +11 -3
  17. package/dist-esm/samples-dev/accountsListSample.js.map +1 -1
  18. package/dist-esm/samples-dev/accountsUpdateSample.js +12 -3
  19. package/dist-esm/samples-dev/accountsUpdateSample.js.map +1 -1
  20. package/dist-esm/samples-dev/projectsCreateOrUpdateSample.js +12 -3
  21. package/dist-esm/samples-dev/projectsCreateOrUpdateSample.js.map +1 -1
  22. package/dist-esm/samples-dev/projectsDeleteSample.js +13 -4
  23. package/dist-esm/samples-dev/projectsDeleteSample.js.map +1 -1
  24. package/dist-esm/samples-dev/projectsGetSample.js +12 -3
  25. package/dist-esm/samples-dev/projectsGetSample.js.map +1 -1
  26. package/dist-esm/samples-dev/projectsListByWorkspaceSample.js +11 -3
  27. package/dist-esm/samples-dev/projectsListByWorkspaceSample.js.map +1 -1
  28. package/dist-esm/samples-dev/projectsUpdateSample.js +12 -3
  29. package/dist-esm/samples-dev/projectsUpdateSample.js.map +1 -1
  30. package/dist-esm/samples-dev/workspacesCreateOrUpdateSample.js +12 -3
  31. package/dist-esm/samples-dev/workspacesCreateOrUpdateSample.js.map +1 -1
  32. package/dist-esm/samples-dev/workspacesDeleteSample.js +12 -3
  33. package/dist-esm/samples-dev/workspacesDeleteSample.js.map +1 -1
  34. package/dist-esm/samples-dev/workspacesGetSample.js +12 -3
  35. package/dist-esm/samples-dev/workspacesGetSample.js.map +1 -1
  36. package/dist-esm/samples-dev/workspacesListByAccountsSample.js +12 -3
  37. package/dist-esm/samples-dev/workspacesListByAccountsSample.js.map +1 -1
  38. package/dist-esm/samples-dev/workspacesUpdateSample.js +12 -3
  39. package/dist-esm/samples-dev/workspacesUpdateSample.js.map +1 -1
  40. package/dist-esm/src/index.d.ts +1 -0
  41. package/dist-esm/src/index.d.ts.map +1 -1
  42. package/dist-esm/src/index.js +1 -0
  43. package/dist-esm/src/index.js.map +1 -1
  44. package/dist-esm/src/mLTeamAccountManagementClient.d.ts +2 -0
  45. package/dist-esm/src/mLTeamAccountManagementClient.d.ts.map +1 -1
  46. package/dist-esm/src/mLTeamAccountManagementClient.js +49 -18
  47. package/dist-esm/src/mLTeamAccountManagementClient.js.map +1 -1
  48. package/dist-esm/src/models/index.d.ts +6 -6
  49. package/dist-esm/src/models/index.d.ts.map +1 -1
  50. package/dist-esm/src/operations/accounts.d.ts.map +1 -1
  51. package/dist-esm/src/operations/accounts.js +37 -16
  52. package/dist-esm/src/operations/accounts.js.map +1 -1
  53. package/dist-esm/src/operations/operations.d.ts.map +1 -1
  54. package/dist-esm/src/operations/operations.js +8 -4
  55. package/dist-esm/src/operations/operations.js.map +1 -1
  56. package/dist-esm/src/operations/projects.d.ts.map +1 -1
  57. package/dist-esm/src/operations/projects.js +19 -8
  58. package/dist-esm/src/operations/projects.js.map +1 -1
  59. package/dist-esm/src/operations/workspaces.d.ts.map +1 -1
  60. package/dist-esm/src/operations/workspaces.js +19 -8
  61. package/dist-esm/src/operations/workspaces.js.map +1 -1
  62. package/dist-esm/src/pagingHelper.d.ts +13 -0
  63. package/dist-esm/src/pagingHelper.d.ts.map +1 -0
  64. package/dist-esm/src/pagingHelper.js +32 -0
  65. package/dist-esm/src/pagingHelper.js.map +1 -0
  66. package/dist-esm/test/sampleTest.js +11 -13
  67. package/dist-esm/test/sampleTest.js.map +1 -1
  68. package/package.json +17 -12
  69. package/review/arm-machinelearningexperimentation.api.md +21 -18
  70. package/src/index.ts +1 -0
  71. package/src/mLTeamAccountManagementClient.ts +60 -20
  72. package/src/models/index.ts +7 -6
  73. package/src/operations/accounts.ts +46 -19
  74. package/src/operations/operations.ts +10 -5
  75. package/src/operations/projects.ts +28 -15
  76. package/src/operations/workspaces.ts +27 -14
  77. package/src/pagingHelper.ts +39 -0
  78. package/types/arm-machinelearningexperimentation.d.ts +17 -6
  79. package/types/tsdoc-metadata.json +1 -1
  80. package/dist-esm/samples-dev/accountCreate.d.ts +0 -2
  81. package/dist-esm/samples-dev/accountCreate.d.ts.map +0 -1
  82. package/dist-esm/samples-dev/accountCreate.js +0 -33
  83. package/dist-esm/samples-dev/accountCreate.js.map +0 -1
  84. package/dist-esm/samples-dev/accountGet.d.ts +0 -2
  85. package/dist-esm/samples-dev/accountGet.d.ts.map +0 -1
  86. package/dist-esm/samples-dev/accountGet.js +0 -31
  87. package/dist-esm/samples-dev/accountGet.js.map +0 -1
  88. package/dist-esm/samples-dev/accountUpdate.d.ts +0 -2
  89. package/dist-esm/samples-dev/accountUpdate.d.ts.map +0 -1
  90. package/dist-esm/samples-dev/accountUpdate.js +0 -35
  91. package/dist-esm/samples-dev/accountUpdate.js.map +0 -1
  92. package/dist-esm/samples-dev/createProject.d.ts +0 -2
  93. package/dist-esm/samples-dev/createProject.d.ts.map +0 -1
  94. package/dist-esm/samples-dev/createProject.js +0 -39
  95. package/dist-esm/samples-dev/createProject.js.map +0 -1
  96. package/dist-esm/samples-dev/getProject.d.ts +0 -2
  97. package/dist-esm/samples-dev/getProject.d.ts.map +0 -1
  98. package/dist-esm/samples-dev/getProject.js +0 -33
  99. package/dist-esm/samples-dev/getProject.js.map +0 -1
  100. package/dist-esm/samples-dev/listWorkspacesByAccounts.d.ts +0 -2
  101. package/dist-esm/samples-dev/listWorkspacesByAccounts.d.ts.map +0 -1
  102. package/dist-esm/samples-dev/listWorkspacesByAccounts.js +0 -45
  103. package/dist-esm/samples-dev/listWorkspacesByAccounts.js.map +0 -1
  104. package/dist-esm/samples-dev/projectListByWorkspaces.d.ts +0 -2
  105. package/dist-esm/samples-dev/projectListByWorkspaces.d.ts.map +0 -1
  106. package/dist-esm/samples-dev/projectListByWorkspaces.js +0 -46
  107. package/dist-esm/samples-dev/projectListByWorkspaces.js.map +0 -1
  108. package/dist-esm/samples-dev/updateProject.d.ts +0 -2
  109. package/dist-esm/samples-dev/updateProject.d.ts.map +0 -1
  110. package/dist-esm/samples-dev/updateProject.js +0 -37
  111. package/dist-esm/samples-dev/updateProject.js.map +0 -1
  112. package/dist-esm/samples-dev/workspaceCreate.d.ts +0 -2
  113. package/dist-esm/samples-dev/workspaceCreate.d.ts.map +0 -1
  114. package/dist-esm/samples-dev/workspaceCreate.js +0 -37
  115. package/dist-esm/samples-dev/workspaceCreate.js.map +0 -1
  116. package/dist-esm/samples-dev/workspaceDelete.d.ts +0 -2
  117. package/dist-esm/samples-dev/workspaceDelete.d.ts.map +0 -1
  118. package/dist-esm/samples-dev/workspaceDelete.js +0 -32
  119. package/dist-esm/samples-dev/workspaceDelete.js.map +0 -1
  120. package/dist-esm/samples-dev/workspaceGet.d.ts +0 -2
  121. package/dist-esm/samples-dev/workspaceGet.d.ts.map +0 -1
  122. package/dist-esm/samples-dev/workspaceGet.js +0 -32
  123. package/dist-esm/samples-dev/workspaceGet.js.map +0 -1
  124. package/dist-esm/samples-dev/workspaceUpdate.d.ts +0 -2
  125. package/dist-esm/samples-dev/workspaceUpdate.d.ts.map +0 -1
  126. package/dist-esm/samples-dev/workspaceUpdate.js +0 -33
  127. package/dist-esm/samples-dev/workspaceUpdate.js.map +0 -1
@@ -9,18 +9,18 @@ import * as coreClient from '@azure/core-client';
9
9
  import { PagedAsyncIterableIterator } from '@azure/core-paging';
10
10
 
11
11
  // @public
12
- export type Account = Resource & {
13
- vsoAccountId?: string;
12
+ export interface Account extends Resource {
14
13
  readonly accountId?: string;
14
+ readonly creationDate?: Date;
15
15
  description?: string;
16
+ readonly discoveryUri?: string;
16
17
  friendlyName?: string;
17
18
  keyVaultId?: string;
19
+ readonly provisioningState?: ProvisioningState;
18
20
  seats?: string;
19
- readonly discoveryUri?: string;
20
- readonly creationDate?: Date;
21
21
  storageAccount?: StorageAccountProperties;
22
- readonly provisioningState?: ProvisioningState;
23
- };
22
+ vsoAccountId?: string;
23
+ }
24
24
 
25
25
  // @public
26
26
  export interface AccountListResult {
@@ -108,6 +108,9 @@ export interface ErrorResponse {
108
108
  message: string;
109
109
  }
110
110
 
111
+ // @public
112
+ export function getContinuationToken(page: unknown): string | undefined;
113
+
111
114
  // @public (undocumented)
112
115
  export class MLTeamAccountManagementClient extends coreClient.ServiceClient {
113
116
  // (undocumented)
@@ -166,16 +169,16 @@ export interface OperationsListOptionalParams extends coreClient.OperationOption
166
169
  export type OperationsListResponse = OperationListResult;
167
170
 
168
171
  // @public
169
- export type Project = Resource & {
170
- description?: string;
172
+ export interface Project extends Resource {
171
173
  readonly accountId?: string;
172
- readonly workspaceId?: string;
173
- readonly projectId?: string;
174
- gitrepo?: string;
175
- friendlyName?: string;
176
174
  readonly creationDate?: Date;
175
+ description?: string;
176
+ friendlyName?: string;
177
+ gitrepo?: string;
178
+ readonly projectId?: string;
177
179
  readonly provisioningState?: ProvisioningState;
178
- };
180
+ readonly workspaceId?: string;
181
+ }
179
182
 
180
183
  // @public
181
184
  export interface ProjectListResult {
@@ -262,14 +265,14 @@ export interface StorageAccountProperties {
262
265
  }
263
266
 
264
267
  // @public
265
- export type Workspace = Resource & {
266
- description?: string;
268
+ export interface Workspace extends Resource {
267
269
  readonly accountId?: string;
268
- readonly workspaceId?: string;
269
- friendlyName?: string;
270
270
  readonly creationDate?: Date;
271
+ description?: string;
272
+ friendlyName?: string;
271
273
  readonly provisioningState?: ProvisioningState;
272
- };
274
+ readonly workspaceId?: string;
275
+ }
273
276
 
274
277
  // @public
275
278
  export interface WorkspaceListResult {
package/src/index.ts CHANGED
@@ -7,6 +7,7 @@
7
7
  */
8
8
 
9
9
  /// <reference lib="esnext.asynciterable" />
10
+ export { getContinuationToken } from "./pagingHelper";
10
11
  export * from "./models";
11
12
  export { MLTeamAccountManagementClient } from "./mLTeamAccountManagementClient";
12
13
  export * from "./operationsInterfaces";
@@ -8,6 +8,11 @@
8
8
 
9
9
  import * as coreClient from "@azure/core-client";
10
10
  import * as coreRestPipeline from "@azure/core-rest-pipeline";
11
+ import {
12
+ PipelineRequest,
13
+ PipelineResponse,
14
+ SendRequest
15
+ } from "@azure/core-rest-pipeline";
11
16
  import * as coreAuth from "@azure/core-auth";
12
17
  import {
13
18
  OperationsImpl,
@@ -55,47 +60,53 @@ export class MLTeamAccountManagementClient extends coreClient.ServiceClient {
55
60
  credential: credentials
56
61
  };
57
62
 
58
- const packageDetails = `azsdk-js-arm-machinelearningexperimentation/2.0.0-beta.2`;
63
+ const packageDetails = `azsdk-js-arm-machinelearningexperimentation/2.0.0-beta.4`;
59
64
  const userAgentPrefix =
60
65
  options.userAgentOptions && options.userAgentOptions.userAgentPrefix
61
66
  ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}`
62
67
  : `${packageDetails}`;
63
68
 
64
- if (!options.credentialScopes) {
65
- options.credentialScopes = ["https://management.azure.com/.default"];
66
- }
67
69
  const optionsWithDefaults = {
68
70
  ...defaults,
69
71
  ...options,
70
72
  userAgentOptions: {
71
73
  userAgentPrefix
72
74
  },
73
- baseUri:
75
+ endpoint:
74
76
  options.endpoint ?? options.baseUri ?? "https://management.azure.com"
75
77
  };
76
78
  super(optionsWithDefaults);
77
79
 
80
+ let bearerTokenAuthenticationPolicyFound: boolean = false;
78
81
  if (options?.pipeline && options.pipeline.getOrderedPolicies().length > 0) {
79
82
  const pipelinePolicies: coreRestPipeline.PipelinePolicy[] = options.pipeline.getOrderedPolicies();
80
- const bearerTokenAuthenticationPolicyFound = pipelinePolicies.some(
83
+ bearerTokenAuthenticationPolicyFound = pipelinePolicies.some(
81
84
  (pipelinePolicy) =>
82
85
  pipelinePolicy.name ===
83
86
  coreRestPipeline.bearerTokenAuthenticationPolicyName
84
87
  );
85
- if (!bearerTokenAuthenticationPolicyFound) {
86
- this.pipeline.removePolicy({
87
- name: coreRestPipeline.bearerTokenAuthenticationPolicyName
88
- });
89
- this.pipeline.addPolicy(
90
- coreRestPipeline.bearerTokenAuthenticationPolicy({
91
- scopes: `${optionsWithDefaults.baseUri}/.default`,
92
- challengeCallbacks: {
93
- authorizeRequestOnChallenge:
94
- coreClient.authorizeRequestOnClaimChallenge
95
- }
96
- })
97
- );
98
- }
88
+ }
89
+ if (
90
+ !options ||
91
+ !options.pipeline ||
92
+ options.pipeline.getOrderedPolicies().length == 0 ||
93
+ !bearerTokenAuthenticationPolicyFound
94
+ ) {
95
+ this.pipeline.removePolicy({
96
+ name: coreRestPipeline.bearerTokenAuthenticationPolicyName
97
+ });
98
+ this.pipeline.addPolicy(
99
+ coreRestPipeline.bearerTokenAuthenticationPolicy({
100
+ credential: credentials,
101
+ scopes:
102
+ optionsWithDefaults.credentialScopes ??
103
+ `${optionsWithDefaults.endpoint}/.default`,
104
+ challengeCallbacks: {
105
+ authorizeRequestOnChallenge:
106
+ coreClient.authorizeRequestOnClaimChallenge
107
+ }
108
+ })
109
+ );
99
110
  }
100
111
  // Parameter assignments
101
112
  this.subscriptionId = subscriptionId;
@@ -107,6 +118,35 @@ export class MLTeamAccountManagementClient extends coreClient.ServiceClient {
107
118
  this.accounts = new AccountsImpl(this);
108
119
  this.workspaces = new WorkspacesImpl(this);
109
120
  this.projects = new ProjectsImpl(this);
121
+ this.addCustomApiVersionPolicy(options.apiVersion);
122
+ }
123
+
124
+ /** A function that adds a policy that sets the api-version (or equivalent) to reflect the library version. */
125
+ private addCustomApiVersionPolicy(apiVersion?: string) {
126
+ if (!apiVersion) {
127
+ return;
128
+ }
129
+ const apiVersionPolicy = {
130
+ name: "CustomApiVersionPolicy",
131
+ async sendRequest(
132
+ request: PipelineRequest,
133
+ next: SendRequest
134
+ ): Promise<PipelineResponse> {
135
+ const param = request.url.split("?");
136
+ if (param.length > 1) {
137
+ const newParams = param[1].split("&").map((item) => {
138
+ if (item.indexOf("api-version") > -1) {
139
+ return "api-version=" + apiVersion;
140
+ } else {
141
+ return item;
142
+ }
143
+ });
144
+ request.url = param[0] + "?" + newParams.join("&");
145
+ }
146
+ return next(request);
147
+ }
148
+ };
149
+ this.pipeline.addPolicy(apiVersionPolicy);
110
150
  }
111
151
 
112
152
  operations: Operations;
@@ -134,7 +134,7 @@ export interface ProjectListResult {
134
134
  }
135
135
 
136
136
  /** An object that represents a machine learning team account. */
137
- export type Account = Resource & {
137
+ export interface Account extends Resource {
138
138
  /** The fully qualified arm id of the vso account to be used for this team account. */
139
139
  vsoAccountId?: string;
140
140
  /**
@@ -167,10 +167,10 @@ export type Account = Resource & {
167
167
  * NOTE: This property will not be serialized. It can only be populated by the server.
168
168
  */
169
169
  readonly provisioningState?: ProvisioningState;
170
- };
170
+ }
171
171
 
172
172
  /** An object that represents a machine learning team account workspace. */
173
- export type Workspace = Resource & {
173
+ export interface Workspace extends Resource {
174
174
  /** The description of this workspace. */
175
175
  description?: string;
176
176
  /**
@@ -195,10 +195,10 @@ export type Workspace = Resource & {
195
195
  * NOTE: This property will not be serialized. It can only be populated by the server.
196
196
  */
197
197
  readonly provisioningState?: ProvisioningState;
198
- };
198
+ }
199
199
 
200
200
  /** An object that represents a machine learning project. */
201
- export type Project = Resource & {
201
+ export interface Project extends Resource {
202
202
  /** The description of this project. */
203
203
  description?: string;
204
204
  /**
@@ -230,7 +230,8 @@ export type Project = Resource & {
230
230
  * NOTE: This property will not be serialized. It can only be populated by the server.
231
231
  */
232
232
  readonly provisioningState?: ProvisioningState;
233
- };
233
+ }
234
+
234
235
  /** Defines values for ProvisioningState. */
235
236
  export type ProvisioningState =
236
237
  | "Creating"
@@ -6,7 +6,8 @@
6
6
  * Changes may cause incorrect behavior and will be lost if the code is regenerated.
7
7
  */
8
8
 
9
- import { PagedAsyncIterableIterator } from "@azure/core-paging";
9
+ import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging";
10
+ import { setContinuationToken } from "../pagingHelper";
10
11
  import { Accounts } from "../operationsInterfaces";
11
12
  import * as coreClient from "@azure/core-client";
12
13
  import * as Mappers from "../models/mappers";
@@ -16,8 +17,10 @@ import {
16
17
  Account,
17
18
  AccountsListByResourceGroupNextOptionalParams,
18
19
  AccountsListByResourceGroupOptionalParams,
20
+ AccountsListByResourceGroupResponse,
19
21
  AccountsListNextOptionalParams,
20
22
  AccountsListOptionalParams,
23
+ AccountsListResponse,
21
24
  AccountsGetOptionalParams,
22
25
  AccountsGetResponse,
23
26
  AccountsCreateOrUpdateOptionalParams,
@@ -26,8 +29,6 @@ import {
26
29
  AccountUpdateParameters,
27
30
  AccountsUpdateOptionalParams,
28
31
  AccountsUpdateResponse,
29
- AccountsListByResourceGroupResponse,
30
- AccountsListResponse,
31
32
  AccountsListByResourceGroupNextResponse,
32
33
  AccountsListNextResponse
33
34
  } from "../models";
@@ -63,19 +64,33 @@ export class AccountsImpl implements Accounts {
63
64
  [Symbol.asyncIterator]() {
64
65
  return this;
65
66
  },
66
- byPage: () => {
67
- return this.listByResourceGroupPagingPage(resourceGroupName, options);
67
+ byPage: (settings?: PageSettings) => {
68
+ if (settings?.maxPageSize) {
69
+ throw new Error("maxPageSize is not supported by this operation.");
70
+ }
71
+ return this.listByResourceGroupPagingPage(
72
+ resourceGroupName,
73
+ options,
74
+ settings
75
+ );
68
76
  }
69
77
  };
70
78
  }
71
79
 
72
80
  private async *listByResourceGroupPagingPage(
73
81
  resourceGroupName: string,
74
- options?: AccountsListByResourceGroupOptionalParams
82
+ options?: AccountsListByResourceGroupOptionalParams,
83
+ settings?: PageSettings
75
84
  ): AsyncIterableIterator<Account[]> {
76
- let result = await this._listByResourceGroup(resourceGroupName, options);
77
- yield result.value || [];
78
- let continuationToken = result.nextLink;
85
+ let result: AccountsListByResourceGroupResponse;
86
+ let continuationToken = settings?.continuationToken;
87
+ if (!continuationToken) {
88
+ result = await this._listByResourceGroup(resourceGroupName, options);
89
+ let page = result.value || [];
90
+ continuationToken = result.nextLink;
91
+ setContinuationToken(page, continuationToken);
92
+ yield page;
93
+ }
79
94
  while (continuationToken) {
80
95
  result = await this._listByResourceGroupNext(
81
96
  resourceGroupName,
@@ -83,7 +98,9 @@ export class AccountsImpl implements Accounts {
83
98
  options
84
99
  );
85
100
  continuationToken = result.nextLink;
86
- yield result.value || [];
101
+ let page = result.value || [];
102
+ setContinuationToken(page, continuationToken);
103
+ yield page;
87
104
  }
88
105
  }
89
106
 
@@ -114,22 +131,34 @@ export class AccountsImpl implements Accounts {
114
131
  [Symbol.asyncIterator]() {
115
132
  return this;
116
133
  },
117
- byPage: () => {
118
- return this.listPagingPage(options);
134
+ byPage: (settings?: PageSettings) => {
135
+ if (settings?.maxPageSize) {
136
+ throw new Error("maxPageSize is not supported by this operation.");
137
+ }
138
+ return this.listPagingPage(options, settings);
119
139
  }
120
140
  };
121
141
  }
122
142
 
123
143
  private async *listPagingPage(
124
- options?: AccountsListOptionalParams
144
+ options?: AccountsListOptionalParams,
145
+ settings?: PageSettings
125
146
  ): AsyncIterableIterator<Account[]> {
126
- let result = await this._list(options);
127
- yield result.value || [];
128
- let continuationToken = result.nextLink;
147
+ let result: AccountsListResponse;
148
+ let continuationToken = settings?.continuationToken;
149
+ if (!continuationToken) {
150
+ result = await this._list(options);
151
+ let page = result.value || [];
152
+ continuationToken = result.nextLink;
153
+ setContinuationToken(page, continuationToken);
154
+ yield page;
155
+ }
129
156
  while (continuationToken) {
130
157
  result = await this._listNext(continuationToken, options);
131
158
  continuationToken = result.nextLink;
132
- yield result.value || [];
159
+ let page = result.value || [];
160
+ setContinuationToken(page, continuationToken);
161
+ yield page;
133
162
  }
134
163
  }
135
164
 
@@ -422,7 +451,6 @@ const listByResourceGroupNextOperationSpec: coreClient.OperationSpec = {
422
451
  bodyMapper: Mappers.ErrorResponse
423
452
  }
424
453
  },
425
- queryParameters: [Parameters.apiVersion],
426
454
  urlParameters: [
427
455
  Parameters.$host,
428
456
  Parameters.subscriptionId,
@@ -443,7 +471,6 @@ const listNextOperationSpec: coreClient.OperationSpec = {
443
471
  bodyMapper: Mappers.ErrorResponse
444
472
  }
445
473
  },
446
- queryParameters: [Parameters.apiVersion],
447
474
  urlParameters: [
448
475
  Parameters.$host,
449
476
  Parameters.subscriptionId,
@@ -6,7 +6,7 @@
6
6
  * Changes may cause incorrect behavior and will be lost if the code is regenerated.
7
7
  */
8
8
 
9
- import { PagedAsyncIterableIterator } from "@azure/core-paging";
9
+ import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging";
10
10
  import { Operations } from "../operationsInterfaces";
11
11
  import * as coreClient from "@azure/core-client";
12
12
  import * as Mappers from "../models/mappers";
@@ -46,16 +46,21 @@ export class OperationsImpl implements Operations {
46
46
  [Symbol.asyncIterator]() {
47
47
  return this;
48
48
  },
49
- byPage: () => {
50
- return this.listPagingPage(options);
49
+ byPage: (settings?: PageSettings) => {
50
+ if (settings?.maxPageSize) {
51
+ throw new Error("maxPageSize is not supported by this operation.");
52
+ }
53
+ return this.listPagingPage(options, settings);
51
54
  }
52
55
  };
53
56
  }
54
57
 
55
58
  private async *listPagingPage(
56
- options?: OperationsListOptionalParams
59
+ options?: OperationsListOptionalParams,
60
+ _settings?: PageSettings
57
61
  ): AsyncIterableIterator<Operation[]> {
58
- let result = await this._list(options);
62
+ let result: OperationsListResponse;
63
+ result = await this._list(options);
59
64
  yield result.value || [];
60
65
  }
61
66
 
@@ -6,7 +6,8 @@
6
6
  * Changes may cause incorrect behavior and will be lost if the code is regenerated.
7
7
  */
8
8
 
9
- import { PagedAsyncIterableIterator } from "@azure/core-paging";
9
+ import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging";
10
+ import { setContinuationToken } from "../pagingHelper";
10
11
  import { Projects } from "../operationsInterfaces";
11
12
  import * as coreClient from "@azure/core-client";
12
13
  import * as Mappers from "../models/mappers";
@@ -16,6 +17,7 @@ import {
16
17
  Project,
17
18
  ProjectsListByWorkspaceNextOptionalParams,
18
19
  ProjectsListByWorkspaceOptionalParams,
20
+ ProjectsListByWorkspaceResponse,
19
21
  ProjectsGetOptionalParams,
20
22
  ProjectsGetResponse,
21
23
  ProjectsCreateOrUpdateOptionalParams,
@@ -24,7 +26,6 @@ import {
24
26
  ProjectUpdateParameters,
25
27
  ProjectsUpdateOptionalParams,
26
28
  ProjectsUpdateResponse,
27
- ProjectsListByWorkspaceResponse,
28
29
  ProjectsListByWorkspaceNextResponse
29
30
  } from "../models";
30
31
 
@@ -68,12 +69,16 @@ export class ProjectsImpl implements Projects {
68
69
  [Symbol.asyncIterator]() {
69
70
  return this;
70
71
  },
71
- byPage: () => {
72
+ byPage: (settings?: PageSettings) => {
73
+ if (settings?.maxPageSize) {
74
+ throw new Error("maxPageSize is not supported by this operation.");
75
+ }
72
76
  return this.listByWorkspacePagingPage(
73
77
  accountName,
74
78
  workspaceName,
75
79
  resourceGroupName,
76
- options
80
+ options,
81
+ settings
77
82
  );
78
83
  }
79
84
  };
@@ -83,16 +88,23 @@ export class ProjectsImpl implements Projects {
83
88
  accountName: string,
84
89
  workspaceName: string,
85
90
  resourceGroupName: string,
86
- options?: ProjectsListByWorkspaceOptionalParams
91
+ options?: ProjectsListByWorkspaceOptionalParams,
92
+ settings?: PageSettings
87
93
  ): AsyncIterableIterator<Project[]> {
88
- let result = await this._listByWorkspace(
89
- accountName,
90
- workspaceName,
91
- resourceGroupName,
92
- options
93
- );
94
- yield result.value || [];
95
- let continuationToken = result.nextLink;
94
+ let result: ProjectsListByWorkspaceResponse;
95
+ let continuationToken = settings?.continuationToken;
96
+ if (!continuationToken) {
97
+ result = await this._listByWorkspace(
98
+ accountName,
99
+ workspaceName,
100
+ resourceGroupName,
101
+ options
102
+ );
103
+ let page = result.value || [];
104
+ continuationToken = result.nextLink;
105
+ setContinuationToken(page, continuationToken);
106
+ yield page;
107
+ }
96
108
  while (continuationToken) {
97
109
  result = await this._listByWorkspaceNext(
98
110
  accountName,
@@ -102,7 +114,9 @@ export class ProjectsImpl implements Projects {
102
114
  options
103
115
  );
104
116
  continuationToken = result.nextLink;
105
- yield result.value || [];
117
+ let page = result.value || [];
118
+ setContinuationToken(page, continuationToken);
119
+ yield page;
106
120
  }
107
121
  }
108
122
 
@@ -409,7 +423,6 @@ const listByWorkspaceNextOperationSpec: coreClient.OperationSpec = {
409
423
  bodyMapper: Mappers.ErrorResponse
410
424
  }
411
425
  },
412
- queryParameters: [Parameters.apiVersion],
413
426
  urlParameters: [
414
427
  Parameters.$host,
415
428
  Parameters.subscriptionId,
@@ -6,7 +6,8 @@
6
6
  * Changes may cause incorrect behavior and will be lost if the code is regenerated.
7
7
  */
8
8
 
9
- import { PagedAsyncIterableIterator } from "@azure/core-paging";
9
+ import { PagedAsyncIterableIterator, PageSettings } from "@azure/core-paging";
10
+ import { setContinuationToken } from "../pagingHelper";
10
11
  import { Workspaces } from "../operationsInterfaces";
11
12
  import * as coreClient from "@azure/core-client";
12
13
  import * as Mappers from "../models/mappers";
@@ -16,6 +17,7 @@ import {
16
17
  Workspace,
17
18
  WorkspacesListByAccountsNextOptionalParams,
18
19
  WorkspacesListByAccountsOptionalParams,
20
+ WorkspacesListByAccountsResponse,
19
21
  WorkspacesGetOptionalParams,
20
22
  WorkspacesGetResponse,
21
23
  WorkspacesCreateOrUpdateOptionalParams,
@@ -24,7 +26,6 @@ import {
24
26
  WorkspaceUpdateParameters,
25
27
  WorkspacesUpdateOptionalParams,
26
28
  WorkspacesUpdateResponse,
27
- WorkspacesListByAccountsResponse,
28
29
  WorkspacesListByAccountsNextResponse
29
30
  } from "../models";
30
31
 
@@ -65,11 +66,15 @@ export class WorkspacesImpl implements Workspaces {
65
66
  [Symbol.asyncIterator]() {
66
67
  return this;
67
68
  },
68
- byPage: () => {
69
+ byPage: (settings?: PageSettings) => {
70
+ if (settings?.maxPageSize) {
71
+ throw new Error("maxPageSize is not supported by this operation.");
72
+ }
69
73
  return this.listByAccountsPagingPage(
70
74
  accountName,
71
75
  resourceGroupName,
72
- options
76
+ options,
77
+ settings
73
78
  );
74
79
  }
75
80
  };
@@ -78,15 +83,22 @@ export class WorkspacesImpl implements Workspaces {
78
83
  private async *listByAccountsPagingPage(
79
84
  accountName: string,
80
85
  resourceGroupName: string,
81
- options?: WorkspacesListByAccountsOptionalParams
86
+ options?: WorkspacesListByAccountsOptionalParams,
87
+ settings?: PageSettings
82
88
  ): AsyncIterableIterator<Workspace[]> {
83
- let result = await this._listByAccounts(
84
- accountName,
85
- resourceGroupName,
86
- options
87
- );
88
- yield result.value || [];
89
- let continuationToken = result.nextLink;
89
+ let result: WorkspacesListByAccountsResponse;
90
+ let continuationToken = settings?.continuationToken;
91
+ if (!continuationToken) {
92
+ result = await this._listByAccounts(
93
+ accountName,
94
+ resourceGroupName,
95
+ options
96
+ );
97
+ let page = result.value || [];
98
+ continuationToken = result.nextLink;
99
+ setContinuationToken(page, continuationToken);
100
+ yield page;
101
+ }
90
102
  while (continuationToken) {
91
103
  result = await this._listByAccountsNext(
92
104
  accountName,
@@ -95,7 +107,9 @@ export class WorkspacesImpl implements Workspaces {
95
107
  options
96
108
  );
97
109
  continuationToken = result.nextLink;
98
- yield result.value || [];
110
+ let page = result.value || [];
111
+ setContinuationToken(page, continuationToken);
112
+ yield page;
99
113
  }
100
114
  }
101
115
 
@@ -369,7 +383,6 @@ const listByAccountsNextOperationSpec: coreClient.OperationSpec = {
369
383
  bodyMapper: Mappers.ErrorResponse
370
384
  }
371
385
  },
372
- queryParameters: [Parameters.apiVersion],
373
386
  urlParameters: [
374
387
  Parameters.$host,
375
388
  Parameters.subscriptionId,
@@ -0,0 +1,39 @@
1
+ /*
2
+ * Copyright (c) Microsoft Corporation.
3
+ * Licensed under the MIT License.
4
+ *
5
+ * Code generated by Microsoft (R) AutoRest Code Generator.
6
+ * Changes may cause incorrect behavior and will be lost if the code is regenerated.
7
+ */
8
+
9
+ export interface PageInfo {
10
+ continuationToken?: string;
11
+ }
12
+
13
+ const pageMap = new WeakMap<object, PageInfo>();
14
+
15
+ /**
16
+ * Given the last `.value` produced by the `byPage` iterator,
17
+ * returns a continuation token that can be used to begin paging from
18
+ * that point later.
19
+ * @param page An object from accessing `value` on the IteratorResult from a `byPage` iterator.
20
+ * @returns The continuation token that can be passed into byPage() during future calls.
21
+ */
22
+ export function getContinuationToken(page: unknown): string | undefined {
23
+ if (typeof page !== "object" || page === null) {
24
+ return undefined;
25
+ }
26
+ return pageMap.get(page)?.continuationToken;
27
+ }
28
+
29
+ export function setContinuationToken(
30
+ page: unknown,
31
+ continuationToken: string | undefined
32
+ ): void {
33
+ if (typeof page !== "object" || page === null || !continuationToken) {
34
+ return;
35
+ }
36
+ const pageInfo = pageMap.get(page) ?? {};
37
+ pageInfo.continuationToken = continuationToken;
38
+ pageMap.set(page, pageInfo);
39
+ }