There are 3 major use cases for RestClient that are listed in the order of priority:
- Developers for data planes want to customize HTTP & REST configurations
- Developers for management planes want to reuse HTTP client and configurations across multiple services
- Developers for management planes that are not yet converted to fluent
For these use cases, there are following inconveniences:
RestClient.Builder asks for base URL, which developers need to look into implementation to know, especially for dynamic base URLs
RestClient.Builder requires a call of .withMapperAdapter() which is unknown to developers
The proposal
Data plane usage
- Basic scenario
PetDataPlaneClient client = new PetDataPlaneClientImpl(credentials);
- For working with non-standard environments
PetDataPlaneClient client = new PetDataPlaneClientImpl(AzureEnvironment.AzureChinaCloud, credentials);
PetDataPlaneClient client = new PetDataPlaneClientImpl("azurestack.contoso.com", credentials);
- For advanced scenario
RestClient restClient = new RestClient.Builder()
.withDefaultBaseUrl(PetDataPlaneClient.class)
.withCredentials(credentials)
.withReadTimeout(5, TimeUnit.Minutes)
.withUserAgent("Contoso")
.build();
PetDataPlaneClient client = new PetDataPlaneClientImpl(restClient);
Management plane usage
- Basic scenario
PetManager petManager = PetManager.authenticate(credentials);
- Advanced scenario
RestClient restClient = new RestClient.Builder()
.withDefaultBaseUrl(AzureEnvironment.Azure)
.withCredentials(credentials)
.withUserAgent("Contoso")
.build();
PetManager petManager = PetManager.authenticate(restClient);
ProduceManager produceManager = ProduceManager.authenticate(restClient);
Management plane, without fluent interface
- Basic scenario
PetManagementClient petClient = new PetDataPlaneClientImpl(credentials);
- Advanced scenario
RestClient restClient = new RestClient.Builder()
.withDefaultBaseUrl(AzureEnvironment.Azure)
.withCredentials(credentials)
.withUserAgent("Contoso")
.build();
PetManagementClient petClient = new PetDataPlaneClientImpl(restClient);
There are 3 major use cases for
RestClientthat are listed in the order of priority:For these use cases, there are following inconveniences:
RestClient.Builderasks for base URL, which developers need to look into implementation to know, especially for dynamic base URLsRestClient.Builderrequires a call of.withMapperAdapter()which is unknown to developersThe proposal
Data plane usage
Management plane usage
Management plane, without fluent interface