diff --git a/eng/versioning/external_dependencies.txt b/eng/versioning/external_dependencies.txt index a921d3da23804..616f212a45a97 100644 --- a/eng/versioning/external_dependencies.txt +++ b/eng/versioning/external_dependencies.txt @@ -208,4 +208,4 @@ media_com.microsoft.azure:adal4j;1.2.0 servicebus_com.microsoft.azure:azure-client-authentication;1.6.7 # sdk\storage\azure-storage-blob-cryptography\pom.xml -storage_com.microsoft.azure:azure-storage;8.4.0 +storage_com.microsoft.azure:azure-storage;8.4.0 \ No newline at end of file diff --git a/eng/versioning/version_client_java_files.txt b/eng/versioning/version_client_java_files.txt index 9f2721aa11bad..b59b8ee005c97 100644 --- a/eng/versioning/version_client_java_files.txt +++ b/eng/versioning/version_client_java_files.txt @@ -4,3 +4,12 @@ # The file format here should be the relative path from the root of the azure-sdk-for-java sdk/core/azure-core-amqp/src/main/java/com/azure/core/amqp/implementation/ClientConstants.java +sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/AzureKeyVaultConfiguration.java +sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/AzureKeyVaultConfiguration.java +sdk/keyvault/azure-security-keyvault-secrets/src/main/java/com/azure/security/keyvault/secrets/AzureKeyVaultConfiguration.java +sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/util/BuilderHelper.java +sdk/storage/azure-storage-blob-cryptography/src/main/java/com/azure/storage/blob/specialized/cryptography/BlobCryptographyConfiguration.java +sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/util/BuilderHelper.java +sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/FileConfiguration.java +sdk/storage/azure-storage-queue/src/main/java/com/azure/storage/queue/implementation/util/BuilderHelper.java +sdk/storage/azure-storage-queue/src/main/java/com/azure/storage/queue/QueueConfiguration.java diff --git a/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/ConfigurationClient.java b/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/ConfigurationClient.java index cc68fd2e2aa27..d3a3a8b58bbfb 100644 --- a/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/ConfigurationClient.java +++ b/sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/ConfigurationClient.java @@ -334,7 +334,7 @@ public ConfigurationSetting setReadOnly(String key, String label, boolean isRead * *

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 policies; private final HttpHeaders headers; - private final UserAgentProperties properties; + private final String clientName; + private final String clientVersion; private ConfigurationClientCredentials credential; private TokenCredential tokenCredential; @@ -103,7 +105,9 @@ public ConfigurationClientBuilder() { policies = new ArrayList<>(); httpLogOptions = new HttpLogOptions(); - properties = CoreUtils.getUserAgentProperties(APP_CONFIG_PROPERTIES); + Map properties = CoreUtils.getProperties(APP_CONFIG_PROPERTIES); + clientName = properties.getOrDefault(NAME, "UnknownName"); + clientVersion = properties.getOrDefault(VERSION, "UnknownVersion"); headers = new HttpHeaders() .put(ECHO_REQUEST_ID_HEADER, "true") @@ -171,8 +175,8 @@ public ConfigurationAsyncClient buildAsyncClient() { // Closest to API goes first, closest to wire goes last. final List policies = new ArrayList<>(); - policies.add(new UserAgentPolicy(httpLogOptions.getApplicationId(), properties.getName(), - properties.getVersion(), buildConfiguration)); + policies.add(new UserAgentPolicy(httpLogOptions.getApplicationId(), clientName, clientVersion, + buildConfiguration)); policies.add(new RequestIdPolicy()); policies.add(new AddHeadersPolicy(headers)); policies.add(new AddDatePolicy()); diff --git a/sdk/core/azure-core/src/main/java/com/azure/core/util/CoreUtils.java b/sdk/core/azure-core/src/main/java/com/azure/core/util/CoreUtils.java index 7931bca141018..b9b34cdd8be9a 100644 --- a/sdk/core/azure-core/src/main/java/com/azure/core/util/CoreUtils.java +++ b/sdk/core/azure-core/src/main/java/com/azure/core/util/CoreUtils.java @@ -24,10 +24,6 @@ */ public final class CoreUtils { private static final String COMMA = ","; - private static final String NAME = "name"; - private static final String VERSION = "version"; - private static final String UNKNOWN_NAME = "UnknownName"; - private static final String UNKNOWN_VERSION = "UnknownVersion"; private CoreUtils() { // Exists only to defeat instantiation. @@ -165,19 +161,6 @@ public static Publisher extractAndFetch(PagedResponse page, Context co } - /** - * Helper method that returns {@link UserAgentProperties} from properties defined in {@code propertiesFileName}. - * - * @param propertiesFileName The file name defining the properties. - * @return {@link UserAgentProperties}. - */ - public static UserAgentProperties getUserAgentProperties(String propertiesFileName) { - Map propertyMap = getProperties(propertiesFileName); - String name = propertyMap.getOrDefault(NAME, UNKNOWN_NAME); - String version = propertyMap.getOrDefault(VERSION, UNKNOWN_VERSION); - return new UserAgentProperties(name, version); - } - /** * Helper method that returns an immutable {@link Map} of properties defined in {@code propertiesFileName}. * diff --git a/sdk/core/azure-core/src/test/java/com/azure/core/util/CoreUtilsTests.java b/sdk/core/azure-core/src/test/java/com/azure/core/util/CoreUtilsTests.java index 9842599eb15a6..ca1052fae5fa6 100644 --- a/sdk/core/azure-core/src/test/java/com/azure/core/util/CoreUtilsTests.java +++ b/sdk/core/azure-core/src/test/java/com/azure/core/util/CoreUtilsTests.java @@ -3,7 +3,7 @@ package com.azure.core.util; -import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -40,18 +40,16 @@ public void findFirstOfTypeWithNoneOfType() { @Test public void testProperties() { - UserAgentProperties properties = - CoreUtils.getUserAgentProperties("azure-core.properties"); - assertFalse(properties.getName().matches("UnknownName")); - assertTrue(CoreUtils.getUserAgentProperties("azure-core.properties").getVersion() + assertNotNull(CoreUtils.getProperties("azure-core.properties").get("version")); + assertNotNull(CoreUtils.getProperties("azure-core.properties").get("name")); + assertTrue(CoreUtils.getProperties("azure-core.properties").get("version") .matches("\\d.\\d.\\d([-a-zA-Z0-9.])*")); } @Test public void testMissingProperties() { - assertTrue(CoreUtils.getUserAgentProperties("foo.properties") - .getVersion().matches("UnknownVersion")); - assertTrue(CoreUtils.getUserAgentProperties("foo.properties") - .getName().matches("UnknownName")); + assertNotNull(CoreUtils.getProperties("foo.properties")); + assertTrue(CoreUtils.getProperties("foo.properties").isEmpty()); + assertNull(CoreUtils.getProperties("azure-core.properties").get("foo")); } } diff --git a/sdk/eventhubs/azure-messaging-eventhubs/src/main/resources/azure-messaging-eventhubs.properties b/sdk/eventhubs/azure-messaging-eventhubs/src/main/resources/azure-messaging-eventhubs.properties deleted file mode 100644 index ca812989b4f27..0000000000000 --- a/sdk/eventhubs/azure-messaging-eventhubs/src/main/resources/azure-messaging-eventhubs.properties +++ /dev/null @@ -1,2 +0,0 @@ -name=${project.artifactId} -version=${project.version} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/AzureKeyVaultConfiguration.java b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/AzureKeyVaultConfiguration.java new file mode 100644 index 0000000000000..802163cc7f086 --- /dev/null +++ b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/AzureKeyVaultConfiguration.java @@ -0,0 +1,12 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.security.keyvault.certificates; + +class AzureKeyVaultConfiguration { + //TODO: Eventually remove these hardcoded strings with https://github.com/Azure/azure-sdk-for-java/issues/3141 + static final String SDK_NAME = "Azure-Keyvault"; + // {x-version-update-start;com.azure:azure-security-keyvault-certificates;current} + static final String SDK_VERSION = "4.0.0-beta.6"; + // {x-version-update-end} +} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/CertificateClientBuilder.java b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/CertificateClientBuilder.java index ce34e7c254352..8fbc0583e74e6 100644 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/CertificateClientBuilder.java +++ b/sdk/keyvault/azure-security-keyvault-certificates/src/main/java/com/azure/security/keyvault/certificates/CertificateClientBuilder.java @@ -17,7 +17,6 @@ import com.azure.core.http.policy.UserAgentPolicy; import com.azure.core.util.CoreUtils; import com.azure.core.util.Configuration; -import com.azure.core.util.UserAgentProperties; import com.azure.core.util.logging.ClientLogger; import com.azure.security.keyvault.certificates.implementation.KeyVaultCredentialPolicy; @@ -58,10 +57,8 @@ @ServiceClientBuilder(serviceClients = {CertificateClient.class, CertificateAsyncClient.class}) public final class CertificateClientBuilder { private final ClientLogger logger = new ClientLogger(CertificateClientBuilder.class); - // This is properties file's name. - private static final String AZURE_KEY_VAULT_CERTIFICATES_PROPERTIES = "azure-key-vault-certificates.properties"; + private final List policies; - private final UserAgentProperties properties; private TokenCredential credential; private HttpPipeline pipeline; private URL vaultUrl; @@ -78,7 +75,6 @@ public CertificateClientBuilder() { retryPolicy = new RetryPolicy(); httpLogOptions = new HttpLogOptions(); policies = new ArrayList<>(); - properties = CoreUtils.getUserAgentProperties(AZURE_KEY_VAULT_CERTIFICATES_PROPERTIES); } /** @@ -114,13 +110,11 @@ public CertificateClient buildClient() { * {@link CertificateClientBuilder#vaultUrl(String)} have not been set. */ public CertificateAsyncClient buildAsyncClient() { - Configuration buildConfiguration = (configuration == null) ? Configuration.getGlobalConfiguration().clone() - : configuration; + Configuration buildConfiguration = (configuration == null) ? Configuration.getGlobalConfiguration().clone() : configuration; URL buildEndpoint = getBuildEndpoint(buildConfiguration); if (buildEndpoint == null) { - throw logger.logExceptionAsError(new IllegalStateException( - KeyVaultErrorCodeStrings.getErrorString(KeyVaultErrorCodeStrings.VAULT_END_POINT_REQUIRED))); + throw logger.logExceptionAsError(new IllegalStateException(KeyVaultErrorCodeStrings.getErrorString(KeyVaultErrorCodeStrings.VAULT_END_POINT_REQUIRED))); } CertificateServiceVersion serviceVersion = version != null ? version : CertificateServiceVersion.getLatest(); @@ -129,14 +123,12 @@ public CertificateAsyncClient buildAsyncClient() { } if (credential == null) { - throw logger.logExceptionAsError(new IllegalStateException( - KeyVaultErrorCodeStrings.getErrorString(KeyVaultErrorCodeStrings.CREDENTIALS_REQUIRED))); + throw logger.logExceptionAsError(new IllegalStateException(KeyVaultErrorCodeStrings.getErrorString(KeyVaultErrorCodeStrings.CREDENTIALS_REQUIRED))); } // Closest to API goes first, closest to wire goes last. final List policies = new ArrayList<>(); - policies.add(new UserAgentPolicy(httpLogOptions.getApplicationId(), properties.getName(), - properties.getVersion(), buildConfiguration)); + policies.add(new UserAgentPolicy(httpLogOptions.getApplicationId(), AzureKeyVaultConfiguration.SDK_NAME, AzureKeyVaultConfiguration.SDK_VERSION, buildConfiguration)); HttpPolicyProviders.addBeforeRetryPolicies(policies); policies.add(retryPolicy); policies.add(new KeyVaultCredentialPolicy(credential)); diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/resources/azure-key-vault-certificates.properties b/sdk/keyvault/azure-security-keyvault-certificates/src/main/resources/azure-key-vault-certificates.properties deleted file mode 100644 index ca812989b4f27..0000000000000 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/resources/azure-key-vault-certificates.properties +++ /dev/null @@ -1,2 +0,0 @@ -name=${project.artifactId} -version=${project.version} diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/main/resources/kvErrorStrings.properties b/sdk/keyvault/azure-security-keyvault-certificates/src/main/resources/kvErrorStrings.properties index df9cd43cfcc12..ffced4746fc3a 100644 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/main/resources/kvErrorStrings.properties +++ b/sdk/keyvault/azure-security-keyvault-certificates/src/main/resources/kvErrorStrings.properties @@ -1,3 +1,2 @@ credentials_required=Azure Key Vault credentials are required. vault_endpoint_required=Azure Key Vault endpoint url is required. - diff --git a/sdk/keyvault/azure-security-keyvault-certificates/src/test/java/com/azure/security/keyvault/certificates/CertificateClientTestBase.java b/sdk/keyvault/azure-security-keyvault-certificates/src/test/java/com/azure/security/keyvault/certificates/CertificateClientTestBase.java index f7003dbf352eb..f7d2d5be365e4 100644 --- a/sdk/keyvault/azure-security-keyvault-certificates/src/test/java/com/azure/security/keyvault/certificates/CertificateClientTestBase.java +++ b/sdk/keyvault/azure-security-keyvault-certificates/src/test/java/com/azure/security/keyvault/certificates/CertificateClientTestBase.java @@ -57,8 +57,6 @@ import static org.junit.jupiter.api.Assertions.fail; public abstract class CertificateClientTestBase extends TestBase { - private static final String SDK_NAME = "client_name"; - private static final String SDK_VERSION = "client_version"; @Override protected String getTestName() { @@ -82,7 +80,7 @@ T clientSetup(Function clientBuilder) { HttpClient httpClient; // Closest to API goes first, closest to wire goes last. final List policies = new ArrayList<>(); - policies.add(new UserAgentPolicy(SDK_NAME, SDK_VERSION, + policies.add(new UserAgentPolicy(AzureKeyVaultConfiguration.SDK_NAME, AzureKeyVaultConfiguration.SDK_VERSION, Configuration.getGlobalConfiguration().clone(), CertificateServiceVersion.getLatest())); HttpPolicyProviders.addBeforeRetryPolicies(policies); policies.add(new RetryPolicy()); diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/KeyClientBuilder.java b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/KeyClientBuilder.java index dc2c90c778786..986fe3c7d0c33 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/KeyClientBuilder.java +++ b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/KeyClientBuilder.java @@ -17,8 +17,8 @@ import com.azure.core.http.policy.RetryPolicy; import com.azure.core.http.policy.UserAgentPolicy; import com.azure.core.annotation.ServiceClientBuilder; -import com.azure.core.util.UserAgentProperties; import com.azure.core.util.logging.ClientLogger; +import com.azure.security.keyvault.keys.implementation.AzureKeyVaultConfiguration; import com.azure.security.keyvault.keys.implementation.KeyVaultCredentialPolicy; import java.net.MalformedURLException; @@ -60,11 +60,8 @@ @ServiceClientBuilder(serviceClients = KeyClient.class) public final class KeyClientBuilder { private final ClientLogger logger = new ClientLogger(KeyClientBuilder.class); - // This is properties file's name. - private static final String AZURE_KEY_VAULT_KEYS = "azure-key-vault-keys.properties"; private final List policies; - private final UserAgentProperties properties; private TokenCredential credential; private HttpPipeline pipeline; private URL vaultUrl; @@ -81,7 +78,6 @@ public KeyClientBuilder() { retryPolicy = new RetryPolicy(); httpLogOptions = new HttpLogOptions(); policies = new ArrayList<>(); - properties = CoreUtils.getUserAgentProperties(AZURE_KEY_VAULT_KEYS); } /** @@ -140,7 +136,7 @@ public KeyAsyncClient buildAsyncClient() { // Closest to API goes first, closest to wire goes last. final List policies = new ArrayList<>(); - policies.add(new UserAgentPolicy(httpLogOptions.getApplicationId(), properties.getName(), properties.getVersion(), + policies.add(new UserAgentPolicy(httpLogOptions.getApplicationId(), AzureKeyVaultConfiguration.SDK_NAME, AzureKeyVaultConfiguration.SDK_VERSION, buildConfiguration)); HttpPolicyProviders.addBeforeRetryPolicies(policies); policies.add(retryPolicy); diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/cryptography/CryptographyClientBuilder.java b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/cryptography/CryptographyClientBuilder.java index 3343309705c93..5a76313f4fc85 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/cryptography/CryptographyClientBuilder.java +++ b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/cryptography/CryptographyClientBuilder.java @@ -16,10 +16,9 @@ import com.azure.core.annotation.ServiceClientBuilder; import com.azure.core.http.policy.HttpPolicyProviders; 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.security.keyvault.keys.implementation.KeyVaultCredentialPolicy; +import com.azure.security.keyvault.keys.implementation.AzureKeyVaultConfiguration; import com.azure.security.keyvault.keys.models.JsonWebKey; import java.util.ArrayList; @@ -64,10 +63,7 @@ @ServiceClientBuilder(serviceClients = CryptographyClient.class) public final class CryptographyClientBuilder { final List policies; - final UserAgentProperties properties; private final ClientLogger logger = new ClientLogger(CryptographyClientBuilder.class); - // This is properties file's name. - private static final String AZURE_KEY_VAULT_KEYS = "azure-key-vault-keys.properties"; private TokenCredential credential; private HttpPipeline pipeline; private JsonWebKey jsonWebKey; @@ -85,7 +81,6 @@ public CryptographyClientBuilder() { retryPolicy = new RetryPolicy(); httpLogOptions = new HttpLogOptions(); policies = new ArrayList<>(); - properties = CoreUtils.getUserAgentProperties(AZURE_KEY_VAULT_KEYS); } /** @@ -158,8 +153,8 @@ HttpPipeline setupPipeline() { // Closest to API goes first, closest to wire goes last. final List policies = new ArrayList<>(); - policies.add(new UserAgentPolicy(httpLogOptions.getApplicationId(), properties.getName(), - properties.getVersion(), buildConfiguration)); + policies.add(new UserAgentPolicy(httpLogOptions.getApplicationId(), AzureKeyVaultConfiguration.SDK_NAME, AzureKeyVaultConfiguration.SDK_VERSION, + buildConfiguration)); HttpPolicyProviders.addBeforeRetryPolicies(policies); policies.add(retryPolicy); policies.add(new KeyVaultCredentialPolicy(credential)); diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/AzureKeyVaultConfiguration.java b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/AzureKeyVaultConfiguration.java new file mode 100644 index 0000000000000..46296bf3478b5 --- /dev/null +++ b/sdk/keyvault/azure-security-keyvault-keys/src/main/java/com/azure/security/keyvault/keys/implementation/AzureKeyVaultConfiguration.java @@ -0,0 +1,12 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.security.keyvault.keys.implementation; + +public final class AzureKeyVaultConfiguration { + //TODO: Eventually remove these hardcoded strings with https://github.com/Azure/azure-sdk-for-java/issues/3141 + public static final String SDK_NAME = "Azure-Keyvault"; + // {x-version-update-start;com.azure:azure-security-keyvault-keys;current} + public static final String SDK_VERSION = "4.1.0-beta.1"; + // {x-version-update-end} +} diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/main/resources/azure-key-vault-keys.properties b/sdk/keyvault/azure-security-keyvault-keys/src/main/resources/azure-key-vault-keys.properties deleted file mode 100644 index ca812989b4f27..0000000000000 --- a/sdk/keyvault/azure-security-keyvault-keys/src/main/resources/azure-key-vault-keys.properties +++ /dev/null @@ -1,2 +0,0 @@ -name=${project.artifactId} -version=${project.version} diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/test/java/com/azure/security/keyvault/keys/KeyClientTestBase.java b/sdk/keyvault/azure-security-keyvault-keys/src/test/java/com/azure/security/keyvault/keys/KeyClientTestBase.java index 16bcf9b89b7c1..89d86b36d0d35 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/test/java/com/azure/security/keyvault/keys/KeyClientTestBase.java +++ b/sdk/keyvault/azure-security-keyvault-keys/src/test/java/com/azure/security/keyvault/keys/KeyClientTestBase.java @@ -21,6 +21,7 @@ import com.azure.core.test.TestBase; import com.azure.core.util.Configuration; import com.azure.identity.DefaultAzureCredentialBuilder; +import com.azure.security.keyvault.keys.implementation.AzureKeyVaultConfiguration; import com.azure.security.keyvault.keys.models.CreateKeyOptions; import com.azure.security.keyvault.keys.models.KeyType; import com.azure.security.keyvault.keys.models.KeyVaultKey; @@ -46,8 +47,6 @@ public abstract class KeyClientTestBase extends TestBase { private static final String KEY_NAME = "javaKeyTemp"; private static final KeyType RSA_KEY_TYPE = KeyType.RSA; private static final KeyType EC_KEY_TYPE = KeyType.EC; - private static final String SDK_NAME = "client_name"; - private static final String SDK_VERSION = "client_version"; @Override protected String getTestName() { @@ -71,7 +70,7 @@ T clientSetup(Function clientBuilder) { HttpClient httpClient; // Closest to API goes first, closest to wire goes last. final List policies = new ArrayList<>(); - policies.add(new UserAgentPolicy(SDK_NAME, SDK_VERSION, Configuration.getGlobalConfiguration().clone(), KeyServiceVersion.getLatest())); + policies.add(new UserAgentPolicy(AzureKeyVaultConfiguration.SDK_NAME, AzureKeyVaultConfiguration.SDK_VERSION, Configuration.getGlobalConfiguration().clone(), KeyServiceVersion.getLatest())); HttpPolicyProviders.addBeforeRetryPolicies(policies); policies.add(new RetryPolicy()); if (credential != null) { diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/test/java/com/azure/security/keyvault/keys/KeyVaultKeysUserAgentPropertiesTest.java b/sdk/keyvault/azure-security-keyvault-keys/src/test/java/com/azure/security/keyvault/keys/KeyVaultKeysUserAgentPropertiesTest.java deleted file mode 100644 index af1ecc5c9b28c..0000000000000 --- a/sdk/keyvault/azure-security-keyvault-keys/src/test/java/com/azure/security/keyvault/keys/KeyVaultKeysUserAgentPropertiesTest.java +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.security.keyvault.keys; - -import com.azure.core.util.CoreUtils; -import com.azure.core.util.UserAgentProperties; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertTrue; - -public class KeyVaultKeysUserAgentPropertiesTest { - - @Test - public void testAzureConfiguration() { - UserAgentProperties properties = CoreUtils.getUserAgentProperties("azure-key-vault-keys.properties"); - assertFalse(properties.getName().matches("UnknownName")); - assertTrue(properties.getVersion().matches("(\\d)+.(\\d)+.(\\d)+([-a-zA-Z0-9.])*")); - } -} diff --git a/sdk/keyvault/azure-security-keyvault-keys/src/test/java/com/azure/security/keyvault/keys/cryptography/CryptographyClientTestBase.java b/sdk/keyvault/azure-security-keyvault-keys/src/test/java/com/azure/security/keyvault/keys/cryptography/CryptographyClientTestBase.java index 31df034c7ffca..7d7df1d6280e0 100644 --- a/sdk/keyvault/azure-security-keyvault-keys/src/test/java/com/azure/security/keyvault/keys/cryptography/CryptographyClientTestBase.java +++ b/sdk/keyvault/azure-security-keyvault-keys/src/test/java/com/azure/security/keyvault/keys/cryptography/CryptographyClientTestBase.java @@ -20,6 +20,7 @@ import com.azure.core.test.TestBase; import com.azure.core.util.Configuration; import com.azure.identity.DefaultAzureCredentialBuilder; +import com.azure.security.keyvault.keys.implementation.AzureKeyVaultConfiguration; import org.junit.jupiter.api.Test; import java.math.BigInteger; @@ -44,8 +45,6 @@ public abstract class CryptographyClientTestBase extends TestBase { - private static final String SDK_NAME = "client_name"; - private static final String SDK_VERSION = "client_version"; @Override protected String getTestName() { @@ -78,7 +77,7 @@ T clientSetup(Function clientBuilder) { // Closest to API goes first, closest to wire goes last. final List policies = new ArrayList<>(); - policies.add(new UserAgentPolicy(SDK_NAME, SDK_VERSION, Configuration.getGlobalConfiguration().clone(), CryptographyServiceVersion.getLatest())); + policies.add(new UserAgentPolicy(AzureKeyVaultConfiguration.SDK_NAME, AzureKeyVaultConfiguration.SDK_VERSION, Configuration.getGlobalConfiguration().clone(), CryptographyServiceVersion.getLatest())); HttpPolicyProviders.addBeforeRetryPolicies(policies); policies.add(new RetryPolicy()); if (credential != null) { diff --git a/sdk/keyvault/azure-security-keyvault-secrets/src/main/java/com/azure/security/keyvault/secrets/AzureKeyVaultConfiguration.java b/sdk/keyvault/azure-security-keyvault-secrets/src/main/java/com/azure/security/keyvault/secrets/AzureKeyVaultConfiguration.java new file mode 100644 index 0000000000000..6fb1ecc775071 --- /dev/null +++ b/sdk/keyvault/azure-security-keyvault-secrets/src/main/java/com/azure/security/keyvault/secrets/AzureKeyVaultConfiguration.java @@ -0,0 +1,12 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.security.keyvault.secrets; + +class AzureKeyVaultConfiguration { + //TODO: Eventually remove these hardcoded strings with https://github.com/Azure/azure-sdk-for-java/issues/3141 + static final String SDK_NAME = "Azure-Keyvault"; + // {x-version-update-start;com.azure:azure-security-keyvault-secrets;current} + static final String SDK_VERSION = "4.0.1"; + // {x-version-update-end} +} diff --git a/sdk/keyvault/azure-security-keyvault-secrets/src/main/java/com/azure/security/keyvault/secrets/SecretClientBuilder.java b/sdk/keyvault/azure-security-keyvault-secrets/src/main/java/com/azure/security/keyvault/secrets/SecretClientBuilder.java index 1726b90c19ca1..2cc1c59a4a52d 100644 --- a/sdk/keyvault/azure-security-keyvault-secrets/src/main/java/com/azure/security/keyvault/secrets/SecretClientBuilder.java +++ b/sdk/keyvault/azure-security-keyvault-secrets/src/main/java/com/azure/security/keyvault/secrets/SecretClientBuilder.java @@ -17,7 +17,6 @@ import com.azure.core.http.policy.RetryPolicy; import com.azure.core.http.policy.UserAgentPolicy; import com.azure.core.util.CoreUtils; -import com.azure.core.util.UserAgentProperties; import com.azure.core.util.logging.ClientLogger; import com.azure.security.keyvault.secrets.implementation.KeyVaultCredentialPolicy; @@ -59,11 +58,8 @@ @ServiceClientBuilder(serviceClients = SecretClient.class) public final class SecretClientBuilder { private final ClientLogger logger = new ClientLogger(SecretClientBuilder.class); - // This is properties file's name. - private static final String AZURE_KEY_VAULT_SECRETS = "azure-key-vault-secrets.properties"; private final List policies; - final UserAgentProperties properties; private TokenCredential credential; private HttpPipeline pipeline; private URL vaultUrl; @@ -80,7 +76,6 @@ public SecretClientBuilder() { retryPolicy = new RetryPolicy(); httpLogOptions = new HttpLogOptions(); policies = new ArrayList<>(); - properties = CoreUtils.getUserAgentProperties(AZURE_KEY_VAULT_SECRETS); } /** @@ -142,8 +137,8 @@ public SecretAsyncClient buildAsyncClient() { // Closest to API goes first, closest to wire goes last. final List policies = new ArrayList<>(); - policies.add(new UserAgentPolicy(httpLogOptions.getApplicationId(), properties.getName(), - properties.getVersion(), buildConfiguration)); + policies.add(new UserAgentPolicy(httpLogOptions.getApplicationId(), AzureKeyVaultConfiguration.SDK_NAME, AzureKeyVaultConfiguration.SDK_VERSION, + buildConfiguration)); HttpPolicyProviders.addBeforeRetryPolicies(policies); policies.add(retryPolicy); policies.add(new KeyVaultCredentialPolicy(credential)); diff --git a/sdk/keyvault/azure-security-keyvault-secrets/src/main/resources/azure-key-vault-secrets.properties b/sdk/keyvault/azure-security-keyvault-secrets/src/main/resources/azure-key-vault-secrets.properties deleted file mode 100644 index ca812989b4f27..0000000000000 --- a/sdk/keyvault/azure-security-keyvault-secrets/src/main/resources/azure-key-vault-secrets.properties +++ /dev/null @@ -1,2 +0,0 @@ -name=${project.artifactId} -version=${project.version} diff --git a/sdk/keyvault/azure-security-keyvault-secrets/src/test/java/com/azure/security/keyvault/secrets/KeyVaultSecretsUserAgentPropertiesTest.java b/sdk/keyvault/azure-security-keyvault-secrets/src/test/java/com/azure/security/keyvault/secrets/KeyVaultSecretsUserAgentPropertiesTest.java deleted file mode 100644 index d3410876b23c1..0000000000000 --- a/sdk/keyvault/azure-security-keyvault-secrets/src/test/java/com/azure/security/keyvault/secrets/KeyVaultSecretsUserAgentPropertiesTest.java +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.security.keyvault.secrets; - -import com.azure.core.util.CoreUtils; -import com.azure.core.util.UserAgentProperties; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertTrue; - -public class KeyVaultSecretsUserAgentPropertiesTest { - - @Test - public void testAzureConfiguration() { - UserAgentProperties properties = CoreUtils.getUserAgentProperties("azure-key-vault-secrets.properties"); - assertFalse(properties.getName().matches("UnknownName")); - assertTrue(properties.getVersion().matches("(\\d)+.(\\d)+.(\\d)+([-a-zA-Z0-9.])*")); - } -} diff --git a/sdk/keyvault/azure-security-keyvault-secrets/src/test/java/com/azure/security/keyvault/secrets/SecretClientTestBase.java b/sdk/keyvault/azure-security-keyvault-secrets/src/test/java/com/azure/security/keyvault/secrets/SecretClientTestBase.java index 1af14cd26fe1a..7bc64e3579f2d 100644 --- a/sdk/keyvault/azure-security-keyvault-secrets/src/test/java/com/azure/security/keyvault/secrets/SecretClientTestBase.java +++ b/sdk/keyvault/azure-security-keyvault-secrets/src/test/java/com/azure/security/keyvault/secrets/SecretClientTestBase.java @@ -45,9 +45,6 @@ public abstract class SecretClientTestBase extends TestBase { private static final String SECRET_NAME = "javaSecretTemp"; private static final String SECRET_VALUE = "Chocolate is hidden in the toothpaste cabinet"; - private static final String SDK_NAME = "client_name"; - private static final String SDK_VERSION = "client_version"; - @Override protected String getTestName() { return ""; @@ -66,7 +63,7 @@ T clientSetup(Function clientBuilder) { HttpClient httpClient; // Closest to API goes first, closest to wire goes last. final List policies = new ArrayList<>(); - policies.add(new UserAgentPolicy(SDK_NAME, SDK_VERSION, Configuration.getGlobalConfiguration().clone(), SecretServiceVersion.getLatest())); + policies.add(new UserAgentPolicy(AzureKeyVaultConfiguration.SDK_NAME, AzureKeyVaultConfiguration.SDK_VERSION, Configuration.getGlobalConfiguration().clone(), SecretServiceVersion.getLatest())); HttpPolicyProviders.addBeforeRetryPolicies(policies); policies.add(new RetryPolicy()); if (credential != null) { diff --git a/sdk/storage/azure-storage-blob-cryptography/src/main/java/com/azure/storage/blob/specialized/cryptography/BlobCryptographyConfiguration.java b/sdk/storage/azure-storage-blob-cryptography/src/main/java/com/azure/storage/blob/specialized/cryptography/BlobCryptographyConfiguration.java new file mode 100644 index 0000000000000..49a15917659ee --- /dev/null +++ b/sdk/storage/azure-storage-blob-cryptography/src/main/java/com/azure/storage/blob/specialized/cryptography/BlobCryptographyConfiguration.java @@ -0,0 +1,10 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.storage.blob.specialized.cryptography; + +class BlobCryptographyConfiguration { + static final String NAME = "azure-storage-blob-cryptography"; + // {x-version-update-start;com.azure:azure-storage-blob-cryptography;current} + static final String VERSION = "12.1.0"; + // {x-version-update-end} +} diff --git a/sdk/storage/azure-storage-blob-cryptography/src/main/java/com/azure/storage/blob/specialized/cryptography/CryptographyConstants.java b/sdk/storage/azure-storage-blob-cryptography/src/main/java/com/azure/storage/blob/specialized/cryptography/CryptographyConstants.java index b617093b9837b..b6dd0dce11875 100644 --- a/sdk/storage/azure-storage-blob-cryptography/src/main/java/com/azure/storage/blob/specialized/cryptography/CryptographyConstants.java +++ b/sdk/storage/azure-storage-blob-cryptography/src/main/java/com/azure/storage/blob/specialized/cryptography/CryptographyConstants.java @@ -4,9 +4,6 @@ package com.azure.storage.blob.specialized.cryptography; -import com.azure.core.util.CoreUtils; -import com.azure.core.util.UserAgentProperties; - final class CryptographyConstants { static final String ENCRYPTION_PROTOCOL_V1 = "1.0"; @@ -18,12 +15,7 @@ final class CryptographyConstants { static final String AES = "AES"; - // This is properties file's name. - private static final String AZURE_STORAGE_PROPERTIES = "azure-storage-blob.properties"; - - static final UserAgentProperties USER_AGENT_PROPERTIES = CoreUtils.getUserAgentProperties(AZURE_STORAGE_PROPERTIES); - - static final String AGENT_METADATA_VALUE = "JavaTrack2" + USER_AGENT_PROPERTIES.getVersion(); + static final String AGENT_METADATA_VALUE = "JavaTrack2" + BlobCryptographyConfiguration.VERSION; static final String ENCRYPTION_DATA_KEY = "encryptiondata"; @@ -42,8 +34,6 @@ final class CryptographyConstants { static final String DECRYPT_UNENCRYPTED_BLOB = "Encryption client is being used but the blob metadata indicates " + "that it is not encrypted."; - private CryptographyConstants() { } - } diff --git a/sdk/storage/azure-storage-blob-cryptography/src/main/java/com/azure/storage/blob/specialized/cryptography/EncryptedBlobClientBuilder.java b/sdk/storage/azure-storage-blob-cryptography/src/main/java/com/azure/storage/blob/specialized/cryptography/EncryptedBlobClientBuilder.java index 225cde011f16e..c2a6cb419d909 100644 --- a/sdk/storage/azure-storage-blob-cryptography/src/main/java/com/azure/storage/blob/specialized/cryptography/EncryptedBlobClientBuilder.java +++ b/sdk/storage/azure-storage-blob-cryptography/src/main/java/com/azure/storage/blob/specialized/cryptography/EncryptedBlobClientBuilder.java @@ -45,8 +45,6 @@ import java.util.List; import java.util.Objects; -import static com.azure.storage.blob.specialized.cryptography.CryptographyConstants.USER_AGENT_PROPERTIES; - /** * This class provides a fluent builder API to help aid the configuration and instantiation of Storage Blob clients. * @@ -153,14 +151,16 @@ private HttpPipeline getHttpPipeline() { return httpPipeline; } + String userAgentName = BlobCryptographyConfiguration.NAME; + String userAgentVersion = BlobCryptographyConfiguration.VERSION; Configuration userAgentConfiguration = (configuration == null) ? Configuration.NONE : configuration; // Closest to API goes first, closest to wire goes last. List policies = new ArrayList<>(); policies.add(new BlobDecryptionPolicy(keyWrapper, keyResolver)); - policies.add(new UserAgentPolicy(logOptions.getApplicationId(), USER_AGENT_PROPERTIES.getName(), - USER_AGENT_PROPERTIES.getVersion(), userAgentConfiguration)); + policies.add(new UserAgentPolicy(logOptions.getApplicationId(), userAgentName, userAgentVersion, + userAgentConfiguration)); policies.add(new RequestIdPolicy()); policies.add(new AddDatePolicy()); diff --git a/sdk/storage/azure-storage-blob-cryptography/src/test/java/com/azure/storage/blob/specialized/cryptography/BlobCryptographyUserAgentPropertiesTest.groovy b/sdk/storage/azure-storage-blob-cryptography/src/test/java/com/azure/storage/blob/specialized/cryptography/BlobCryptographyUserAgentPropertiesTest.groovy deleted file mode 100644 index 9494d059a7040..0000000000000 --- a/sdk/storage/azure-storage-blob-cryptography/src/test/java/com/azure/storage/blob/specialized/cryptography/BlobCryptographyUserAgentPropertiesTest.groovy +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob.specialized.cryptography - -import com.azure.core.util.CoreUtils -import com.azure.core.util.UserAgentProperties -import spock.lang.Specification - -class BlobCryptographyUserAgentPropertiesTest extends Specification { - - def "User agent properties not null"() { - given: - UserAgentProperties properties = CoreUtils.getUserAgentProperties( - "azure-storage-blob.properties") - expect: - !properties.getName().matches("UnknownName") - properties.getVersion().matches("(\\d)+.(\\d)+.(\\d)+([-a-zA-Z0-9.])*") - } -} diff --git a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/util/BuilderHelper.java b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/util/BuilderHelper.java index 9535f1a224c52..9598ccf5f2031 100644 --- a/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/util/BuilderHelper.java +++ b/sdk/storage/azure-storage-blob/src/main/java/com/azure/storage/blob/implementation/util/BuilderHelper.java @@ -16,8 +16,6 @@ import com.azure.core.http.policy.RequestIdPolicy; 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.storage.blob.BlobUrlParts; import com.azure.storage.common.StorageSharedKeyCredential; @@ -39,8 +37,10 @@ * RESERVED FOR INTERNAL USE. */ public final class BuilderHelper { - private static final UserAgentProperties PROPERTIES = - CoreUtils.getUserAgentProperties("azure-storage-blob.properties"); + private static final String DEFAULT_USER_AGENT_NAME = "azure-storage-blob"; + // {x-version-update-start;com.azure:azure-storage-blob;current} + private static final String DEFAULT_USER_AGENT_VERSION = "12.1.0"; + // {x-version-update-end} /** * Constructs a {@link HttpPipeline} from values passed from a builder. @@ -153,8 +153,8 @@ public static void httpsValidation(Object objectToCheck, String objectName, Stri private static UserAgentPolicy getUserAgentPolicy(Configuration configuration) { configuration = (configuration == null) ? Configuration.NONE : configuration; - return new UserAgentPolicy(getDefaultHttpLogOptions().getApplicationId(), PROPERTIES.getName(), - PROPERTIES.getVersion(), configuration); + return new UserAgentPolicy(getDefaultHttpLogOptions().getApplicationId(), DEFAULT_USER_AGENT_NAME, + DEFAULT_USER_AGENT_VERSION, configuration); } /* diff --git a/sdk/storage/azure-storage-blob/src/main/resources/azure-storage-blob.properties b/sdk/storage/azure-storage-blob/src/main/resources/azure-storage-blob.properties deleted file mode 100644 index ca812989b4f27..0000000000000 --- a/sdk/storage/azure-storage-blob/src/main/resources/azure-storage-blob.properties +++ /dev/null @@ -1,2 +0,0 @@ -name=${project.artifactId} -version=${project.version} diff --git a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/BlobUserAgentPropertiesTest.groovy b/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/BlobUserAgentPropertiesTest.groovy deleted file mode 100644 index 67fc96cb840c0..0000000000000 --- a/sdk/storage/azure-storage-blob/src/test/java/com/azure/storage/blob/BlobUserAgentPropertiesTest.groovy +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.blob - -import com.azure.core.util.CoreUtils -import com.azure.core.util.UserAgentProperties -import spock.lang.Specification - -class BlobUserAgentPropertiesTest extends Specification { - - def "User agent properties not null"() { - given: - UserAgentProperties properties = CoreUtils.getUserAgentProperties( - "azure-storage-blob.properties") - expect: - !properties.getName().matches("UnknownName") - properties.getVersion().matches("(\\d)+.(\\d)+.(\\d)+([-a-zA-Z0-9.])*") - } -} diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/FileConfiguration.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/FileConfiguration.java new file mode 100644 index 0000000000000..272939249d3b2 --- /dev/null +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/FileConfiguration.java @@ -0,0 +1,15 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.storage.file.share; + +/* + * Gets the SDK information for this library component. + */ +class FileConfiguration { + //TODO: Eventually remove these hardcoded strings with https://github.com/Azure/azure-sdk-for-java/issues/3141 + static final String NAME = "azure-storage-file-share"; + // {x-version-update-start;com.azure:azure-storage-file-share;current} + static final String VERSION = "12.0.0"; + // {x-version-update-end} +} diff --git a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/util/BuilderHelper.java b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/util/BuilderHelper.java index 518eaae5de9b3..66f8722672c8f 100644 --- a/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/util/BuilderHelper.java +++ b/sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/implementation/util/BuilderHelper.java @@ -15,7 +15,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.storage.common.implementation.Constants; import com.azure.storage.common.policy.RequestRetryOptions; import com.azure.storage.common.policy.RequestRetryPolicy; @@ -32,8 +31,10 @@ * This class provides helper methods for common builder patterns. */ public final class BuilderHelper { - private static final UserAgentProperties PROPERTIES = - CoreUtils.getUserAgentProperties("azure-storage-file-share.properties"); + private static final String DEFAULT_USER_AGENT_NAME = "azure-storage-file-share"; + // {x-version-update-start;com.azure:azure-storage-file-share;current} + private static final String DEFAULT_USER_AGENT_VERSION = "12.0.0"; + // {x-version-update-end} private static final Pattern IP_URL_PATTERN = Pattern .compile("(?:\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3})|(?:localhost)"); @@ -94,7 +95,7 @@ private static UserAgentPolicy getUserAgentPolicy(Configuration configuration) { configuration = (configuration == null) ? Configuration.NONE : configuration; return new UserAgentPolicy(getDefaultHttpLogOptions().getApplicationId(), - PROPERTIES.getName(), PROPERTIES.getVersion(), configuration); + DEFAULT_USER_AGENT_NAME, DEFAULT_USER_AGENT_VERSION, configuration); } /** diff --git a/sdk/storage/azure-storage-file-share/src/main/resources/azure-storage-file-share.properties b/sdk/storage/azure-storage-file-share/src/main/resources/azure-storage-file-share.properties deleted file mode 100644 index ca812989b4f27..0000000000000 --- a/sdk/storage/azure-storage-file-share/src/main/resources/azure-storage-file-share.properties +++ /dev/null @@ -1,2 +0,0 @@ -name=${project.artifactId} -version=${project.version} diff --git a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileShareUserAgentPropertiesTest.groovy b/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileShareUserAgentPropertiesTest.groovy deleted file mode 100644 index d4f8af956cc6f..0000000000000 --- a/sdk/storage/azure-storage-file-share/src/test/java/com/azure/storage/file/share/FileShareUserAgentPropertiesTest.groovy +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.file.share - -import com.azure.core.util.CoreUtils -import com.azure.core.util.UserAgentProperties -import spock.lang.Specification - -class FileShareUserAgentPropertiesTest extends Specification { - - def "User agent properties not null"() { - given: - UserAgentProperties properties = CoreUtils.getUserAgentProperties( - "azure-storage-file-share.properties") - expect: - !properties.getName().matches("UnknownName") - properties.getVersion().matches("(\\d)+.(\\d)+.(\\d)+([-a-zA-Z0-9.])*") - } -} diff --git a/sdk/storage/azure-storage-queue/src/main/java/com/azure/storage/queue/QueueConfiguration.java b/sdk/storage/azure-storage-queue/src/main/java/com/azure/storage/queue/QueueConfiguration.java new file mode 100644 index 0000000000000..983e7f833b3bf --- /dev/null +++ b/sdk/storage/azure-storage-queue/src/main/java/com/azure/storage/queue/QueueConfiguration.java @@ -0,0 +1,15 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.storage.queue; + +/* + * Gets the SDK information for this library component. + */ +class QueueConfiguration { + //TODO: Eventually remove these hardcoded strings with https://github.com/Azure/azure-sdk-for-java/issues/3141 + static final String NAME = "azure-storage-queue"; + // {x-version-update-start;com.azure:azure-storage-queue;current} + static final String VERSION = "12.1.0"; + // {x-version-update-end} +} diff --git a/sdk/storage/azure-storage-queue/src/main/java/com/azure/storage/queue/implementation/util/BuilderHelper.java b/sdk/storage/azure-storage-queue/src/main/java/com/azure/storage/queue/implementation/util/BuilderHelper.java index fb0ecb71288d1..2a14ca7f402c4 100644 --- a/sdk/storage/azure-storage-queue/src/main/java/com/azure/storage/queue/implementation/util/BuilderHelper.java +++ b/sdk/storage/azure-storage-queue/src/main/java/com/azure/storage/queue/implementation/util/BuilderHelper.java @@ -17,7 +17,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.storage.common.StorageSharedKeyCredential; import com.azure.storage.common.implementation.Constants; @@ -42,8 +41,10 @@ * This class provides helper methods for common builder patterns. */ public final class BuilderHelper { - private static final UserAgentProperties PROPERTIES = - CoreUtils.getUserAgentProperties("azure-storage-queue.properties"); + private static final String DEFAULT_USER_AGENT_NAME = "azure-storage-queue"; + // {x-version-update-start;com.azure:azure-storage-queue;current} + private static final String DEFAULT_USER_AGENT_VERSION = "12.1.0"; + // {x-version-update-end} private static final Pattern IP_URL_PATTERN = Pattern .compile("(?:\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3})|(?:localhost)"); @@ -201,7 +202,7 @@ private static UserAgentPolicy getUserAgentPolicy(Configuration configuration) { configuration = (configuration == null) ? Configuration.NONE : configuration; return new UserAgentPolicy(getDefaultHttpLogOptions().getApplicationId(), - PROPERTIES.getName(), PROPERTIES.getVersion(), configuration); + DEFAULT_USER_AGENT_NAME, DEFAULT_USER_AGENT_VERSION, configuration); } /* diff --git a/sdk/storage/azure-storage-queue/src/main/resources/azure-storage-queue.properties b/sdk/storage/azure-storage-queue/src/main/resources/azure-storage-queue.properties deleted file mode 100644 index ca812989b4f27..0000000000000 --- a/sdk/storage/azure-storage-queue/src/main/resources/azure-storage-queue.properties +++ /dev/null @@ -1,2 +0,0 @@ -name=${project.artifactId} -version=${project.version} diff --git a/sdk/storage/azure-storage-queue/src/test/java/com/azure/storage/queue/QueueUserAgentPropertiesTest.groovy b/sdk/storage/azure-storage-queue/src/test/java/com/azure/storage/queue/QueueUserAgentPropertiesTest.groovy deleted file mode 100644 index 523a6b626407f..0000000000000 --- a/sdk/storage/azure-storage-queue/src/test/java/com/azure/storage/queue/QueueUserAgentPropertiesTest.groovy +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -package com.azure.storage.queue; - -import com.azure.core.util.CoreUtils -import com.azure.core.util.UserAgentProperties -import spock.lang.Specification - -class QueueUserAgentPropertiesTest extends Specification { - - def "User agent properties not null"() { - given: - UserAgentProperties properties = CoreUtils.getUserAgentProperties( - "azure-storage-queue.properties") - expect: - !properties.getName().matches("UnknownName") - properties.getVersion().matches("(\\d)+.(\\d)+.(\\d)+([-a-zA-Z0-9.])*") - } -}