@azure/arm-datamigration 3.0.0-alpha.20221026.1 → 3.0.0-alpha.20221129.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. package/CHANGELOG.md +3 -13
  2. package/dist/index.js +629 -109
  3. package/dist/index.js.map +1 -1
  4. package/dist/index.min.js +1 -1
  5. package/dist/index.min.js.map +1 -1
  6. package/dist-esm/samples-dev/databaseMigrationsSqlMiCreateOrUpdateSample.js +2 -2
  7. package/dist-esm/samples-dev/databaseMigrationsSqlMiCreateOrUpdateSample.js.map +1 -1
  8. package/dist-esm/samples-dev/databaseMigrationsSqlVMCreateOrUpdateSample.js +2 -2
  9. package/dist-esm/samples-dev/databaseMigrationsSqlVMCreateOrUpdateSample.js.map +1 -1
  10. package/dist-esm/src/dataMigrationManagementClient.d.ts +2 -0
  11. package/dist-esm/src/dataMigrationManagementClient.d.ts.map +1 -1
  12. package/dist-esm/src/dataMigrationManagementClient.js +48 -17
  13. package/dist-esm/src/dataMigrationManagementClient.js.map +1 -1
  14. package/dist-esm/src/index.d.ts +1 -0
  15. package/dist-esm/src/index.d.ts.map +1 -1
  16. package/dist-esm/src/index.js +1 -0
  17. package/dist-esm/src/index.js.map +1 -1
  18. package/dist-esm/src/models/index.d.ts +556 -240
  19. package/dist-esm/src/models/index.d.ts.map +1 -1
  20. package/dist-esm/src/models/index.js +314 -0
  21. package/dist-esm/src/models/index.js.map +1 -1
  22. package/dist-esm/src/operations/files.d.ts.map +1 -1
  23. package/dist-esm/src/operations/files.js +19 -7
  24. package/dist-esm/src/operations/files.js.map +1 -1
  25. package/dist-esm/src/operations/operations.d.ts.map +1 -1
  26. package/dist-esm/src/operations/operations.js +19 -7
  27. package/dist-esm/src/operations/operations.js.map +1 -1
  28. package/dist-esm/src/operations/projects.d.ts.map +1 -1
  29. package/dist-esm/src/operations/projects.js +19 -7
  30. package/dist-esm/src/operations/projects.js.map +1 -1
  31. package/dist-esm/src/operations/resourceSkus.d.ts.map +1 -1
  32. package/dist-esm/src/operations/resourceSkus.js +19 -7
  33. package/dist-esm/src/operations/resourceSkus.js.map +1 -1
  34. package/dist-esm/src/operations/serviceTasks.d.ts.map +1 -1
  35. package/dist-esm/src/operations/serviceTasks.js +19 -7
  36. package/dist-esm/src/operations/serviceTasks.js.map +1 -1
  37. package/dist-esm/src/operations/services.d.ts.map +1 -1
  38. package/dist-esm/src/operations/services.js +55 -21
  39. package/dist-esm/src/operations/services.js.map +1 -1
  40. package/dist-esm/src/operations/sqlMigrationServices.d.ts.map +1 -1
  41. package/dist-esm/src/operations/sqlMigrationServices.js +55 -21
  42. package/dist-esm/src/operations/sqlMigrationServices.js.map +1 -1
  43. package/dist-esm/src/operations/tasks.d.ts.map +1 -1
  44. package/dist-esm/src/operations/tasks.js +19 -7
  45. package/dist-esm/src/operations/tasks.js.map +1 -1
  46. package/dist-esm/src/operations/usages.d.ts.map +1 -1
  47. package/dist-esm/src/operations/usages.js +19 -7
  48. package/dist-esm/src/operations/usages.js.map +1 -1
  49. package/dist-esm/src/pagingHelper.d.ts +13 -0
  50. package/dist-esm/src/pagingHelper.d.ts.map +1 -0
  51. package/dist-esm/src/pagingHelper.js +32 -0
  52. package/dist-esm/src/pagingHelper.js.map +1 -0
  53. package/dist-esm/test/sampleTest.js +11 -13
  54. package/dist-esm/test/sampleTest.js.map +1 -1
  55. package/package.json +12 -8
  56. package/review/arm-datamigration.api.md +564 -872
  57. package/src/dataMigrationManagementClient.ts +59 -19
  58. package/src/index.ts +1 -0
  59. package/src/models/index.ts +646 -246
  60. package/src/operations/files.ts +22 -8
  61. package/src/operations/operations.ts +21 -8
  62. package/src/operations/projects.ts +21 -8
  63. package/src/operations/resourceSkus.ts +21 -8
  64. package/src/operations/serviceTasks.ts +21 -8
  65. package/src/operations/services.ts +67 -25
  66. package/src/operations/sqlMigrationServices.ts +71 -29
  67. package/src/operations/tasks.ts +22 -8
  68. package/src/operations/usages.ts +21 -8
  69. package/src/pagingHelper.ts +39 -0
  70. package/types/arm-datamigration.d.ts +567 -240
  71. package/types/tsdoc-metadata.json +1 -1
@@ -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
  DatabaseMigrationsSqlMiImpl,
@@ -75,41 +80,47 @@ export class DataMigrationManagementClient extends coreClient.ServiceClient {
75
80
  ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}`
76
81
  : `${packageDetails}`;
77
82
 
78
- if (!options.credentialScopes) {
79
- options.credentialScopes = ["https://management.azure.com/.default"];
80
- }
81
83
  const optionsWithDefaults = {
82
84
  ...defaults,
83
85
  ...options,
84
86
  userAgentOptions: {
85
87
  userAgentPrefix
86
88
  },
87
- baseUri:
89
+ endpoint:
88
90
  options.endpoint ?? options.baseUri ?? "https://management.azure.com"
89
91
  };
90
92
  super(optionsWithDefaults);
91
93
 
94
+ let bearerTokenAuthenticationPolicyFound: boolean = false;
92
95
  if (options?.pipeline && options.pipeline.getOrderedPolicies().length > 0) {
93
96
  const pipelinePolicies: coreRestPipeline.PipelinePolicy[] = options.pipeline.getOrderedPolicies();
94
- const bearerTokenAuthenticationPolicyFound = pipelinePolicies.some(
97
+ bearerTokenAuthenticationPolicyFound = pipelinePolicies.some(
95
98
  (pipelinePolicy) =>
96
99
  pipelinePolicy.name ===
97
100
  coreRestPipeline.bearerTokenAuthenticationPolicyName
98
101
  );
99
- if (!bearerTokenAuthenticationPolicyFound) {
100
- this.pipeline.removePolicy({
101
- name: coreRestPipeline.bearerTokenAuthenticationPolicyName
102
- });
103
- this.pipeline.addPolicy(
104
- coreRestPipeline.bearerTokenAuthenticationPolicy({
105
- scopes: `${optionsWithDefaults.baseUri}/.default`,
106
- challengeCallbacks: {
107
- authorizeRequestOnChallenge:
108
- coreClient.authorizeRequestOnClaimChallenge
109
- }
110
- })
111
- );
112
- }
102
+ }
103
+ if (
104
+ !options ||
105
+ !options.pipeline ||
106
+ options.pipeline.getOrderedPolicies().length == 0 ||
107
+ !bearerTokenAuthenticationPolicyFound
108
+ ) {
109
+ this.pipeline.removePolicy({
110
+ name: coreRestPipeline.bearerTokenAuthenticationPolicyName
111
+ });
112
+ this.pipeline.addPolicy(
113
+ coreRestPipeline.bearerTokenAuthenticationPolicy({
114
+ credential: credentials,
115
+ scopes:
116
+ optionsWithDefaults.credentialScopes ??
117
+ `${optionsWithDefaults.endpoint}/.default`,
118
+ challengeCallbacks: {
119
+ authorizeRequestOnChallenge:
120
+ coreClient.authorizeRequestOnClaimChallenge
121
+ }
122
+ })
123
+ );
113
124
  }
114
125
  // Parameter assignments
115
126
  this.subscriptionId = subscriptionId;
@@ -128,6 +139,35 @@ export class DataMigrationManagementClient extends coreClient.ServiceClient {
128
139
  this.projects = new ProjectsImpl(this);
129
140
  this.usages = new UsagesImpl(this);
130
141
  this.files = new FilesImpl(this);
142
+ this.addCustomApiVersionPolicy(options.apiVersion);
143
+ }
144
+
145
+ /** A function that adds a policy that sets the api-version (or equivalent) to reflect the library version. */
146
+ private addCustomApiVersionPolicy(apiVersion?: string) {
147
+ if (!apiVersion) {
148
+ return;
149
+ }
150
+ const apiVersionPolicy = {
151
+ name: "CustomApiVersionPolicy",
152
+ async sendRequest(
153
+ request: PipelineRequest,
154
+ next: SendRequest
155
+ ): Promise<PipelineResponse> {
156
+ const param = request.url.split("?");
157
+ if (param.length > 1) {
158
+ const newParams = param[1].split("&").map((item) => {
159
+ if (item.indexOf("api-version") > -1) {
160
+ return "api-version=" + apiVersion;
161
+ } else {
162
+ return item;
163
+ }
164
+ });
165
+ request.url = param[0] + "?" + newParams.join("&");
166
+ }
167
+ return next(request);
168
+ }
169
+ };
170
+ this.pipeline.addPolicy(apiVersionPolicy);
131
171
  }
132
172
 
133
173
  databaseMigrationsSqlMi: DatabaseMigrationsSqlMi;
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 { DataMigrationManagementClient } from "./dataMigrationManagementClient";
12
13
  export * from "./operationsInterfaces";