@azure/template 1.0.12-beta.1293619 → 1.0.12-beta.1346364

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.
package/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Release History
2
2
 
3
- ## 1.0.12-beta.1293619 (2022-01-13)
3
+ ## 1.0.12-beta.1346364 (2022-02-04)
4
4
 
5
5
  - Test Release Pipeline
6
6
 
package/dist/index.js CHANGED
@@ -2,9 +2,30 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var coreHttp = require('@azure/core-http');
5
+ var coreRestPipeline = require('@azure/core-rest-pipeline');
6
6
  var coreTracing = require('@azure/core-tracing');
7
7
  var logger$1 = require('@azure/logger');
8
+ var coreClient = require('@azure/core-client');
9
+
10
+ function _interopNamespace(e) {
11
+ if (e && e.__esModule) return e;
12
+ var n = Object.create(null);
13
+ if (e) {
14
+ Object.keys(e).forEach(function (k) {
15
+ if (k !== 'default') {
16
+ var d = Object.getOwnPropertyDescriptor(e, k);
17
+ Object.defineProperty(n, k, d.get ? d : {
18
+ enumerable: true,
19
+ get: function () { return e[k]; }
20
+ });
21
+ }
22
+ });
23
+ }
24
+ n["default"] = e;
25
+ return Object.freeze(n);
26
+ }
27
+
28
+ var coreClient__namespace = /*#__PURE__*/_interopNamespace(coreClient);
8
29
 
9
30
  /*
10
31
  * Copyright (c) Microsoft Corporation.
@@ -675,7 +696,7 @@ const select = {
675
696
  }
676
697
  }
677
698
  },
678
- collectionFormat: coreHttp.QueryCollectionFormat.Csv
699
+ collectionFormat: "CSV"
679
700
  };
680
701
  const accept2 = {
681
702
  parameterPath: "accept",
@@ -757,7 +778,7 @@ const select1 = {
757
778
  }
758
779
  }
759
780
  },
760
- collectionFormat: coreHttp.QueryCollectionFormat.Csv
781
+ collectionFormat: "CSV"
761
782
  };
762
783
  const nextLink = {
763
784
  parameterPath: "nextLink",
@@ -778,10 +799,8 @@ const nextLink = {
778
799
  * Code generated by Microsoft (R) AutoRest Code Generator.
779
800
  * Changes may cause incorrect behavior and will be lost if the code is regenerated.
780
801
  */
781
- const packageName = "@azure/template";
782
- const packageVersion = "1.0.12-beta.1293619";
783
- /** @hidden */
784
- class GeneratedClientContext extends coreHttp.ServiceClient {
802
+ /** @internal */
803
+ class GeneratedClientContext extends coreClient__namespace.ServiceClient {
785
804
  /**
786
805
  * Initializes a new instance of the GeneratedClientContext class.
787
806
  * @param endpoint The endpoint of the App Configuration instance to send requests to.
@@ -795,13 +814,17 @@ class GeneratedClientContext extends coreHttp.ServiceClient {
795
814
  if (!options) {
796
815
  options = {};
797
816
  }
798
- if (!options.userAgent) {
799
- const defaultUserAgent = coreHttp.getDefaultUserAgentValue();
800
- options.userAgent = `${packageName}/${packageVersion} ${defaultUserAgent}`;
801
- }
802
- super(undefined, options);
803
- this.requestContentType = "application/json; charset=utf-8";
804
- this.baseUri = options.endpoint || "{endpoint}";
817
+ const defaults = {
818
+ requestContentType: "application/json; charset=utf-8"
819
+ };
820
+ const packageDetails = `azsdk-js-template/1.0.12-beta.1346364`;
821
+ const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix
822
+ ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}`
823
+ : `${packageDetails}`;
824
+ const optionsWithDefaults = Object.assign(Object.assign(Object.assign({}, defaults), options), { userAgentOptions: {
825
+ userAgentPrefix
826
+ }, baseUri: options.endpoint || "{endpoint}" });
827
+ super(optionsWithDefaults);
805
828
  // Parameter assignments
806
829
  this.endpoint = endpoint;
807
830
  // Assigning values to Constant parameters
@@ -816,7 +839,7 @@ class GeneratedClientContext extends coreHttp.ServiceClient {
816
839
  * Code generated by Microsoft (R) AutoRest Code Generator.
817
840
  * Changes may cause incorrect behavior and will be lost if the code is regenerated.
818
841
  */
819
- /** @hidden */
842
+ /** @internal */
820
843
  class GeneratedClient extends GeneratedClientContext {
821
844
  /**
822
845
  * Initializes a new instance of the GeneratedClient class.
@@ -831,40 +854,28 @@ class GeneratedClient extends GeneratedClientContext {
831
854
  * @param options The options parameters.
832
855
  */
833
856
  getKeys(options) {
834
- const operationArguments = {
835
- options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
836
- };
837
- return this.sendOperationRequest(operationArguments, getKeysOperationSpec);
857
+ return this.sendOperationRequest({ options }, getKeysOperationSpec);
838
858
  }
839
859
  /**
840
860
  * Requests the headers and status of the given resource.
841
861
  * @param options The options parameters.
842
862
  */
843
863
  checkKeys(options) {
844
- const operationArguments = {
845
- options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
846
- };
847
- return this.sendOperationRequest(operationArguments, checkKeysOperationSpec);
864
+ return this.sendOperationRequest({ options }, checkKeysOperationSpec);
848
865
  }
849
866
  /**
850
867
  * Gets a list of key-values.
851
868
  * @param options The options parameters.
852
869
  */
853
870
  getKeyValues(options) {
854
- const operationArguments = {
855
- options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
856
- };
857
- return this.sendOperationRequest(operationArguments, getKeyValuesOperationSpec);
871
+ return this.sendOperationRequest({ options }, getKeyValuesOperationSpec);
858
872
  }
859
873
  /**
860
874
  * Requests the headers and status of the given resource.
861
875
  * @param options The options parameters.
862
876
  */
863
877
  checkKeyValues(options) {
864
- const operationArguments = {
865
- options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
866
- };
867
- return this.sendOperationRequest(operationArguments, checkKeyValuesOperationSpec);
878
+ return this.sendOperationRequest({ options }, checkKeyValuesOperationSpec);
868
879
  }
869
880
  /**
870
881
  * Gets a single key-value.
@@ -872,11 +883,7 @@ class GeneratedClient extends GeneratedClientContext {
872
883
  * @param options The options parameters.
873
884
  */
874
885
  getKeyValue(key, options) {
875
- const operationArguments = {
876
- key,
877
- options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
878
- };
879
- return this.sendOperationRequest(operationArguments, getKeyValueOperationSpec);
886
+ return this.sendOperationRequest({ key, options }, getKeyValueOperationSpec);
880
887
  }
881
888
  /**
882
889
  * Creates a key-value.
@@ -884,11 +891,7 @@ class GeneratedClient extends GeneratedClientContext {
884
891
  * @param options The options parameters.
885
892
  */
886
893
  putKeyValue(key, options) {
887
- const operationArguments = {
888
- key,
889
- options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
890
- };
891
- return this.sendOperationRequest(operationArguments, putKeyValueOperationSpec);
894
+ return this.sendOperationRequest({ key, options }, putKeyValueOperationSpec);
892
895
  }
893
896
  /**
894
897
  * Deletes a key-value.
@@ -896,11 +899,7 @@ class GeneratedClient extends GeneratedClientContext {
896
899
  * @param options The options parameters.
897
900
  */
898
901
  deleteKeyValue(key, options) {
899
- const operationArguments = {
900
- key,
901
- options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
902
- };
903
- return this.sendOperationRequest(operationArguments, deleteKeyValueOperationSpec);
902
+ return this.sendOperationRequest({ key, options }, deleteKeyValueOperationSpec);
904
903
  }
905
904
  /**
906
905
  * Requests the headers and status of the given resource.
@@ -908,31 +907,21 @@ class GeneratedClient extends GeneratedClientContext {
908
907
  * @param options The options parameters.
909
908
  */
910
909
  checkKeyValue(key, options) {
911
- const operationArguments = {
912
- key,
913
- options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
914
- };
915
- return this.sendOperationRequest(operationArguments, checkKeyValueOperationSpec);
910
+ return this.sendOperationRequest({ key, options }, checkKeyValueOperationSpec);
916
911
  }
917
912
  /**
918
913
  * Gets a list of labels.
919
914
  * @param options The options parameters.
920
915
  */
921
916
  getLabels(options) {
922
- const operationArguments = {
923
- options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
924
- };
925
- return this.sendOperationRequest(operationArguments, getLabelsOperationSpec);
917
+ return this.sendOperationRequest({ options }, getLabelsOperationSpec);
926
918
  }
927
919
  /**
928
920
  * Requests the headers and status of the given resource.
929
921
  * @param options The options parameters.
930
922
  */
931
923
  checkLabels(options) {
932
- const operationArguments = {
933
- options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
934
- };
935
- return this.sendOperationRequest(operationArguments, checkLabelsOperationSpec);
924
+ return this.sendOperationRequest({ options }, checkLabelsOperationSpec);
936
925
  }
937
926
  /**
938
927
  * Locks a key-value.
@@ -940,11 +929,7 @@ class GeneratedClient extends GeneratedClientContext {
940
929
  * @param options The options parameters.
941
930
  */
942
931
  putLock(key, options) {
943
- const operationArguments = {
944
- key,
945
- options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
946
- };
947
- return this.sendOperationRequest(operationArguments, putLockOperationSpec);
932
+ return this.sendOperationRequest({ key, options }, putLockOperationSpec);
948
933
  }
949
934
  /**
950
935
  * Unlocks a key-value.
@@ -952,31 +937,21 @@ class GeneratedClient extends GeneratedClientContext {
952
937
  * @param options The options parameters.
953
938
  */
954
939
  deleteLock(key, options) {
955
- const operationArguments = {
956
- key,
957
- options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
958
- };
959
- return this.sendOperationRequest(operationArguments, deleteLockOperationSpec);
940
+ return this.sendOperationRequest({ key, options }, deleteLockOperationSpec);
960
941
  }
961
942
  /**
962
943
  * Gets a list of key-value revisions.
963
944
  * @param options The options parameters.
964
945
  */
965
946
  getRevisions(options) {
966
- const operationArguments = {
967
- options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
968
- };
969
- return this.sendOperationRequest(operationArguments, getRevisionsOperationSpec);
947
+ return this.sendOperationRequest({ options }, getRevisionsOperationSpec);
970
948
  }
971
949
  /**
972
950
  * Requests the headers and status of the given resource.
973
951
  * @param options The options parameters.
974
952
  */
975
953
  checkRevisions(options) {
976
- const operationArguments = {
977
- options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
978
- };
979
- return this.sendOperationRequest(operationArguments, checkRevisionsOperationSpec);
954
+ return this.sendOperationRequest({ options }, checkRevisionsOperationSpec);
980
955
  }
981
956
  /**
982
957
  * GetKeysNext
@@ -984,11 +959,7 @@ class GeneratedClient extends GeneratedClientContext {
984
959
  * @param options The options parameters.
985
960
  */
986
961
  getKeysNext(nextLink, options) {
987
- const operationArguments = {
988
- nextLink,
989
- options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
990
- };
991
- return this.sendOperationRequest(operationArguments, getKeysNextOperationSpec);
962
+ return this.sendOperationRequest({ nextLink, options }, getKeysNextOperationSpec);
992
963
  }
993
964
  /**
994
965
  * GetKeyValuesNext
@@ -996,11 +967,7 @@ class GeneratedClient extends GeneratedClientContext {
996
967
  * @param options The options parameters.
997
968
  */
998
969
  getKeyValuesNext(nextLink, options) {
999
- const operationArguments = {
1000
- nextLink,
1001
- options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
1002
- };
1003
- return this.sendOperationRequest(operationArguments, getKeyValuesNextOperationSpec);
970
+ return this.sendOperationRequest({ nextLink, options }, getKeyValuesNextOperationSpec);
1004
971
  }
1005
972
  /**
1006
973
  * GetLabelsNext
@@ -1008,11 +975,7 @@ class GeneratedClient extends GeneratedClientContext {
1008
975
  * @param options The options parameters.
1009
976
  */
1010
977
  getLabelsNext(nextLink, options) {
1011
- const operationArguments = {
1012
- nextLink,
1013
- options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
1014
- };
1015
- return this.sendOperationRequest(operationArguments, getLabelsNextOperationSpec);
978
+ return this.sendOperationRequest({ nextLink, options }, getLabelsNextOperationSpec);
1016
979
  }
1017
980
  /**
1018
981
  * GetRevisionsNext
@@ -1020,15 +983,11 @@ class GeneratedClient extends GeneratedClientContext {
1020
983
  * @param options The options parameters.
1021
984
  */
1022
985
  getRevisionsNext(nextLink, options) {
1023
- const operationArguments = {
1024
- nextLink,
1025
- options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
1026
- };
1027
- return this.sendOperationRequest(operationArguments, getRevisionsNextOperationSpec);
986
+ return this.sendOperationRequest({ nextLink, options }, getRevisionsNextOperationSpec);
1028
987
  }
1029
988
  }
1030
989
  // Operation Specifications
1031
- const serializer = new coreHttp.Serializer(Mappers, /* isXml */ false);
990
+ const serializer = coreClient__namespace.createSerializer(Mappers, /* isXml */ false);
1032
991
  const getKeysOperationSpec = {
1033
992
  path: "/keys",
1034
993
  httpMethod: "GET",
@@ -1442,21 +1401,7 @@ const getRevisionsNextOperationSpec = {
1442
1401
 
1443
1402
  // Copyright (c) Microsoft Corporation.
1444
1403
  // Licensed under the MIT license.
1445
- const SDK_VERSION = "1.0.12-beta.1293619";
1446
-
1447
- // Copyright (c) Microsoft Corporation.
1448
- /**
1449
- * Creates a span using the global tracer.
1450
- *
1451
- * @param name - The name of the operation being performed.
1452
- * @param tracingOptions - The options for the underlying http request.
1453
- *
1454
- * @internal
1455
- */
1456
- const createSpan = coreTracing.createSpanFunction({
1457
- namespace: "Microsoft.Learn",
1458
- packagePrefix: "Azure.Learn.ApiLearn",
1459
- });
1404
+ const SDK_VERSION = "1.0.12-beta.1346364";
1460
1405
 
1461
1406
  // Copyright (c) Microsoft Corporation.
1462
1407
  /**
@@ -1515,21 +1460,13 @@ class ConfigurationClient {
1515
1460
  * @param options - optional configuration used to send requests to the service
1516
1461
  */
1517
1462
  constructor(endpointUrl, credential, options = {}) {
1518
- // The below code helps us set a proper User-Agent header on all requests
1519
- const libInfo = `azsdk-js-template-template/${SDK_VERSION}`;
1520
- if (!options.userAgentOptions) {
1521
- options.userAgentOptions = {};
1522
- }
1523
- if (options.userAgentOptions.userAgentPrefix) {
1524
- options.userAgentOptions.userAgentPrefix = `${options.userAgentOptions.userAgentPrefix} ${libInfo}`;
1525
- }
1526
- else {
1527
- options.userAgentOptions.userAgentPrefix = libInfo;
1528
- }
1529
1463
  // The AAD scope for an API is usually the baseUri + "/.default", but it
1530
1464
  // may be different for your service.
1531
- const authPolicy = coreHttp.bearerTokenAuthenticationPolicy(credential, `${endpointUrl}/.default`);
1532
- const internalPipelineOptions = Object.assign(Object.assign(Object.assign({}, options), { deserializationOptions: {
1465
+ const authPolicy = coreRestPipeline.bearerTokenAuthenticationPolicy({
1466
+ credential,
1467
+ scopes: `${endpointUrl}/.default`,
1468
+ });
1469
+ const internalClientPipelineOptions = Object.assign(Object.assign(Object.assign({}, options), { deserializationOptions: {
1533
1470
  expectedContentTypes: {
1534
1471
  json: [
1535
1472
  "application/vnd.microsoft.appconfig.kvset+json",
@@ -1544,44 +1481,42 @@ class ConfigurationClient {
1544
1481
  logger: logger.info,
1545
1482
  // This array contains header names we want to log that are not already
1546
1483
  // included as safe. Unknown/unsafe headers are logged as "<REDACTED>".
1547
- allowedHeaderNames: ["x-ms-correlation-request-id"],
1484
+ additionalAllowedHeaderNames: ["x-ms-correlation-request-id"],
1548
1485
  },
1549
1486
  });
1550
- const pipeline = coreHttp.createPipelineFromOptions(internalPipelineOptions, authPolicy);
1551
- this.client = new GeneratedClient(endpointUrl, pipeline);
1487
+ this.client = new GeneratedClient(endpointUrl, internalClientPipelineOptions);
1488
+ this.client.pipeline.addPolicy(authPolicy);
1489
+ this.tracingClient = coreTracing.createTracingClient({
1490
+ // The name of the resource provider requests are made against, as described in
1491
+ // https://github.com/Azure/azure-sdk/blob/main/docs/tracing/distributed-tracing-conventions.yml#L11-L15
1492
+ namespace: "Microsoft.Learn",
1493
+ // The package name and version
1494
+ packageName: "@azure/template",
1495
+ packageVersion: SDK_VERSION,
1496
+ });
1552
1497
  }
1553
1498
  async getConfigurationSetting(keyOrSetting, options = {}) {
1554
1499
  let key;
1555
1500
  let ifNoneMatch;
1556
- if (typeof keyOrSetting === "string") {
1557
- key = keyOrSetting;
1558
- if (options.onlyIfChanged) {
1559
- throw new RangeError("You must pass a ConfigurationSetting instead of a key to perform a conditional fetch.");
1501
+ return this.tracingClient.withSpan(
1502
+ // Span names should take the form "<className>.<methodName>".
1503
+ "ConfigurationClient.getConfigurationSetting", options, (updatedOptions) => {
1504
+ if (typeof keyOrSetting === "string") {
1505
+ key = keyOrSetting;
1506
+ if (options.onlyIfChanged) {
1507
+ throw new RangeError("You must pass a ConfigurationSetting instead of a key to perform a conditional fetch.");
1508
+ }
1560
1509
  }
1561
- }
1562
- else {
1563
- key = keyOrSetting.key;
1564
- const etag = keyOrSetting.etag;
1565
- if (options.onlyIfChanged) {
1566
- ifNoneMatch = quoteETag(etag);
1510
+ else {
1511
+ key = keyOrSetting.key;
1512
+ const etag = keyOrSetting.etag;
1513
+ if (options.onlyIfChanged) {
1514
+ ifNoneMatch = quoteETag(etag);
1515
+ }
1567
1516
  }
1568
- }
1569
- const { span, updatedOptions } = createSpan(
1570
- // Here you set the name of the span, usually clientName-operationName
1571
- "ConfigurationClient-getConfigurationSetting", options);
1572
- try {
1573
- const result = await this.client.getKeyValue(key, Object.assign(Object.assign({}, updatedOptions), { ifNoneMatch }));
1574
- return result;
1575
- }
1576
- catch (e) {
1577
- // There are different standard codes available for different errors:
1578
- // https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/trace/api.md#status
1579
- span.setStatus({ code: coreTracing.SpanStatusCode.ERROR, message: e.message });
1580
- throw e;
1581
- }
1582
- finally {
1583
- span.end();
1584
- }
1517
+ // You must pass updatedOptions to any calls you make within the callback.
1518
+ return this.client.getKeyValue(key, Object.assign(Object.assign({}, updatedOptions), { ifNoneMatch }));
1519
+ });
1585
1520
  }
1586
1521
  }
1587
1522