Set the setting to read-only with the key-label "prodDBConnection"-"westUS".
* - * {@codesnippet com.azure.data.applicationconfig.configurationclient.setReadOnlyWithResponse#ConfigurationSetting-boolean-Context} + * {@codesnippet com.azure.data.applicationconfig.configurationclient.setReadOnlyWithResponse#ConfigurationSetting-Boolean-Context} * *Clear read-only of the setting with the key-label "prodDBConnection"-"westUS".
* diff --git a/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/ConfigurationClientBuilder.java b/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/ConfigurationClientBuilder.java index df4d670d247e0..259c633c45073 100644 --- a/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/ConfigurationClientBuilder.java +++ b/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/ConfigurationClientBuilder.java @@ -22,6 +22,7 @@ import com.azure.core.http.policy.UserAgentPolicy; import com.azure.core.util.Configuration; import com.azure.core.util.CoreUtils; +import com.azure.core.util.UserAgentProperties; import com.azure.core.util.logging.ClientLogger; import com.azure.data.appconfiguration.implementation.ConfigurationClientCredentials; import com.azure.data.appconfiguration.implementation.ConfigurationCredentialsPolicy; @@ -34,7 +35,6 @@ import java.time.temporal.ChronoUnit; import java.util.ArrayList; import java.util.List; -import java.util.Map; import java.util.Objects; /** @@ -76,16 +76,14 @@ public final class ConfigurationClientBuilder { private static final String CONTENT_TYPE_HEADER_VALUE = "application/json"; private static final String ACCEPT_HEADER = "Accept"; private static final String ACCEPT_HEADER_VALUE = "application/vnd.microsoft.azconfig.kv+json"; + // This is properties file's name. private static final String APP_CONFIG_PROPERTIES = "azure-appconfig.properties"; - private static final String NAME = "name"; - private static final String VERSION = "version"; private static final RetryPolicy DEFAULT_RETRY_POLICY = new RetryPolicy("retry-after-ms", ChronoUnit.MILLIS); private final ClientLogger logger = new ClientLogger(ConfigurationClientBuilder.class); private final List+ * The default time-to-live value on a collection is an optional property. If set, the documents within the collection + * expires after the specified number of seconds since their last write time. The value of this property should be one of the following: + *
+ * null - indicates evaluation of time-to-live is disabled and documents within the collection will never expire, regardless whether + * individual documents have their time-to-live set. + *
+ * nonzero positive integer - indicates the default time-to-live value for all documents within the collection. This value can be overridden + * by individual documents' time-to-live value. + *
+ * -1 - indicates by default all documents within the collection never expire. This value can be overridden by individual documents'
+ * time-to-live value.
+ *
+ * @param timeToLive the default time-to-live value in seconds.
+ */
+ public void defaultTimeToLive(Integer timeToLive) {
+ // a "null" value is represented as a missing element on the wire.
+ // setting timeToLive to null should remove the property from the property bag.
+ if (timeToLive != null) {
+ super.set(Constants.Properties.DEFAULT_TTL, timeToLive);
+ } else if (super.has(Constants.Properties.DEFAULT_TTL)) {
+ super.remove(Constants.Properties.DEFAULT_TTL);
+ }
+ }
+
DocumentCollection getV2Collection(){
DocumentCollection collection = new DocumentCollection(this.toJson());
collection.setPartitionKey(this.partitionKeyDefinition());
diff --git a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/CosmosResponseValidator.java b/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/CosmosResponseValidator.java
index e0e0afe4d42b2..a9590fe1e0fba 100644
--- a/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/CosmosResponseValidator.java
+++ b/sdk/cosmos/microsoft-azure-cosmos/src/test/java/com/azure/data/cosmos/CosmosResponseValidator.java
@@ -86,6 +86,19 @@ public void validate(CosmosContainerResponse resourceResponse) {
return this;
}
+ public Builder
Set the setting to read-only with the key-label "prodDBConnection"-"westUS".
* - * {@codesnippet com.azure.data.applicationconfig.configurationclient.setReadOnlyWithResponse#ConfigurationSetting-Boolean-Context} + * {@codesnippet com.azure.data.applicationconfig.configurationclient.setReadOnlyWithResponse#ConfigurationSetting-boolean-Context} * *Clear read-only of the setting with the key-label "prodDBConnection"-"westUS".
* diff --git a/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/ConfigurationClientBuilder.java b/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/ConfigurationClientBuilder.java index 259c633c45073..df4d670d247e0 100644 --- a/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/ConfigurationClientBuilder.java +++ b/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/ConfigurationClientBuilder.java @@ -22,7 +22,6 @@ import com.azure.core.http.policy.UserAgentPolicy; import com.azure.core.util.Configuration; import com.azure.core.util.CoreUtils; -import com.azure.core.util.UserAgentProperties; import com.azure.core.util.logging.ClientLogger; import com.azure.data.appconfiguration.implementation.ConfigurationClientCredentials; import com.azure.data.appconfiguration.implementation.ConfigurationCredentialsPolicy; @@ -35,6 +34,7 @@ import java.time.temporal.ChronoUnit; import java.util.ArrayList; import java.util.List; +import java.util.Map; import java.util.Objects; /** @@ -76,14 +76,16 @@ public final class ConfigurationClientBuilder { private static final String CONTENT_TYPE_HEADER_VALUE = "application/json"; private static final String ACCEPT_HEADER = "Accept"; private static final String ACCEPT_HEADER_VALUE = "application/vnd.microsoft.azconfig.kv+json"; - // This is properties file's name. private static final String APP_CONFIG_PROPERTIES = "azure-appconfig.properties"; + private static final String NAME = "name"; + private static final String VERSION = "version"; private static final RetryPolicy DEFAULT_RETRY_POLICY = new RetryPolicy("retry-after-ms", ChronoUnit.MILLIS); private final ClientLogger logger = new ClientLogger(ConfigurationClientBuilder.class); private final List