@azure/app-configuration 1.3.2-alpha.20220401.1 → 1.4.0-alpha.20220412.2

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 (55) hide show
  1. package/CHANGELOG.md +15 -7
  2. package/dist/index.js +175 -423
  3. package/dist/index.js.map +1 -1
  4. package/dist-esm/src/appConfigCredential.js +24 -30
  5. package/dist-esm/src/appConfigCredential.js.map +1 -1
  6. package/dist-esm/src/appConfigurationClient.js +63 -81
  7. package/dist-esm/src/appConfigurationClient.js.map +1 -1
  8. package/dist-esm/src/generated/src/appConfiguration.js +47 -89
  9. package/dist-esm/src/generated/src/appConfiguration.js.map +1 -1
  10. package/dist-esm/src/generated/src/index.js +0 -1
  11. package/dist-esm/src/generated/src/index.js.map +1 -1
  12. package/dist-esm/src/generated/src/models/index.js +78 -1
  13. package/dist-esm/src/generated/src/models/index.js.map +1 -1
  14. package/dist-esm/src/generated/src/models/mappers.js.map +1 -1
  15. package/dist-esm/src/generated/src/models/parameters.js +7 -8
  16. package/dist-esm/src/generated/src/models/parameters.js.map +1 -1
  17. package/dist-esm/src/internal/helpers.js +35 -18
  18. package/dist-esm/src/internal/helpers.js.map +1 -1
  19. package/dist-esm/src/internal/synctokenpolicy.js +9 -18
  20. package/dist-esm/src/internal/synctokenpolicy.js.map +1 -1
  21. package/dist-esm/src/internal/tracing.js +11 -0
  22. package/dist-esm/src/internal/tracing.js.map +1 -0
  23. package/dist-esm/src/models.js.map +1 -1
  24. package/dist-esm/test/internal/helpers.spec.js +3 -12
  25. package/dist-esm/test/internal/helpers.spec.js.map +1 -1
  26. package/dist-esm/test/internal/http.spec.js +2 -14
  27. package/dist-esm/test/internal/http.spec.js.map +1 -1
  28. package/dist-esm/test/internal/node/throttlingRetryPolicy.spec.js +6 -5
  29. package/dist-esm/test/internal/node/throttlingRetryPolicy.spec.js.map +1 -1
  30. package/dist-esm/test/public/auth.spec.js +1 -1
  31. package/dist-esm/test/public/auth.spec.js.map +1 -1
  32. package/dist-esm/test/public/etags.spec.js +1 -2
  33. package/dist-esm/test/public/etags.spec.js.map +1 -1
  34. package/dist-esm/test/public/index.readonlytests.spec.js +6 -1
  35. package/dist-esm/test/public/index.readonlytests.spec.js.map +1 -1
  36. package/dist-esm/test/public/index.spec.js +23 -8
  37. package/dist-esm/test/public/index.spec.js.map +1 -1
  38. package/dist-esm/test/public/secretReference.spec.js.map +1 -1
  39. package/dist-esm/test/public/throwOrNotThrow.spec.js +1 -1
  40. package/dist-esm/test/public/throwOrNotThrow.spec.js.map +1 -1
  41. package/dist-esm/test/public/tracing.spec.js +34 -0
  42. package/dist-esm/test/public/tracing.spec.js.map +1 -0
  43. package/dist-esm/test/public/utils/testHelpers.js.map +1 -1
  44. package/package.json +12 -4
  45. package/types/app-configuration.d.ts +5 -14
  46. package/dist-esm/src/generated/src/appConfigurationContext.js +0 -46
  47. package/dist-esm/src/generated/src/appConfigurationContext.js.map +0 -1
  48. package/dist-esm/src/internal/tracingHelpers.js +0 -46
  49. package/dist-esm/src/internal/tracingHelpers.js.map +0 -1
  50. package/dist-esm/src/policies/throttlingRetryPolicy.js +0 -126
  51. package/dist-esm/src/policies/throttlingRetryPolicy.js.map +0 -1
  52. package/dist-esm/test/internal/throttlingRetryPolicyTests.spec.js +0 -145
  53. package/dist-esm/test/internal/throttlingRetryPolicyTests.spec.js.map +0 -1
  54. package/dist-esm/test/internal/tracingHelpers.spec.js +0 -112
  55. package/dist-esm/test/internal/tracingHelpers.spec.js.map +0 -1
package/dist/index.js CHANGED
@@ -3,10 +3,11 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var tslib = require('tslib');
6
- var coreHttp = require('@azure/core-http');
7
6
  var crypto = require('crypto');
8
- var abortController = require('@azure/abort-controller');
9
- require('@azure/core-asynciterator-polyfill');
7
+ var coreClient = require('@azure/core-client');
8
+ var coreHttpCompat = require('@azure/core-http-compat');
9
+ var coreAuth = require('@azure/core-auth');
10
+ var coreRestPipeline = require('@azure/core-rest-pipeline');
10
11
  var coreTracing = require('@azure/core-tracing');
11
12
 
12
13
  function _interopNamespace(e) {
@@ -27,7 +28,8 @@ function _interopNamespace(e) {
27
28
  return Object.freeze(n);
28
29
  }
29
30
 
30
- var coreHttp__namespace = /*#__PURE__*/_interopNamespace(coreHttp);
31
+ var coreClient__namespace = /*#__PURE__*/_interopNamespace(coreClient);
32
+ var coreHttpCompat__namespace = /*#__PURE__*/_interopNamespace(coreHttpCompat);
31
33
 
32
34
  // Copyright (c) Microsoft Corporation.
33
35
  /**
@@ -48,36 +50,31 @@ async function sha256Hmac(secret, stringToSign) {
48
50
 
49
51
  // Copyright (c) Microsoft Corporation.
50
52
  /**
51
- * @internal
53
+ * Create an HTTP pipeline policy to authenticate a request
54
+ * using an `AzureKeyCredential` for AppConfig.
52
55
  */
53
- class AppConfigCredential {
54
- constructor(credential, secret) {
55
- this.credential = credential;
56
- this.secret = secret;
57
- }
58
- /**
59
- * Signs a request with the values provided in the credential and secret parameter.
60
- *
61
- * @param webResource - The WebResource to be signed.
62
- * @returns The signed request object.
63
- */
64
- async signRequest(webResource) {
65
- const verb = webResource.method.toUpperCase();
66
- const utcNow = new Date().toUTCString();
67
- const contentHash = await sha256Digest(webResource.body || "");
68
- const signedHeaders = "x-ms-date;host;x-ms-content-sha256";
69
- const url = coreHttp.URLBuilder.parse(webResource.url);
70
- const query = url.getQuery();
71
- const urlPathAndQuery = `${url.getPath()}${query ? "?" + query : ""}`;
72
- const stringToSign = `${verb}\n${urlPathAndQuery}\n${utcNow};${url.getHost()};${contentHash}`;
73
- const signature = await sha256Hmac(this.secret, stringToSign);
74
- webResource.headers.set("x-ms-date", utcNow);
75
- webResource.headers.set("x-ms-content-sha256", contentHash);
76
- // Syntax for Authorization header
77
- // Reference - https://docs.microsoft.com/en-us/azure/azure-app-configuration/rest-api-authentication-hmac#syntax
78
- webResource.headers.set("Authorization", `HMAC-SHA256 Credential=${this.credential}&SignedHeaders=${signedHeaders}&Signature=${signature}`);
79
- return webResource;
80
- }
56
+ function appConfigKeyCredentialPolicy(credential, secret) {
57
+ return {
58
+ name: "AppConfigKeyCredentialPolicy",
59
+ async sendRequest(request, next) {
60
+ var _a;
61
+ const verb = request.method;
62
+ const utcNow = new Date().toUTCString();
63
+ const contentHash = await sha256Digest(((_a = request.body) === null || _a === void 0 ? void 0 : _a.toString()) || "");
64
+ const signedHeaders = "x-ms-date;host;x-ms-content-sha256";
65
+ const url = new URL(request.url);
66
+ const query = url.search;
67
+ const urlPathAndQuery = query ? `${url.pathname}${query}` : url.pathname;
68
+ const stringToSign = `${verb}\n${urlPathAndQuery}\n${utcNow};${url.host};${contentHash}`;
69
+ const signature = await sha256Hmac(secret, stringToSign);
70
+ request.headers.set("x-ms-date", utcNow);
71
+ request.headers.set("x-ms-content-sha256", contentHash);
72
+ // Syntax for Authorization header
73
+ // Reference - https://docs.microsoft.com/en-us/azure/azure-app-configuration/rest-api-authentication-hmac#syntax
74
+ request.headers.set("Authorization", `HMAC-SHA256 Credential=${credential}&SignedHeaders=${signedHeaders}&Signature=${signature}`);
75
+ return next(request);
76
+ },
77
+ };
81
78
  }
82
79
 
83
80
  /*
@@ -738,7 +735,7 @@ const select = {
738
735
  }
739
736
  }
740
737
  },
741
- collectionFormat: coreHttp.QueryCollectionFormat.Csv
738
+ collectionFormat: "CSV"
742
739
  };
743
740
  const select1 = {
744
741
  parameterPath: ["options", "select"],
@@ -753,7 +750,7 @@ const select1 = {
753
750
  }
754
751
  }
755
752
  },
756
- collectionFormat: coreHttp.QueryCollectionFormat.Csv
753
+ collectionFormat: "CSV"
757
754
  };
758
755
  const accept2 = {
759
756
  parameterPath: "accept",
@@ -807,7 +804,7 @@ const select2 = {
807
804
  }
808
805
  }
809
806
  },
810
- collectionFormat: coreHttp.QueryCollectionFormat.Csv
807
+ collectionFormat: "CSV"
811
808
  };
812
809
  const contentType = {
813
810
  parameterPath: ["options", "contentType"],
@@ -837,7 +834,7 @@ const select3 = {
837
834
  }
838
835
  }
839
836
  },
840
- collectionFormat: coreHttp.QueryCollectionFormat.Csv
837
+ collectionFormat: "CSV"
841
838
  };
842
839
  const accept3 = {
843
840
  parameterPath: "accept",
@@ -865,7 +862,7 @@ const select4 = {
865
862
  }
866
863
  }
867
864
  },
868
- collectionFormat: coreHttp.QueryCollectionFormat.Csv
865
+ collectionFormat: "CSV"
869
866
  };
870
867
  const select5 = {
871
868
  parameterPath: ["options", "select"],
@@ -880,7 +877,7 @@ const select5 = {
880
877
  }
881
878
  }
882
879
  },
883
- collectionFormat: coreHttp.QueryCollectionFormat.Csv
880
+ collectionFormat: "CSV"
884
881
  };
885
882
  const select6 = {
886
883
  parameterPath: ["options", "select"],
@@ -895,7 +892,7 @@ const select6 = {
895
892
  }
896
893
  }
897
894
  },
898
- collectionFormat: coreHttp.QueryCollectionFormat.Csv
895
+ collectionFormat: "CSV"
899
896
  };
900
897
  const nextLink = {
901
898
  parameterPath: "nextLink",
@@ -916,21 +913,15 @@ const nextLink = {
916
913
  * Code generated by Microsoft (R) AutoRest Code Generator.
917
914
  * Changes may cause incorrect behavior and will be lost if the code is regenerated.
918
915
  */
919
- const packageName$1 = "app-configuration";
920
- const packageVersion$1 = "1.3.2";
921
916
  /** @internal */
922
- class AppConfigurationContext extends coreHttp__namespace.ServiceClient {
917
+ class AppConfiguration extends coreHttpCompat__namespace.ExtendedServiceClient {
923
918
  /**
924
- * Initializes a new instance of the AppConfigurationContext class.
925
- * @param credentials Subscription credentials which uniquely identify client subscription.
919
+ * Initializes a new instance of the AppConfiguration class.
926
920
  * @param endpoint The endpoint of the App Configuration instance to send requests to.
927
921
  * @param apiVersion Api Version
928
922
  * @param options The parameter options
929
923
  */
930
- constructor(credentials, endpoint, apiVersion, options) {
931
- if (credentials === undefined) {
932
- throw new Error("'credentials' cannot be null");
933
- }
924
+ constructor(endpoint, apiVersion, options) {
934
925
  if (endpoint === undefined) {
935
926
  throw new Error("'endpoint' cannot be null");
936
927
  }
@@ -941,77 +932,48 @@ class AppConfigurationContext extends coreHttp__namespace.ServiceClient {
941
932
  if (!options) {
942
933
  options = {};
943
934
  }
944
- if (!options.userAgent) {
945
- const defaultUserAgent = coreHttp__namespace.getDefaultUserAgentValue();
946
- options.userAgent = `${packageName$1}/${packageVersion$1} ${defaultUserAgent}`;
947
- }
948
- super(credentials, options);
949
- this.requestContentType = "application/json; charset=utf-8";
950
- this.baseUri = options.endpoint || "{endpoint}";
935
+ const defaults = {
936
+ requestContentType: "application/json; charset=utf-8"
937
+ };
938
+ const packageDetails = `azsdk-js-app-configuration/1.4.0-beta.1`;
939
+ const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix
940
+ ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}`
941
+ : `${packageDetails}`;
942
+ const optionsWithDefaults = Object.assign(Object.assign(Object.assign({}, defaults), options), { userAgentOptions: {
943
+ userAgentPrefix
944
+ }, baseUri: options.endpoint || "{endpoint}" });
945
+ super(optionsWithDefaults);
951
946
  // Parameter assignments
952
947
  this.endpoint = endpoint;
953
948
  this.apiVersion = apiVersion;
954
949
  }
955
- }
956
-
957
- /*
958
- * Copyright (c) Microsoft Corporation.
959
- * Licensed under the MIT License.
960
- *
961
- * Code generated by Microsoft (R) AutoRest Code Generator.
962
- * Changes may cause incorrect behavior and will be lost if the code is regenerated.
963
- */
964
- /** @internal */
965
- class AppConfiguration extends AppConfigurationContext {
966
- /**
967
- * Initializes a new instance of the AppConfiguration class.
968
- * @param credentials Subscription credentials which uniquely identify client subscription.
969
- * @param endpoint The endpoint of the App Configuration instance to send requests to.
970
- * @param apiVersion Api Version
971
- * @param options The parameter options
972
- */
973
- constructor(credentials, endpoint, apiVersion, options) {
974
- super(credentials, endpoint, apiVersion, options);
975
- }
976
950
  /**
977
951
  * Gets a list of keys.
978
952
  * @param options The options parameters.
979
953
  */
980
954
  getKeys(options) {
981
- const operationArguments = {
982
- options: coreHttp__namespace.operationOptionsToRequestOptionsBase(options || {})
983
- };
984
- return this.sendOperationRequest(operationArguments, getKeysOperationSpec);
955
+ return this.sendOperationRequest({ options }, getKeysOperationSpec);
985
956
  }
986
957
  /**
987
958
  * Requests the headers and status of the given resource.
988
959
  * @param options The options parameters.
989
960
  */
990
961
  checkKeys(options) {
991
- const operationArguments = {
992
- options: coreHttp__namespace.operationOptionsToRequestOptionsBase(options || {})
993
- };
994
- return this.sendOperationRequest(operationArguments, checkKeysOperationSpec);
962
+ return this.sendOperationRequest({ options }, checkKeysOperationSpec);
995
963
  }
996
964
  /**
997
965
  * Gets a list of key-values.
998
966
  * @param options The options parameters.
999
967
  */
1000
968
  getKeyValues(options) {
1001
- const operationArguments = {
1002
- options: coreHttp__namespace.operationOptionsToRequestOptionsBase(options || {})
1003
- };
1004
- return this.sendOperationRequest(operationArguments, getKeyValuesOperationSpec);
969
+ return this.sendOperationRequest({ options }, getKeyValuesOperationSpec);
1005
970
  }
1006
971
  /**
1007
972
  * Requests the headers and status of the given resource.
1008
973
  * @param options The options parameters.
1009
974
  */
1010
975
  checkKeyValues(options) {
1011
- const operationArguments = {
1012
- options: coreHttp__namespace.operationOptionsToRequestOptionsBase(options || {})
1013
- };
1014
- return this.sendOperationRequest(operationArguments, checkKeyValuesOperationSpec);
976
+ return this.sendOperationRequest({ options }, checkKeyValuesOperationSpec);
1015
977
  }
1016
978
  /**
1017
979
  * Gets a single key-value.
@@ -1019,11 +981,7 @@ class AppConfiguration extends AppConfigurationContext {
1019
981
  * @param options The options parameters.
1020
982
  */
1021
983
  getKeyValue(key, options) {
1022
- const operationArguments = {
1023
- key,
1024
- options: coreHttp__namespace.operationOptionsToRequestOptionsBase(options || {})
1025
- };
1026
- return this.sendOperationRequest(operationArguments, getKeyValueOperationSpec);
984
+ return this.sendOperationRequest({ key, options }, getKeyValueOperationSpec);
1027
985
  }
1028
986
  /**
1029
987
  * Creates a key-value.
@@ -1031,11 +989,7 @@ class AppConfiguration extends AppConfigurationContext {
1031
989
  * @param options The options parameters.
1032
990
  */
1033
991
  putKeyValue(key, options) {
1034
- const operationArguments = {
1035
- key,
1036
- options: coreHttp__namespace.operationOptionsToRequestOptionsBase(options || {})
1037
- };
1038
- return this.sendOperationRequest(operationArguments, putKeyValueOperationSpec);
992
+ return this.sendOperationRequest({ key, options }, putKeyValueOperationSpec);
1039
993
  }
1040
994
  /**
1041
995
  * Deletes a key-value.
@@ -1043,11 +997,7 @@ class AppConfiguration extends AppConfigurationContext {
1043
997
  * @param options The options parameters.
1044
998
  */
1045
999
  deleteKeyValue(key, options) {
1046
- const operationArguments = {
1047
- key,
1048
- options: coreHttp__namespace.operationOptionsToRequestOptionsBase(options || {})
1049
- };
1050
- return this.sendOperationRequest(operationArguments, deleteKeyValueOperationSpec);
1000
+ return this.sendOperationRequest({ key, options }, deleteKeyValueOperationSpec);
1051
1001
  }
1052
1002
  /**
1053
1003
  * Requests the headers and status of the given resource.
@@ -1055,31 +1005,21 @@ class AppConfiguration extends AppConfigurationContext {
1055
1005
  * @param options The options parameters.
1056
1006
  */
1057
1007
  checkKeyValue(key, options) {
1058
- const operationArguments = {
1059
- key,
1060
- options: coreHttp__namespace.operationOptionsToRequestOptionsBase(options || {})
1061
- };
1062
- return this.sendOperationRequest(operationArguments, checkKeyValueOperationSpec);
1008
+ return this.sendOperationRequest({ key, options }, checkKeyValueOperationSpec);
1063
1009
  }
1064
1010
  /**
1065
1011
  * Gets a list of labels.
1066
1012
  * @param options The options parameters.
1067
1013
  */
1068
1014
  getLabels(options) {
1069
- const operationArguments = {
1070
- options: coreHttp__namespace.operationOptionsToRequestOptionsBase(options || {})
1071
- };
1072
- return this.sendOperationRequest(operationArguments, getLabelsOperationSpec);
1015
+ return this.sendOperationRequest({ options }, getLabelsOperationSpec);
1073
1016
  }
1074
1017
  /**
1075
1018
  * Requests the headers and status of the given resource.
1076
1019
  * @param options The options parameters.
1077
1020
  */
1078
1021
  checkLabels(options) {
1079
- const operationArguments = {
1080
- options: coreHttp__namespace.operationOptionsToRequestOptionsBase(options || {})
1081
- };
1082
- return this.sendOperationRequest(operationArguments, checkLabelsOperationSpec);
1022
+ return this.sendOperationRequest({ options }, checkLabelsOperationSpec);
1083
1023
  }
1084
1024
  /**
1085
1025
  * Locks a key-value.
@@ -1087,11 +1027,7 @@ class AppConfiguration extends AppConfigurationContext {
1087
1027
  * @param options The options parameters.
1088
1028
  */
1089
1029
  putLock(key, options) {
1090
- const operationArguments = {
1091
- key,
1092
- options: coreHttp__namespace.operationOptionsToRequestOptionsBase(options || {})
1093
- };
1094
- return this.sendOperationRequest(operationArguments, putLockOperationSpec);
1030
+ return this.sendOperationRequest({ key, options }, putLockOperationSpec);
1095
1031
  }
1096
1032
  /**
1097
1033
  * Unlocks a key-value.
@@ -1099,31 +1035,21 @@ class AppConfiguration extends AppConfigurationContext {
1099
1035
  * @param options The options parameters.
1100
1036
  */
1101
1037
  deleteLock(key, options) {
1102
- const operationArguments = {
1103
- key,
1104
- options: coreHttp__namespace.operationOptionsToRequestOptionsBase(options || {})
1105
- };
1106
- return this.sendOperationRequest(operationArguments, deleteLockOperationSpec);
1038
+ return this.sendOperationRequest({ key, options }, deleteLockOperationSpec);
1107
1039
  }
1108
1040
  /**
1109
1041
  * Gets a list of key-value revisions.
1110
1042
  * @param options The options parameters.
1111
1043
  */
1112
1044
  getRevisions(options) {
1113
- const operationArguments = {
1114
- options: coreHttp__namespace.operationOptionsToRequestOptionsBase(options || {})
1115
- };
1116
- return this.sendOperationRequest(operationArguments, getRevisionsOperationSpec);
1045
+ return this.sendOperationRequest({ options }, getRevisionsOperationSpec);
1117
1046
  }
1118
1047
  /**
1119
1048
  * Requests the headers and status of the given resource.
1120
1049
  * @param options The options parameters.
1121
1050
  */
1122
1051
  checkRevisions(options) {
1123
- const operationArguments = {
1124
- options: coreHttp__namespace.operationOptionsToRequestOptionsBase(options || {})
1125
- };
1126
- return this.sendOperationRequest(operationArguments, checkRevisionsOperationSpec);
1052
+ return this.sendOperationRequest({ options }, checkRevisionsOperationSpec);
1127
1053
  }
1128
1054
  /**
1129
1055
  * GetKeysNext
@@ -1131,11 +1057,7 @@ class AppConfiguration extends AppConfigurationContext {
1131
1057
  * @param options The options parameters.
1132
1058
  */
1133
1059
  getKeysNext(nextLink, options) {
1134
- const operationArguments = {
1135
- nextLink,
1136
- options: coreHttp__namespace.operationOptionsToRequestOptionsBase(options || {})
1137
- };
1138
- return this.sendOperationRequest(operationArguments, getKeysNextOperationSpec);
1060
+ return this.sendOperationRequest({ nextLink, options }, getKeysNextOperationSpec);
1139
1061
  }
1140
1062
  /**
1141
1063
  * GetKeyValuesNext
@@ -1143,11 +1065,7 @@ class AppConfiguration extends AppConfigurationContext {
1143
1065
  * @param options The options parameters.
1144
1066
  */
1145
1067
  getKeyValuesNext(nextLink, options) {
1146
- const operationArguments = {
1147
- nextLink,
1148
- options: coreHttp__namespace.operationOptionsToRequestOptionsBase(options || {})
1149
- };
1150
- return this.sendOperationRequest(operationArguments, getKeyValuesNextOperationSpec);
1068
+ return this.sendOperationRequest({ nextLink, options }, getKeyValuesNextOperationSpec);
1151
1069
  }
1152
1070
  /**
1153
1071
  * GetLabelsNext
@@ -1155,11 +1073,7 @@ class AppConfiguration extends AppConfigurationContext {
1155
1073
  * @param options The options parameters.
1156
1074
  */
1157
1075
  getLabelsNext(nextLink, options) {
1158
- const operationArguments = {
1159
- nextLink,
1160
- options: coreHttp__namespace.operationOptionsToRequestOptionsBase(options || {})
1161
- };
1162
- return this.sendOperationRequest(operationArguments, getLabelsNextOperationSpec);
1076
+ return this.sendOperationRequest({ nextLink, options }, getLabelsNextOperationSpec);
1163
1077
  }
1164
1078
  /**
1165
1079
  * GetRevisionsNext
@@ -1167,15 +1081,11 @@ class AppConfiguration extends AppConfigurationContext {
1167
1081
  * @param options The options parameters.
1168
1082
  */
1169
1083
  getRevisionsNext(nextLink, options) {
1170
- const operationArguments = {
1171
- nextLink,
1172
- options: coreHttp__namespace.operationOptionsToRequestOptionsBase(options || {})
1173
- };
1174
- return this.sendOperationRequest(operationArguments, getRevisionsNextOperationSpec);
1084
+ return this.sendOperationRequest({ nextLink, options }, getRevisionsNextOperationSpec);
1175
1085
  }
1176
1086
  }
1177
1087
  // Operation Specifications
1178
- const serializer = new coreHttp__namespace.Serializer(Mappers, /* isXml */ false);
1088
+ const serializer = coreClient__namespace.createSerializer(Mappers, /* isXml */ false);
1179
1089
  const getKeysOperationSpec = {
1180
1090
  path: "/keys",
1181
1091
  httpMethod: "GET",
@@ -1601,128 +1511,6 @@ const getRevisionsNextOperationSpec = {
1601
1511
  serializer
1602
1512
  };
1603
1513
 
1604
- // Copyright (c) Microsoft Corporation.
1605
- /**
1606
- * @internal
1607
- */
1608
- function throttlingRetryPolicy(retryOptions) {
1609
- return {
1610
- create: (nextPolicy, options) => {
1611
- return new ThrottlingRetryPolicy(nextPolicy, options, retryOptions);
1612
- },
1613
- };
1614
- }
1615
- const StandardAbortMessage = "The operation was aborted.";
1616
- // Merge this constant with the one in core-http when we unify throttling retry policy in core-http and app-config
1617
- const DEFAULT_CLIENT_RETRY_COUNT = 3;
1618
- /**
1619
- * This policy is a close copy of the ThrottlingRetryPolicy class from
1620
- * core-http with modifications to work with how AppConfig is currently
1621
- * responding to 429 responses (which is to throw a RestError).
1622
- *
1623
- * @internal
1624
- */
1625
- class ThrottlingRetryPolicy extends coreHttp.BaseRequestPolicy {
1626
- constructor(nextPolicy, options, retryOptions = { maxRetries: DEFAULT_CLIENT_RETRY_COUNT }) {
1627
- super(nextPolicy, options);
1628
- this.retryOptions = retryOptions;
1629
- this.numberOfRetries = 0;
1630
- }
1631
- async sendRequest(httpRequest) {
1632
- return this._nextPolicy.sendRequest(httpRequest.clone()).catch(async (err) => {
1633
- var _a;
1634
- if (isRestErrorWithHeaders(err)) {
1635
- let delayInMs = getDelayInMs(err.response.headers);
1636
- if (delayInMs == null) {
1637
- throw err;
1638
- }
1639
- if (this.retryOptions.maxRetryDelayInMs &&
1640
- delayInMs > this.retryOptions.maxRetryDelayInMs) {
1641
- delayInMs = this.retryOptions.maxRetryDelayInMs;
1642
- }
1643
- this.numberOfRetries += 1;
1644
- await coreHttp.delay(delayInMs, undefined, {
1645
- abortSignal: httpRequest.abortSignal,
1646
- abortErrorMsg: StandardAbortMessage,
1647
- });
1648
- if ((_a = httpRequest.abortSignal) === null || _a === void 0 ? void 0 : _a.aborted) {
1649
- throw new abortController.AbortError(StandardAbortMessage);
1650
- }
1651
- if (this.retryOptions.maxRetries === undefined || this.retryOptions.maxRetries === null) {
1652
- this.retryOptions.maxRetries = DEFAULT_CLIENT_RETRY_COUNT;
1653
- }
1654
- if (this.numberOfRetries < this.retryOptions.maxRetries) {
1655
- // retries
1656
- return this.sendRequest(httpRequest.clone());
1657
- }
1658
- else {
1659
- // passes on to the next policy
1660
- return this._nextPolicy.sendRequest(httpRequest.clone());
1661
- }
1662
- }
1663
- else {
1664
- throw err;
1665
- }
1666
- });
1667
- }
1668
- static parseRetryAfterHeader(headerValue) {
1669
- const retryAfterInSeconds = Number(headerValue);
1670
- if (Number.isNaN(retryAfterInSeconds)) {
1671
- return ThrottlingRetryPolicy.parseDateRetryAfterHeader(headerValue);
1672
- }
1673
- else {
1674
- return retryAfterInSeconds * 1000;
1675
- }
1676
- }
1677
- static parseDateRetryAfterHeader(headerValue) {
1678
- try {
1679
- const now = Date.now();
1680
- const date = Date.parse(headerValue);
1681
- const diff = date - now;
1682
- return Number.isNaN(diff) ? undefined : diff;
1683
- }
1684
- catch (error) {
1685
- return undefined;
1686
- }
1687
- }
1688
- }
1689
- /**
1690
- * The headers that come back from Azure services representing
1691
- * the amount of time (minimum) to wait to retry (in milliseconds).
1692
- */
1693
- const RetryAfterMillisecondsHeaders = ["retry-after-ms", "x-ms-retry-after-ms"];
1694
- /**
1695
- * Extracts the retry response header, checking against several
1696
- * header names.
1697
- * @internal
1698
- */
1699
- function getDelayInMs(responseHeaders) {
1700
- for (const name of RetryAfterMillisecondsHeaders) {
1701
- const delayValueString = responseHeaders.get(name);
1702
- if (delayValueString == null) {
1703
- continue;
1704
- }
1705
- const delayValueMs = Number(delayValueString);
1706
- if (Number.isNaN(delayValueMs)) {
1707
- return undefined;
1708
- }
1709
- return delayValueMs;
1710
- }
1711
- const retryAfterValue = responseHeaders.get(coreHttp.Constants.HeaderConstants.RETRY_AFTER);
1712
- if (retryAfterValue != null) {
1713
- return ThrottlingRetryPolicy.parseRetryAfterHeader(retryAfterValue);
1714
- }
1715
- return undefined;
1716
- }
1717
- function isRestErrorWithHeaders(err) {
1718
- return (err &&
1719
- err.statusCode &&
1720
- typeof err.statusCode === "number" &&
1721
- err.response &&
1722
- err.response.headers &&
1723
- typeof err.response.headers.get === "function");
1724
- }
1725
-
1726
1514
  // Copyright (c) Microsoft Corporation.
1727
1515
  // Licensed under the MIT license.
1728
1516
  /**
@@ -1927,8 +1715,8 @@ function formatAcceptDateTime(newOptions) {
1927
1715
  * @internal
1928
1716
  */
1929
1717
  function extractAfterTokenFromNextLink(nextLink) {
1930
- const parsedLink = coreHttp.URLBuilder.parse(nextLink);
1931
- const afterToken = parsedLink.getQueryParameterValue("after");
1718
+ const searchParams = new URLSearchParams(nextLink);
1719
+ const afterToken = searchParams.get("after");
1932
1720
  if (afterToken == null || Array.isArray(afterToken)) {
1933
1721
  throw new Error("Invalid nextLink - invalid after token");
1934
1722
  }
@@ -2008,24 +1796,29 @@ function serializeAsConfigurationSettingParam(setting) {
2008
1796
  /**
2009
1797
  * @internal
2010
1798
  */
2011
- function transformKeyValueResponseWithStatusCode(kvp) {
2012
- return normalizeResponse(kvp, Object.assign(Object.assign({}, transformKeyValue(kvp)), { statusCode: kvp._response.status }));
1799
+ function transformKeyValueResponseWithStatusCode(kvp, status) {
1800
+ const response = Object.assign(Object.assign({}, transformKeyValue(kvp)), { statusCode: status !== null && status !== void 0 ? status : -1 });
1801
+ if (hasUnderscoreResponse(kvp)) {
1802
+ Object.defineProperty(response, "_response", {
1803
+ enumerable: false,
1804
+ value: kvp._response,
1805
+ });
1806
+ }
1807
+ return response;
2013
1808
  }
2014
1809
  /**
2015
1810
  * @internal
2016
1811
  */
2017
1812
  function transformKeyValueResponse(kvp) {
2018
- return normalizeResponse(kvp, Object.assign({}, transformKeyValue(kvp)));
2019
- }
2020
- function normalizeResponse(originalResponse, newResponse) {
2021
- Object.defineProperty(newResponse, "_response", {
2022
- enumerable: false,
2023
- value: originalResponse._response,
2024
- });
2025
- // this field comes from the header but it's redundant with
2026
- // the one serialized in the model itself
2027
- delete newResponse.eTag;
2028
- return newResponse;
1813
+ const setting = transformKeyValue(kvp);
1814
+ if (hasUnderscoreResponse(kvp)) {
1815
+ Object.defineProperty(setting, "_response", {
1816
+ enumerable: false,
1817
+ value: kvp._response,
1818
+ });
1819
+ }
1820
+ delete setting.eTag;
1821
+ return setting;
2029
1822
  }
2030
1823
  /**
2031
1824
  * Translates user-facing field names into their `select` equivalents (these can be
@@ -2054,46 +1847,22 @@ function formatFieldsForSelect(fieldNames) {
2054
1847
  });
2055
1848
  return mappedFieldNames;
2056
1849
  }
2057
-
2058
- // Copyright (c) Microsoft Corporation.
2059
- /** @internal */
2060
- const createSpan = coreTracing.createSpanFunction({
2061
- namespace: "Microsoft.AppConfiguration",
2062
- packagePrefix: "Azure.Data.AppConfiguration",
2063
- });
2064
- /**
2065
- * Traces an operation and properly handles reporting start, end and errors for a given span
2066
- *
2067
- * @param operationName - Name of a method in the TClient type
2068
- * @param options - An options class, typically derived from \@azure/core-http/RequestOptionsBase
2069
- * @param fn - The function to call with an options class that properly propagates the span context
2070
- *
2071
- * @internal
2072
- */
2073
- async function trace(operationName, options, fn, createSpanFn = createSpan) {
2074
- const { updatedOptions, span } = createSpanFn(operationName, options);
2075
- try {
2076
- // NOTE: we really do need to await on this function here so we can handle any exceptions thrown and properly
2077
- // close the span.
2078
- const result = await fn(updatedOptions, span);
2079
- span.setStatus({
2080
- code: coreTracing.SpanStatusCode.OK,
2081
- });
2082
- return result;
2083
- }
2084
- catch (err) {
2085
- span.setStatus({
2086
- code: coreTracing.SpanStatusCode.ERROR,
2087
- message: err.message,
1850
+ // eslint-disable-next-line @typescript-eslint/ban-types
1851
+ function assertResponse(result) {
1852
+ if (!hasUnderscoreResponse(result)) {
1853
+ Object.defineProperty(result, "_response", {
1854
+ enumerable: false,
1855
+ value: "Something went wrong, _response(raw response) is supposed to be part of the response. Please file a bug at https://github.com/Azure/azure-sdk-for-js",
2088
1856
  });
2089
- throw err;
2090
- }
2091
- finally {
2092
- span.end();
2093
1857
  }
2094
1858
  }
1859
+ // eslint-disable-next-line @typescript-eslint/ban-types
1860
+ function hasUnderscoreResponse(result) {
1861
+ return Object.prototype.hasOwnProperty.call(result, "_response");
1862
+ }
2095
1863
 
2096
1864
  // Copyright (c) Microsoft Corporation.
1865
+ // Licensed under the MIT license.
2097
1866
  /**
2098
1867
  * The sync token header, as described here:
2099
1868
  * https://docs.microsoft.com/azure/azure-app-configuration/rest-api-consistency
@@ -2107,26 +1876,18 @@ const SyncTokenHeaderName = "sync-token";
2107
1876
  */
2108
1877
  function syncTokenPolicy(syncTokens) {
2109
1878
  return {
2110
- create: (nextPolicy, options) => {
2111
- return new SyncTokenPolicy(nextPolicy, options, syncTokens);
1879
+ name: "Sync Token Policy",
1880
+ async sendRequest(request, next) {
1881
+ const syncTokenHeaderValue = syncTokens.getSyncTokenHeaderValue();
1882
+ if (syncTokenHeaderValue) {
1883
+ request.headers.set(SyncTokenHeaderName, syncTokenHeaderValue);
1884
+ }
1885
+ const response = await next(request);
1886
+ syncTokens.addSyncTokenFromHeaderValue(response.headers.get(SyncTokenHeaderName));
1887
+ return response;
2112
1888
  },
2113
1889
  };
2114
1890
  }
2115
- class SyncTokenPolicy extends coreHttp.BaseRequestPolicy {
2116
- constructor(nextPolicy, options, _syncTokens) {
2117
- super(nextPolicy, options);
2118
- this._syncTokens = _syncTokens;
2119
- }
2120
- async sendRequest(webResource) {
2121
- const syncTokenHeaderValue = this._syncTokens.getSyncTokenHeaderValue();
2122
- if (syncTokenHeaderValue != null) {
2123
- webResource.headers.set(SyncTokenHeaderName, syncTokenHeaderValue);
2124
- }
2125
- const response = await this._nextPolicy.sendRequest(webResource);
2126
- this._syncTokens.addSyncTokenFromHeaderValue(response.headers.get(SyncTokenHeaderName));
2127
- return response;
2128
- }
2129
- }
2130
1891
  /**
2131
1892
  * Sync token tracker (allows for real-time consistency, even in the face of
2132
1893
  * caching and load balancing within App Configuration).
@@ -2216,13 +1977,18 @@ function parseSyncToken(syncToken) {
2216
1977
  }
2217
1978
 
2218
1979
  // Copyright (c) Microsoft Corporation.
2219
- const packageName = "azsdk-js-app-configuration";
1980
+ /** @internal */
1981
+ const tracingClient = coreTracing.createTracingClient({
1982
+ namespace: "Microsoft.AppConfiguration",
1983
+ packageName: "@azure/app-configuration",
1984
+ packageVersion,
1985
+ });
1986
+
1987
+ // Copyright (c) Microsoft Corporation.
2220
1988
  /**
2221
- * This constant should always be the same as the package.json's version - we use it when forming the
2222
- * User - Agent header. There's a unit test that makes sure it always stays in sync.
2223
1989
  * @internal
2224
1990
  */
2225
- const packageVersion = "1.3.2";
1991
+ const packageVersion = "1.4.0-beta.1";
2226
1992
  const apiVersion = "1.0";
2227
1993
  const ConnectionStringRegex = /Endpoint=(.*);Id=(.*);Secret=(.*)/;
2228
1994
  const deserializationContentTypes = {
@@ -2239,29 +2005,38 @@ const deserializationContentTypes = {
2239
2005
  */
2240
2006
  class AppConfigurationClient {
2241
2007
  constructor(connectionStringOrEndpoint, tokenCredentialOrOptions, options) {
2242
- // (for tests)
2243
- this._trace = trace;
2244
2008
  let appConfigOptions = {};
2245
2009
  let appConfigCredential;
2246
2010
  let appConfigEndpoint;
2247
- if (coreHttp.isTokenCredential(tokenCredentialOrOptions)) {
2011
+ let authPolicy;
2012
+ if (coreAuth.isTokenCredential(tokenCredentialOrOptions)) {
2248
2013
  appConfigOptions = options || {};
2249
2014
  appConfigCredential = tokenCredentialOrOptions;
2250
- appConfigEndpoint = connectionStringOrEndpoint;
2015
+ appConfigEndpoint = connectionStringOrEndpoint.endsWith("/")
2016
+ ? connectionStringOrEndpoint.slice(0, -1)
2017
+ : connectionStringOrEndpoint;
2018
+ authPolicy = coreRestPipeline.bearerTokenAuthenticationPolicy({
2019
+ scopes: `${appConfigEndpoint}/.default`,
2020
+ credential: appConfigCredential,
2021
+ });
2251
2022
  }
2252
2023
  else {
2253
2024
  appConfigOptions = tokenCredentialOrOptions || {};
2254
2025
  const regexMatch = connectionStringOrEndpoint === null || connectionStringOrEndpoint === void 0 ? void 0 : connectionStringOrEndpoint.match(ConnectionStringRegex);
2255
2026
  if (regexMatch) {
2256
- appConfigCredential = new AppConfigCredential(regexMatch[2], regexMatch[3]);
2257
2027
  appConfigEndpoint = regexMatch[1];
2028
+ authPolicy = appConfigKeyCredentialPolicy(regexMatch[2], regexMatch[3]);
2258
2029
  }
2259
2030
  else {
2260
2031
  throw new Error(`Invalid connection string. Valid connection strings should match the regex '${ConnectionStringRegex.source}'.`);
2261
2032
  }
2262
2033
  }
2263
2034
  this._syncTokens = appConfigOptions.syncTokens || new SyncTokens();
2264
- this.client = new AppConfiguration(appConfigCredential, appConfigEndpoint, apiVersion, getGeneratedClientOptions(appConfigEndpoint, this._syncTokens, appConfigOptions));
2035
+ this.client = new AppConfiguration(appConfigEndpoint, apiVersion, appConfigOptions);
2036
+ this.client.pipeline.addPolicy(authPolicy, { phase: "Sign" });
2037
+ this.client.pipeline.addPolicy(syncTokenPolicy(this._syncTokens), { afterPhase: "Retry" });
2038
+ this.client.pipeline.removePolicy({ name: coreClient.deserializationPolicyName });
2039
+ this.client.pipeline.addPolicy(coreClient.deserializationPolicy({ expectedContentTypes: deserializationContentTypes }), { phase: "Deserialize" });
2265
2040
  }
2266
2041
  /**
2267
2042
  * Add a setting into the Azure App Configuration service, failing if it
@@ -2275,10 +2050,12 @@ class AppConfigurationClient {
2275
2050
  * @param options - Optional parameters for the request.
2276
2051
  */
2277
2052
  addConfigurationSetting(configurationSetting, options = {}) {
2278
- return this._trace("addConfigurationSetting", options, async (newOptions) => {
2053
+ return tracingClient.withSpan("AppConfigurationClient.addConfigurationSetting", options, async (updatedOptions) => {
2279
2054
  const keyValue = serializeAsConfigurationSettingParam(configurationSetting);
2280
- const originalResponse = await this.client.putKeyValue(configurationSetting.key, Object.assign({ ifNoneMatch: "*", label: configurationSetting.label, entity: keyValue }, newOptions));
2281
- return transformKeyValueResponse(originalResponse);
2055
+ const originalResponse = await this.client.putKeyValue(configurationSetting.key, Object.assign({ ifNoneMatch: "*", label: configurationSetting.label, entity: keyValue }, updatedOptions));
2056
+ const response = transformKeyValueResponse(originalResponse);
2057
+ assertResponse(response);
2058
+ return response;
2282
2059
  });
2283
2060
  }
2284
2061
  /**
@@ -2292,9 +2069,14 @@ class AppConfigurationClient {
2292
2069
  * @param options - Optional parameters for the request (ex: etag, label)
2293
2070
  */
2294
2071
  deleteConfigurationSetting(id, options = {}) {
2295
- return this._trace("deleteConfigurationSetting", options, async (newOptions) => {
2296
- const originalResponse = await this.client.deleteKeyValue(id.key, Object.assign(Object.assign({ label: id.label }, newOptions), checkAndFormatIfAndIfNoneMatch(id, options)));
2297
- return transformKeyValueResponseWithStatusCode(originalResponse);
2072
+ return tracingClient.withSpan("AppConfigurationClient.deleteConfigurationSetting", options, async (updatedOptions) => {
2073
+ let status;
2074
+ const originalResponse = await this.client.deleteKeyValue(id.key, Object.assign(Object.assign(Object.assign({ label: id.label }, updatedOptions), checkAndFormatIfAndIfNoneMatch(id, options)), { onResponse: (response) => {
2075
+ status = response.status;
2076
+ } }));
2077
+ const response = transformKeyValueResponseWithStatusCode(originalResponse, status);
2078
+ assertResponse(response);
2079
+ return response;
2298
2080
  });
2299
2081
  }
2300
2082
  /**
@@ -2308,9 +2090,12 @@ class AppConfigurationClient {
2308
2090
  * @param options - Optional parameters for the request.
2309
2091
  */
2310
2092
  async getConfigurationSetting(id, options = {}) {
2311
- return this._trace("getConfigurationSetting", options, async (newOptions) => {
2312
- const originalResponse = await this.client.getKeyValue(id.key, Object.assign(Object.assign(Object.assign(Object.assign({}, newOptions), { label: id.label, select: formatFieldsForSelect(options.fields) }), formatAcceptDateTime(options)), checkAndFormatIfAndIfNoneMatch(id, options)));
2313
- const response = transformKeyValueResponseWithStatusCode(originalResponse);
2093
+ return tracingClient.withSpan("AppConfigurationClient.getConfigurationSetting", options, async (updatedOptions) => {
2094
+ let status;
2095
+ const originalResponse = await this.client.getKeyValue(id.key, Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, updatedOptions), { label: id.label, select: formatFieldsForSelect(options.fields) }), formatAcceptDateTime(options)), checkAndFormatIfAndIfNoneMatch(id, options)), { onResponse: (response) => {
2096
+ status = response.status;
2097
+ } }));
2098
+ const response = transformKeyValueResponseWithStatusCode(originalResponse, status);
2314
2099
  // 304 only comes back if the user has passed a conditional option in their
2315
2100
  // request _and_ the remote object has the same etag as what the user passed.
2316
2101
  if (response.statusCode === 304) {
@@ -2320,6 +2105,7 @@ class AppConfigurationClient {
2320
2105
  // and now we'll undefine all the other properties that are not HTTP related
2321
2106
  makeConfigurationSettingEmpty(response);
2322
2107
  }
2108
+ assertResponse(response);
2323
2109
  return response;
2324
2110
  });
2325
2111
  }
@@ -2371,16 +2157,16 @@ class AppConfigurationClient {
2371
2157
  }
2372
2158
  listConfigurationSettingsByPage(options = {}) {
2373
2159
  return tslib.__asyncGenerator(this, arguments, function* listConfigurationSettingsByPage_1() {
2374
- let currentResponse = yield tslib.__await(this._trace("listConfigurationSettings", options, async (newOptions) => {
2375
- const response = await this.client.getKeyValues(Object.assign(Object.assign(Object.assign(Object.assign({}, newOptions), formatAcceptDateTime(options)), formatFiltersAndSelect(options)), { after: options.continuationToken }));
2160
+ let currentResponse = yield tslib.__await(tracingClient.withSpan("AppConfigurationClient.listConfigurationSettings", options, async (updatedOptions) => {
2161
+ const response = await this.client.getKeyValues(Object.assign(Object.assign(Object.assign(Object.assign({}, updatedOptions), formatAcceptDateTime(options)), formatFiltersAndSelect(options)), { after: options.continuationToken }));
2376
2162
  return response;
2377
2163
  }));
2378
2164
  yield tslib.__await(yield* tslib.__asyncDelegator(tslib.__asyncValues(this.createListConfigurationPageFromResponse(currentResponse))));
2379
2165
  while (currentResponse.nextLink) {
2380
- currentResponse = yield tslib.__await(this._trace("listConfigurationSettings", options,
2166
+ currentResponse = yield tslib.__await(tracingClient.withSpan("AppConfigurationClient.listConfigurationSettings", options,
2381
2167
  // TODO: same code up above. Unify.
2382
- async (newOptions) => {
2383
- const response = await this.client.getKeyValues(Object.assign(Object.assign(Object.assign(Object.assign({}, newOptions), formatAcceptDateTime(options)), formatFiltersAndSelect(options)), { after: extractAfterTokenFromNextLink(currentResponse.nextLink) }));
2168
+ async (updatedOptions) => {
2169
+ const response = await this.client.getKeyValues(Object.assign(Object.assign(Object.assign(Object.assign({}, updatedOptions), formatAcceptDateTime(options)), formatFiltersAndSelect(options)), { after: extractAfterTokenFromNextLink(currentResponse.nextLink) }));
2384
2170
  return response;
2385
2171
  }));
2386
2172
  if (!currentResponse.items) {
@@ -2443,15 +2229,15 @@ class AppConfigurationClient {
2443
2229
  }
2444
2230
  listRevisionsByPage(options = {}) {
2445
2231
  return tslib.__asyncGenerator(this, arguments, function* listRevisionsByPage_1() {
2446
- let currentResponse = yield tslib.__await(this._trace("listRevisions", options, async (newOptions) => {
2447
- const response = await this.client.getRevisions(Object.assign(Object.assign(Object.assign(Object.assign({}, newOptions), formatAcceptDateTime(options)), formatFiltersAndSelect(newOptions)), { after: options.continuationToken }));
2232
+ let currentResponse = yield tslib.__await(tracingClient.withSpan("AppConfigurationClient.listRevisions", options, async (updatedOptions) => {
2233
+ const response = await this.client.getRevisions(Object.assign(Object.assign(Object.assign(Object.assign({}, updatedOptions), formatAcceptDateTime(options)), formatFiltersAndSelect(updatedOptions)), { after: options.continuationToken }));
2448
2234
  return response;
2449
2235
  }));
2450
2236
  yield tslib.__await(yield* tslib.__asyncDelegator(tslib.__asyncValues(this.createListRevisionsPageFromResponse(currentResponse))));
2451
2237
  while (currentResponse.nextLink) {
2452
- currentResponse = yield tslib.__await(this._trace("listRevisions", options, (newOptions) => {
2453
- return this.client.getRevisions(Object.assign(Object.assign(Object.assign(Object.assign({}, newOptions), formatAcceptDateTime(options)), formatFiltersAndSelect(options)), { after: extractAfterTokenFromNextLink(currentResponse.nextLink) }));
2454
- }));
2238
+ currentResponse = (yield tslib.__await(tracingClient.withSpan("AppConfigurationClient.listRevisions", options, (updatedOptions) => {
2239
+ return this.client.getRevisions(Object.assign(Object.assign(Object.assign(Object.assign({}, updatedOptions), formatAcceptDateTime(options)), formatFiltersAndSelect(options)), { after: extractAfterTokenFromNextLink(currentResponse.nextLink) }));
2240
+ })));
2455
2241
  if (!currentResponse.items) {
2456
2242
  break;
2457
2243
  }
@@ -2476,10 +2262,11 @@ class AppConfigurationClient {
2476
2262
  * ```
2477
2263
  */
2478
2264
  async setConfigurationSetting(configurationSetting, options = {}) {
2479
- return this._trace("setConfigurationSetting", options, async (newOptions) => {
2265
+ return tracingClient.withSpan("AppConfigurationClient.setConfigurationSetting", options, async (updatedOptions) => {
2480
2266
  const keyValue = serializeAsConfigurationSettingParam(configurationSetting);
2481
- const response = await this.client.putKeyValue(configurationSetting.key, Object.assign(Object.assign(Object.assign({}, newOptions), { label: configurationSetting.label, entity: keyValue }), checkAndFormatIfAndIfNoneMatch(configurationSetting, options)));
2482
- return transformKeyValueResponse(response);
2267
+ const response = transformKeyValueResponse(await this.client.putKeyValue(configurationSetting.key, Object.assign(Object.assign(Object.assign({}, updatedOptions), { label: configurationSetting.label, entity: keyValue }), checkAndFormatIfAndIfNoneMatch(configurationSetting, options))));
2268
+ assertResponse(response);
2269
+ return response;
2483
2270
  });
2484
2271
  }
2485
2272
  /**
@@ -2487,15 +2274,17 @@ class AppConfigurationClient {
2487
2274
  * @param id - The id of the configuration setting to modify.
2488
2275
  */
2489
2276
  async setReadOnly(id, readOnly, options = {}) {
2490
- return this._trace("setReadOnly", options, async (newOptions) => {
2277
+ return tracingClient.withSpan("AppConfigurationClient.setReadOnly", options, async (newOptions) => {
2278
+ let response;
2491
2279
  if (readOnly) {
2492
- const response = await this.client.putLock(id.key, Object.assign(Object.assign(Object.assign({}, newOptions), { label: id.label }), checkAndFormatIfAndIfNoneMatch(id, options)));
2493
- return transformKeyValueResponse(response);
2280
+ response = await this.client.putLock(id.key, Object.assign(Object.assign(Object.assign({}, newOptions), { label: id.label }), checkAndFormatIfAndIfNoneMatch(id, options)));
2494
2281
  }
2495
2282
  else {
2496
- const response = await this.client.deleteLock(id.key, Object.assign(Object.assign(Object.assign({}, newOptions), { label: id.label }), checkAndFormatIfAndIfNoneMatch(id, options)));
2497
- return transformKeyValueResponse(response);
2283
+ response = await this.client.deleteLock(id.key, Object.assign(Object.assign(Object.assign({}, newOptions), { label: id.label }), checkAndFormatIfAndIfNoneMatch(id, options)));
2498
2284
  }
2285
+ response = transformKeyValueResponse(response);
2286
+ assertResponse(response);
2287
+ return response;
2499
2288
  });
2500
2289
  }
2501
2290
  /**
@@ -2507,43 +2296,6 @@ class AppConfigurationClient {
2507
2296
  this._syncTokens.addSyncTokenFromHeaderValue(syncToken);
2508
2297
  }
2509
2298
  }
2510
- /**
2511
- * Gets the options for the generated AppConfigurationClient
2512
- * @internal
2513
- */
2514
- function getGeneratedClientOptions(endpoint, syncTokens, internalAppConfigOptions) {
2515
- const retryPolicies = [
2516
- coreHttp.exponentialRetryPolicy(),
2517
- coreHttp.systemErrorRetryPolicy(),
2518
- throttlingRetryPolicy(internalAppConfigOptions.retryOptions),
2519
- ];
2520
- const userAgent = getUserAgentPrefix(internalAppConfigOptions.userAgentOptions &&
2521
- internalAppConfigOptions.userAgentOptions.userAgentPrefix);
2522
- return {
2523
- endpoint,
2524
- deserializationContentTypes,
2525
- // we'll add in our own custom retry policies
2526
- noRetryPolicy: true,
2527
- requestPolicyFactories: (defaults) => [
2528
- coreHttp.tracingPolicy({ userAgent }),
2529
- syncTokenPolicy(syncTokens),
2530
- coreHttp.userAgentPolicy({ value: userAgent }),
2531
- ...retryPolicies,
2532
- ...defaults,
2533
- ],
2534
- generateClientRequestIdHeader: true,
2535
- };
2536
- }
2537
- /**
2538
- * @internal
2539
- */
2540
- function getUserAgentPrefix(userSuppliedUserAgent) {
2541
- const appConfigDefaultUserAgent = `${packageName}/${packageVersion} ${coreHttp.getDefaultUserAgentValue()}`;
2542
- if (!userSuppliedUserAgent) {
2543
- return appConfigDefaultUserAgent;
2544
- }
2545
- return `${userSuppliedUserAgent} ${appConfigDefaultUserAgent}`;
2546
- }
2547
2299
 
2548
2300
  exports.AppConfigurationClient = AppConfigurationClient;
2549
2301
  exports.featureFlagContentType = featureFlagContentType;