Skip to content

Commit eefdcca

Browse files
authored
Builder interfaces (Azure#26562)
* Update Log4j to 2.17.0 * First batch of TokenCredentialSupport. * move package. * trait? * http options minus retry. * fix build? * ClientOptionsTrait * revapi suppression. * checkstyle. * servicebus token cred. * eventhub tokencredential. * Amqp trait. * sas credential trait. * connection string trait. * Key and Named Key. * Named Key in Storage. * Does this solve retry ? * attestation post-merge. * fix java 8 compilation... * fix checkstyle warnings. * this isn't necessary. * checkstyle. * undo services outside of spring scope. * configuration trait. * remove client options trait in favor of configuration. * rename http and amqp * aaa.... * retryOptions and retryPolicy mutually exclusive. * tweaks. * tweaks. * client options and endpoint trait. * the util. * fixedretry options. * allow null retry options. * pr feedback. * validate ExponentialBackoffOptions * storage. * remove these two. * @throws * traits comments. * fix core build. * fix kv build. * fix tables. build. * checkstyle.. * copy http client docs. * aka.ms * copy pipeline docs. * copy addPolicy docs. * update configuration trait docs. * copy retry options docs. * copy log options docs. * copy client options docs. * copy token credential docs. * fix build. * pr feedback. * added KeyEncryptionKeyClientBuilderTest
1 parent 565ae2a commit eefdcca

File tree

103 files changed

+5069
-640
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+5069
-640
lines changed

eng/versioning/version_client.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ com.azure.tools:azure-sdk-archetype;1.0.0;1.0.0
344344
# note: The unreleased dependencies will not be manipulated with the automatic PR creation code.
345345
# In the pom, the version update tag after the version should name the unreleased package and the dependency version:
346346
# <!-- {x-version-update;unreleased_com.azure:azure-core;dependency} -->
347-
347+
unreleased_com.azure:azure-core;1.25.0-beta.1
348348
unreleased_com.azure:azure-core-amqp;2.4.0-beta.1
349349

350350
# Released Beta dependencies: Copy the entry from above, prepend "beta_", remove the current

sdk/appconfiguration/azure-data-appconfiguration/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
<dependency>
4646
<groupId>com.azure</groupId>
4747
<artifactId>azure-core</artifactId>
48-
<version>1.24.1</version> <!-- {x-version-update;com.azure:azure-core;dependency} -->
48+
<version>1.25.0-beta.1</version> <!-- {x-version-update;unreleased_com.azure:azure-core;dependency} -->
4949
</dependency>
5050
<dependency>
5151
<groupId>com.azure</groupId>

sdk/appconfiguration/azure-data-appconfiguration/src/main/java/com/azure/data/appconfiguration/ConfigurationClientBuilder.java

Lines changed: 108 additions & 23 deletions
Large diffs are not rendered by default.

sdk/appconfiguration/azure-data-appconfiguration/src/test/java/com/azure/data/appconfiguration/ConfigurationClientBuilderTest.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@
77
import com.azure.core.http.HttpClient;
88
import com.azure.core.http.HttpPipelineBuilder;
99
import com.azure.core.http.netty.NettyAsyncHttpClientBuilder;
10+
import com.azure.core.http.policy.ExponentialBackoffOptions;
1011
import com.azure.core.http.policy.FixedDelay;
1112
import com.azure.core.http.policy.HttpLogDetailLevel;
1213
import com.azure.core.http.policy.HttpLogOptions;
14+
import com.azure.core.http.policy.RetryOptions;
1315
import com.azure.core.http.policy.RetryPolicy;
1416
import com.azure.core.http.policy.TimeoutPolicy;
1517
import com.azure.core.test.TestBase;
@@ -128,6 +130,18 @@ public void timeoutPolicy() {
128130
assertThrows(RuntimeException.class, () -> client.setConfigurationSetting(key, null, value));
129131
}
130132

133+
@Test
134+
@DoNotRecord
135+
public void throwIfBothRetryOptionsAndRetryPolicyIsConfigured() {
136+
final ConfigurationClientBuilder clientBuilder = new ConfigurationClientBuilder()
137+
.connectionString(connectionString)
138+
.retryOptions(new RetryOptions(new ExponentialBackoffOptions()))
139+
.retryPolicy(new RetryPolicy())
140+
.addPolicy(new TimeoutPolicy(Duration.ofMillis(1)));
141+
142+
assertThrows(IllegalStateException.class, clientBuilder::buildClient);
143+
}
144+
131145
@ParameterizedTest(name = DISPLAY_NAME_WITH_ARGUMENTS)
132146
@MethodSource("com.azure.data.appconfiguration.TestHelper#getTestParameters")
133147
public void nullServiceVersion(HttpClient httpClient) {
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
package com.azure.core.amqp.client.traits;
5+
6+
import com.azure.core.amqp.AmqpRetryOptions;
7+
import com.azure.core.amqp.AmqpTransportType;
8+
import com.azure.core.amqp.ProxyOptions;
9+
import com.azure.core.util.ClientOptions;
10+
11+
/**
12+
* An {@link com.azure.core.client.traits Azure SDK for Java trait} providing a consistent interface for configuration
13+
* of AMQP-specific settings.
14+
*
15+
* @param <T> The concrete type that implements the trait. This is required so that fluent operations can continue
16+
* to return the concrete type, rather than the trait type.
17+
* @see com.azure.core.amqp.client.traits
18+
* @see com.azure.core.client.traits
19+
* @see AmqpRetryOptions
20+
* @see AmqpTransportType
21+
* @see ProxyOptions
22+
*/
23+
public interface AmqpTrait<T extends AmqpTrait<T>> {
24+
/**
25+
* Sets the retry policy. If not specified, the default retry options are used.
26+
*
27+
* @param retryOptions The retry options to use.
28+
* @return Returns the same concrete type with the appropriate properties updated, to allow for fluent chaining of
29+
* operations.
30+
*/
31+
T retryOptions(AmqpRetryOptions retryOptions);
32+
33+
/**
34+
* Sets the transport type by which all the communication with Azure service occurs. The default value is {@link
35+
* AmqpTransportType#AMQP}.
36+
*
37+
* @param transport The transport type to use.
38+
* @return Returns the same concrete type with the appropriate properties updated, to allow for fluent chaining of
39+
* operations.
40+
*/
41+
T transportType(AmqpTransportType transport);
42+
43+
/**
44+
* Sets the proxy configuration to use. When a proxy is configured, {@link
45+
* AmqpTransportType#AMQP_WEB_SOCKETS} must be used for the transport type.
46+
*
47+
* @param proxyOptions The proxy configuration to use.
48+
* @return Returns the same concrete type with the appropriate properties updated, to allow for fluent chaining of
49+
* operations.
50+
*/
51+
T proxyOptions(ProxyOptions proxyOptions);
52+
53+
/**
54+
* Allows for setting common properties such as application ID, headers, etc.
55+
*
56+
* @param clientOptions A configured instance of {@link ClientOptions}.
57+
* @return Returns the same concrete type with the appropriate properties updated, to allow for fluent chaining of
58+
* operations.
59+
*/
60+
T clientOptions(ClientOptions clientOptions);
61+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
/**
5+
* This package contains interfaces that represent common cross-cutting (and AMQP-related) aspects of functionality
6+
* offered by libraries in the Azure SDK for Java. Each interface is referred to as a 'trait', and classes that
7+
* implement the interface are said to have that trait. There are additional traits that are more general
8+
* purpose in the {@link com.azure.core.client.traits} package.
9+
*
10+
* <p>The particular focus of traits in the Azure SDK for Java is to enable higher-level
11+
* libraries the ability to more abstractly configure client libraries as part of their builders, prior to the client
12+
* itself being instantiated. By doing this, these high-level libraries are able to reason about functionality more
13+
* simply. It is important to appreciate that despite the availability of these cross-cutting traits, there is no
14+
* promise that configuration of each builder can simply be a matter of providing the same arguments for all builders!
15+
* Each builder must be configured appropriately for its requirements, or else runtime failures may occur when the
16+
* builder is asked to create the associated client.</p>
17+
*
18+
* @see com.azure.core.client.traits
19+
*/
20+
package com.azure.core.amqp.client.traits;

sdk/core/azure-core-amqp/src/main/java/module-info.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
requires transitive org.apache.qpid.proton.j;
1010

1111
exports com.azure.core.amqp;
12+
exports com.azure.core.amqp.client.traits;
1213
exports com.azure.core.amqp.models;
1314
exports com.azure.core.amqp.exception;
1415

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
package com.azure.core.client.traits;
5+
6+
import com.azure.core.credential.AzureKeyCredential;
7+
8+
/**
9+
* An {@link com.azure.core.client.traits Azure SDK for Java trait} providing a consistent interface for setting
10+
* {@link AzureKeyCredential}. Refer to the Azure SDK for Java
11+
* <a href="https://aka.ms/azsdk/java/docs/identity">identity and authentication</a>
12+
* documentation for more details on proper usage of the {@link AzureKeyCredential} type.
13+
*
14+
* @param <T> The concrete type that implements the trait. This is required so that fluent operations can continue
15+
* to return the concrete type, rather than the trait type.
16+
* @see com.azure.core.client.traits
17+
* @see AzureKeyCredential
18+
*/
19+
public interface AzureKeyCredentialTrait<T extends AzureKeyCredentialTrait<T>> {
20+
/**
21+
* Sets the {@link AzureKeyCredential} used for authentication. Refer to the Azure SDK for Java
22+
* <a href="https://aka.ms/azsdk/java/docs/identity">identity and authentication</a>
23+
* documentation for more details on proper usage of the {@link AzureKeyCredential} type.
24+
*
25+
* @param credential the {@link AzureKeyCredential} to be used for authentication.
26+
* @return Returns the same concrete type with the appropriate properties updated, to allow for fluent chaining of
27+
* operations.
28+
*/
29+
T credential(AzureKeyCredential credential);
30+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
package com.azure.core.client.traits;
5+
6+
import com.azure.core.credential.AzureNamedKeyCredential;
7+
8+
/**
9+
* An {@link com.azure.core.client.traits Azure SDK for Java trait} providing a consistent interface for setting
10+
* {@link AzureNamedKeyCredential}. Refer to the Azure SDK for Java
11+
* <a href="https://aka.ms/azsdk/java/docs/identity">identity and authentication</a>
12+
* documentation for more details on proper usage of the {@link AzureNamedKeyCredential} type.
13+
*
14+
* @param <T> The concrete type that implements the trait. This is required so that fluent operations can continue
15+
* to return the concrete type, rather than the trait type.
16+
* @see com.azure.core.client.traits
17+
* @see AzureNamedKeyCredential
18+
*/
19+
public interface AzureNamedKeyCredentialTrait<T extends AzureNamedKeyCredentialTrait<T>> {
20+
/**
21+
* Sets the {@link AzureNamedKeyCredential} used for authentication. Refer to the Azure SDK for Java
22+
* <a href="https://aka.ms/azsdk/java/docs/identity">identity and authentication</a>
23+
* documentation for more details on proper usage of the {@link AzureNamedKeyCredential} type.
24+
*
25+
* @param credential the {@link AzureNamedKeyCredential} to be used for authentication.
26+
* @return Returns the same concrete type with the appropriate properties updated, to allow for fluent chaining of
27+
* operations.
28+
*/
29+
T credential(AzureNamedKeyCredential credential);
30+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
package com.azure.core.client.traits;
5+
6+
import com.azure.core.credential.AzureSasCredential;
7+
8+
/**
9+
* An {@link com.azure.core.client.traits Azure SDK for Java trait} providing a consistent interface for setting
10+
* {@link AzureSasCredential}. Refer to the Azure SDK for Java
11+
* <a href="https://aka.ms/azsdk/java/docs/identity">identity and authentication</a>
12+
* documentation for more details on proper usage of the {@link AzureSasCredential} type.
13+
*
14+
* @param <T> The concrete type that implements the trait. This is required so that fluent operations can continue
15+
* to return the concrete type, rather than the trait type.
16+
* @see com.azure.core.client.traits
17+
* @see AzureSasCredential
18+
*/
19+
public interface AzureSasCredentialTrait<T extends AzureSasCredentialTrait<T>> {
20+
/**
21+
* Sets the {@link AzureSasCredential} used for authentication. Refer to the Azure SDK for Java
22+
* <a href="https://aka.ms/azsdk/java/docs/identity">identity and authentication</a>
23+
* documentation for more details on proper usage of the {@link AzureSasCredential} type.
24+
*
25+
* @param credential the {@link AzureSasCredential} to be used for authentication.
26+
* @return Returns the same concrete type with the appropriate properties updated, to allow for fluent chaining of
27+
* operations.
28+
*/
29+
T credential(AzureSasCredential credential);
30+
}

0 commit comments

Comments
 (0)