@azure/app-configuration 1.4.1 → 1.5.0-alpha.20230717.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 (39) hide show
  1. package/README.md +79 -1
  2. package/dist/index.js +1120 -77
  3. package/dist/index.js.map +1 -1
  4. package/dist-esm/samples-dev/snapshot.js +130 -0
  5. package/dist-esm/samples-dev/snapshot.js.map +1 -0
  6. package/dist-esm/src/appConfigurationClient.js +139 -3
  7. package/dist-esm/src/appConfigurationClient.js.map +1 -1
  8. package/dist-esm/src/generated/src/appConfiguration.js +313 -28
  9. package/dist-esm/src/generated/src/appConfiguration.js.map +1 -1
  10. package/dist-esm/src/generated/src/lroImpl.js +21 -0
  11. package/dist-esm/src/generated/src/lroImpl.js.map +1 -0
  12. package/dist-esm/src/generated/src/models/index.js +61 -6
  13. package/dist-esm/src/generated/src/models/index.js.map +1 -1
  14. package/dist-esm/src/generated/src/models/mappers.js +406 -8
  15. package/dist-esm/src/generated/src/models/mappers.js.map +1 -1
  16. package/dist-esm/src/generated/src/models/parameters.js +140 -5
  17. package/dist-esm/src/generated/src/models/parameters.js.map +1 -1
  18. package/dist-esm/src/index.js.map +1 -1
  19. package/dist-esm/src/internal/constants.js +1 -1
  20. package/dist-esm/src/internal/constants.js.map +1 -1
  21. package/dist-esm/src/internal/helpers.js +44 -4
  22. package/dist-esm/src/internal/helpers.js.map +1 -1
  23. package/dist-esm/src/models.js +26 -1
  24. package/dist-esm/src/models.js.map +1 -1
  25. package/dist-esm/test/internal/helpers.spec.js +16 -4
  26. package/dist-esm/test/internal/helpers.spec.js.map +1 -1
  27. package/dist-esm/test/internal/node/http.spec.js.map +1 -1
  28. package/dist-esm/test/public/auth.spec.js +1 -1
  29. package/dist-esm/test/public/auth.spec.js.map +1 -1
  30. package/dist-esm/test/public/index.readonlytests.spec.js +2 -1
  31. package/dist-esm/test/public/index.readonlytests.spec.js.map +1 -1
  32. package/dist-esm/test/public/index.spec.js +13 -18
  33. package/dist-esm/test/public/index.spec.js.map +1 -1
  34. package/dist-esm/test/public/snapshot.spec.js +256 -0
  35. package/dist-esm/test/public/snapshot.spec.js.map +1 -0
  36. package/dist-esm/test/public/utils/testHelpers.js +68 -1
  37. package/dist-esm/test/public/utils/testHelpers.js.map +1 -1
  38. package/package.json +6 -5
  39. package/types/app-configuration.d.ts +369 -12
package/README.md CHANGED
@@ -7,6 +7,7 @@ Use the client library for App Configuration to:
7
7
  - Create flexible key representations and mappings
8
8
  - Tag keys with labels
9
9
  - Replay settings from any point in time
10
+ - Manage snapshots of an app's configuration
10
11
 
11
12
  Key links:
12
13
 
@@ -143,9 +144,11 @@ let setting = await client.getConfigurationSetting({
143
144
  setting = await client.getConfigurationSetting(setting);
144
145
  ```
145
146
 
147
+ The `2022-11-01-preview` API version supports configuration snapshots: immutable, point-in-time copies of a configuration store. Snapshots can be created with filters that determine which key-value pairs are contained within the snapshot, creating an immutable, composed view of the configuration store. This feature enables applications to hold a consistent view of configuration, ensuring that there are no version mismatches to individual settings due to reading as updates were made. For example, this feature can be used to create "release configuration snapshots" within an App Configuration. See [the _create and get a snapshot_ section](#create-and-get-a-setting) in the example below.
148
+
146
149
  ## Examples
147
150
 
148
- #### Create and get a setting
151
+ ### Create and get a setting
149
152
 
150
153
  ```javascript
151
154
  const appConfig = require("@azure/app-configuration");
@@ -175,6 +178,81 @@ async function run() {
175
178
  run().catch((err) => console.log("ERROR:", err));
176
179
  ```
177
180
 
181
+ ### Create a snapshot
182
+
183
+ `beginCreateSnapshot` gives you the poller to poll for the snapshot creation.
184
+
185
+ ```javascript
186
+ const { AppConfigurationClient } = require("@azure/app-configuration");
187
+
188
+ const client = new AppConfigurationClient(
189
+ "<App Configuration connection string goes here>"
190
+ );
191
+
192
+ const key = "testkey";
193
+ const value = "testvalue";
194
+ const label = "optional-label";
195
+
196
+ await client.addConfigurationSetting({
197
+ key,
198
+ value,
199
+ label
200
+ });
201
+
202
+ const poller = await this.beginCreateSnapshot({
203
+ name:"testsnapshot",
204
+ retentionPeriod: 2592000,
205
+ filters: [{key, label}],
206
+ });
207
+ const snapshot = await poller.pollUntilDone();
208
+ ```
209
+
210
+ You can also use `beginCreateSnapshotAndWait` to have the result of the creation directly after the polling is done.
211
+ ```js
212
+ const snapshot = await client.beginCreateSnapshotAndWait({
213
+ name:"testsnapshot",
214
+ retentionPeriod: 2592000,
215
+ filters: [{key, label}],
216
+ });
217
+ ```
218
+
219
+ ### Get a snapshot
220
+
221
+ ```js
222
+ const retrievedSnapshot = await client.getSnapshot("testsnapshot");
223
+ console.log("Retrieved snapshot:", retrievedSnapshot);
224
+ ```
225
+
226
+ ### List the `ConfigurationSetting` in the snapshot
227
+ ```javascript
228
+ let retrievedSnapshotSettings = await client.listConfigurationSettings({
229
+ snapshotFilter: "testsnapshot"
230
+ });
231
+
232
+ for await (const setting of retrievedSnapshotSettings) {
233
+ console.log(`Found key: ${setting.key}, label: ${setting.label}`);
234
+ }
235
+ ```
236
+
237
+ ### List all snapshots from the service
238
+ ```javascript
239
+ let snapshots = await client.listSnapshots();
240
+
241
+ for await (const snapshot of snapshots) {
242
+ console.log(`Found snapshot: ${snapshot.name}`);
243
+ }
244
+ ```
245
+
246
+ ### Recover and archive the snapshot
247
+ ```javascript
248
+ // Snapshot is in ready status
249
+ let archivedSnapshot = await client.archiveSnapshot("testsnapshot");
250
+ console.log("Snapshot updated status is:", archivedSnapshot.status);
251
+
252
+ // Snapshot is in archive status
253
+ let recoverSnapshot = await client.recoverSnapshot("testsnapshot");
254
+ console.log("Snapshot updated status is:", recoverSnapshot.status);
255
+ ```
178
256
  ## Troubleshooting
179
257
 
180
258
  ### Logging