Class ConfigurationAsyncClient

java.lang.Object
com.azure.data.appconfiguration.ConfigurationAsyncClient

public final class ConfigurationAsyncClient extends Object
This class provides a client that contains all the operations for ConfigurationSettings in Azure App Configuration Store. Operations allowed by the client are adding, retrieving, deleting, set read-only status ConfigurationSettings, and listing settings or revision of a setting based on a filter.

Instantiating an asynchronous Configuration Client

 ConfigurationAsyncClient configurationAsyncClient = new ConfigurationClientBuilder()
     .connectionString(connectionString)
     .buildAsyncClient();
 

View this for additional ways to construct the client.

See Also:
  • Method Details

    • addConfigurationSetting

      public Mono<ConfigurationSetting> addConfigurationSetting(String key, String label, String value)
      Adds a configuration value in the service if that key does not exist. The label is optional.

      Code Samples

      Add a setting with the key "prodDBConnection", label "westUS" and value "db_connection".

       client.addConfigurationSetting("prodDBConnection", "westUS", "db_connection")
           .subscribe(response -> System.out.printf("Key: %s, Label: %s, Value: %s",
               response.getKey(), response.getLabel(), response.getValue()));
       
      Parameters:
      key - The key of the configuration setting to add.
      label - The label of the configuration setting to add. If null no label will be used.
      value - The value associated with this configuration setting key.
      Returns:
      The ConfigurationSetting that was created, or null if a key collision occurs or the key is an invalid value (which will also throw HttpResponseException described below).
      Throws:
      IllegalArgumentException - If key is null.
      ResourceModifiedException - If a ConfigurationSetting with the same key exists.
      HttpResponseException - If key is an empty string.
    • addConfigurationSetting

      public Mono<ConfigurationSetting> addConfigurationSetting(ConfigurationSetting setting)
      Adds a configuration value in the service if that key and label does not exist. The label value of the ConfigurationSetting is optional. For more configuration setting types, see FeatureFlagConfigurationSetting and SecretReferenceConfigurationSetting.

      Code Samples

      Add a setting with the key "prodDBConnection", label "westUS", and value "db_connection".

       client.addConfigurationSetting(
           new ConfigurationSetting().setKey("prodDBConnection").setLabel("westUS").setValue("db_connection"))
           .subscribe(response -> System.out.printf("Key: %s, Label: %s, Value: %s",
               response.getKey(), response.getLabel(), response.getValue()));
       
      Parameters:
      setting - The setting to add based on its key and optional label combination.
      Returns:
      The ConfigurationSetting that was created, or null if a key collision occurs or the key is an invalid value (which will also throw HttpResponseException described below).
      Throws:
      NullPointerException - If setting is null.
      IllegalArgumentException - If key is null.
      ResourceModifiedException - If a ConfigurationSetting with the same key and label exists.
      HttpResponseException - If key is an empty string.
    • addConfigurationSettingWithResponse

      public Mono<Response<ConfigurationSetting>> addConfigurationSettingWithResponse(ConfigurationSetting setting)
      Adds a configuration value in the service if that key and label does not exist. The label value of the ConfigurationSetting is optional. For more configuration setting types, see FeatureFlagConfigurationSetting and SecretReferenceConfigurationSetting.

      Code Samples

      Add a setting with the key "prodDBConnection", label "westUS", and value "db_connection".

       client.addConfigurationSettingWithResponse(
           new ConfigurationSetting().setKey("prodDBConnection").setLabel("westUS").setValue("db_connection"))
           .subscribe(response -> {
               ConfigurationSetting responseSetting = response.getValue();
               System.out.printf("Key: %s, Label: %s, Value: %s",
                   responseSetting.getKey(), responseSetting.getLabel(), responseSetting.getValue());
           });
       
      Parameters:
      setting - The setting to add based on its key and optional label combination.
      Returns:
      A REST response containing the ConfigurationSetting that was created, if a key collision occurs or the key is an invalid value (which will also throw HttpResponseException described below).
      Throws:
      NullPointerException - If setting is null.
      IllegalArgumentException - If key is null.
      ResourceModifiedException - If a ConfigurationSetting with the same key and label exists.
      HttpResponseException - If key is an empty string.
    • setConfigurationSetting

      public Mono<ConfigurationSetting> setConfigurationSetting(String key, String label, String value)
      Creates or updates a configuration value in the service with the given key. the label is optional.

      Code Samples

      Add a setting with the key "prodDBConnection", "westUS" and value "db_connection"

      Update setting's value "db_connection" to "updated_db_connection"

       client.setConfigurationSetting("prodDBConnection", "westUS", "db_connection")
           .subscribe(response -> System.out.printf("Key: %s, Label: %s, Value: %s",
               response.getKey(), response.getLabel(), response.getValue()));
       // Update the value of the setting to "updated_db_connection"
       client.setConfigurationSetting("prodDBConnection", "westUS", "updated_db_connection")
           .subscribe(response -> System.out.printf("Key: %s, Label: %s, Value: %s",
               response.getKey(), response.getLabel(), response.getValue()));
       
      Parameters:
      key - The key of the configuration setting to create or update.
      label - The label of the configuration setting to create or update, If null no label will be used.
      value - The value of this configuration setting.
      Returns:
      The ConfigurationSetting that was created or updated, or an empty Mono if the key is an invalid value (which will also throw HttpResponseException described below).
      Throws:
      IllegalArgumentException - If key is null.
      ResourceModifiedException - If the setting exists and is read-only.
      HttpResponseException - If key is an empty string.
    • setConfigurationSetting

      public Mono<ConfigurationSetting> setConfigurationSetting(ConfigurationSetting setting)
      Creates or updates a configuration value in the service. Partial updates are not supported and the entire configuration setting is updated. For more configuration setting types, see FeatureFlagConfigurationSetting and SecretReferenceConfigurationSetting.

      Code Samples

      Add a setting with the key "prodDBConnection", "westUS" and value "db_connection"

      Update setting's value "db_connection" to "updated_db_connection"

       client.setConfigurationSetting(new ConfigurationSetting().setKey("prodDBConnection").setLabel("westUS"))
           .subscribe(response -> System.out.printf("Key: %s, Label: %s, Value: %s",
               response.getKey(), response.getLabel(), response.getValue()));
       // Update the value of the setting to "updated_db_connection"
       client.setConfigurationSetting(
           new ConfigurationSetting().setKey("prodDBConnection").setLabel("westUS").setValue("updated_db_connection"))
           .subscribe(response -> System.out.printf("Key: %s, Label: %s, Value: %s",
               response.getKey(), response.getLabel(), response.getValue()));
       
      Parameters:
      setting - The setting to add based on its key and optional label combination.
      Returns:
      The ConfigurationSetting that was created or updated, or an empty Mono if the key is an invalid value (which will also throw HttpResponseException described below).
      Throws:
      NullPointerException - If setting is null.
      IllegalArgumentException - If key is null.
      ResourceModifiedException - If the setting exists and is read-only.
      HttpResponseException - If key is an empty string.
    • setConfigurationSettingWithResponse

      public Mono<Response<ConfigurationSetting>> setConfigurationSettingWithResponse(ConfigurationSetting setting, boolean ifUnchanged)
      Creates or updates a configuration value in the service. Partial updates are not supported and the entire configuration setting is updated. For more configuration setting types, see FeatureFlagConfigurationSetting and SecretReferenceConfigurationSetting. If ETag is specified, the configuration value is updated if the current setting's ETag matches. If the ETag's value is equal to the wildcard character ("*"), the setting will always be updated.

      Code Samples

      Add a setting with the key "prodDBConnection", label "westUS", and value "db_connection".

      Update setting's value "db_connection" to "updated_db_connection"

       client.setConfigurationSettingWithResponse(new ConfigurationSetting().setKey("prodDBConnection").setLabel("westUS")
           .setValue("db_connection"), false)
           .subscribe(response -> {
               final ConfigurationSetting result = response.getValue();
               System.out.printf("Key: %s, Label: %s, Value: %s",
                   result.getKey(), result.getLabel(), result.getValue());
           });
       // Update the value of the setting to "updated_db_connection"
       client.setConfigurationSettingWithResponse(new ConfigurationSetting().setKey("prodDBConnection").setLabel("westUS")
           .setValue("updated_db_connection"), false)
           .subscribe(response -> {
               final ConfigurationSetting responseSetting = response.getValue();
               System.out.printf("Key: %s, Label: %s, Value: %s",
                   responseSetting.getKey(), responseSetting.getLabel(), responseSetting.getValue());
           });
       
      Parameters:
      setting - The setting to create or update based on its key, optional label and optional ETag combination.
      ifUnchanged - Flag indicating if the setting ETag is used as a IF-MATCH header.
      Returns:
      A REST response containing the ConfigurationSetting that was created or updated, if the key is an invalid value, the setting is read-only, or an ETag was provided but does not match the service's current ETag value (which will also throw HttpResponseException described below).
      Throws:
      NullPointerException - If setting is null.
      IllegalArgumentException - If key is null.
      ResourceModifiedException - If the ETag was specified, is not the wildcard character, and the current configuration value's ETag does not match, or the setting exists and is read-only.
      HttpResponseException - If key is an empty string.
    • getConfigurationSetting

      public Mono<ConfigurationSetting> getConfigurationSetting(String key, String label)
      Attempts to get a ConfigurationSetting that matches the key, and the optional label combination.

      Code Samples

      Retrieve the setting with the key "prodDBConnection".

       client.getConfigurationSetting("prodDBConnection", null)
           .subscribe(response -> System.out.printf("Key: %s, Label: %s, Value: %s",
               response.getKey(), response.getLabel(), response.getValue()));
       
      Parameters:
      key - The key of the setting to retrieve.
      label - The label of the configuration setting to retrieve. If null no label will be used.
      Returns:
      The ConfigurationSetting stored in the service, or an empty Mono if the configuration value does not exist or the key is an invalid value (which will also throw HttpResponseException described below).
      Throws:
      IllegalArgumentException - If key is null.
      ResourceNotFoundException - If a ConfigurationSetting with key does not exist.
      HttpResponseException - If key is an empty string.
    • getConfigurationSetting

      public Mono<ConfigurationSetting> getConfigurationSetting(String key, String label, OffsetDateTime acceptDateTime)
      Attempts to get a ConfigurationSetting that matches the key, the optional label, and the optional acceptDateTime combination.

      Code Samples

      Retrieve the setting with the key "prodDBConnection" and a time that one minute before now at UTC-Zone

       client.getConfigurationSetting(
           "prodDBConnection", null, OffsetDateTime.now(ZoneOffset.UTC).minusMinutes(1))
           .subscribe(response -> System.out.printf("Key: %s, Label: %s, Value: %s",
               response.getKey(), response.getLabel(), response.getValue()));
       
      Parameters:
      key - The key of the setting to retrieve.
      label - The label of the configuration setting to retrieve. If null no label will be used.
      acceptDateTime - Datetime to access a past state of the configuration setting. If null then the current state of the configuration setting will be returned.
      Returns:
      The ConfigurationSetting stored in the service, or an empty Mono if the configuration value does not exist or the key is an invalid value (which will also throw HttpResponseException described below).
      Throws:
      IllegalArgumentException - If key is null.
      ResourceNotFoundException - If a ConfigurationSetting with key does not exist.
      HttpResponseException - If key is an empty string.
    • getConfigurationSetting

      public Mono<ConfigurationSetting> getConfigurationSetting(ConfigurationSetting setting)
      Attempts to get the ConfigurationSetting with a matching key, and optional label, optional acceptDateTime and optional ETag combination. For more configuration setting types, see FeatureFlagConfigurationSetting and SecretReferenceConfigurationSetting.

      Code Samples

      Retrieve the setting with the key "prodDBConnection" and a time that one minute before now at UTC-Zone

       client.getConfigurationSetting(new ConfigurationSetting().setKey("prodDBConnection").setLabel("westUS"))
           .subscribe(response -> System.out.printf("Key: %s, Label: %s, Value: %s",
               response.getKey(), response.getLabel(), response.getValue()));
       
      Parameters:
      setting - The setting to retrieve.
      Returns:
      The ConfigurationSetting stored in the service, or an empty Mono if the configuration value does not exist or the key is an invalid value (which will also throw HttpResponseException described below).
      Throws:
      NullPointerException - If setting is null.
      IllegalArgumentException - If key is null.
      ResourceNotFoundException - If a ConfigurationSetting with the same key and label does not exist.
      HttpResponseException - If the key is an empty string.
    • getConfigurationSettingWithResponse

      public Mono<Response<ConfigurationSetting>> getConfigurationSettingWithResponse(ConfigurationSetting setting, OffsetDateTime acceptDateTime, boolean ifChanged)
      Attempts to get the ConfigurationSetting with a matching key, and optional label, optional acceptDateTime and optional ETag combination. For more configuration setting types, see FeatureFlagConfigurationSetting and SecretReferenceConfigurationSetting.

      Code Samples

      Retrieve the setting with the key-label "prodDBConnection"-"westUS".

       client.getConfigurationSettingWithResponse(
           new ConfigurationSetting().setKey("prodDBConnection").setLabel("westUS"), null, false)
           .contextWrite(Context.of(key1, value1, key2, value2))
           .subscribe(response -> {
               final ConfigurationSetting result = response.getValue();
               System.out.printf("Key: %s, Label: %s, Value: %s",
                   result.getKey(), result.getLabel(), result.getValue());
           });
       
      Parameters:
      setting - The setting to retrieve.
      acceptDateTime - Datetime to access a past state of the configuration setting. If null then the current state of the configuration setting will be returned.
      ifChanged - Flag indicating if the setting ETag is used as a If-None-Match header.
      Returns:
      A REST response containing the ConfigurationSetting stored in the service, or null if didn't exist. null is also returned if the configuration value does not exist or the key is an invalid value (which will also throw HttpResponseException described below).
      Throws:
      NullPointerException - If setting is null.
      IllegalArgumentException - If key is null.
      ResourceNotFoundException - If a ConfigurationSetting with the same key and label does not exist.
      HttpResponseException - If the key is an empty string.
    • deleteConfigurationSetting

      public Mono<ConfigurationSetting> deleteConfigurationSetting(String key, String label)
      Deletes the ConfigurationSetting with a matching key and optional label combination.

      Code Samples

      Delete the setting with the key "prodDBConnection".

       client.deleteConfigurationSetting("prodDBConnection", null)
           .subscribe(response -> System.out.printf("Key: %s, Label: %s, Value: %s",
               response.getKey(), response.getLabel(), response.getValue()));
       
      Parameters:
      key - The key of configuration setting to delete.
      label - The label of configuration setting to delete. If null no label will be used.
      Returns:
      The deleted ConfigurationSetting or an empty Mono is also returned if the key is an invalid value (which will also throw HttpResponseException described below).
      Throws:
      IllegalArgumentException - If key is null.
      ResourceModifiedException - If setting is read-only.
      HttpResponseException - If key is an empty string.
    • deleteConfigurationSetting

      public Mono<ConfigurationSetting> deleteConfigurationSetting(ConfigurationSetting setting)
      Deletes the ConfigurationSetting with a matching key, and optional label and optional ETag combination from the service. For more configuration setting types, see FeatureFlagConfigurationSetting and SecretReferenceConfigurationSetting. If ETag is specified and is not the wildcard character ("*"), then the setting is only deleted if the ETag matches the current ETag; this means that no one has updated the ConfigurationSetting yet.

      Code Samples

      Delete the setting with the key "prodDBConnection".

       client.deleteConfigurationSetting(new ConfigurationSetting().setKey("prodDBConnection"))
           .subscribe(response -> System.out.printf("Key: %s, Label: %s, Value: %s",
               response.getKey(), response.getValue()));
       
      Parameters:
      setting - The setting to delete based on its key, optional label and optional ETag combination.
      Returns:
      The deleted ConfigurationSetting or an empty Mono is also returned if the key is an invalid value (which will also throw HttpResponseException described below).
      Throws:
      IllegalArgumentException - If key is null.
      NullPointerException - When setting is null.
      ResourceModifiedException - If setting is read-only.
      ResourceNotFoundException - If ETag is specified, not the wildcard character, and does not match the current ETag value.
      HttpResponseException - If key is an empty string.
    • deleteConfigurationSettingWithResponse

      public Mono<Response<ConfigurationSetting>> deleteConfigurationSettingWithResponse(ConfigurationSetting setting, boolean ifUnchanged)
      Deletes the ConfigurationSetting with a matching key, and optional label and optional ETag combination from the service. For more configuration setting types, see FeatureFlagConfigurationSetting and SecretReferenceConfigurationSetting. If ETag is specified and is not the wildcard character ("*"), then the setting is only deleted if the ETag matches the current ETag; this means that no one has updated the ConfigurationSetting yet.

      Code Samples

      Delete the setting with the key-label "prodDBConnection"-"westUS"

       client.deleteConfigurationSettingWithResponse(
           new ConfigurationSetting().setKey("prodDBConnection").setLabel("westUS"), false)
           .contextWrite(Context.of(key1, value1, key2, value2))
           .subscribe(response -> {
               final ConfigurationSetting responseSetting = response.getValue();
               System.out.printf("Key: %s, Label: %s, Value: %s",
                   responseSetting.getKey(), responseSetting.getLabel(), responseSetting.getValue());
           });
       
      Parameters:
      setting - The setting to delete based on its key, optional label and optional ETag combination.
      ifUnchanged - Flag indicating if the setting ETag is used as a IF-MATCH header.
      Returns:
      A REST response containing the deleted ConfigurationSetting or null if didn't exist. null is also returned if the key is an invalid value or ETag is set but does not match the current ETag (which will also throw HttpResponseException described below).
      Throws:
      IllegalArgumentException - If key is null.
      NullPointerException - When setting is null.
      ResourceModifiedException - If setting is read-only.
      ResourceNotFoundException - If ETag is specified, not the wildcard character, and does not match the current ETag value.
      HttpResponseException - If key is an empty string.
    • setReadOnly

      public Mono<ConfigurationSetting> setReadOnly(String key, String label, boolean isReadOnly)
      Sets the read-only status for the ConfigurationSetting that matches the key, the optional label.

      Code Samples

      Set the setting to read-only with the key-label "prodDBConnection"-"westUS".

       client.setReadOnly("prodDBConnection", "westUS", true)
           .subscribe(response -> System.out.printf("Key: %s, Label: %s, Value: %s",
               response.getKey(), response.getLabel(), response.getValue()));
       

      Clear read-only of the setting with the key-label "prodDBConnection"-"westUS".

       client.setReadOnly("prodDBConnection", "westUS", false)
           .contextWrite(Context.of(key1, value1, key2, value2))
           .subscribe(response -> System.out.printf("Key: %s, Value: %s", response.getKey(), response.getValue()));
       
      Parameters:
      key - The key of configuration setting to set to be read-only.
      label - The label of configuration setting to read-only. If null no label will be used.
      isReadOnly - Flag used to set the read-only status of the configuration. true will put the configuration into a read-only state, false will clear the state.
      Returns:
      The ConfigurationSetting that is read-only, or an empty Mono if a key collision occurs or the key is an invalid value (which will also throw HttpResponseException described below).
      Throws:
      IllegalArgumentException - If key is null.
      HttpResponseException - If key is an empty string.
    • setReadOnly

      public Mono<ConfigurationSetting> setReadOnly(ConfigurationSetting setting, boolean isReadOnly)
      Sets the read-only status for the ConfigurationSetting. For more configuration setting types, see FeatureFlagConfigurationSetting and SecretReferenceConfigurationSetting.

      Code Samples

      Set the setting to read-only with the key-label "prodDBConnection"-"westUS".

       client.setReadOnly(new ConfigurationSetting().setKey("prodDBConnection").setLabel("westUS"), true)
           .subscribe(response -> System.out.printf("Key: %s, Label: %s, Value: %s",
               response.getKey(), response.getLabel(), response.getValue()));
       

      Clear read-only of the setting with the key-label "prodDBConnection"-"westUS".

       client.setReadOnly(new ConfigurationSetting().setKey("prodDBConnection").setLabel("westUS"), false)
           .subscribe(response -> System.out.printf("Key: %s, Value: %s", response.getKey(), response.getValue()));
       
      Parameters:
      setting - The configuration setting to set to read-only or not read-only based on the isReadOnly.
      isReadOnly - Flag used to set the read-only status of the configuration. true will put the configuration into a read-only state, false will clear the state.
      Returns:
      The ConfigurationSetting that is read-only, or an empty Mono if a key collision occurs or the key is an invalid value (which will also throw HttpResponseException described below).
      Throws:
      IllegalArgumentException - If key is null.
      HttpResponseException - If key is an empty string.
    • setReadOnlyWithResponse

      public Mono<Response<ConfigurationSetting>> setReadOnlyWithResponse(ConfigurationSetting setting, boolean isReadOnly)
      Sets the read-only status for the ConfigurationSetting. For more configuration setting types, see FeatureFlagConfigurationSetting and SecretReferenceConfigurationSetting.

      Code Samples

      Set the setting to read-only with the key-label "prodDBConnection"-"westUS".

       client.setReadOnlyWithResponse(new ConfigurationSetting().setKey("prodDBConnection").setLabel("westUS"), true)
           .subscribe(response -> {
               final ConfigurationSetting result = response.getValue();
               System.out.printf("Key: %s, Label: %s, Value: %s",
                   result.getKey(), result.getLabel(), result.getValue());
           });
       

      Clear read-only of the setting with the key-label "prodDBConnection"-"westUS".

       client.setReadOnlyWithResponse(new ConfigurationSetting().setKey("prodDBConnection").setLabel("westUS"), false)
           .contextWrite(Context.of(key1, value1, key2, value2))
           .subscribe(response -> {
               ConfigurationSetting result = response.getValue();
               System.out.printf("Key: %s, Value: %s", result.getKey(), result.getValue());
           });
       
      Parameters:
      setting - The configuration setting to set to read-only or not read-only based on the isReadOnly.
      isReadOnly - Flag used to set the read-only status of the configuration. true will put the configuration into a read-only state, false will clear the state.
      Returns:
      A REST response containing the read-only or not read-only ConfigurationSetting if isReadOnly is true or null, or false respectively. Or return null if the setting didn't exist. null is also returned if the key is an invalid value. (which will also throw HttpResponseException described below).
      Throws:
      IllegalArgumentException - If key is null.
      HttpResponseException - If key is an empty string.
    • listConfigurationSettings

      public PagedFlux<ConfigurationSetting> listConfigurationSettings(SettingSelector selector)
      Fetches the configuration settings that match the selector. If selector is null, then all the configuration settings are fetched with their current values.

      Code Samples

      Retrieve all settings that use the key "prodDBConnection".

       client.listConfigurationSettings(new SettingSelector().setKeyFilter("prodDBConnection"))
           .contextWrite(Context.of(key1, value1, key2, value2))
           .subscribe(setting ->
               System.out.printf("Key: %s, Value: %s", setting.getKey(), setting.getValue()));
       
      Parameters:
      selector - Optional. Selector to filter configuration setting results from the service.
      Returns:
      A Flux of ConfigurationSettings that matches the selector. If no options were provided, the Flux contains all of the current settings in the service.
      Throws:
      HttpResponseException - If a client or service error occurs, such as a 404, 409, 429 or 500.
    • listRevisions

      public PagedFlux<ConfigurationSetting> listRevisions(SettingSelector selector)
      Lists chronological/historical representation of ConfigurationSetting resource(s). Revisions are provided in descending order from their lastModified date. Revisions expire after a period of time, see Pricing for more information. If selector is null, then all the ConfigurationSettings are fetched in their current state. Otherwise, the results returned match the parameters given in selector.

      Code Samples

      Retrieve all revisions of the setting that has the key "prodDBConnection".

       client.listRevisions(new SettingSelector().setKeyFilter("prodDBConnection"))
           .contextWrite(Context.of(key1, value1, key2, value2))
           .subscribe(setting ->
               System.out.printf("Key: %s, Value: %s", setting.getKey(), setting.getValue()));
       
      Parameters:
      selector - Optional. Used to filter configuration setting revisions from the service.
      Returns:
      Revisions of the ConfigurationSetting
      Throws:
      HttpResponseException - If a client or service error occurs, such as a 404, 409, 429 or 500.
    • updateSyncToken

      public void updateSyncToken(String token)
      Adds an external synchronization token to ensure service requests receive up-to-date values.
      Parameters:
      token - an external synchronization token to ensure service requests receive up-to-date values.
      Throws:
      NullPointerException - if the given token is null.