From 14ecdd3f1897830cf598567a1798df8cce1f73cf Mon Sep 17 00:00:00 2001 From: Jianghao Lu Date: Wed, 17 Feb 2016 12:14:20 -0800 Subject: [PATCH] Support parameterized hosts in Java --- .../Extensions/Extensions/Extensions.cs | 1 + .../AutoRestParameterGroupingTestService.java | 8 +-- ...oRestParameterGroupingTestServiceImpl.java | 34 ++++++------ .../AutoRestReportServiceForAzure.java | 8 +-- .../AutoRestReportServiceForAzureImpl.java | 34 ++++++------ ...oRestAzureSpecialParametersTestClient.java | 8 +-- ...tAzureSpecialParametersTestClientImpl.java | 34 ++++++------ .../AutoRestParameterizedHostTestClient.java | 8 +-- ...toRestParameterizedHostTestClientImpl.java | 36 +++++++------ .../custombaseuri/PathsOperations.java | 3 +- .../custombaseuri/PathsOperationsImpl.java | 8 ++- .../head/AutoRestHeadTestService.java | 8 +-- .../head/AutoRestHeadTestServiceImpl.java | 34 ++++++------ .../AutoRestHeadExceptionTestService.java | 8 +-- .../AutoRestHeadExceptionTestServiceImpl.java | 34 ++++++------ ...toRestLongRunningOperationTestService.java | 8 +-- ...stLongRunningOperationTestServiceImpl.java | 34 ++++++------ .../paging/AutoRestPagingTestService.java | 8 +-- .../paging/AutoRestPagingTestServiceImpl.java | 34 ++++++------ ...AutoRestResourceFlatteningTestService.java | 8 +-- ...RestResourceFlatteningTestServiceImpl.java | 34 ++++++------ .../MicrosoftAzureTestUrl.java | 8 +-- .../MicrosoftAzureTestUrlImpl.java | 34 ++++++------ .../AzureCustomBaseUriTests.java | 6 +-- ...AzureServiceClientInterfaceTemplate.cshtml | 7 +-- .../AzureServiceClientTemplate.cshtml | 50 ++++++++--------- .../AutoRestSwaggerBATArrayService.java | 7 +-- .../AutoRestSwaggerBATArrayServiceImpl.java | 28 +++++----- .../bodyboolean/AutoRestBoolTestService.java | 7 +-- .../AutoRestBoolTestServiceImpl.java | 28 +++++----- .../AutoRestSwaggerBATByteService.java | 7 +-- .../AutoRestSwaggerBATByteServiceImpl.java | 28 +++++----- .../AutoRestComplexTestService.java | 7 +-- .../AutoRestComplexTestServiceImpl.java | 28 +++++----- .../bodydate/AutoRestDateTestService.java | 7 +-- .../bodydate/AutoRestDateTestServiceImpl.java | 28 +++++----- .../AutoRestDateTimeTestService.java | 7 +-- .../AutoRestDateTimeTestServiceImpl.java | 28 +++++----- .../AutoRestRFC1123DateTimeTestService.java | 7 +-- ...utoRestRFC1123DateTimeTestServiceImpl.java | 28 +++++----- .../AutoRestSwaggerBATdictionaryService.java | 7 +-- ...toRestSwaggerBATdictionaryServiceImpl.java | 28 +++++----- .../AutoRestDurationTestService.java | 7 +-- .../AutoRestDurationTestServiceImpl.java | 28 +++++----- .../AutoRestSwaggerBATFileService.java | 7 +-- .../AutoRestSwaggerBATFileServiceImpl.java | 28 +++++----- .../AutoRestSwaggerBATFormDataService.java | 7 +-- ...AutoRestSwaggerBATFormDataServiceImpl.java | 28 +++++----- .../AutoRestIntegerTestService.java | 7 +-- .../AutoRestIntegerTestServiceImpl.java | 28 +++++----- .../bodynumber/AutoRestNumberTestService.java | 7 +-- .../AutoRestNumberTestServiceImpl.java | 28 +++++----- .../bodystring/AutoRestSwaggerBATService.java | 7 +-- .../AutoRestSwaggerBATServiceImpl.java | 28 +++++----- .../AutoRestParameterizedHostTestClient.java | 7 +-- ...toRestParameterizedHostTestClientImpl.java | 24 +++++---- .../custombaseuri/PathsOperations.java | 3 +- .../custombaseuri/PathsOperationsImpl.java | 8 ++- .../AutoRestSwaggerBATHeaderService.java | 7 +-- .../AutoRestSwaggerBATHeaderServiceImpl.java | 28 +++++----- ...AutoRestHttpInfrastructureTestService.java | 7 +-- ...RestHttpInfrastructureTestServiceImpl.java | 28 +++++----- .../report/AutoRestReportService.java | 7 +-- .../report/AutoRestReportServiceImpl.java | 28 +++++----- .../AutoRestRequiredOptionalTestService.java | 7 +-- ...toRestRequiredOptionalTestServiceImpl.java | 28 +++++----- .../fixtures/url/AutoRestUrlTestService.java | 7 +-- .../url/AutoRestUrlTestServiceImpl.java | 28 +++++----- .../validation/AutoRestValidationTest.java | 7 +-- .../AutoRestValidationTestImpl.java | 28 +++++----- .../custombaseuri/CustomBaseUriTests.java | 6 +-- .../TemplateModels/MethodTemplateModel.cs | 7 +-- .../ServiceClientTemplateModel.cs | 2 + .../Java/Java/Templates/MethodTemplate.cshtml | 14 +++++ .../ServiceClientInterfaceTemplate.cshtml | 6 +-- .../Templates/ServiceClientTemplate.cshtml | 29 +++++----- .../com/microsoft/rest/AutoRestBaseUrl.java | 53 +++++++++++++++++++ 77 files changed, 769 insertions(+), 587 deletions(-) create mode 100644 ClientRuntimes/Java/client-runtime/src/main/java/com/microsoft/rest/AutoRestBaseUrl.java diff --git a/AutoRest/Generators/Extensions/Extensions/Extensions.cs b/AutoRest/Generators/Extensions/Extensions/Extensions.cs index 2fae716c95..fc8189b2bf 100644 --- a/AutoRest/Generators/Extensions/Extensions/Extensions.cs +++ b/AutoRest/Generators/Extensions/Extensions/Extensions.cs @@ -82,6 +82,7 @@ public static void ProcessParameterizedHost(ServiceClient serviceClient, Setting { parameter.ClientProperty = serviceClient.Properties.Single(p => p.SerializedName.Equals(parameter.SerializedName)); } + parameter.Extensions["hostParameter"] = true; foreach (var method in serviceClient.Methods) { diff --git a/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/azureparametergrouping/AutoRestParameterGroupingTestService.java b/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/azureparametergrouping/AutoRestParameterGroupingTestService.java index 074dea6d41..c3ea7d744f 100644 --- a/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/azureparametergrouping/AutoRestParameterGroupingTestService.java +++ b/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/azureparametergrouping/AutoRestParameterGroupingTestService.java @@ -11,6 +11,7 @@ package fixtures.azureparametergrouping; import com.microsoft.azure.AzureClient; +import com.microsoft.rest.AutoRestBaseUrl; import com.microsoft.rest.credentials.ServiceClientCredentials; import com.microsoft.rest.serializer.JacksonMapperAdapter; import java.util.List; @@ -22,10 +23,11 @@ */ public interface AutoRestParameterGroupingTestService { /** - * Gets the URI used as the base for all cloud service requests. - * @return The BaseUri value. + * Gets the URL used as the base for all cloud service requests. + * + * @return the BaseUrl object. */ - String getBaseUri(); + AutoRestBaseUrl getBaseUrl(); /** * Gets the list of interceptors the OkHttp client will execute. diff --git a/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/azureparametergrouping/AutoRestParameterGroupingTestServiceImpl.java b/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/azureparametergrouping/AutoRestParameterGroupingTestServiceImpl.java index b0af0732e0..c9f66c75eb 100644 --- a/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/azureparametergrouping/AutoRestParameterGroupingTestServiceImpl.java +++ b/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/azureparametergrouping/AutoRestParameterGroupingTestServiceImpl.java @@ -13,6 +13,7 @@ import com.microsoft.azure.AzureClient; import com.microsoft.azure.AzureServiceClient; import com.microsoft.azure.CustomHeaderInterceptor; +import com.microsoft.rest.AutoRestBaseUrl; import com.microsoft.rest.credentials.ServiceClientCredentials; import java.util.UUID; import okhttp3.OkHttpClient; @@ -22,17 +23,18 @@ * Initializes a new instance of the AutoRestParameterGroupingTestService class. */ public final class AutoRestParameterGroupingTestServiceImpl extends AzureServiceClient implements AutoRestParameterGroupingTestService { - /** The URI used as the base for all cloud service requests. */ - private final String baseUri; + /** The URL used as the base for all cloud service requests. */ + private final AutoRestBaseUrl baseUrl; /** the {@link AzureClient} used for long running operations. */ private AzureClient azureClient; /** - * Gets the URI used as the base for all cloud service requests. - * @return The BaseUri value. + * Gets the URL used as the base for all cloud service requests. + * + * @return The BaseUrl value. */ - public String getBaseUri() { - return this.baseUri; + public AutoRestBaseUrl getBaseUrl() { + return this.baseUrl; } /** @@ -136,10 +138,10 @@ public AutoRestParameterGroupingTestServiceImpl() { /** * Initializes an instance of AutoRestParameterGroupingTestService client. * - * @param baseUri the base URI of the host + * @param baseUrl the base URL of the host */ - public AutoRestParameterGroupingTestServiceImpl(String baseUri) { - this(baseUri, null); + public AutoRestParameterGroupingTestServiceImpl(String baseUrl) { + this(baseUrl, null); } /** @@ -154,12 +156,12 @@ public AutoRestParameterGroupingTestServiceImpl(ServiceClientCredentials credent /** * Initializes an instance of AutoRestParameterGroupingTestService client. * - * @param baseUri the base URI of the host + * @param baseUrl the base URL of the host * @param credentials the management credentials for Azure */ - public AutoRestParameterGroupingTestServiceImpl(String baseUri, ServiceClientCredentials credentials) { + public AutoRestParameterGroupingTestServiceImpl(String baseUrl, ServiceClientCredentials credentials) { super(); - this.baseUri = baseUri; + this.baseUrl = new AutoRestBaseUrl(baseUrl); this.credentials = credentials; initialize(); } @@ -167,14 +169,14 @@ public AutoRestParameterGroupingTestServiceImpl(String baseUri, ServiceClientCre /** * Initializes an instance of AutoRestParameterGroupingTestService client. * - * @param baseUri the base URI of the host + * @param baseUrl the base URL of the host * @param credentials the management credentials for Azure * @param clientBuilder the builder for building up an {@link OkHttpClient} * @param retrofitBuilder the builder for building up a {@link Retrofit} */ - public AutoRestParameterGroupingTestServiceImpl(String baseUri, ServiceClientCredentials credentials, OkHttpClient.Builder clientBuilder, Retrofit.Builder retrofitBuilder) { + public AutoRestParameterGroupingTestServiceImpl(String baseUrl, ServiceClientCredentials credentials, OkHttpClient.Builder clientBuilder, Retrofit.Builder retrofitBuilder) { super(clientBuilder, retrofitBuilder); - this.baseUri = baseUri; + this.baseUrl = new AutoRestBaseUrl(baseUrl); this.credentials = credentials; initialize(); } @@ -191,6 +193,6 @@ protected void initialize() { super.initialize(); this.azureClient = new AzureClient(clientBuilder, retrofitBuilder); this.azureClient.setCredentials(this.credentials); - this.retrofitBuilder.baseUrl(baseUri); + this.retrofitBuilder.baseUrl(baseUrl); } } diff --git a/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/azurereport/AutoRestReportServiceForAzure.java b/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/azurereport/AutoRestReportServiceForAzure.java index 5f1aaaabb6..637a98901e 100644 --- a/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/azurereport/AutoRestReportServiceForAzure.java +++ b/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/azurereport/AutoRestReportServiceForAzure.java @@ -11,6 +11,7 @@ package fixtures.azurereport; import com.microsoft.azure.AzureClient; +import com.microsoft.rest.AutoRestBaseUrl; import com.microsoft.rest.credentials.ServiceClientCredentials; import com.microsoft.rest.serializer.JacksonMapperAdapter; import com.microsoft.rest.ServiceCallback; @@ -32,10 +33,11 @@ */ public interface AutoRestReportServiceForAzure { /** - * Gets the URI used as the base for all cloud service requests. - * @return The BaseUri value. + * Gets the URL used as the base for all cloud service requests. + * + * @return the BaseUrl object. */ - String getBaseUri(); + AutoRestBaseUrl getBaseUrl(); /** * Gets the list of interceptors the OkHttp client will execute. diff --git a/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/azurereport/AutoRestReportServiceForAzureImpl.java b/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/azurereport/AutoRestReportServiceForAzureImpl.java index bc04481420..18c2e2c31e 100644 --- a/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/azurereport/AutoRestReportServiceForAzureImpl.java +++ b/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/azurereport/AutoRestReportServiceForAzureImpl.java @@ -15,6 +15,7 @@ import com.microsoft.azure.AzureServiceClient; import com.microsoft.azure.AzureServiceResponseBuilder; import com.microsoft.azure.CustomHeaderInterceptor; +import com.microsoft.rest.AutoRestBaseUrl; import com.microsoft.rest.credentials.ServiceClientCredentials; import com.microsoft.rest.ServiceCallback; import com.microsoft.rest.ServiceResponse; @@ -36,17 +37,18 @@ public final class AutoRestReportServiceForAzureImpl extends AzureServiceClient implements AutoRestReportServiceForAzure { /** The Retrofit service to perform REST calls. */ private AutoRestReportServiceForAzureService service; - /** The URI used as the base for all cloud service requests. */ - private final String baseUri; + /** The URL used as the base for all cloud service requests. */ + private final AutoRestBaseUrl baseUrl; /** the {@link AzureClient} used for long running operations. */ private AzureClient azureClient; /** - * Gets the URI used as the base for all cloud service requests. - * @return The BaseUri value. + * Gets the URL used as the base for all cloud service requests. + * + * @return The BaseUrl value. */ - public String getBaseUri() { - return this.baseUri; + public AutoRestBaseUrl getBaseUrl() { + return this.baseUrl; } /** @@ -142,10 +144,10 @@ public AutoRestReportServiceForAzureImpl() { /** * Initializes an instance of AutoRestReportServiceForAzure client. * - * @param baseUri the base URI of the host + * @param baseUrl the base URL of the host */ - public AutoRestReportServiceForAzureImpl(String baseUri) { - this(baseUri, null); + public AutoRestReportServiceForAzureImpl(String baseUrl) { + this(baseUrl, null); } /** @@ -160,12 +162,12 @@ public AutoRestReportServiceForAzureImpl(ServiceClientCredentials credentials) { /** * Initializes an instance of AutoRestReportServiceForAzure client. * - * @param baseUri the base URI of the host + * @param baseUrl the base URL of the host * @param credentials the management credentials for Azure */ - public AutoRestReportServiceForAzureImpl(String baseUri, ServiceClientCredentials credentials) { + public AutoRestReportServiceForAzureImpl(String baseUrl, ServiceClientCredentials credentials) { super(); - this.baseUri = baseUri; + this.baseUrl = new AutoRestBaseUrl(baseUrl); this.credentials = credentials; initialize(); } @@ -173,14 +175,14 @@ public AutoRestReportServiceForAzureImpl(String baseUri, ServiceClientCredential /** * Initializes an instance of AutoRestReportServiceForAzure client. * - * @param baseUri the base URI of the host + * @param baseUrl the base URL of the host * @param credentials the management credentials for Azure * @param clientBuilder the builder for building up an {@link OkHttpClient} * @param retrofitBuilder the builder for building up a {@link Retrofit} */ - public AutoRestReportServiceForAzureImpl(String baseUri, ServiceClientCredentials credentials, OkHttpClient.Builder clientBuilder, Retrofit.Builder retrofitBuilder) { + public AutoRestReportServiceForAzureImpl(String baseUrl, ServiceClientCredentials credentials, OkHttpClient.Builder clientBuilder, Retrofit.Builder retrofitBuilder) { super(clientBuilder, retrofitBuilder); - this.baseUri = baseUri; + this.baseUrl = new AutoRestBaseUrl(baseUrl); this.credentials = credentials; initialize(); } @@ -197,7 +199,7 @@ protected void initialize() { super.initialize(); this.azureClient = new AzureClient(clientBuilder, retrofitBuilder); this.azureClient.setCredentials(this.credentials); - this.retrofitBuilder.baseUrl(baseUri); + this.retrofitBuilder.baseUrl(baseUrl); initializeService(); } diff --git a/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/azurespecials/AutoRestAzureSpecialParametersTestClient.java b/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/azurespecials/AutoRestAzureSpecialParametersTestClient.java index e87fc54d3e..16589ace1e 100644 --- a/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/azurespecials/AutoRestAzureSpecialParametersTestClient.java +++ b/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/azurespecials/AutoRestAzureSpecialParametersTestClient.java @@ -11,6 +11,7 @@ package fixtures.azurespecials; import com.microsoft.azure.AzureClient; +import com.microsoft.rest.AutoRestBaseUrl; import com.microsoft.rest.credentials.ServiceClientCredentials; import com.microsoft.rest.serializer.JacksonMapperAdapter; import java.util.List; @@ -22,10 +23,11 @@ */ public interface AutoRestAzureSpecialParametersTestClient { /** - * Gets the URI used as the base for all cloud service requests. - * @return The BaseUri value. + * Gets the URL used as the base for all cloud service requests. + * + * @return the BaseUrl object. */ - String getBaseUri(); + AutoRestBaseUrl getBaseUrl(); /** * Gets the list of interceptors the OkHttp client will execute. diff --git a/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/azurespecials/AutoRestAzureSpecialParametersTestClientImpl.java b/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/azurespecials/AutoRestAzureSpecialParametersTestClientImpl.java index b7c2d2c44b..28d319a3dc 100644 --- a/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/azurespecials/AutoRestAzureSpecialParametersTestClientImpl.java +++ b/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/azurespecials/AutoRestAzureSpecialParametersTestClientImpl.java @@ -13,6 +13,7 @@ import com.microsoft.azure.AzureClient; import com.microsoft.azure.AzureServiceClient; import com.microsoft.azure.CustomHeaderInterceptor; +import com.microsoft.rest.AutoRestBaseUrl; import com.microsoft.rest.credentials.ServiceClientCredentials; import java.util.UUID; import okhttp3.OkHttpClient; @@ -22,17 +23,18 @@ * Initializes a new instance of the AutoRestAzureSpecialParametersTestClient class. */ public final class AutoRestAzureSpecialParametersTestClientImpl extends AzureServiceClient implements AutoRestAzureSpecialParametersTestClient { - /** The URI used as the base for all cloud service requests. */ - private final String baseUri; + /** The URL used as the base for all cloud service requests. */ + private final AutoRestBaseUrl baseUrl; /** the {@link AzureClient} used for long running operations. */ private AzureClient azureClient; /** - * Gets the URI used as the base for all cloud service requests. - * @return The BaseUri value. + * Gets the URL used as the base for all cloud service requests. + * + * @return The BaseUrl value. */ - public String getBaseUri() { - return this.baseUri; + public AutoRestBaseUrl getBaseUrl() { + return this.baseUrl; } /** @@ -225,10 +227,10 @@ public AutoRestAzureSpecialParametersTestClientImpl() { /** * Initializes an instance of AutoRestAzureSpecialParametersTestClient client. * - * @param baseUri the base URI of the host + * @param baseUrl the base URL of the host */ - public AutoRestAzureSpecialParametersTestClientImpl(String baseUri) { - this(baseUri, null); + public AutoRestAzureSpecialParametersTestClientImpl(String baseUrl) { + this(baseUrl, null); } /** @@ -243,12 +245,12 @@ public AutoRestAzureSpecialParametersTestClientImpl(ServiceClientCredentials cre /** * Initializes an instance of AutoRestAzureSpecialParametersTestClient client. * - * @param baseUri the base URI of the host + * @param baseUrl the base URL of the host * @param credentials the management credentials for Azure */ - public AutoRestAzureSpecialParametersTestClientImpl(String baseUri, ServiceClientCredentials credentials) { + public AutoRestAzureSpecialParametersTestClientImpl(String baseUrl, ServiceClientCredentials credentials) { super(); - this.baseUri = baseUri; + this.baseUrl = new AutoRestBaseUrl(baseUrl); this.credentials = credentials; initialize(); } @@ -256,14 +258,14 @@ public AutoRestAzureSpecialParametersTestClientImpl(String baseUri, ServiceClien /** * Initializes an instance of AutoRestAzureSpecialParametersTestClient client. * - * @param baseUri the base URI of the host + * @param baseUrl the base URL of the host * @param credentials the management credentials for Azure * @param clientBuilder the builder for building up an {@link OkHttpClient} * @param retrofitBuilder the builder for building up a {@link Retrofit} */ - public AutoRestAzureSpecialParametersTestClientImpl(String baseUri, ServiceClientCredentials credentials, OkHttpClient.Builder clientBuilder, Retrofit.Builder retrofitBuilder) { + public AutoRestAzureSpecialParametersTestClientImpl(String baseUrl, ServiceClientCredentials credentials, OkHttpClient.Builder clientBuilder, Retrofit.Builder retrofitBuilder) { super(clientBuilder, retrofitBuilder); - this.baseUri = baseUri; + this.baseUrl = new AutoRestBaseUrl(baseUrl); this.credentials = credentials; initialize(); } @@ -281,6 +283,6 @@ protected void initialize() { super.initialize(); this.azureClient = new AzureClient(clientBuilder, retrofitBuilder); this.azureClient.setCredentials(this.credentials); - this.retrofitBuilder.baseUrl(baseUri); + this.retrofitBuilder.baseUrl(baseUrl); } } diff --git a/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/custombaseuri/AutoRestParameterizedHostTestClient.java b/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/custombaseuri/AutoRestParameterizedHostTestClient.java index 8e9899a594..02ebd705bc 100644 --- a/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/custombaseuri/AutoRestParameterizedHostTestClient.java +++ b/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/custombaseuri/AutoRestParameterizedHostTestClient.java @@ -11,6 +11,7 @@ package fixtures.custombaseuri; import com.microsoft.azure.AzureClient; +import com.microsoft.rest.AutoRestBaseUrl; import com.microsoft.rest.credentials.ServiceClientCredentials; import com.microsoft.rest.serializer.JacksonMapperAdapter; import java.util.List; @@ -22,10 +23,11 @@ */ public interface AutoRestParameterizedHostTestClient { /** - * Gets the URI used as the base for all cloud service requests. - * @return The BaseUri value. + * Gets the URL used as the base for all cloud service requests. + * + * @return the BaseUrl object. */ - String getBaseUri(); + AutoRestBaseUrl getBaseUrl(); /** * Gets the list of interceptors the OkHttp client will execute. diff --git a/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/custombaseuri/AutoRestParameterizedHostTestClientImpl.java b/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/custombaseuri/AutoRestParameterizedHostTestClientImpl.java index 5f5e5332e7..70e1b42e6e 100644 --- a/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/custombaseuri/AutoRestParameterizedHostTestClientImpl.java +++ b/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/custombaseuri/AutoRestParameterizedHostTestClientImpl.java @@ -13,6 +13,7 @@ import com.microsoft.azure.AzureClient; import com.microsoft.azure.AzureServiceClient; import com.microsoft.azure.CustomHeaderInterceptor; +import com.microsoft.rest.AutoRestBaseUrl; import com.microsoft.rest.credentials.ServiceClientCredentials; import java.util.UUID; import okhttp3.OkHttpClient; @@ -22,17 +23,18 @@ * Initializes a new instance of the AutoRestParameterizedHostTestClient class. */ public final class AutoRestParameterizedHostTestClientImpl extends AzureServiceClient implements AutoRestParameterizedHostTestClient { - /** The URI used as the base for all cloud service requests. */ - private final String baseUri; + /** The URL used as the base for all cloud service requests. */ + private final AutoRestBaseUrl baseUrl; /** the {@link AzureClient} used for long running operations. */ private AzureClient azureClient; /** - * Gets the URI used as the base for all cloud service requests. - * @return The BaseUri value. + * Gets the URL used as the base for all cloud service requests. + * + * @return The BaseUrl value. */ - public String getBaseUri() { - return this.baseUri; + public AutoRestBaseUrl getBaseUrl() { + return this.baseUrl; } /** @@ -157,10 +159,10 @@ public AutoRestParameterizedHostTestClientImpl() { /** * Initializes an instance of AutoRestParameterizedHostTestClient client. * - * @param baseUri the base URI of the host + * @param baseUrl the base URL of the host */ - private AutoRestParameterizedHostTestClientImpl(String baseUri) { - this(baseUri, null); + private AutoRestParameterizedHostTestClientImpl(String baseUrl) { + this(baseUrl, null); } /** @@ -175,12 +177,12 @@ public AutoRestParameterizedHostTestClientImpl(ServiceClientCredentials credenti /** * Initializes an instance of AutoRestParameterizedHostTestClient client. * - * @param baseUri the base URI of the host + * @param baseUrl the base URL of the host * @param credentials the management credentials for Azure */ - private AutoRestParameterizedHostTestClientImpl(String baseUri, ServiceClientCredentials credentials) { + private AutoRestParameterizedHostTestClientImpl(String baseUrl, ServiceClientCredentials credentials) { super(); - this.baseUri = baseUri; + this.baseUrl = new AutoRestBaseUrl(baseUrl); this.credentials = credentials; initialize(); } @@ -189,12 +191,12 @@ private AutoRestParameterizedHostTestClientImpl(String baseUri, ServiceClientCre * Initializes an instance of AutoRestParameterizedHostTestClient client. * * @param credentials the management credentials for Azure - * @param client the {@link OkHttpClient} client to use for REST calls + * @param clientBuilder the builder for building up an {@link OkHttpClient} * @param retrofitBuilder the builder for building up a {@link Retrofit} */ - public AutoRestParameterizedHostTestClientImpl(ServiceClientCredentials credentials, OkHttpClient client, Retrofit.Builder retrofitBuilder) { - super(client, retrofitBuilder); - this.baseUri = "http://{accountName}{host}"; + public AutoRestParameterizedHostTestClientImpl(ServiceClientCredentials credentials, OkHttpClient.Builder clientBuilder, Retrofit.Builder retrofitBuilder) { + super(clientBuilder, retrofitBuilder); + this.baseUrl = new AutoRestBaseUrl("http://{accountName}{host}"); this.credentials = credentials; initialize(); } @@ -212,6 +214,6 @@ protected void initialize() { super.initialize(); this.azureClient = new AzureClient(clientBuilder, retrofitBuilder); this.azureClient.setCredentials(this.credentials); - this.retrofitBuilder.baseUrl(baseUri); + this.retrofitBuilder.baseUrl(baseUrl); } } diff --git a/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/custombaseuri/PathsOperations.java b/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/custombaseuri/PathsOperations.java index 72c993e6d8..3d46012f18 100644 --- a/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/custombaseuri/PathsOperations.java +++ b/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/custombaseuri/PathsOperations.java @@ -19,7 +19,6 @@ import retrofit2.http.GET; import retrofit2.http.Header; import retrofit2.http.Headers; -import retrofit2.http.Path; /** * An instance of this class provides access to all the operations defined @@ -33,7 +32,7 @@ public interface PathsOperations { interface PathsService { @Headers("Content-Type: application/json; charset=utf-8") @GET("customuri") - Call getEmpty(@Path("accountName") String accountName, @Path("host") String host, @Header("accept-language") String acceptLanguage); + Call getEmpty(@Header("accept-language") String acceptLanguage); } /** diff --git a/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/custombaseuri/PathsOperationsImpl.java b/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/custombaseuri/PathsOperationsImpl.java index 11e276041b..f238e77183 100644 --- a/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/custombaseuri/PathsOperationsImpl.java +++ b/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/custombaseuri/PathsOperationsImpl.java @@ -59,7 +59,9 @@ public ServiceResponse getEmpty(String accountName) throws ErrorException, if (this.client.getHost() == null) { throw new IllegalArgumentException("Parameter this.client.getHost() is required and cannot be null."); } - Call call = service.getEmpty(accountName, this.client.getHost(), this.client.getAcceptLanguage()); + client.getBaseUrl().set("{accountName}", accountName); + client.getBaseUrl().set("{host}", this.client.getHost()); + Call call = service.getEmpty(this.client.getAcceptLanguage()); return getEmptyDelegate(call.execute()); } @@ -79,7 +81,9 @@ public Call getEmptyAsync(String accountName, final ServiceCallbac serviceCallback.failure(new IllegalArgumentException("Parameter this.client.getHost() is required and cannot be null.")); return null; } - Call call = service.getEmpty(accountName, this.client.getHost(), this.client.getAcceptLanguage()); + client.getBaseUrl().set("{accountName}", accountName); + client.getBaseUrl().set("{host}", this.client.getHost()); + Call call = service.getEmpty(this.client.getAcceptLanguage()); call.enqueue(new ServiceResponseCallback(serviceCallback) { @Override public void onResponse(Call call, Response response) { diff --git a/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/head/AutoRestHeadTestService.java b/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/head/AutoRestHeadTestService.java index c10beaff5d..96dd3b3df2 100644 --- a/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/head/AutoRestHeadTestService.java +++ b/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/head/AutoRestHeadTestService.java @@ -11,6 +11,7 @@ package fixtures.head; import com.microsoft.azure.AzureClient; +import com.microsoft.rest.AutoRestBaseUrl; import com.microsoft.rest.credentials.ServiceClientCredentials; import com.microsoft.rest.serializer.JacksonMapperAdapter; import java.util.List; @@ -22,10 +23,11 @@ */ public interface AutoRestHeadTestService { /** - * Gets the URI used as the base for all cloud service requests. - * @return The BaseUri value. + * Gets the URL used as the base for all cloud service requests. + * + * @return the BaseUrl object. */ - String getBaseUri(); + AutoRestBaseUrl getBaseUrl(); /** * Gets the list of interceptors the OkHttp client will execute. diff --git a/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/head/AutoRestHeadTestServiceImpl.java b/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/head/AutoRestHeadTestServiceImpl.java index 15a80d835d..8cfd3f08a3 100644 --- a/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/head/AutoRestHeadTestServiceImpl.java +++ b/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/head/AutoRestHeadTestServiceImpl.java @@ -13,6 +13,7 @@ import com.microsoft.azure.AzureClient; import com.microsoft.azure.AzureServiceClient; import com.microsoft.azure.CustomHeaderInterceptor; +import com.microsoft.rest.AutoRestBaseUrl; import com.microsoft.rest.credentials.ServiceClientCredentials; import java.util.UUID; import okhttp3.OkHttpClient; @@ -22,17 +23,18 @@ * Initializes a new instance of the AutoRestHeadTestService class. */ public final class AutoRestHeadTestServiceImpl extends AzureServiceClient implements AutoRestHeadTestService { - /** The URI used as the base for all cloud service requests. */ - private final String baseUri; + /** The URL used as the base for all cloud service requests. */ + private final AutoRestBaseUrl baseUrl; /** the {@link AzureClient} used for long running operations. */ private AzureClient azureClient; /** - * Gets the URI used as the base for all cloud service requests. - * @return The BaseUri value. + * Gets the URL used as the base for all cloud service requests. + * + * @return The BaseUrl value. */ - public String getBaseUri() { - return this.baseUri; + public AutoRestBaseUrl getBaseUrl() { + return this.baseUrl; } /** @@ -136,10 +138,10 @@ public AutoRestHeadTestServiceImpl() { /** * Initializes an instance of AutoRestHeadTestService client. * - * @param baseUri the base URI of the host + * @param baseUrl the base URL of the host */ - public AutoRestHeadTestServiceImpl(String baseUri) { - this(baseUri, null); + public AutoRestHeadTestServiceImpl(String baseUrl) { + this(baseUrl, null); } /** @@ -154,12 +156,12 @@ public AutoRestHeadTestServiceImpl(ServiceClientCredentials credentials) { /** * Initializes an instance of AutoRestHeadTestService client. * - * @param baseUri the base URI of the host + * @param baseUrl the base URL of the host * @param credentials the management credentials for Azure */ - public AutoRestHeadTestServiceImpl(String baseUri, ServiceClientCredentials credentials) { + public AutoRestHeadTestServiceImpl(String baseUrl, ServiceClientCredentials credentials) { super(); - this.baseUri = baseUri; + this.baseUrl = new AutoRestBaseUrl(baseUrl); this.credentials = credentials; initialize(); } @@ -167,14 +169,14 @@ public AutoRestHeadTestServiceImpl(String baseUri, ServiceClientCredentials cred /** * Initializes an instance of AutoRestHeadTestService client. * - * @param baseUri the base URI of the host + * @param baseUrl the base URL of the host * @param credentials the management credentials for Azure * @param clientBuilder the builder for building up an {@link OkHttpClient} * @param retrofitBuilder the builder for building up a {@link Retrofit} */ - public AutoRestHeadTestServiceImpl(String baseUri, ServiceClientCredentials credentials, OkHttpClient.Builder clientBuilder, Retrofit.Builder retrofitBuilder) { + public AutoRestHeadTestServiceImpl(String baseUrl, ServiceClientCredentials credentials, OkHttpClient.Builder clientBuilder, Retrofit.Builder retrofitBuilder) { super(clientBuilder, retrofitBuilder); - this.baseUri = baseUri; + this.baseUrl = new AutoRestBaseUrl(baseUrl); this.credentials = credentials; initialize(); } @@ -191,6 +193,6 @@ protected void initialize() { super.initialize(); this.azureClient = new AzureClient(clientBuilder, retrofitBuilder); this.azureClient.setCredentials(this.credentials); - this.retrofitBuilder.baseUrl(baseUri); + this.retrofitBuilder.baseUrl(baseUrl); } } diff --git a/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/headexceptions/AutoRestHeadExceptionTestService.java b/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/headexceptions/AutoRestHeadExceptionTestService.java index 1dd32c64cd..f8508d9a92 100644 --- a/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/headexceptions/AutoRestHeadExceptionTestService.java +++ b/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/headexceptions/AutoRestHeadExceptionTestService.java @@ -11,6 +11,7 @@ package fixtures.headexceptions; import com.microsoft.azure.AzureClient; +import com.microsoft.rest.AutoRestBaseUrl; import com.microsoft.rest.credentials.ServiceClientCredentials; import com.microsoft.rest.serializer.JacksonMapperAdapter; import java.util.List; @@ -22,10 +23,11 @@ */ public interface AutoRestHeadExceptionTestService { /** - * Gets the URI used as the base for all cloud service requests. - * @return The BaseUri value. + * Gets the URL used as the base for all cloud service requests. + * + * @return the BaseUrl object. */ - String getBaseUri(); + AutoRestBaseUrl getBaseUrl(); /** * Gets the list of interceptors the OkHttp client will execute. diff --git a/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/headexceptions/AutoRestHeadExceptionTestServiceImpl.java b/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/headexceptions/AutoRestHeadExceptionTestServiceImpl.java index d70d01dd48..5a6a68d03b 100644 --- a/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/headexceptions/AutoRestHeadExceptionTestServiceImpl.java +++ b/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/headexceptions/AutoRestHeadExceptionTestServiceImpl.java @@ -13,6 +13,7 @@ import com.microsoft.azure.AzureClient; import com.microsoft.azure.AzureServiceClient; import com.microsoft.azure.CustomHeaderInterceptor; +import com.microsoft.rest.AutoRestBaseUrl; import com.microsoft.rest.credentials.ServiceClientCredentials; import java.util.UUID; import okhttp3.OkHttpClient; @@ -22,17 +23,18 @@ * Initializes a new instance of the AutoRestHeadExceptionTestService class. */ public final class AutoRestHeadExceptionTestServiceImpl extends AzureServiceClient implements AutoRestHeadExceptionTestService { - /** The URI used as the base for all cloud service requests. */ - private final String baseUri; + /** The URL used as the base for all cloud service requests. */ + private final AutoRestBaseUrl baseUrl; /** the {@link AzureClient} used for long running operations. */ private AzureClient azureClient; /** - * Gets the URI used as the base for all cloud service requests. - * @return The BaseUri value. + * Gets the URL used as the base for all cloud service requests. + * + * @return The BaseUrl value. */ - public String getBaseUri() { - return this.baseUri; + public AutoRestBaseUrl getBaseUrl() { + return this.baseUrl; } /** @@ -136,10 +138,10 @@ public AutoRestHeadExceptionTestServiceImpl() { /** * Initializes an instance of AutoRestHeadExceptionTestService client. * - * @param baseUri the base URI of the host + * @param baseUrl the base URL of the host */ - public AutoRestHeadExceptionTestServiceImpl(String baseUri) { - this(baseUri, null); + public AutoRestHeadExceptionTestServiceImpl(String baseUrl) { + this(baseUrl, null); } /** @@ -154,12 +156,12 @@ public AutoRestHeadExceptionTestServiceImpl(ServiceClientCredentials credentials /** * Initializes an instance of AutoRestHeadExceptionTestService client. * - * @param baseUri the base URI of the host + * @param baseUrl the base URL of the host * @param credentials the management credentials for Azure */ - public AutoRestHeadExceptionTestServiceImpl(String baseUri, ServiceClientCredentials credentials) { + public AutoRestHeadExceptionTestServiceImpl(String baseUrl, ServiceClientCredentials credentials) { super(); - this.baseUri = baseUri; + this.baseUrl = new AutoRestBaseUrl(baseUrl); this.credentials = credentials; initialize(); } @@ -167,14 +169,14 @@ public AutoRestHeadExceptionTestServiceImpl(String baseUri, ServiceClientCredent /** * Initializes an instance of AutoRestHeadExceptionTestService client. * - * @param baseUri the base URI of the host + * @param baseUrl the base URL of the host * @param credentials the management credentials for Azure * @param clientBuilder the builder for building up an {@link OkHttpClient} * @param retrofitBuilder the builder for building up a {@link Retrofit} */ - public AutoRestHeadExceptionTestServiceImpl(String baseUri, ServiceClientCredentials credentials, OkHttpClient.Builder clientBuilder, Retrofit.Builder retrofitBuilder) { + public AutoRestHeadExceptionTestServiceImpl(String baseUrl, ServiceClientCredentials credentials, OkHttpClient.Builder clientBuilder, Retrofit.Builder retrofitBuilder) { super(clientBuilder, retrofitBuilder); - this.baseUri = baseUri; + this.baseUrl = new AutoRestBaseUrl(baseUrl); this.credentials = credentials; initialize(); } @@ -191,6 +193,6 @@ protected void initialize() { super.initialize(); this.azureClient = new AzureClient(clientBuilder, retrofitBuilder); this.azureClient.setCredentials(this.credentials); - this.retrofitBuilder.baseUrl(baseUri); + this.retrofitBuilder.baseUrl(baseUrl); } } diff --git a/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/lro/AutoRestLongRunningOperationTestService.java b/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/lro/AutoRestLongRunningOperationTestService.java index aa65569aeb..5995142bf9 100644 --- a/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/lro/AutoRestLongRunningOperationTestService.java +++ b/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/lro/AutoRestLongRunningOperationTestService.java @@ -11,6 +11,7 @@ package fixtures.lro; import com.microsoft.azure.AzureClient; +import com.microsoft.rest.AutoRestBaseUrl; import com.microsoft.rest.credentials.ServiceClientCredentials; import com.microsoft.rest.serializer.JacksonMapperAdapter; import java.util.List; @@ -22,10 +23,11 @@ */ public interface AutoRestLongRunningOperationTestService { /** - * Gets the URI used as the base for all cloud service requests. - * @return The BaseUri value. + * Gets the URL used as the base for all cloud service requests. + * + * @return the BaseUrl object. */ - String getBaseUri(); + AutoRestBaseUrl getBaseUrl(); /** * Gets the list of interceptors the OkHttp client will execute. diff --git a/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/lro/AutoRestLongRunningOperationTestServiceImpl.java b/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/lro/AutoRestLongRunningOperationTestServiceImpl.java index c25d2ff1a4..2cac31f8b5 100644 --- a/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/lro/AutoRestLongRunningOperationTestServiceImpl.java +++ b/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/lro/AutoRestLongRunningOperationTestServiceImpl.java @@ -13,6 +13,7 @@ import com.microsoft.azure.AzureClient; import com.microsoft.azure.AzureServiceClient; import com.microsoft.azure.CustomHeaderInterceptor; +import com.microsoft.rest.AutoRestBaseUrl; import com.microsoft.rest.credentials.ServiceClientCredentials; import java.util.UUID; import okhttp3.OkHttpClient; @@ -22,17 +23,18 @@ * Initializes a new instance of the AutoRestLongRunningOperationTestService class. */ public final class AutoRestLongRunningOperationTestServiceImpl extends AzureServiceClient implements AutoRestLongRunningOperationTestService { - /** The URI used as the base for all cloud service requests. */ - private final String baseUri; + /** The URL used as the base for all cloud service requests. */ + private final AutoRestBaseUrl baseUrl; /** the {@link AzureClient} used for long running operations. */ private AzureClient azureClient; /** - * Gets the URI used as the base for all cloud service requests. - * @return The BaseUri value. + * Gets the URL used as the base for all cloud service requests. + * + * @return The BaseUrl value. */ - public String getBaseUri() { - return this.baseUri; + public AutoRestBaseUrl getBaseUrl() { + return this.baseUrl; } /** @@ -160,10 +162,10 @@ public AutoRestLongRunningOperationTestServiceImpl() { /** * Initializes an instance of AutoRestLongRunningOperationTestService client. * - * @param baseUri the base URI of the host + * @param baseUrl the base URL of the host */ - public AutoRestLongRunningOperationTestServiceImpl(String baseUri) { - this(baseUri, null); + public AutoRestLongRunningOperationTestServiceImpl(String baseUrl) { + this(baseUrl, null); } /** @@ -178,12 +180,12 @@ public AutoRestLongRunningOperationTestServiceImpl(ServiceClientCredentials cred /** * Initializes an instance of AutoRestLongRunningOperationTestService client. * - * @param baseUri the base URI of the host + * @param baseUrl the base URL of the host * @param credentials the management credentials for Azure */ - public AutoRestLongRunningOperationTestServiceImpl(String baseUri, ServiceClientCredentials credentials) { + public AutoRestLongRunningOperationTestServiceImpl(String baseUrl, ServiceClientCredentials credentials) { super(); - this.baseUri = baseUri; + this.baseUrl = new AutoRestBaseUrl(baseUrl); this.credentials = credentials; initialize(); } @@ -191,14 +193,14 @@ public AutoRestLongRunningOperationTestServiceImpl(String baseUri, ServiceClient /** * Initializes an instance of AutoRestLongRunningOperationTestService client. * - * @param baseUri the base URI of the host + * @param baseUrl the base URL of the host * @param credentials the management credentials for Azure * @param clientBuilder the builder for building up an {@link OkHttpClient} * @param retrofitBuilder the builder for building up a {@link Retrofit} */ - public AutoRestLongRunningOperationTestServiceImpl(String baseUri, ServiceClientCredentials credentials, OkHttpClient.Builder clientBuilder, Retrofit.Builder retrofitBuilder) { + public AutoRestLongRunningOperationTestServiceImpl(String baseUrl, ServiceClientCredentials credentials, OkHttpClient.Builder clientBuilder, Retrofit.Builder retrofitBuilder) { super(clientBuilder, retrofitBuilder); - this.baseUri = baseUri; + this.baseUrl = new AutoRestBaseUrl(baseUrl); this.credentials = credentials; initialize(); } @@ -215,6 +217,6 @@ protected void initialize() { super.initialize(); this.azureClient = new AzureClient(clientBuilder, retrofitBuilder); this.azureClient.setCredentials(this.credentials); - this.retrofitBuilder.baseUrl(baseUri); + this.retrofitBuilder.baseUrl(baseUrl); } } diff --git a/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/paging/AutoRestPagingTestService.java b/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/paging/AutoRestPagingTestService.java index 6ae7316a7a..7e52f4b783 100644 --- a/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/paging/AutoRestPagingTestService.java +++ b/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/paging/AutoRestPagingTestService.java @@ -11,6 +11,7 @@ package fixtures.paging; import com.microsoft.azure.AzureClient; +import com.microsoft.rest.AutoRestBaseUrl; import com.microsoft.rest.credentials.ServiceClientCredentials; import com.microsoft.rest.serializer.JacksonMapperAdapter; import java.util.List; @@ -22,10 +23,11 @@ */ public interface AutoRestPagingTestService { /** - * Gets the URI used as the base for all cloud service requests. - * @return The BaseUri value. + * Gets the URL used as the base for all cloud service requests. + * + * @return the BaseUrl object. */ - String getBaseUri(); + AutoRestBaseUrl getBaseUrl(); /** * Gets the list of interceptors the OkHttp client will execute. diff --git a/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/paging/AutoRestPagingTestServiceImpl.java b/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/paging/AutoRestPagingTestServiceImpl.java index cf17e74115..2500abb523 100644 --- a/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/paging/AutoRestPagingTestServiceImpl.java +++ b/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/paging/AutoRestPagingTestServiceImpl.java @@ -13,6 +13,7 @@ import com.microsoft.azure.AzureClient; import com.microsoft.azure.AzureServiceClient; import com.microsoft.azure.CustomHeaderInterceptor; +import com.microsoft.rest.AutoRestBaseUrl; import com.microsoft.rest.credentials.ServiceClientCredentials; import java.util.UUID; import okhttp3.OkHttpClient; @@ -22,17 +23,18 @@ * Initializes a new instance of the AutoRestPagingTestService class. */ public final class AutoRestPagingTestServiceImpl extends AzureServiceClient implements AutoRestPagingTestService { - /** The URI used as the base for all cloud service requests. */ - private final String baseUri; + /** The URL used as the base for all cloud service requests. */ + private final AutoRestBaseUrl baseUrl; /** the {@link AzureClient} used for long running operations. */ private AzureClient azureClient; /** - * Gets the URI used as the base for all cloud service requests. - * @return The BaseUri value. + * Gets the URL used as the base for all cloud service requests. + * + * @return The BaseUrl value. */ - public String getBaseUri() { - return this.baseUri; + public AutoRestBaseUrl getBaseUrl() { + return this.baseUrl; } /** @@ -136,10 +138,10 @@ public AutoRestPagingTestServiceImpl() { /** * Initializes an instance of AutoRestPagingTestService client. * - * @param baseUri the base URI of the host + * @param baseUrl the base URL of the host */ - public AutoRestPagingTestServiceImpl(String baseUri) { - this(baseUri, null); + public AutoRestPagingTestServiceImpl(String baseUrl) { + this(baseUrl, null); } /** @@ -154,12 +156,12 @@ public AutoRestPagingTestServiceImpl(ServiceClientCredentials credentials) { /** * Initializes an instance of AutoRestPagingTestService client. * - * @param baseUri the base URI of the host + * @param baseUrl the base URL of the host * @param credentials the management credentials for Azure */ - public AutoRestPagingTestServiceImpl(String baseUri, ServiceClientCredentials credentials) { + public AutoRestPagingTestServiceImpl(String baseUrl, ServiceClientCredentials credentials) { super(); - this.baseUri = baseUri; + this.baseUrl = new AutoRestBaseUrl(baseUrl); this.credentials = credentials; initialize(); } @@ -167,14 +169,14 @@ public AutoRestPagingTestServiceImpl(String baseUri, ServiceClientCredentials cr /** * Initializes an instance of AutoRestPagingTestService client. * - * @param baseUri the base URI of the host + * @param baseUrl the base URL of the host * @param credentials the management credentials for Azure * @param clientBuilder the builder for building up an {@link OkHttpClient} * @param retrofitBuilder the builder for building up a {@link Retrofit} */ - public AutoRestPagingTestServiceImpl(String baseUri, ServiceClientCredentials credentials, OkHttpClient.Builder clientBuilder, Retrofit.Builder retrofitBuilder) { + public AutoRestPagingTestServiceImpl(String baseUrl, ServiceClientCredentials credentials, OkHttpClient.Builder clientBuilder, Retrofit.Builder retrofitBuilder) { super(clientBuilder, retrofitBuilder); - this.baseUri = baseUri; + this.baseUrl = new AutoRestBaseUrl(baseUrl); this.credentials = credentials; initialize(); } @@ -191,6 +193,6 @@ protected void initialize() { super.initialize(); this.azureClient = new AzureClient(clientBuilder, retrofitBuilder); this.azureClient.setCredentials(this.credentials); - this.retrofitBuilder.baseUrl(baseUri); + this.retrofitBuilder.baseUrl(baseUrl); } } diff --git a/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/resourceflattening/AutoRestResourceFlatteningTestService.java b/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/resourceflattening/AutoRestResourceFlatteningTestService.java index c6587856bf..1f888008f7 100644 --- a/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/resourceflattening/AutoRestResourceFlatteningTestService.java +++ b/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/resourceflattening/AutoRestResourceFlatteningTestService.java @@ -11,6 +11,7 @@ package fixtures.resourceflattening; import com.microsoft.azure.AzureClient; +import com.microsoft.rest.AutoRestBaseUrl; import com.microsoft.rest.credentials.ServiceClientCredentials; import com.microsoft.rest.serializer.JacksonMapperAdapter; import com.microsoft.rest.ServiceCallback; @@ -37,10 +38,11 @@ */ public interface AutoRestResourceFlatteningTestService { /** - * Gets the URI used as the base for all cloud service requests. - * @return The BaseUri value. + * Gets the URL used as the base for all cloud service requests. + * + * @return the BaseUrl object. */ - String getBaseUri(); + AutoRestBaseUrl getBaseUrl(); /** * Gets the list of interceptors the OkHttp client will execute. diff --git a/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/resourceflattening/AutoRestResourceFlatteningTestServiceImpl.java b/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/resourceflattening/AutoRestResourceFlatteningTestServiceImpl.java index 92dff1d443..44cfbe1450 100644 --- a/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/resourceflattening/AutoRestResourceFlatteningTestServiceImpl.java +++ b/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/resourceflattening/AutoRestResourceFlatteningTestServiceImpl.java @@ -15,6 +15,7 @@ import com.microsoft.azure.AzureServiceClient; import com.microsoft.azure.AzureServiceResponseBuilder; import com.microsoft.azure.CustomHeaderInterceptor; +import com.microsoft.rest.AutoRestBaseUrl; import com.microsoft.rest.credentials.ServiceClientCredentials; import com.microsoft.rest.ServiceCallback; import com.microsoft.rest.ServiceResponse; @@ -40,17 +41,18 @@ public final class AutoRestResourceFlatteningTestServiceImpl extends AzureServiceClient implements AutoRestResourceFlatteningTestService { /** The Retrofit service to perform REST calls. */ private AutoRestResourceFlatteningTestServiceService service; - /** The URI used as the base for all cloud service requests. */ - private final String baseUri; + /** The URL used as the base for all cloud service requests. */ + private final AutoRestBaseUrl baseUrl; /** the {@link AzureClient} used for long running operations. */ private AzureClient azureClient; /** - * Gets the URI used as the base for all cloud service requests. - * @return The BaseUri value. + * Gets the URL used as the base for all cloud service requests. + * + * @return The BaseUrl value. */ - public String getBaseUri() { - return this.baseUri; + public AutoRestBaseUrl getBaseUrl() { + return this.baseUrl; } /** @@ -146,10 +148,10 @@ public AutoRestResourceFlatteningTestServiceImpl() { /** * Initializes an instance of AutoRestResourceFlatteningTestService client. * - * @param baseUri the base URI of the host + * @param baseUrl the base URL of the host */ - public AutoRestResourceFlatteningTestServiceImpl(String baseUri) { - this(baseUri, null); + public AutoRestResourceFlatteningTestServiceImpl(String baseUrl) { + this(baseUrl, null); } /** @@ -164,12 +166,12 @@ public AutoRestResourceFlatteningTestServiceImpl(ServiceClientCredentials creden /** * Initializes an instance of AutoRestResourceFlatteningTestService client. * - * @param baseUri the base URI of the host + * @param baseUrl the base URL of the host * @param credentials the management credentials for Azure */ - public AutoRestResourceFlatteningTestServiceImpl(String baseUri, ServiceClientCredentials credentials) { + public AutoRestResourceFlatteningTestServiceImpl(String baseUrl, ServiceClientCredentials credentials) { super(); - this.baseUri = baseUri; + this.baseUrl = new AutoRestBaseUrl(baseUrl); this.credentials = credentials; initialize(); } @@ -177,14 +179,14 @@ public AutoRestResourceFlatteningTestServiceImpl(String baseUri, ServiceClientCr /** * Initializes an instance of AutoRestResourceFlatteningTestService client. * - * @param baseUri the base URI of the host + * @param baseUrl the base URL of the host * @param credentials the management credentials for Azure * @param clientBuilder the builder for building up an {@link OkHttpClient} * @param retrofitBuilder the builder for building up a {@link Retrofit} */ - public AutoRestResourceFlatteningTestServiceImpl(String baseUri, ServiceClientCredentials credentials, OkHttpClient.Builder clientBuilder, Retrofit.Builder retrofitBuilder) { + public AutoRestResourceFlatteningTestServiceImpl(String baseUrl, ServiceClientCredentials credentials, OkHttpClient.Builder clientBuilder, Retrofit.Builder retrofitBuilder) { super(clientBuilder, retrofitBuilder); - this.baseUri = baseUri; + this.baseUrl = new AutoRestBaseUrl(baseUrl); this.credentials = credentials; initialize(); } @@ -201,7 +203,7 @@ protected void initialize() { super.initialize(); this.azureClient = new AzureClient(clientBuilder, retrofitBuilder); this.azureClient.setCredentials(this.credentials); - this.retrofitBuilder.baseUrl(baseUri); + this.retrofitBuilder.baseUrl(baseUrl); initializeService(); } diff --git a/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/subscriptionidapiversion/MicrosoftAzureTestUrl.java b/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/subscriptionidapiversion/MicrosoftAzureTestUrl.java index 4d4224eb18..c2e0228cf8 100644 --- a/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/subscriptionidapiversion/MicrosoftAzureTestUrl.java +++ b/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/subscriptionidapiversion/MicrosoftAzureTestUrl.java @@ -11,6 +11,7 @@ package fixtures.subscriptionidapiversion; import com.microsoft.azure.AzureClient; +import com.microsoft.rest.AutoRestBaseUrl; import com.microsoft.rest.credentials.ServiceClientCredentials; import com.microsoft.rest.serializer.JacksonMapperAdapter; import java.util.List; @@ -22,10 +23,11 @@ */ public interface MicrosoftAzureTestUrl { /** - * Gets the URI used as the base for all cloud service requests. - * @return The BaseUri value. + * Gets the URL used as the base for all cloud service requests. + * + * @return the BaseUrl object. */ - String getBaseUri(); + AutoRestBaseUrl getBaseUrl(); /** * Gets the list of interceptors the OkHttp client will execute. diff --git a/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/subscriptionidapiversion/MicrosoftAzureTestUrlImpl.java b/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/subscriptionidapiversion/MicrosoftAzureTestUrlImpl.java index f65b3fd2a5..d72cbafa4c 100644 --- a/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/subscriptionidapiversion/MicrosoftAzureTestUrlImpl.java +++ b/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/subscriptionidapiversion/MicrosoftAzureTestUrlImpl.java @@ -13,6 +13,7 @@ import com.microsoft.azure.AzureClient; import com.microsoft.azure.AzureServiceClient; import com.microsoft.azure.CustomHeaderInterceptor; +import com.microsoft.rest.AutoRestBaseUrl; import com.microsoft.rest.credentials.ServiceClientCredentials; import java.util.UUID; import okhttp3.OkHttpClient; @@ -22,17 +23,18 @@ * Initializes a new instance of the MicrosoftAzureTestUrl class. */ public final class MicrosoftAzureTestUrlImpl extends AzureServiceClient implements MicrosoftAzureTestUrl { - /** The URI used as the base for all cloud service requests. */ - private final String baseUri; + /** The URL used as the base for all cloud service requests. */ + private final AutoRestBaseUrl baseUrl; /** the {@link AzureClient} used for long running operations. */ private AzureClient azureClient; /** - * Gets the URI used as the base for all cloud service requests. - * @return The BaseUri value. + * Gets the URL used as the base for all cloud service requests. + * + * @return The BaseUrl value. */ - public String getBaseUri() { - return this.baseUri; + public AutoRestBaseUrl getBaseUrl() { + return this.baseUrl; } /** @@ -169,10 +171,10 @@ public MicrosoftAzureTestUrlImpl() { /** * Initializes an instance of MicrosoftAzureTestUrl client. * - * @param baseUri the base URI of the host + * @param baseUrl the base URL of the host */ - public MicrosoftAzureTestUrlImpl(String baseUri) { - this(baseUri, null); + public MicrosoftAzureTestUrlImpl(String baseUrl) { + this(baseUrl, null); } /** @@ -187,12 +189,12 @@ public MicrosoftAzureTestUrlImpl(ServiceClientCredentials credentials) { /** * Initializes an instance of MicrosoftAzureTestUrl client. * - * @param baseUri the base URI of the host + * @param baseUrl the base URL of the host * @param credentials the management credentials for Azure */ - public MicrosoftAzureTestUrlImpl(String baseUri, ServiceClientCredentials credentials) { + public MicrosoftAzureTestUrlImpl(String baseUrl, ServiceClientCredentials credentials) { super(); - this.baseUri = baseUri; + this.baseUrl = new AutoRestBaseUrl(baseUrl); this.credentials = credentials; initialize(); } @@ -200,14 +202,14 @@ public MicrosoftAzureTestUrlImpl(String baseUri, ServiceClientCredentials creden /** * Initializes an instance of MicrosoftAzureTestUrl client. * - * @param baseUri the base URI of the host + * @param baseUrl the base URL of the host * @param credentials the management credentials for Azure * @param clientBuilder the builder for building up an {@link OkHttpClient} * @param retrofitBuilder the builder for building up a {@link Retrofit} */ - public MicrosoftAzureTestUrlImpl(String baseUri, ServiceClientCredentials credentials, OkHttpClient.Builder clientBuilder, Retrofit.Builder retrofitBuilder) { + public MicrosoftAzureTestUrlImpl(String baseUrl, ServiceClientCredentials credentials, OkHttpClient.Builder clientBuilder, Retrofit.Builder retrofitBuilder) { super(clientBuilder, retrofitBuilder); - this.baseUri = baseUri; + this.baseUrl = new AutoRestBaseUrl(baseUrl); this.credentials = credentials; initialize(); } @@ -225,6 +227,6 @@ protected void initialize() { super.initialize(); this.azureClient = new AzureClient(clientBuilder, retrofitBuilder); this.azureClient.setCredentials(this.credentials); - this.retrofitBuilder.baseUrl(baseUri); + this.retrofitBuilder.baseUrl(baseUrl); } } diff --git a/AutoRest/Generators/Java/Azure.Java.Tests/src/test/java/fixtures/azurecustombaseuri/AzureCustomBaseUriTests.java b/AutoRest/Generators/Java/Azure.Java.Tests/src/test/java/fixtures/azurecustombaseuri/AzureCustomBaseUriTests.java index e9f676820c..876dae8fab 100644 --- a/AutoRest/Generators/Java/Azure.Java.Tests/src/test/java/fixtures/azurecustombaseuri/AzureCustomBaseUriTests.java +++ b/AutoRest/Generators/Java/Azure.Java.Tests/src/test/java/fixtures/azurecustombaseuri/AzureCustomBaseUriTests.java @@ -6,11 +6,11 @@ import org.junit.BeforeClass; import org.junit.Test; +import java.net.UnknownHostException; import java.util.UUID; import fixtures.custombaseuri.AutoRestParameterizedHostTestClient; import fixtures.custombaseuri.AutoRestParameterizedHostTestClientImpl; -import fixtures.custombaseuri.models.ErrorException; public class AzureCustomBaseUriTests { private static AutoRestParameterizedHostTestClient client; @@ -33,7 +33,7 @@ public void getEmptyWithInvalidCustomUriAccountName() throws Exception { client.getPathsOperations().getEmpty("bad"); Assert.assertTrue(false); } - catch (ErrorException e) { + catch (UnknownHostException e) { Assert.assertTrue(true); } } @@ -45,7 +45,7 @@ public void getEmptyWithInvalidCustomUriHostName() throws Exception { client.getPathsOperations().getEmpty("local"); Assert.assertTrue(false); } - catch (ErrorException e) { + catch (UnknownHostException e) { Assert.assertTrue(true); } finally { diff --git a/AutoRest/Generators/Java/Azure.Java/Templates/AzureServiceClientInterfaceTemplate.cshtml b/AutoRest/Generators/Java/Azure.Java/Templates/AzureServiceClientInterfaceTemplate.cshtml index 8c93a511bc..30566f0ec5 100644 --- a/AutoRest/Generators/Java/Azure.Java/Templates/AzureServiceClientInterfaceTemplate.cshtml +++ b/AutoRest/Generators/Java/Azure.Java/Templates/AzureServiceClientInterfaceTemplate.cshtml @@ -23,10 +23,11 @@ package @(Settings.Namespace.ToLower()); */ public interface @Model.Name { /** - * Gets the URI used as the base for all cloud service requests. - * @@return The BaseUri value. + * Gets the URL used as the base for all cloud service requests. + * + * @@return the BaseUrl object. */ - String getBaseUri(); + AutoRestBaseUrl getBaseUrl(); @EmptyLine /** * Gets the list of interceptors the OkHttp client will execute. diff --git a/AutoRest/Generators/Java/Azure.Java/Templates/AzureServiceClientTemplate.cshtml b/AutoRest/Generators/Java/Azure.Java/Templates/AzureServiceClientTemplate.cshtml index 89b0b73d03..b3defce517 100644 --- a/AutoRest/Generators/Java/Azure.Java/Templates/AzureServiceClientTemplate.cshtml +++ b/AutoRest/Generators/Java/Azure.Java/Templates/AzureServiceClientTemplate.cshtml @@ -28,17 +28,18 @@ public final class @(Model.Name)Impl extends AzureServiceClient implements @Mode @: /** The Retrofit service to perform REST calls. */ @: private @Model.ServiceClientServiceType service; } - /** The URI used as the base for all cloud service requests. */ - private final String baseUri; + /** The URL used as the base for all cloud service requests. */ + private final AutoRestBaseUrl baseUrl; /** the {@@link AzureClient} used for long running operations. */ private AzureClient azureClient; @EmptyLine /** - * Gets the URI used as the base for all cloud service requests. - * @@return The BaseUri value. + * Gets the URL used as the base for all cloud service requests. + * + * @@return The BaseUrl value. */ - public String getBaseUri() { - return this.baseUri; + public AutoRestBaseUrl getBaseUrl() { + return this.baseUrl; } @EmptyLine /** @@ -98,10 +99,10 @@ if(!property.IsReadOnly) /** * Initializes an instance of @(Model.Name) client. * - * @@param baseUri the base URI of the host + * @@param baseUrl the base URL of the host */ - @(Model.IsCustomBaseUri ? "private" : "public") @(Model.Name)Impl(String baseUri) { - this(baseUri, null); + @(Model.IsCustomBaseUri ? "private" : "public") @(Model.Name)Impl(String baseUrl) { + this(baseUrl, null); } @EmptyLine @@ -120,12 +121,12 @@ if(!property.IsReadOnly) /** * Initializes an instance of @(Model.Name) client. * - * @@param baseUri the base URI of the host + * @@param baseUrl the base URL of the host * @@param credentials the management credentials for Azure */ - @(Model.IsCustomBaseUri ? "private" : "public") @(Model.Name)Impl(String baseUri, ServiceClientCredentials credentials) { + @(Model.IsCustomBaseUri ? "private" : "public") @(Model.Name)Impl(String baseUrl, ServiceClientCredentials credentials) { super(); - this.baseUri = baseUri; + this.baseUrl = new AutoRestBaseUrl(baseUrl); this.credentials = credentials; initialize(); } @@ -135,14 +136,14 @@ if(!property.IsReadOnly) @: /** @: * Initializes an instance of @(Model.Name) client. @: * -@: * @@param baseUri the base URI of the host +@: * @@param baseUrl the base URL of the host @: * @@param credentials the management credentials for Azure @: * @@param clientBuilder the builder for building up an {@@link OkHttpClient} @: * @@param retrofitBuilder the builder for building up a {@@link Retrofit} @: */ -@: public @(Model.Name)Impl(String baseUri, ServiceClientCredentials credentials, OkHttpClient.Builder clientBuilder, Retrofit.Builder retrofitBuilder) { +@: public @(Model.Name)Impl(String baseUrl, ServiceClientCredentials credentials, OkHttpClient.Builder clientBuilder, Retrofit.Builder retrofitBuilder) { @: super(clientBuilder, retrofitBuilder); -@: this.baseUri = baseUri; +@: this.baseUrl = new AutoRestBaseUrl(baseUrl); @: this.credentials = credentials; @: initialize(); @: } @@ -153,12 +154,12 @@ else @: * Initializes an instance of @(Model.Name) client. @: * @: * @@param credentials the management credentials for Azure -@: * @@param client the {@@link OkHttpClient} client to use for REST calls +@: * @@param clientBuilder the builder for building up an {@@link OkHttpClient} @: * @@param retrofitBuilder the builder for building up a {@@link Retrofit} @: */ -@: public @(Model.Name)Impl(ServiceClientCredentials credentials, OkHttpClient client, Retrofit.Builder retrofitBuilder) { -@: super(client, retrofitBuilder); -@: this.baseUri = "@Model.BaseUrl"; +@: public @(Model.Name)Impl(ServiceClientCredentials credentials, OkHttpClient.Builder clientBuilder, Retrofit.Builder retrofitBuilder) { +@: super(clientBuilder, retrofitBuilder); +@: this.baseUrl = new AutoRestBaseUrl("@Model.BaseUrl"); @: this.credentials = credentials; @: initialize(); @: } @@ -175,13 +176,12 @@ else @: /** @: * Initializes an instance of @(Model.Name) client. @: * -@: * @@param baseUri the base URI of the host @: * @@param clientBuilder the builder for building up an {@@link OkHttpClient} @: * @@param retrofitBuilder the builder for building up a {@@link Retrofit} @: */ @: public @(Model.Name)Impl(OkHttpClient.Builder clientBuilder, Retrofit.Builder retrofitBuilder) { @: super(clientBuilder, retrofitBuilder); -@: this.baseUri = "@Model.BaseUrl"; +@: this.baseUrl = new AutoRestBaseUrl("@Model.BaseUrl"); @: initialize(); @: } } @@ -190,13 +190,13 @@ else @: /** @: * Initializes an instance of @(Model.Name) client. @: * -@: * @@param baseUri the base URI of the host +@: * @@param baseUrl the base URL of the host @: * @@param clientBuilder the builder for building up an {@@link OkHttpClient} @: * @@param retrofitBuilder the builder for building up a {@@link Retrofit} @: */ -@: public @(Model.Name)Impl(String baseUri, OkHttpClient.Builder clientBuilder, Retrofit.Builder retrofitBuilder) { +@: public @(Model.Name)Impl(String baseUrl, OkHttpClient.Builder clientBuilder, Retrofit.Builder retrofitBuilder) { @: super(clientBuilder, retrofitBuilder); -@: this.baseUri = baseUri; +@: this.baseUrl = new AutoRestBaseUrl(baseUrl); @: initialize(); @: } } @@ -220,7 +220,7 @@ else this.azureClient = new AzureClient(clientBuilder, retrofitBuilder); this.azureClient.setCredentials(this.credentials); - this.retrofitBuilder.baseUrl(baseUri); + this.retrofitBuilder.baseUrl(baseUrl); @if (Model.MethodTemplateModels.Any()) { @: initializeService(); diff --git a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodyarray/AutoRestSwaggerBATArrayService.java b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodyarray/AutoRestSwaggerBATArrayService.java index 3c88b86c4e..24e483d04f 100644 --- a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodyarray/AutoRestSwaggerBATArrayService.java +++ b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodyarray/AutoRestSwaggerBATArrayService.java @@ -13,6 +13,7 @@ import java.util.List; import okhttp3.Interceptor; import okhttp3.logging.HttpLoggingInterceptor.Level; +import com.microsoft.rest.AutoRestBaseUrl; import com.microsoft.rest.serializer.JacksonMapperAdapter; /** @@ -20,11 +21,11 @@ */ public interface AutoRestSwaggerBATArrayService { /** - * Gets the URI used as the base for all cloud service requests. + * Gets the URL used as the base for all cloud service requests. * - * @return the BaseUri value. + * @return the BaseUrl object. */ - String getBaseUri(); + AutoRestBaseUrl getBaseUrl(); /** * Gets the list of interceptors the OkHttp client will execute. diff --git a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodyarray/AutoRestSwaggerBATArrayServiceImpl.java b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodyarray/AutoRestSwaggerBATArrayServiceImpl.java index 40613a7454..40fba451c5 100644 --- a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodyarray/AutoRestSwaggerBATArrayServiceImpl.java +++ b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodyarray/AutoRestSwaggerBATArrayServiceImpl.java @@ -11,6 +11,7 @@ package fixtures.bodyarray; import com.microsoft.rest.ServiceClient; +import com.microsoft.rest.AutoRestBaseUrl; import okhttp3.OkHttpClient; import retrofit2.Retrofit; @@ -19,16 +20,17 @@ */ public final class AutoRestSwaggerBATArrayServiceImpl extends ServiceClient implements AutoRestSwaggerBATArrayService { /** - * The URI used as the base for all cloud service requests. + * The URL used as the base for all cloud service requests. */ - private final String baseUri; + private final AutoRestBaseUrl baseUrl; /** - * Gets the URI used as the base for all cloud service requests. - * @return The BaseUri value. + * Gets the URL used as the base for all cloud service requests. + * + * @return The BaseUrl value. */ - public String getBaseUri() { - return this.baseUri; + public AutoRestBaseUrl getBaseUrl() { + return this.baseUrl; } /** @@ -49,30 +51,30 @@ public AutoRestSwaggerBATArrayServiceImpl() { /** * Initializes an instance of AutoRestSwaggerBATArrayService client. * - * @param baseUri the base URI of the host + * @param baseUrl the base URL of the host */ - public AutoRestSwaggerBATArrayServiceImpl(String baseUri) { + public AutoRestSwaggerBATArrayServiceImpl(String baseUrl) { super(); - this.baseUri = baseUri; + this.baseUrl = new AutoRestBaseUrl(baseUrl); initialize(); } /** * Initializes an instance of AutoRestSwaggerBATArrayService client. * - * @param baseUri the base URI of the host + * @param baseUrl the base URL of the host * @param clientBuilder the builder for building up an {@link OkHttpClient} * @param retrofitBuilder the builder for building up a {@link Retrofit} */ - public AutoRestSwaggerBATArrayServiceImpl(String baseUri, OkHttpClient.Builder clientBuilder, Retrofit.Builder retrofitBuilder) { + public AutoRestSwaggerBATArrayServiceImpl(String baseUrl, OkHttpClient.Builder clientBuilder, Retrofit.Builder retrofitBuilder) { super(clientBuilder, retrofitBuilder); - this.baseUri = baseUri; + this.baseUrl = new AutoRestBaseUrl(baseUrl); initialize(); } @Override protected void initialize() { super.initialize(); - this.retrofitBuilder.baseUrl(baseUri); + this.retrofitBuilder.baseUrl(baseUrl); } } diff --git a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodyboolean/AutoRestBoolTestService.java b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodyboolean/AutoRestBoolTestService.java index 1127156a28..8309fd526a 100644 --- a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodyboolean/AutoRestBoolTestService.java +++ b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodyboolean/AutoRestBoolTestService.java @@ -13,6 +13,7 @@ import java.util.List; import okhttp3.Interceptor; import okhttp3.logging.HttpLoggingInterceptor.Level; +import com.microsoft.rest.AutoRestBaseUrl; import com.microsoft.rest.serializer.JacksonMapperAdapter; /** @@ -20,11 +21,11 @@ */ public interface AutoRestBoolTestService { /** - * Gets the URI used as the base for all cloud service requests. + * Gets the URL used as the base for all cloud service requests. * - * @return the BaseUri value. + * @return the BaseUrl object. */ - String getBaseUri(); + AutoRestBaseUrl getBaseUrl(); /** * Gets the list of interceptors the OkHttp client will execute. diff --git a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodyboolean/AutoRestBoolTestServiceImpl.java b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodyboolean/AutoRestBoolTestServiceImpl.java index 406bb45c47..00aeca2dbc 100644 --- a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodyboolean/AutoRestBoolTestServiceImpl.java +++ b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodyboolean/AutoRestBoolTestServiceImpl.java @@ -11,6 +11,7 @@ package fixtures.bodyboolean; import com.microsoft.rest.ServiceClient; +import com.microsoft.rest.AutoRestBaseUrl; import okhttp3.OkHttpClient; import retrofit2.Retrofit; @@ -19,16 +20,17 @@ */ public final class AutoRestBoolTestServiceImpl extends ServiceClient implements AutoRestBoolTestService { /** - * The URI used as the base for all cloud service requests. + * The URL used as the base for all cloud service requests. */ - private final String baseUri; + private final AutoRestBaseUrl baseUrl; /** - * Gets the URI used as the base for all cloud service requests. - * @return The BaseUri value. + * Gets the URL used as the base for all cloud service requests. + * + * @return The BaseUrl value. */ - public String getBaseUri() { - return this.baseUri; + public AutoRestBaseUrl getBaseUrl() { + return this.baseUrl; } /** @@ -49,30 +51,30 @@ public AutoRestBoolTestServiceImpl() { /** * Initializes an instance of AutoRestBoolTestService client. * - * @param baseUri the base URI of the host + * @param baseUrl the base URL of the host */ - public AutoRestBoolTestServiceImpl(String baseUri) { + public AutoRestBoolTestServiceImpl(String baseUrl) { super(); - this.baseUri = baseUri; + this.baseUrl = new AutoRestBaseUrl(baseUrl); initialize(); } /** * Initializes an instance of AutoRestBoolTestService client. * - * @param baseUri the base URI of the host + * @param baseUrl the base URL of the host * @param clientBuilder the builder for building up an {@link OkHttpClient} * @param retrofitBuilder the builder for building up a {@link Retrofit} */ - public AutoRestBoolTestServiceImpl(String baseUri, OkHttpClient.Builder clientBuilder, Retrofit.Builder retrofitBuilder) { + public AutoRestBoolTestServiceImpl(String baseUrl, OkHttpClient.Builder clientBuilder, Retrofit.Builder retrofitBuilder) { super(clientBuilder, retrofitBuilder); - this.baseUri = baseUri; + this.baseUrl = new AutoRestBaseUrl(baseUrl); initialize(); } @Override protected void initialize() { super.initialize(); - this.retrofitBuilder.baseUrl(baseUri); + this.retrofitBuilder.baseUrl(baseUrl); } } diff --git a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodybyte/AutoRestSwaggerBATByteService.java b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodybyte/AutoRestSwaggerBATByteService.java index 4124f9f6ae..741a41b9b5 100644 --- a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodybyte/AutoRestSwaggerBATByteService.java +++ b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodybyte/AutoRestSwaggerBATByteService.java @@ -13,6 +13,7 @@ import java.util.List; import okhttp3.Interceptor; import okhttp3.logging.HttpLoggingInterceptor.Level; +import com.microsoft.rest.AutoRestBaseUrl; import com.microsoft.rest.serializer.JacksonMapperAdapter; /** @@ -20,11 +21,11 @@ */ public interface AutoRestSwaggerBATByteService { /** - * Gets the URI used as the base for all cloud service requests. + * Gets the URL used as the base for all cloud service requests. * - * @return the BaseUri value. + * @return the BaseUrl object. */ - String getBaseUri(); + AutoRestBaseUrl getBaseUrl(); /** * Gets the list of interceptors the OkHttp client will execute. diff --git a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodybyte/AutoRestSwaggerBATByteServiceImpl.java b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodybyte/AutoRestSwaggerBATByteServiceImpl.java index b42582c614..7d0154870e 100644 --- a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodybyte/AutoRestSwaggerBATByteServiceImpl.java +++ b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodybyte/AutoRestSwaggerBATByteServiceImpl.java @@ -11,6 +11,7 @@ package fixtures.bodybyte; import com.microsoft.rest.ServiceClient; +import com.microsoft.rest.AutoRestBaseUrl; import okhttp3.OkHttpClient; import retrofit2.Retrofit; @@ -19,16 +20,17 @@ */ public final class AutoRestSwaggerBATByteServiceImpl extends ServiceClient implements AutoRestSwaggerBATByteService { /** - * The URI used as the base for all cloud service requests. + * The URL used as the base for all cloud service requests. */ - private final String baseUri; + private final AutoRestBaseUrl baseUrl; /** - * Gets the URI used as the base for all cloud service requests. - * @return The BaseUri value. + * Gets the URL used as the base for all cloud service requests. + * + * @return The BaseUrl value. */ - public String getBaseUri() { - return this.baseUri; + public AutoRestBaseUrl getBaseUrl() { + return this.baseUrl; } /** @@ -49,30 +51,30 @@ public AutoRestSwaggerBATByteServiceImpl() { /** * Initializes an instance of AutoRestSwaggerBATByteService client. * - * @param baseUri the base URI of the host + * @param baseUrl the base URL of the host */ - public AutoRestSwaggerBATByteServiceImpl(String baseUri) { + public AutoRestSwaggerBATByteServiceImpl(String baseUrl) { super(); - this.baseUri = baseUri; + this.baseUrl = new AutoRestBaseUrl(baseUrl); initialize(); } /** * Initializes an instance of AutoRestSwaggerBATByteService client. * - * @param baseUri the base URI of the host + * @param baseUrl the base URL of the host * @param clientBuilder the builder for building up an {@link OkHttpClient} * @param retrofitBuilder the builder for building up a {@link Retrofit} */ - public AutoRestSwaggerBATByteServiceImpl(String baseUri, OkHttpClient.Builder clientBuilder, Retrofit.Builder retrofitBuilder) { + public AutoRestSwaggerBATByteServiceImpl(String baseUrl, OkHttpClient.Builder clientBuilder, Retrofit.Builder retrofitBuilder) { super(clientBuilder, retrofitBuilder); - this.baseUri = baseUri; + this.baseUrl = new AutoRestBaseUrl(baseUrl); initialize(); } @Override protected void initialize() { super.initialize(); - this.retrofitBuilder.baseUrl(baseUri); + this.retrofitBuilder.baseUrl(baseUrl); } } diff --git a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodycomplex/AutoRestComplexTestService.java b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodycomplex/AutoRestComplexTestService.java index 47348e1762..0902fc993c 100644 --- a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodycomplex/AutoRestComplexTestService.java +++ b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodycomplex/AutoRestComplexTestService.java @@ -13,6 +13,7 @@ import java.util.List; import okhttp3.Interceptor; import okhttp3.logging.HttpLoggingInterceptor.Level; +import com.microsoft.rest.AutoRestBaseUrl; import com.microsoft.rest.serializer.JacksonMapperAdapter; /** @@ -20,11 +21,11 @@ */ public interface AutoRestComplexTestService { /** - * Gets the URI used as the base for all cloud service requests. + * Gets the URL used as the base for all cloud service requests. * - * @return the BaseUri value. + * @return the BaseUrl object. */ - String getBaseUri(); + AutoRestBaseUrl getBaseUrl(); /** * Gets the list of interceptors the OkHttp client will execute. diff --git a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodycomplex/AutoRestComplexTestServiceImpl.java b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodycomplex/AutoRestComplexTestServiceImpl.java index 08dd1e39c4..6e65a04255 100644 --- a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodycomplex/AutoRestComplexTestServiceImpl.java +++ b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodycomplex/AutoRestComplexTestServiceImpl.java @@ -11,6 +11,7 @@ package fixtures.bodycomplex; import com.microsoft.rest.ServiceClient; +import com.microsoft.rest.AutoRestBaseUrl; import okhttp3.OkHttpClient; import retrofit2.Retrofit; @@ -19,16 +20,17 @@ */ public final class AutoRestComplexTestServiceImpl extends ServiceClient implements AutoRestComplexTestService { /** - * The URI used as the base for all cloud service requests. + * The URL used as the base for all cloud service requests. */ - private final String baseUri; + private final AutoRestBaseUrl baseUrl; /** - * Gets the URI used as the base for all cloud service requests. - * @return The BaseUri value. + * Gets the URL used as the base for all cloud service requests. + * + * @return The BaseUrl value. */ - public String getBaseUri() { - return this.baseUri; + public AutoRestBaseUrl getBaseUrl() { + return this.baseUrl; } /** API ID. */ @@ -118,30 +120,30 @@ public AutoRestComplexTestServiceImpl() { /** * Initializes an instance of AutoRestComplexTestService client. * - * @param baseUri the base URI of the host + * @param baseUrl the base URL of the host */ - public AutoRestComplexTestServiceImpl(String baseUri) { + public AutoRestComplexTestServiceImpl(String baseUrl) { super(); - this.baseUri = baseUri; + this.baseUrl = new AutoRestBaseUrl(baseUrl); initialize(); } /** * Initializes an instance of AutoRestComplexTestService client. * - * @param baseUri the base URI of the host + * @param baseUrl the base URL of the host * @param clientBuilder the builder for building up an {@link OkHttpClient} * @param retrofitBuilder the builder for building up a {@link Retrofit} */ - public AutoRestComplexTestServiceImpl(String baseUri, OkHttpClient.Builder clientBuilder, Retrofit.Builder retrofitBuilder) { + public AutoRestComplexTestServiceImpl(String baseUrl, OkHttpClient.Builder clientBuilder, Retrofit.Builder retrofitBuilder) { super(clientBuilder, retrofitBuilder); - this.baseUri = baseUri; + this.baseUrl = new AutoRestBaseUrl(baseUrl); initialize(); } @Override protected void initialize() { super.initialize(); - this.retrofitBuilder.baseUrl(baseUri); + this.retrofitBuilder.baseUrl(baseUrl); } } diff --git a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodydate/AutoRestDateTestService.java b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodydate/AutoRestDateTestService.java index c48def1c3a..d331ca3bb8 100644 --- a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodydate/AutoRestDateTestService.java +++ b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodydate/AutoRestDateTestService.java @@ -13,6 +13,7 @@ import java.util.List; import okhttp3.Interceptor; import okhttp3.logging.HttpLoggingInterceptor.Level; +import com.microsoft.rest.AutoRestBaseUrl; import com.microsoft.rest.serializer.JacksonMapperAdapter; /** @@ -20,11 +21,11 @@ */ public interface AutoRestDateTestService { /** - * Gets the URI used as the base for all cloud service requests. + * Gets the URL used as the base for all cloud service requests. * - * @return the BaseUri value. + * @return the BaseUrl object. */ - String getBaseUri(); + AutoRestBaseUrl getBaseUrl(); /** * Gets the list of interceptors the OkHttp client will execute. diff --git a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodydate/AutoRestDateTestServiceImpl.java b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodydate/AutoRestDateTestServiceImpl.java index daa26a9713..e2dea8a6cd 100644 --- a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodydate/AutoRestDateTestServiceImpl.java +++ b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodydate/AutoRestDateTestServiceImpl.java @@ -11,6 +11,7 @@ package fixtures.bodydate; import com.microsoft.rest.ServiceClient; +import com.microsoft.rest.AutoRestBaseUrl; import okhttp3.OkHttpClient; import retrofit2.Retrofit; @@ -19,16 +20,17 @@ */ public final class AutoRestDateTestServiceImpl extends ServiceClient implements AutoRestDateTestService { /** - * The URI used as the base for all cloud service requests. + * The URL used as the base for all cloud service requests. */ - private final String baseUri; + private final AutoRestBaseUrl baseUrl; /** - * Gets the URI used as the base for all cloud service requests. - * @return The BaseUri value. + * Gets the URL used as the base for all cloud service requests. + * + * @return The BaseUrl value. */ - public String getBaseUri() { - return this.baseUri; + public AutoRestBaseUrl getBaseUrl() { + return this.baseUrl; } /** @@ -49,30 +51,30 @@ public AutoRestDateTestServiceImpl() { /** * Initializes an instance of AutoRestDateTestService client. * - * @param baseUri the base URI of the host + * @param baseUrl the base URL of the host */ - public AutoRestDateTestServiceImpl(String baseUri) { + public AutoRestDateTestServiceImpl(String baseUrl) { super(); - this.baseUri = baseUri; + this.baseUrl = new AutoRestBaseUrl(baseUrl); initialize(); } /** * Initializes an instance of AutoRestDateTestService client. * - * @param baseUri the base URI of the host + * @param baseUrl the base URL of the host * @param clientBuilder the builder for building up an {@link OkHttpClient} * @param retrofitBuilder the builder for building up a {@link Retrofit} */ - public AutoRestDateTestServiceImpl(String baseUri, OkHttpClient.Builder clientBuilder, Retrofit.Builder retrofitBuilder) { + public AutoRestDateTestServiceImpl(String baseUrl, OkHttpClient.Builder clientBuilder, Retrofit.Builder retrofitBuilder) { super(clientBuilder, retrofitBuilder); - this.baseUri = baseUri; + this.baseUrl = new AutoRestBaseUrl(baseUrl); initialize(); } @Override protected void initialize() { super.initialize(); - this.retrofitBuilder.baseUrl(baseUri); + this.retrofitBuilder.baseUrl(baseUrl); } } diff --git a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodydatetime/AutoRestDateTimeTestService.java b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodydatetime/AutoRestDateTimeTestService.java index c5a5f38f54..6e71898022 100644 --- a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodydatetime/AutoRestDateTimeTestService.java +++ b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodydatetime/AutoRestDateTimeTestService.java @@ -13,6 +13,7 @@ import java.util.List; import okhttp3.Interceptor; import okhttp3.logging.HttpLoggingInterceptor.Level; +import com.microsoft.rest.AutoRestBaseUrl; import com.microsoft.rest.serializer.JacksonMapperAdapter; /** @@ -20,11 +21,11 @@ */ public interface AutoRestDateTimeTestService { /** - * Gets the URI used as the base for all cloud service requests. + * Gets the URL used as the base for all cloud service requests. * - * @return the BaseUri value. + * @return the BaseUrl object. */ - String getBaseUri(); + AutoRestBaseUrl getBaseUrl(); /** * Gets the list of interceptors the OkHttp client will execute. diff --git a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodydatetime/AutoRestDateTimeTestServiceImpl.java b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodydatetime/AutoRestDateTimeTestServiceImpl.java index 523e74a274..635f85e774 100644 --- a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodydatetime/AutoRestDateTimeTestServiceImpl.java +++ b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodydatetime/AutoRestDateTimeTestServiceImpl.java @@ -11,6 +11,7 @@ package fixtures.bodydatetime; import com.microsoft.rest.ServiceClient; +import com.microsoft.rest.AutoRestBaseUrl; import okhttp3.OkHttpClient; import retrofit2.Retrofit; @@ -19,16 +20,17 @@ */ public final class AutoRestDateTimeTestServiceImpl extends ServiceClient implements AutoRestDateTimeTestService { /** - * The URI used as the base for all cloud service requests. + * The URL used as the base for all cloud service requests. */ - private final String baseUri; + private final AutoRestBaseUrl baseUrl; /** - * Gets the URI used as the base for all cloud service requests. - * @return The BaseUri value. + * Gets the URL used as the base for all cloud service requests. + * + * @return The BaseUrl value. */ - public String getBaseUri() { - return this.baseUri; + public AutoRestBaseUrl getBaseUrl() { + return this.baseUrl; } /** @@ -49,30 +51,30 @@ public AutoRestDateTimeTestServiceImpl() { /** * Initializes an instance of AutoRestDateTimeTestService client. * - * @param baseUri the base URI of the host + * @param baseUrl the base URL of the host */ - public AutoRestDateTimeTestServiceImpl(String baseUri) { + public AutoRestDateTimeTestServiceImpl(String baseUrl) { super(); - this.baseUri = baseUri; + this.baseUrl = new AutoRestBaseUrl(baseUrl); initialize(); } /** * Initializes an instance of AutoRestDateTimeTestService client. * - * @param baseUri the base URI of the host + * @param baseUrl the base URL of the host * @param clientBuilder the builder for building up an {@link OkHttpClient} * @param retrofitBuilder the builder for building up a {@link Retrofit} */ - public AutoRestDateTimeTestServiceImpl(String baseUri, OkHttpClient.Builder clientBuilder, Retrofit.Builder retrofitBuilder) { + public AutoRestDateTimeTestServiceImpl(String baseUrl, OkHttpClient.Builder clientBuilder, Retrofit.Builder retrofitBuilder) { super(clientBuilder, retrofitBuilder); - this.baseUri = baseUri; + this.baseUrl = new AutoRestBaseUrl(baseUrl); initialize(); } @Override protected void initialize() { super.initialize(); - this.retrofitBuilder.baseUrl(baseUri); + this.retrofitBuilder.baseUrl(baseUrl); } } diff --git a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodydatetimerfc1123/AutoRestRFC1123DateTimeTestService.java b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodydatetimerfc1123/AutoRestRFC1123DateTimeTestService.java index 351cff2c83..8c15100de3 100644 --- a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodydatetimerfc1123/AutoRestRFC1123DateTimeTestService.java +++ b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodydatetimerfc1123/AutoRestRFC1123DateTimeTestService.java @@ -13,6 +13,7 @@ import java.util.List; import okhttp3.Interceptor; import okhttp3.logging.HttpLoggingInterceptor.Level; +import com.microsoft.rest.AutoRestBaseUrl; import com.microsoft.rest.serializer.JacksonMapperAdapter; /** @@ -20,11 +21,11 @@ */ public interface AutoRestRFC1123DateTimeTestService { /** - * Gets the URI used as the base for all cloud service requests. + * Gets the URL used as the base for all cloud service requests. * - * @return the BaseUri value. + * @return the BaseUrl object. */ - String getBaseUri(); + AutoRestBaseUrl getBaseUrl(); /** * Gets the list of interceptors the OkHttp client will execute. diff --git a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodydatetimerfc1123/AutoRestRFC1123DateTimeTestServiceImpl.java b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodydatetimerfc1123/AutoRestRFC1123DateTimeTestServiceImpl.java index bcd862d680..4ed4773e21 100644 --- a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodydatetimerfc1123/AutoRestRFC1123DateTimeTestServiceImpl.java +++ b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodydatetimerfc1123/AutoRestRFC1123DateTimeTestServiceImpl.java @@ -11,6 +11,7 @@ package fixtures.bodydatetimerfc1123; import com.microsoft.rest.ServiceClient; +import com.microsoft.rest.AutoRestBaseUrl; import okhttp3.OkHttpClient; import retrofit2.Retrofit; @@ -19,16 +20,17 @@ */ public final class AutoRestRFC1123DateTimeTestServiceImpl extends ServiceClient implements AutoRestRFC1123DateTimeTestService { /** - * The URI used as the base for all cloud service requests. + * The URL used as the base for all cloud service requests. */ - private final String baseUri; + private final AutoRestBaseUrl baseUrl; /** - * Gets the URI used as the base for all cloud service requests. - * @return The BaseUri value. + * Gets the URL used as the base for all cloud service requests. + * + * @return The BaseUrl value. */ - public String getBaseUri() { - return this.baseUri; + public AutoRestBaseUrl getBaseUrl() { + return this.baseUrl; } /** @@ -49,30 +51,30 @@ public AutoRestRFC1123DateTimeTestServiceImpl() { /** * Initializes an instance of AutoRestRFC1123DateTimeTestService client. * - * @param baseUri the base URI of the host + * @param baseUrl the base URL of the host */ - public AutoRestRFC1123DateTimeTestServiceImpl(String baseUri) { + public AutoRestRFC1123DateTimeTestServiceImpl(String baseUrl) { super(); - this.baseUri = baseUri; + this.baseUrl = new AutoRestBaseUrl(baseUrl); initialize(); } /** * Initializes an instance of AutoRestRFC1123DateTimeTestService client. * - * @param baseUri the base URI of the host + * @param baseUrl the base URL of the host * @param clientBuilder the builder for building up an {@link OkHttpClient} * @param retrofitBuilder the builder for building up a {@link Retrofit} */ - public AutoRestRFC1123DateTimeTestServiceImpl(String baseUri, OkHttpClient.Builder clientBuilder, Retrofit.Builder retrofitBuilder) { + public AutoRestRFC1123DateTimeTestServiceImpl(String baseUrl, OkHttpClient.Builder clientBuilder, Retrofit.Builder retrofitBuilder) { super(clientBuilder, retrofitBuilder); - this.baseUri = baseUri; + this.baseUrl = new AutoRestBaseUrl(baseUrl); initialize(); } @Override protected void initialize() { super.initialize(); - this.retrofitBuilder.baseUrl(baseUri); + this.retrofitBuilder.baseUrl(baseUrl); } } diff --git a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodydictionary/AutoRestSwaggerBATdictionaryService.java b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodydictionary/AutoRestSwaggerBATdictionaryService.java index 92e2ac1528..eb3c3c99dd 100644 --- a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodydictionary/AutoRestSwaggerBATdictionaryService.java +++ b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodydictionary/AutoRestSwaggerBATdictionaryService.java @@ -13,6 +13,7 @@ import java.util.List; import okhttp3.Interceptor; import okhttp3.logging.HttpLoggingInterceptor.Level; +import com.microsoft.rest.AutoRestBaseUrl; import com.microsoft.rest.serializer.JacksonMapperAdapter; /** @@ -20,11 +21,11 @@ */ public interface AutoRestSwaggerBATdictionaryService { /** - * Gets the URI used as the base for all cloud service requests. + * Gets the URL used as the base for all cloud service requests. * - * @return the BaseUri value. + * @return the BaseUrl object. */ - String getBaseUri(); + AutoRestBaseUrl getBaseUrl(); /** * Gets the list of interceptors the OkHttp client will execute. diff --git a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodydictionary/AutoRestSwaggerBATdictionaryServiceImpl.java b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodydictionary/AutoRestSwaggerBATdictionaryServiceImpl.java index 1db15e472c..f8e28485b8 100644 --- a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodydictionary/AutoRestSwaggerBATdictionaryServiceImpl.java +++ b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodydictionary/AutoRestSwaggerBATdictionaryServiceImpl.java @@ -11,6 +11,7 @@ package fixtures.bodydictionary; import com.microsoft.rest.ServiceClient; +import com.microsoft.rest.AutoRestBaseUrl; import okhttp3.OkHttpClient; import retrofit2.Retrofit; @@ -19,16 +20,17 @@ */ public final class AutoRestSwaggerBATdictionaryServiceImpl extends ServiceClient implements AutoRestSwaggerBATdictionaryService { /** - * The URI used as the base for all cloud service requests. + * The URL used as the base for all cloud service requests. */ - private final String baseUri; + private final AutoRestBaseUrl baseUrl; /** - * Gets the URI used as the base for all cloud service requests. - * @return The BaseUri value. + * Gets the URL used as the base for all cloud service requests. + * + * @return The BaseUrl value. */ - public String getBaseUri() { - return this.baseUri; + public AutoRestBaseUrl getBaseUrl() { + return this.baseUrl; } /** @@ -49,30 +51,30 @@ public AutoRestSwaggerBATdictionaryServiceImpl() { /** * Initializes an instance of AutoRestSwaggerBATdictionaryService client. * - * @param baseUri the base URI of the host + * @param baseUrl the base URL of the host */ - public AutoRestSwaggerBATdictionaryServiceImpl(String baseUri) { + public AutoRestSwaggerBATdictionaryServiceImpl(String baseUrl) { super(); - this.baseUri = baseUri; + this.baseUrl = new AutoRestBaseUrl(baseUrl); initialize(); } /** * Initializes an instance of AutoRestSwaggerBATdictionaryService client. * - * @param baseUri the base URI of the host + * @param baseUrl the base URL of the host * @param clientBuilder the builder for building up an {@link OkHttpClient} * @param retrofitBuilder the builder for building up a {@link Retrofit} */ - public AutoRestSwaggerBATdictionaryServiceImpl(String baseUri, OkHttpClient.Builder clientBuilder, Retrofit.Builder retrofitBuilder) { + public AutoRestSwaggerBATdictionaryServiceImpl(String baseUrl, OkHttpClient.Builder clientBuilder, Retrofit.Builder retrofitBuilder) { super(clientBuilder, retrofitBuilder); - this.baseUri = baseUri; + this.baseUrl = new AutoRestBaseUrl(baseUrl); initialize(); } @Override protected void initialize() { super.initialize(); - this.retrofitBuilder.baseUrl(baseUri); + this.retrofitBuilder.baseUrl(baseUrl); } } diff --git a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodyduration/AutoRestDurationTestService.java b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodyduration/AutoRestDurationTestService.java index 17526f3a5e..fa0aa8bd58 100644 --- a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodyduration/AutoRestDurationTestService.java +++ b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodyduration/AutoRestDurationTestService.java @@ -13,6 +13,7 @@ import java.util.List; import okhttp3.Interceptor; import okhttp3.logging.HttpLoggingInterceptor.Level; +import com.microsoft.rest.AutoRestBaseUrl; import com.microsoft.rest.serializer.JacksonMapperAdapter; /** @@ -20,11 +21,11 @@ */ public interface AutoRestDurationTestService { /** - * Gets the URI used as the base for all cloud service requests. + * Gets the URL used as the base for all cloud service requests. * - * @return the BaseUri value. + * @return the BaseUrl object. */ - String getBaseUri(); + AutoRestBaseUrl getBaseUrl(); /** * Gets the list of interceptors the OkHttp client will execute. diff --git a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodyduration/AutoRestDurationTestServiceImpl.java b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodyduration/AutoRestDurationTestServiceImpl.java index e8c4af764f..5d1a78410f 100644 --- a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodyduration/AutoRestDurationTestServiceImpl.java +++ b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodyduration/AutoRestDurationTestServiceImpl.java @@ -11,6 +11,7 @@ package fixtures.bodyduration; import com.microsoft.rest.ServiceClient; +import com.microsoft.rest.AutoRestBaseUrl; import okhttp3.OkHttpClient; import retrofit2.Retrofit; @@ -19,16 +20,17 @@ */ public final class AutoRestDurationTestServiceImpl extends ServiceClient implements AutoRestDurationTestService { /** - * The URI used as the base for all cloud service requests. + * The URL used as the base for all cloud service requests. */ - private final String baseUri; + private final AutoRestBaseUrl baseUrl; /** - * Gets the URI used as the base for all cloud service requests. - * @return The BaseUri value. + * Gets the URL used as the base for all cloud service requests. + * + * @return The BaseUrl value. */ - public String getBaseUri() { - return this.baseUri; + public AutoRestBaseUrl getBaseUrl() { + return this.baseUrl; } /** @@ -49,30 +51,30 @@ public AutoRestDurationTestServiceImpl() { /** * Initializes an instance of AutoRestDurationTestService client. * - * @param baseUri the base URI of the host + * @param baseUrl the base URL of the host */ - public AutoRestDurationTestServiceImpl(String baseUri) { + public AutoRestDurationTestServiceImpl(String baseUrl) { super(); - this.baseUri = baseUri; + this.baseUrl = new AutoRestBaseUrl(baseUrl); initialize(); } /** * Initializes an instance of AutoRestDurationTestService client. * - * @param baseUri the base URI of the host + * @param baseUrl the base URL of the host * @param clientBuilder the builder for building up an {@link OkHttpClient} * @param retrofitBuilder the builder for building up a {@link Retrofit} */ - public AutoRestDurationTestServiceImpl(String baseUri, OkHttpClient.Builder clientBuilder, Retrofit.Builder retrofitBuilder) { + public AutoRestDurationTestServiceImpl(String baseUrl, OkHttpClient.Builder clientBuilder, Retrofit.Builder retrofitBuilder) { super(clientBuilder, retrofitBuilder); - this.baseUri = baseUri; + this.baseUrl = new AutoRestBaseUrl(baseUrl); initialize(); } @Override protected void initialize() { super.initialize(); - this.retrofitBuilder.baseUrl(baseUri); + this.retrofitBuilder.baseUrl(baseUrl); } } diff --git a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodyfile/AutoRestSwaggerBATFileService.java b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodyfile/AutoRestSwaggerBATFileService.java index 2d5d95f278..065d716d7f 100644 --- a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodyfile/AutoRestSwaggerBATFileService.java +++ b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodyfile/AutoRestSwaggerBATFileService.java @@ -13,6 +13,7 @@ import java.util.List; import okhttp3.Interceptor; import okhttp3.logging.HttpLoggingInterceptor.Level; +import com.microsoft.rest.AutoRestBaseUrl; import com.microsoft.rest.serializer.JacksonMapperAdapter; /** @@ -20,11 +21,11 @@ */ public interface AutoRestSwaggerBATFileService { /** - * Gets the URI used as the base for all cloud service requests. + * Gets the URL used as the base for all cloud service requests. * - * @return the BaseUri value. + * @return the BaseUrl object. */ - String getBaseUri(); + AutoRestBaseUrl getBaseUrl(); /** * Gets the list of interceptors the OkHttp client will execute. diff --git a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodyfile/AutoRestSwaggerBATFileServiceImpl.java b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodyfile/AutoRestSwaggerBATFileServiceImpl.java index a778289453..f2483361a8 100644 --- a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodyfile/AutoRestSwaggerBATFileServiceImpl.java +++ b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodyfile/AutoRestSwaggerBATFileServiceImpl.java @@ -11,6 +11,7 @@ package fixtures.bodyfile; import com.microsoft.rest.ServiceClient; +import com.microsoft.rest.AutoRestBaseUrl; import okhttp3.OkHttpClient; import retrofit2.Retrofit; @@ -19,16 +20,17 @@ */ public final class AutoRestSwaggerBATFileServiceImpl extends ServiceClient implements AutoRestSwaggerBATFileService { /** - * The URI used as the base for all cloud service requests. + * The URL used as the base for all cloud service requests. */ - private final String baseUri; + private final AutoRestBaseUrl baseUrl; /** - * Gets the URI used as the base for all cloud service requests. - * @return The BaseUri value. + * Gets the URL used as the base for all cloud service requests. + * + * @return The BaseUrl value. */ - public String getBaseUri() { - return this.baseUri; + public AutoRestBaseUrl getBaseUrl() { + return this.baseUrl; } /** @@ -49,30 +51,30 @@ public AutoRestSwaggerBATFileServiceImpl() { /** * Initializes an instance of AutoRestSwaggerBATFileService client. * - * @param baseUri the base URI of the host + * @param baseUrl the base URL of the host */ - public AutoRestSwaggerBATFileServiceImpl(String baseUri) { + public AutoRestSwaggerBATFileServiceImpl(String baseUrl) { super(); - this.baseUri = baseUri; + this.baseUrl = new AutoRestBaseUrl(baseUrl); initialize(); } /** * Initializes an instance of AutoRestSwaggerBATFileService client. * - * @param baseUri the base URI of the host + * @param baseUrl the base URL of the host * @param clientBuilder the builder for building up an {@link OkHttpClient} * @param retrofitBuilder the builder for building up a {@link Retrofit} */ - public AutoRestSwaggerBATFileServiceImpl(String baseUri, OkHttpClient.Builder clientBuilder, Retrofit.Builder retrofitBuilder) { + public AutoRestSwaggerBATFileServiceImpl(String baseUrl, OkHttpClient.Builder clientBuilder, Retrofit.Builder retrofitBuilder) { super(clientBuilder, retrofitBuilder); - this.baseUri = baseUri; + this.baseUrl = new AutoRestBaseUrl(baseUrl); initialize(); } @Override protected void initialize() { super.initialize(); - this.retrofitBuilder.baseUrl(baseUri); + this.retrofitBuilder.baseUrl(baseUrl); } } diff --git a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodyformdata/AutoRestSwaggerBATFormDataService.java b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodyformdata/AutoRestSwaggerBATFormDataService.java index 96438409b2..d3064cdef5 100644 --- a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodyformdata/AutoRestSwaggerBATFormDataService.java +++ b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodyformdata/AutoRestSwaggerBATFormDataService.java @@ -13,6 +13,7 @@ import java.util.List; import okhttp3.Interceptor; import okhttp3.logging.HttpLoggingInterceptor.Level; +import com.microsoft.rest.AutoRestBaseUrl; import com.microsoft.rest.serializer.JacksonMapperAdapter; /** @@ -20,11 +21,11 @@ */ public interface AutoRestSwaggerBATFormDataService { /** - * Gets the URI used as the base for all cloud service requests. + * Gets the URL used as the base for all cloud service requests. * - * @return the BaseUri value. + * @return the BaseUrl object. */ - String getBaseUri(); + AutoRestBaseUrl getBaseUrl(); /** * Gets the list of interceptors the OkHttp client will execute. diff --git a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodyformdata/AutoRestSwaggerBATFormDataServiceImpl.java b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodyformdata/AutoRestSwaggerBATFormDataServiceImpl.java index 91c985ab87..579fdc06c7 100644 --- a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodyformdata/AutoRestSwaggerBATFormDataServiceImpl.java +++ b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodyformdata/AutoRestSwaggerBATFormDataServiceImpl.java @@ -11,6 +11,7 @@ package fixtures.bodyformdata; import com.microsoft.rest.ServiceClient; +import com.microsoft.rest.AutoRestBaseUrl; import okhttp3.OkHttpClient; import retrofit2.Retrofit; @@ -19,16 +20,17 @@ */ public final class AutoRestSwaggerBATFormDataServiceImpl extends ServiceClient implements AutoRestSwaggerBATFormDataService { /** - * The URI used as the base for all cloud service requests. + * The URL used as the base for all cloud service requests. */ - private final String baseUri; + private final AutoRestBaseUrl baseUrl; /** - * Gets the URI used as the base for all cloud service requests. - * @return The BaseUri value. + * Gets the URL used as the base for all cloud service requests. + * + * @return The BaseUrl value. */ - public String getBaseUri() { - return this.baseUri; + public AutoRestBaseUrl getBaseUrl() { + return this.baseUrl; } /** @@ -49,30 +51,30 @@ public AutoRestSwaggerBATFormDataServiceImpl() { /** * Initializes an instance of AutoRestSwaggerBATFormDataService client. * - * @param baseUri the base URI of the host + * @param baseUrl the base URL of the host */ - public AutoRestSwaggerBATFormDataServiceImpl(String baseUri) { + public AutoRestSwaggerBATFormDataServiceImpl(String baseUrl) { super(); - this.baseUri = baseUri; + this.baseUrl = new AutoRestBaseUrl(baseUrl); initialize(); } /** * Initializes an instance of AutoRestSwaggerBATFormDataService client. * - * @param baseUri the base URI of the host + * @param baseUrl the base URL of the host * @param clientBuilder the builder for building up an {@link OkHttpClient} * @param retrofitBuilder the builder for building up a {@link Retrofit} */ - public AutoRestSwaggerBATFormDataServiceImpl(String baseUri, OkHttpClient.Builder clientBuilder, Retrofit.Builder retrofitBuilder) { + public AutoRestSwaggerBATFormDataServiceImpl(String baseUrl, OkHttpClient.Builder clientBuilder, Retrofit.Builder retrofitBuilder) { super(clientBuilder, retrofitBuilder); - this.baseUri = baseUri; + this.baseUrl = new AutoRestBaseUrl(baseUrl); initialize(); } @Override protected void initialize() { super.initialize(); - this.retrofitBuilder.baseUrl(baseUri); + this.retrofitBuilder.baseUrl(baseUrl); } } diff --git a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodyinteger/AutoRestIntegerTestService.java b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodyinteger/AutoRestIntegerTestService.java index c16d06bd9e..b9ee7b2966 100644 --- a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodyinteger/AutoRestIntegerTestService.java +++ b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodyinteger/AutoRestIntegerTestService.java @@ -13,6 +13,7 @@ import java.util.List; import okhttp3.Interceptor; import okhttp3.logging.HttpLoggingInterceptor.Level; +import com.microsoft.rest.AutoRestBaseUrl; import com.microsoft.rest.serializer.JacksonMapperAdapter; /** @@ -20,11 +21,11 @@ */ public interface AutoRestIntegerTestService { /** - * Gets the URI used as the base for all cloud service requests. + * Gets the URL used as the base for all cloud service requests. * - * @return the BaseUri value. + * @return the BaseUrl object. */ - String getBaseUri(); + AutoRestBaseUrl getBaseUrl(); /** * Gets the list of interceptors the OkHttp client will execute. diff --git a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodyinteger/AutoRestIntegerTestServiceImpl.java b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodyinteger/AutoRestIntegerTestServiceImpl.java index 2bd4e240a9..1b3427160c 100644 --- a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodyinteger/AutoRestIntegerTestServiceImpl.java +++ b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodyinteger/AutoRestIntegerTestServiceImpl.java @@ -11,6 +11,7 @@ package fixtures.bodyinteger; import com.microsoft.rest.ServiceClient; +import com.microsoft.rest.AutoRestBaseUrl; import okhttp3.OkHttpClient; import retrofit2.Retrofit; @@ -19,16 +20,17 @@ */ public final class AutoRestIntegerTestServiceImpl extends ServiceClient implements AutoRestIntegerTestService { /** - * The URI used as the base for all cloud service requests. + * The URL used as the base for all cloud service requests. */ - private final String baseUri; + private final AutoRestBaseUrl baseUrl; /** - * Gets the URI used as the base for all cloud service requests. - * @return The BaseUri value. + * Gets the URL used as the base for all cloud service requests. + * + * @return The BaseUrl value. */ - public String getBaseUri() { - return this.baseUri; + public AutoRestBaseUrl getBaseUrl() { + return this.baseUrl; } /** @@ -49,30 +51,30 @@ public AutoRestIntegerTestServiceImpl() { /** * Initializes an instance of AutoRestIntegerTestService client. * - * @param baseUri the base URI of the host + * @param baseUrl the base URL of the host */ - public AutoRestIntegerTestServiceImpl(String baseUri) { + public AutoRestIntegerTestServiceImpl(String baseUrl) { super(); - this.baseUri = baseUri; + this.baseUrl = new AutoRestBaseUrl(baseUrl); initialize(); } /** * Initializes an instance of AutoRestIntegerTestService client. * - * @param baseUri the base URI of the host + * @param baseUrl the base URL of the host * @param clientBuilder the builder for building up an {@link OkHttpClient} * @param retrofitBuilder the builder for building up a {@link Retrofit} */ - public AutoRestIntegerTestServiceImpl(String baseUri, OkHttpClient.Builder clientBuilder, Retrofit.Builder retrofitBuilder) { + public AutoRestIntegerTestServiceImpl(String baseUrl, OkHttpClient.Builder clientBuilder, Retrofit.Builder retrofitBuilder) { super(clientBuilder, retrofitBuilder); - this.baseUri = baseUri; + this.baseUrl = new AutoRestBaseUrl(baseUrl); initialize(); } @Override protected void initialize() { super.initialize(); - this.retrofitBuilder.baseUrl(baseUri); + this.retrofitBuilder.baseUrl(baseUrl); } } diff --git a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodynumber/AutoRestNumberTestService.java b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodynumber/AutoRestNumberTestService.java index 32d7fc54ab..f9902070b7 100644 --- a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodynumber/AutoRestNumberTestService.java +++ b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodynumber/AutoRestNumberTestService.java @@ -13,6 +13,7 @@ import java.util.List; import okhttp3.Interceptor; import okhttp3.logging.HttpLoggingInterceptor.Level; +import com.microsoft.rest.AutoRestBaseUrl; import com.microsoft.rest.serializer.JacksonMapperAdapter; /** @@ -20,11 +21,11 @@ */ public interface AutoRestNumberTestService { /** - * Gets the URI used as the base for all cloud service requests. + * Gets the URL used as the base for all cloud service requests. * - * @return the BaseUri value. + * @return the BaseUrl object. */ - String getBaseUri(); + AutoRestBaseUrl getBaseUrl(); /** * Gets the list of interceptors the OkHttp client will execute. diff --git a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodynumber/AutoRestNumberTestServiceImpl.java b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodynumber/AutoRestNumberTestServiceImpl.java index 79d0c49c80..387798d254 100644 --- a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodynumber/AutoRestNumberTestServiceImpl.java +++ b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodynumber/AutoRestNumberTestServiceImpl.java @@ -11,6 +11,7 @@ package fixtures.bodynumber; import com.microsoft.rest.ServiceClient; +import com.microsoft.rest.AutoRestBaseUrl; import okhttp3.OkHttpClient; import retrofit2.Retrofit; @@ -19,16 +20,17 @@ */ public final class AutoRestNumberTestServiceImpl extends ServiceClient implements AutoRestNumberTestService { /** - * The URI used as the base for all cloud service requests. + * The URL used as the base for all cloud service requests. */ - private final String baseUri; + private final AutoRestBaseUrl baseUrl; /** - * Gets the URI used as the base for all cloud service requests. - * @return The BaseUri value. + * Gets the URL used as the base for all cloud service requests. + * + * @return The BaseUrl value. */ - public String getBaseUri() { - return this.baseUri; + public AutoRestBaseUrl getBaseUrl() { + return this.baseUrl; } /** @@ -49,30 +51,30 @@ public AutoRestNumberTestServiceImpl() { /** * Initializes an instance of AutoRestNumberTestService client. * - * @param baseUri the base URI of the host + * @param baseUrl the base URL of the host */ - public AutoRestNumberTestServiceImpl(String baseUri) { + public AutoRestNumberTestServiceImpl(String baseUrl) { super(); - this.baseUri = baseUri; + this.baseUrl = new AutoRestBaseUrl(baseUrl); initialize(); } /** * Initializes an instance of AutoRestNumberTestService client. * - * @param baseUri the base URI of the host + * @param baseUrl the base URL of the host * @param clientBuilder the builder for building up an {@link OkHttpClient} * @param retrofitBuilder the builder for building up a {@link Retrofit} */ - public AutoRestNumberTestServiceImpl(String baseUri, OkHttpClient.Builder clientBuilder, Retrofit.Builder retrofitBuilder) { + public AutoRestNumberTestServiceImpl(String baseUrl, OkHttpClient.Builder clientBuilder, Retrofit.Builder retrofitBuilder) { super(clientBuilder, retrofitBuilder); - this.baseUri = baseUri; + this.baseUrl = new AutoRestBaseUrl(baseUrl); initialize(); } @Override protected void initialize() { super.initialize(); - this.retrofitBuilder.baseUrl(baseUri); + this.retrofitBuilder.baseUrl(baseUrl); } } diff --git a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodystring/AutoRestSwaggerBATService.java b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodystring/AutoRestSwaggerBATService.java index 62ae076586..8736c6a7b8 100644 --- a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodystring/AutoRestSwaggerBATService.java +++ b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodystring/AutoRestSwaggerBATService.java @@ -13,6 +13,7 @@ import java.util.List; import okhttp3.Interceptor; import okhttp3.logging.HttpLoggingInterceptor.Level; +import com.microsoft.rest.AutoRestBaseUrl; import com.microsoft.rest.serializer.JacksonMapperAdapter; /** @@ -20,11 +21,11 @@ */ public interface AutoRestSwaggerBATService { /** - * Gets the URI used as the base for all cloud service requests. + * Gets the URL used as the base for all cloud service requests. * - * @return the BaseUri value. + * @return the BaseUrl object. */ - String getBaseUri(); + AutoRestBaseUrl getBaseUrl(); /** * Gets the list of interceptors the OkHttp client will execute. diff --git a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodystring/AutoRestSwaggerBATServiceImpl.java b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodystring/AutoRestSwaggerBATServiceImpl.java index a7fb25f027..9242866836 100644 --- a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodystring/AutoRestSwaggerBATServiceImpl.java +++ b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/bodystring/AutoRestSwaggerBATServiceImpl.java @@ -11,6 +11,7 @@ package fixtures.bodystring; import com.microsoft.rest.ServiceClient; +import com.microsoft.rest.AutoRestBaseUrl; import okhttp3.OkHttpClient; import retrofit2.Retrofit; @@ -19,16 +20,17 @@ */ public final class AutoRestSwaggerBATServiceImpl extends ServiceClient implements AutoRestSwaggerBATService { /** - * The URI used as the base for all cloud service requests. + * The URL used as the base for all cloud service requests. */ - private final String baseUri; + private final AutoRestBaseUrl baseUrl; /** - * Gets the URI used as the base for all cloud service requests. - * @return The BaseUri value. + * Gets the URL used as the base for all cloud service requests. + * + * @return The BaseUrl value. */ - public String getBaseUri() { - return this.baseUri; + public AutoRestBaseUrl getBaseUrl() { + return this.baseUrl; } /** @@ -57,30 +59,30 @@ public AutoRestSwaggerBATServiceImpl() { /** * Initializes an instance of AutoRestSwaggerBATService client. * - * @param baseUri the base URI of the host + * @param baseUrl the base URL of the host */ - public AutoRestSwaggerBATServiceImpl(String baseUri) { + public AutoRestSwaggerBATServiceImpl(String baseUrl) { super(); - this.baseUri = baseUri; + this.baseUrl = new AutoRestBaseUrl(baseUrl); initialize(); } /** * Initializes an instance of AutoRestSwaggerBATService client. * - * @param baseUri the base URI of the host + * @param baseUrl the base URL of the host * @param clientBuilder the builder for building up an {@link OkHttpClient} * @param retrofitBuilder the builder for building up a {@link Retrofit} */ - public AutoRestSwaggerBATServiceImpl(String baseUri, OkHttpClient.Builder clientBuilder, Retrofit.Builder retrofitBuilder) { + public AutoRestSwaggerBATServiceImpl(String baseUrl, OkHttpClient.Builder clientBuilder, Retrofit.Builder retrofitBuilder) { super(clientBuilder, retrofitBuilder); - this.baseUri = baseUri; + this.baseUrl = new AutoRestBaseUrl(baseUrl); initialize(); } @Override protected void initialize() { super.initialize(); - this.retrofitBuilder.baseUrl(baseUri); + this.retrofitBuilder.baseUrl(baseUrl); } } diff --git a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/custombaseuri/AutoRestParameterizedHostTestClient.java b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/custombaseuri/AutoRestParameterizedHostTestClient.java index 71d89b32db..c097186557 100644 --- a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/custombaseuri/AutoRestParameterizedHostTestClient.java +++ b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/custombaseuri/AutoRestParameterizedHostTestClient.java @@ -13,6 +13,7 @@ import java.util.List; import okhttp3.Interceptor; import okhttp3.logging.HttpLoggingInterceptor.Level; +import com.microsoft.rest.AutoRestBaseUrl; import com.microsoft.rest.serializer.JacksonMapperAdapter; /** @@ -20,11 +21,11 @@ */ public interface AutoRestParameterizedHostTestClient { /** - * Gets the URI used as the base for all cloud service requests. + * Gets the URL used as the base for all cloud service requests. * - * @return the BaseUri value. + * @return the BaseUrl object. */ - String getBaseUri(); + AutoRestBaseUrl getBaseUrl(); /** * Gets the list of interceptors the OkHttp client will execute. diff --git a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/custombaseuri/AutoRestParameterizedHostTestClientImpl.java b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/custombaseuri/AutoRestParameterizedHostTestClientImpl.java index f9548056b3..dcb01c24ee 100644 --- a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/custombaseuri/AutoRestParameterizedHostTestClientImpl.java +++ b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/custombaseuri/AutoRestParameterizedHostTestClientImpl.java @@ -11,6 +11,7 @@ package fixtures.custombaseuri; import com.microsoft.rest.ServiceClient; +import com.microsoft.rest.AutoRestBaseUrl; import okhttp3.OkHttpClient; import retrofit2.Retrofit; @@ -19,16 +20,17 @@ */ public final class AutoRestParameterizedHostTestClientImpl extends ServiceClient implements AutoRestParameterizedHostTestClient { /** - * The URI used as the base for all cloud service requests. + * The URL used as the base for all cloud service requests. */ - private final String baseUri; + private final AutoRestBaseUrl baseUrl; /** - * Gets the URI used as the base for all cloud service requests. - * @return The BaseUri value. + * Gets the URL used as the base for all cloud service requests. + * + * @return The BaseUrl value. */ - public String getBaseUri() { - return this.baseUri; + public AutoRestBaseUrl getBaseUrl() { + return this.baseUrl; } /** A string value that is used as a global part of the parameterized host. */ @@ -70,11 +72,11 @@ public AutoRestParameterizedHostTestClientImpl() { /** * Initializes an instance of AutoRestParameterizedHostTestClient client. * - * @param baseUri the base URI of the host + * @param baseUrl the base URL of the host */ - private AutoRestParameterizedHostTestClientImpl(String baseUri) { + private AutoRestParameterizedHostTestClientImpl(String baseUrl) { super(); - this.baseUri = baseUri; + this.baseUrl = new AutoRestBaseUrl(baseUrl); initialize(); } @@ -86,13 +88,13 @@ private AutoRestParameterizedHostTestClientImpl(String baseUri) { */ public AutoRestParameterizedHostTestClientImpl(OkHttpClient.Builder clientBuilder, Retrofit.Builder retrofitBuilder) { super(clientBuilder, retrofitBuilder); - this.baseUri = "http://{accountName}{host}"; + this.baseUrl = new AutoRestBaseUrl("http://{accountName}{host}"); initialize(); } @Override protected void initialize() { super.initialize(); - this.retrofitBuilder.baseUrl(baseUri); + this.retrofitBuilder.baseUrl(baseUrl); } } diff --git a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/custombaseuri/PathsOperations.java b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/custombaseuri/PathsOperations.java index 5808013199..9be07769c0 100644 --- a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/custombaseuri/PathsOperations.java +++ b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/custombaseuri/PathsOperations.java @@ -18,7 +18,6 @@ import retrofit2.Call; import retrofit2.http.GET; import retrofit2.http.Headers; -import retrofit2.http.Path; /** * An instance of this class provides access to all the operations defined @@ -32,7 +31,7 @@ public interface PathsOperations { interface PathsService { @Headers("Content-Type: application/json; charset=utf-8") @GET("customuri") - Call getEmpty(@Path("accountName") String accountName, @Path("host") String host); + Call getEmpty(); } /** diff --git a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/custombaseuri/PathsOperationsImpl.java b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/custombaseuri/PathsOperationsImpl.java index 52dc338bff..097fc686c0 100644 --- a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/custombaseuri/PathsOperationsImpl.java +++ b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/custombaseuri/PathsOperationsImpl.java @@ -59,7 +59,9 @@ public ServiceResponse getEmpty(String accountName) throws ErrorException, if (this.client.getHost() == null) { throw new IllegalArgumentException("Parameter this.client.getHost() is required and cannot be null."); } - Call call = service.getEmpty(accountName, this.client.getHost()); + client.getBaseUrl().set("{accountName}", accountName); + client.getBaseUrl().set("{host}", this.client.getHost()); + Call call = service.getEmpty(); return getEmptyDelegate(call.execute()); } @@ -79,7 +81,9 @@ public Call getEmptyAsync(String accountName, final ServiceCallbac serviceCallback.failure(new IllegalArgumentException("Parameter this.client.getHost() is required and cannot be null.")); return null; } - Call call = service.getEmpty(accountName, this.client.getHost()); + client.getBaseUrl().set("{accountName}", accountName); + client.getBaseUrl().set("{host}", this.client.getHost()); + Call call = service.getEmpty(); call.enqueue(new ServiceResponseCallback(serviceCallback) { @Override public void onResponse(Call call, Response response) { diff --git a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/header/AutoRestSwaggerBATHeaderService.java b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/header/AutoRestSwaggerBATHeaderService.java index 10f8439089..62bc93aa70 100644 --- a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/header/AutoRestSwaggerBATHeaderService.java +++ b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/header/AutoRestSwaggerBATHeaderService.java @@ -13,6 +13,7 @@ import java.util.List; import okhttp3.Interceptor; import okhttp3.logging.HttpLoggingInterceptor.Level; +import com.microsoft.rest.AutoRestBaseUrl; import com.microsoft.rest.serializer.JacksonMapperAdapter; /** @@ -20,11 +21,11 @@ */ public interface AutoRestSwaggerBATHeaderService { /** - * Gets the URI used as the base for all cloud service requests. + * Gets the URL used as the base for all cloud service requests. * - * @return the BaseUri value. + * @return the BaseUrl object. */ - String getBaseUri(); + AutoRestBaseUrl getBaseUrl(); /** * Gets the list of interceptors the OkHttp client will execute. diff --git a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/header/AutoRestSwaggerBATHeaderServiceImpl.java b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/header/AutoRestSwaggerBATHeaderServiceImpl.java index 12491b49c8..6dc2c0a1db 100644 --- a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/header/AutoRestSwaggerBATHeaderServiceImpl.java +++ b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/header/AutoRestSwaggerBATHeaderServiceImpl.java @@ -11,6 +11,7 @@ package fixtures.header; import com.microsoft.rest.ServiceClient; +import com.microsoft.rest.AutoRestBaseUrl; import okhttp3.OkHttpClient; import retrofit2.Retrofit; @@ -19,16 +20,17 @@ */ public final class AutoRestSwaggerBATHeaderServiceImpl extends ServiceClient implements AutoRestSwaggerBATHeaderService { /** - * The URI used as the base for all cloud service requests. + * The URL used as the base for all cloud service requests. */ - private final String baseUri; + private final AutoRestBaseUrl baseUrl; /** - * Gets the URI used as the base for all cloud service requests. - * @return The BaseUri value. + * Gets the URL used as the base for all cloud service requests. + * + * @return The BaseUrl value. */ - public String getBaseUri() { - return this.baseUri; + public AutoRestBaseUrl getBaseUrl() { + return this.baseUrl; } /** @@ -49,30 +51,30 @@ public AutoRestSwaggerBATHeaderServiceImpl() { /** * Initializes an instance of AutoRestSwaggerBATHeaderService client. * - * @param baseUri the base URI of the host + * @param baseUrl the base URL of the host */ - public AutoRestSwaggerBATHeaderServiceImpl(String baseUri) { + public AutoRestSwaggerBATHeaderServiceImpl(String baseUrl) { super(); - this.baseUri = baseUri; + this.baseUrl = new AutoRestBaseUrl(baseUrl); initialize(); } /** * Initializes an instance of AutoRestSwaggerBATHeaderService client. * - * @param baseUri the base URI of the host + * @param baseUrl the base URL of the host * @param clientBuilder the builder for building up an {@link OkHttpClient} * @param retrofitBuilder the builder for building up a {@link Retrofit} */ - public AutoRestSwaggerBATHeaderServiceImpl(String baseUri, OkHttpClient.Builder clientBuilder, Retrofit.Builder retrofitBuilder) { + public AutoRestSwaggerBATHeaderServiceImpl(String baseUrl, OkHttpClient.Builder clientBuilder, Retrofit.Builder retrofitBuilder) { super(clientBuilder, retrofitBuilder); - this.baseUri = baseUri; + this.baseUrl = new AutoRestBaseUrl(baseUrl); initialize(); } @Override protected void initialize() { super.initialize(); - this.retrofitBuilder.baseUrl(baseUri); + this.retrofitBuilder.baseUrl(baseUrl); } } diff --git a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/http/AutoRestHttpInfrastructureTestService.java b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/http/AutoRestHttpInfrastructureTestService.java index d04b267703..faf11e6007 100644 --- a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/http/AutoRestHttpInfrastructureTestService.java +++ b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/http/AutoRestHttpInfrastructureTestService.java @@ -13,6 +13,7 @@ import java.util.List; import okhttp3.Interceptor; import okhttp3.logging.HttpLoggingInterceptor.Level; +import com.microsoft.rest.AutoRestBaseUrl; import com.microsoft.rest.serializer.JacksonMapperAdapter; /** @@ -20,11 +21,11 @@ */ public interface AutoRestHttpInfrastructureTestService { /** - * Gets the URI used as the base for all cloud service requests. + * Gets the URL used as the base for all cloud service requests. * - * @return the BaseUri value. + * @return the BaseUrl object. */ - String getBaseUri(); + AutoRestBaseUrl getBaseUrl(); /** * Gets the list of interceptors the OkHttp client will execute. diff --git a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/http/AutoRestHttpInfrastructureTestServiceImpl.java b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/http/AutoRestHttpInfrastructureTestServiceImpl.java index 558ba15a29..77dcab722a 100644 --- a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/http/AutoRestHttpInfrastructureTestServiceImpl.java +++ b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/http/AutoRestHttpInfrastructureTestServiceImpl.java @@ -11,6 +11,7 @@ package fixtures.http; import com.microsoft.rest.ServiceClient; +import com.microsoft.rest.AutoRestBaseUrl; import okhttp3.OkHttpClient; import retrofit2.Retrofit; @@ -19,16 +20,17 @@ */ public final class AutoRestHttpInfrastructureTestServiceImpl extends ServiceClient implements AutoRestHttpInfrastructureTestService { /** - * The URI used as the base for all cloud service requests. + * The URL used as the base for all cloud service requests. */ - private final String baseUri; + private final AutoRestBaseUrl baseUrl; /** - * Gets the URI used as the base for all cloud service requests. - * @return The BaseUri value. + * Gets the URL used as the base for all cloud service requests. + * + * @return The BaseUrl value. */ - public String getBaseUri() { - return this.baseUri; + public AutoRestBaseUrl getBaseUrl() { + return this.baseUrl; } /** @@ -97,30 +99,30 @@ public AutoRestHttpInfrastructureTestServiceImpl() { /** * Initializes an instance of AutoRestHttpInfrastructureTestService client. * - * @param baseUri the base URI of the host + * @param baseUrl the base URL of the host */ - public AutoRestHttpInfrastructureTestServiceImpl(String baseUri) { + public AutoRestHttpInfrastructureTestServiceImpl(String baseUrl) { super(); - this.baseUri = baseUri; + this.baseUrl = new AutoRestBaseUrl(baseUrl); initialize(); } /** * Initializes an instance of AutoRestHttpInfrastructureTestService client. * - * @param baseUri the base URI of the host + * @param baseUrl the base URL of the host * @param clientBuilder the builder for building up an {@link OkHttpClient} * @param retrofitBuilder the builder for building up a {@link Retrofit} */ - public AutoRestHttpInfrastructureTestServiceImpl(String baseUri, OkHttpClient.Builder clientBuilder, Retrofit.Builder retrofitBuilder) { + public AutoRestHttpInfrastructureTestServiceImpl(String baseUrl, OkHttpClient.Builder clientBuilder, Retrofit.Builder retrofitBuilder) { super(clientBuilder, retrofitBuilder); - this.baseUri = baseUri; + this.baseUrl = new AutoRestBaseUrl(baseUrl); initialize(); } @Override protected void initialize() { super.initialize(); - this.retrofitBuilder.baseUrl(baseUri); + this.retrofitBuilder.baseUrl(baseUrl); } } diff --git a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/report/AutoRestReportService.java b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/report/AutoRestReportService.java index d0880259c5..5dbdd959f1 100644 --- a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/report/AutoRestReportService.java +++ b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/report/AutoRestReportService.java @@ -13,6 +13,7 @@ import java.util.List; import okhttp3.Interceptor; import okhttp3.logging.HttpLoggingInterceptor.Level; +import com.microsoft.rest.AutoRestBaseUrl; import com.microsoft.rest.serializer.JacksonMapperAdapter; import com.microsoft.rest.ServiceCallback; import com.microsoft.rest.ServiceResponse; @@ -29,11 +30,11 @@ */ public interface AutoRestReportService { /** - * Gets the URI used as the base for all cloud service requests. + * Gets the URL used as the base for all cloud service requests. * - * @return the BaseUri value. + * @return the BaseUrl object. */ - String getBaseUri(); + AutoRestBaseUrl getBaseUrl(); /** * Gets the list of interceptors the OkHttp client will execute. diff --git a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/report/AutoRestReportServiceImpl.java b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/report/AutoRestReportServiceImpl.java index 9c3775a8bc..c2888d951d 100644 --- a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/report/AutoRestReportServiceImpl.java +++ b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/report/AutoRestReportServiceImpl.java @@ -11,6 +11,7 @@ package fixtures.report; import com.microsoft.rest.ServiceClient; +import com.microsoft.rest.AutoRestBaseUrl; import okhttp3.OkHttpClient; import retrofit2.Retrofit; import okhttp3.logging.HttpLoggingInterceptor.Level; @@ -35,16 +36,17 @@ public final class AutoRestReportServiceImpl extends ServiceClient implements Au */ private AutoRestReportServiceService service; /** - * The URI used as the base for all cloud service requests. + * The URL used as the base for all cloud service requests. */ - private final String baseUri; + private final AutoRestBaseUrl baseUrl; /** - * Gets the URI used as the base for all cloud service requests. - * @return The BaseUri value. + * Gets the URL used as the base for all cloud service requests. + * + * @return The BaseUrl value. */ - public String getBaseUri() { - return this.baseUri; + public AutoRestBaseUrl getBaseUrl() { + return this.baseUrl; } /** @@ -57,31 +59,31 @@ public AutoRestReportServiceImpl() { /** * Initializes an instance of AutoRestReportService client. * - * @param baseUri the base URI of the host + * @param baseUrl the base URL of the host */ - public AutoRestReportServiceImpl(String baseUri) { + public AutoRestReportServiceImpl(String baseUrl) { super(); - this.baseUri = baseUri; + this.baseUrl = new AutoRestBaseUrl(baseUrl); initialize(); } /** * Initializes an instance of AutoRestReportService client. * - * @param baseUri the base URI of the host + * @param baseUrl the base URL of the host * @param clientBuilder the builder for building up an {@link OkHttpClient} * @param retrofitBuilder the builder for building up a {@link Retrofit} */ - public AutoRestReportServiceImpl(String baseUri, OkHttpClient.Builder clientBuilder, Retrofit.Builder retrofitBuilder) { + public AutoRestReportServiceImpl(String baseUrl, OkHttpClient.Builder clientBuilder, Retrofit.Builder retrofitBuilder) { super(clientBuilder, retrofitBuilder); - this.baseUri = baseUri; + this.baseUrl = new AutoRestBaseUrl(baseUrl); initialize(); } @Override protected void initialize() { super.initialize(); - this.retrofitBuilder.baseUrl(baseUri); + this.retrofitBuilder.baseUrl(baseUrl); initializeService(); } diff --git a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/requiredoptional/AutoRestRequiredOptionalTestService.java b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/requiredoptional/AutoRestRequiredOptionalTestService.java index 728c4a5d83..90e50cd109 100644 --- a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/requiredoptional/AutoRestRequiredOptionalTestService.java +++ b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/requiredoptional/AutoRestRequiredOptionalTestService.java @@ -13,6 +13,7 @@ import java.util.List; import okhttp3.Interceptor; import okhttp3.logging.HttpLoggingInterceptor.Level; +import com.microsoft.rest.AutoRestBaseUrl; import com.microsoft.rest.serializer.JacksonMapperAdapter; /** @@ -20,11 +21,11 @@ */ public interface AutoRestRequiredOptionalTestService { /** - * Gets the URI used as the base for all cloud service requests. + * Gets the URL used as the base for all cloud service requests. * - * @return the BaseUri value. + * @return the BaseUrl object. */ - String getBaseUri(); + AutoRestBaseUrl getBaseUrl(); /** * Gets the list of interceptors the OkHttp client will execute. diff --git a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/requiredoptional/AutoRestRequiredOptionalTestServiceImpl.java b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/requiredoptional/AutoRestRequiredOptionalTestServiceImpl.java index 352e460e82..73182e710d 100644 --- a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/requiredoptional/AutoRestRequiredOptionalTestServiceImpl.java +++ b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/requiredoptional/AutoRestRequiredOptionalTestServiceImpl.java @@ -11,6 +11,7 @@ package fixtures.requiredoptional; import com.microsoft.rest.ServiceClient; +import com.microsoft.rest.AutoRestBaseUrl; import okhttp3.OkHttpClient; import retrofit2.Retrofit; @@ -19,16 +20,17 @@ */ public final class AutoRestRequiredOptionalTestServiceImpl extends ServiceClient implements AutoRestRequiredOptionalTestService { /** - * The URI used as the base for all cloud service requests. + * The URL used as the base for all cloud service requests. */ - private final String baseUri; + private final AutoRestBaseUrl baseUrl; /** - * Gets the URI used as the base for all cloud service requests. - * @return The BaseUri value. + * Gets the URL used as the base for all cloud service requests. + * + * @return The BaseUrl value. */ - public String getBaseUri() { - return this.baseUri; + public AutoRestBaseUrl getBaseUrl() { + return this.baseUrl; } /** number of items to skip. */ @@ -120,30 +122,30 @@ public AutoRestRequiredOptionalTestServiceImpl() { /** * Initializes an instance of AutoRestRequiredOptionalTestService client. * - * @param baseUri the base URI of the host + * @param baseUrl the base URL of the host */ - public AutoRestRequiredOptionalTestServiceImpl(String baseUri) { + public AutoRestRequiredOptionalTestServiceImpl(String baseUrl) { super(); - this.baseUri = baseUri; + this.baseUrl = new AutoRestBaseUrl(baseUrl); initialize(); } /** * Initializes an instance of AutoRestRequiredOptionalTestService client. * - * @param baseUri the base URI of the host + * @param baseUrl the base URL of the host * @param clientBuilder the builder for building up an {@link OkHttpClient} * @param retrofitBuilder the builder for building up a {@link Retrofit} */ - public AutoRestRequiredOptionalTestServiceImpl(String baseUri, OkHttpClient.Builder clientBuilder, Retrofit.Builder retrofitBuilder) { + public AutoRestRequiredOptionalTestServiceImpl(String baseUrl, OkHttpClient.Builder clientBuilder, Retrofit.Builder retrofitBuilder) { super(clientBuilder, retrofitBuilder); - this.baseUri = baseUri; + this.baseUrl = new AutoRestBaseUrl(baseUrl); initialize(); } @Override protected void initialize() { super.initialize(); - this.retrofitBuilder.baseUrl(baseUri); + this.retrofitBuilder.baseUrl(baseUrl); } } diff --git a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/url/AutoRestUrlTestService.java b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/url/AutoRestUrlTestService.java index 75765029d1..5162b3bbc8 100644 --- a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/url/AutoRestUrlTestService.java +++ b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/url/AutoRestUrlTestService.java @@ -13,6 +13,7 @@ import java.util.List; import okhttp3.Interceptor; import okhttp3.logging.HttpLoggingInterceptor.Level; +import com.microsoft.rest.AutoRestBaseUrl; import com.microsoft.rest.serializer.JacksonMapperAdapter; /** @@ -20,11 +21,11 @@ */ public interface AutoRestUrlTestService { /** - * Gets the URI used as the base for all cloud service requests. + * Gets the URL used as the base for all cloud service requests. * - * @return the BaseUri value. + * @return the BaseUrl object. */ - String getBaseUri(); + AutoRestBaseUrl getBaseUrl(); /** * Gets the list of interceptors the OkHttp client will execute. diff --git a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/url/AutoRestUrlTestServiceImpl.java b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/url/AutoRestUrlTestServiceImpl.java index b2c498dbee..ba33b3c4af 100644 --- a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/url/AutoRestUrlTestServiceImpl.java +++ b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/url/AutoRestUrlTestServiceImpl.java @@ -11,6 +11,7 @@ package fixtures.url; import com.microsoft.rest.ServiceClient; +import com.microsoft.rest.AutoRestBaseUrl; import okhttp3.OkHttpClient; import retrofit2.Retrofit; @@ -19,16 +20,17 @@ */ public final class AutoRestUrlTestServiceImpl extends ServiceClient implements AutoRestUrlTestService { /** - * The URI used as the base for all cloud service requests. + * The URL used as the base for all cloud service requests. */ - private final String baseUri; + private final AutoRestBaseUrl baseUrl; /** - * Gets the URI used as the base for all cloud service requests. - * @return The BaseUri value. + * Gets the URL used as the base for all cloud service requests. + * + * @return The BaseUrl value. */ - public String getBaseUri() { - return this.baseUri; + public AutoRestBaseUrl getBaseUrl() { + return this.baseUrl; } /** A string value 'globalItemStringPath' that appears in the path. */ @@ -107,30 +109,30 @@ public AutoRestUrlTestServiceImpl() { /** * Initializes an instance of AutoRestUrlTestService client. * - * @param baseUri the base URI of the host + * @param baseUrl the base URL of the host */ - public AutoRestUrlTestServiceImpl(String baseUri) { + public AutoRestUrlTestServiceImpl(String baseUrl) { super(); - this.baseUri = baseUri; + this.baseUrl = new AutoRestBaseUrl(baseUrl); initialize(); } /** * Initializes an instance of AutoRestUrlTestService client. * - * @param baseUri the base URI of the host + * @param baseUrl the base URL of the host * @param clientBuilder the builder for building up an {@link OkHttpClient} * @param retrofitBuilder the builder for building up a {@link Retrofit} */ - public AutoRestUrlTestServiceImpl(String baseUri, OkHttpClient.Builder clientBuilder, Retrofit.Builder retrofitBuilder) { + public AutoRestUrlTestServiceImpl(String baseUrl, OkHttpClient.Builder clientBuilder, Retrofit.Builder retrofitBuilder) { super(clientBuilder, retrofitBuilder); - this.baseUri = baseUri; + this.baseUrl = new AutoRestBaseUrl(baseUrl); initialize(); } @Override protected void initialize() { super.initialize(); - this.retrofitBuilder.baseUrl(baseUri); + this.retrofitBuilder.baseUrl(baseUrl); } } diff --git a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/validation/AutoRestValidationTest.java b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/validation/AutoRestValidationTest.java index 4cee40c21c..b22ebbd955 100644 --- a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/validation/AutoRestValidationTest.java +++ b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/validation/AutoRestValidationTest.java @@ -13,6 +13,7 @@ import java.util.List; import okhttp3.Interceptor; import okhttp3.logging.HttpLoggingInterceptor.Level; +import com.microsoft.rest.AutoRestBaseUrl; import com.microsoft.rest.serializer.JacksonMapperAdapter; import com.microsoft.rest.ServiceCallback; import com.microsoft.rest.ServiceException; @@ -35,11 +36,11 @@ */ public interface AutoRestValidationTest { /** - * Gets the URI used as the base for all cloud service requests. + * Gets the URL used as the base for all cloud service requests. * - * @return the BaseUri value. + * @return the BaseUrl object. */ - String getBaseUri(); + AutoRestBaseUrl getBaseUrl(); /** * Gets the list of interceptors the OkHttp client will execute. diff --git a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/validation/AutoRestValidationTestImpl.java b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/validation/AutoRestValidationTestImpl.java index 594eac1dbb..02d5744404 100644 --- a/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/validation/AutoRestValidationTestImpl.java +++ b/AutoRest/Generators/Java/Java.Tests/src/main/java/fixtures/validation/AutoRestValidationTestImpl.java @@ -11,6 +11,7 @@ package fixtures.validation; import com.microsoft.rest.ServiceClient; +import com.microsoft.rest.AutoRestBaseUrl; import okhttp3.OkHttpClient; import retrofit2.Retrofit; import okhttp3.logging.HttpLoggingInterceptor.Level; @@ -36,16 +37,17 @@ public final class AutoRestValidationTestImpl extends ServiceClient implements A */ private AutoRestValidationTestService service; /** - * The URI used as the base for all cloud service requests. + * The URL used as the base for all cloud service requests. */ - private final String baseUri; + private final AutoRestBaseUrl baseUrl; /** - * Gets the URI used as the base for all cloud service requests. - * @return The BaseUri value. + * Gets the URL used as the base for all cloud service requests. + * + * @return The BaseUrl value. */ - public String getBaseUri() { - return this.baseUri; + public AutoRestBaseUrl getBaseUrl() { + return this.baseUrl; } /** Subscription ID. */ @@ -100,31 +102,31 @@ public AutoRestValidationTestImpl() { /** * Initializes an instance of AutoRestValidationTest client. * - * @param baseUri the base URI of the host + * @param baseUrl the base URL of the host */ - public AutoRestValidationTestImpl(String baseUri) { + public AutoRestValidationTestImpl(String baseUrl) { super(); - this.baseUri = baseUri; + this.baseUrl = new AutoRestBaseUrl(baseUrl); initialize(); } /** * Initializes an instance of AutoRestValidationTest client. * - * @param baseUri the base URI of the host + * @param baseUrl the base URL of the host * @param clientBuilder the builder for building up an {@link OkHttpClient} * @param retrofitBuilder the builder for building up a {@link Retrofit} */ - public AutoRestValidationTestImpl(String baseUri, OkHttpClient.Builder clientBuilder, Retrofit.Builder retrofitBuilder) { + public AutoRestValidationTestImpl(String baseUrl, OkHttpClient.Builder clientBuilder, Retrofit.Builder retrofitBuilder) { super(clientBuilder, retrofitBuilder); - this.baseUri = baseUri; + this.baseUrl = new AutoRestBaseUrl(baseUrl); initialize(); } @Override protected void initialize() { super.initialize(); - this.retrofitBuilder.baseUrl(baseUri); + this.retrofitBuilder.baseUrl(baseUrl); initializeService(); } diff --git a/AutoRest/Generators/Java/Java.Tests/src/test/java/fixtures/custombaseuri/CustomBaseUriTests.java b/AutoRest/Generators/Java/Java.Tests/src/test/java/fixtures/custombaseuri/CustomBaseUriTests.java index 2e26781f1f..2e5ca1f527 100644 --- a/AutoRest/Generators/Java/Java.Tests/src/test/java/fixtures/custombaseuri/CustomBaseUriTests.java +++ b/AutoRest/Generators/Java/Java.Tests/src/test/java/fixtures/custombaseuri/CustomBaseUriTests.java @@ -4,7 +4,7 @@ import org.junit.BeforeClass; import org.junit.Test; -import fixtures.custombaseuri.models.ErrorException; +import java.net.UnknownHostException; public class CustomBaseUriTests { private static AutoRestParameterizedHostTestClient client; @@ -27,7 +27,7 @@ public void getEmptyWithInvalidCustomUriAccountName() throws Exception { client.getPathsOperations().getEmpty("bad"); Assert.assertTrue(false); } - catch (ErrorException e) { + catch (UnknownHostException e) { Assert.assertTrue(true); } } @@ -39,7 +39,7 @@ public void getEmptyWithInvalidCustomUriHostName() throws Exception { client.getPathsOperations().getEmpty("local"); Assert.assertTrue(false); } - catch (ErrorException e) { + catch (UnknownHostException e) { Assert.assertTrue(true); } finally { diff --git a/AutoRest/Generators/Java/Java/TemplateModels/MethodTemplateModel.cs b/AutoRest/Generators/Java/Java/TemplateModels/MethodTemplateModel.cs index de4fe11217..5daa9ae7fd 100644 --- a/AutoRest/Generators/Java/Java/TemplateModels/MethodTemplateModel.cs +++ b/AutoRest/Generators/Java/Java/TemplateModels/MethodTemplateModel.cs @@ -53,7 +53,8 @@ public IEnumerable OrderedLogicalParameters get { return LogicalParameters.Where(p => p.Location == ParameterLocation.Path) - .Union(LogicalParameters.Where(p => p.Location != ParameterLocation.Path)); + .Union(LogicalParameters.Where(p => p.Location != ParameterLocation.Path)) + .Where(p => !p.Extensions.ContainsKey("hostParameter")); } } @@ -558,12 +559,12 @@ public virtual List InterfaceImports imports.Add("com.microsoft.rest.ServiceCallback"); // parameter types this.Parameters.ForEach(p => imports.AddRange(p.Type.ImportFrom(ServiceClient.Namespace))); - this.LogicalParameters + this.OrderedLogicalParameters .Where(p => p.Location == ParameterLocation.Body || !p.Type.NeedsSpecialSerialization()) .ForEach(p => imports.AddRange(p.Type.ImportFrom(ServiceClient.Namespace))); // parameter locations - this.LogicalParameters.ForEach(p => + this.OrderedLogicalParameters.ForEach(p => { string locationImport = p.Location.ImportFrom(); if (!string.IsNullOrEmpty(locationImport)) diff --git a/AutoRest/Generators/Java/Java/TemplateModels/ServiceClientTemplateModel.cs b/AutoRest/Generators/Java/Java/TemplateModels/ServiceClientTemplateModel.cs index 8c4abc16f9..204d878377 100644 --- a/AutoRest/Generators/Java/Java/TemplateModels/ServiceClientTemplateModel.cs +++ b/AutoRest/Generators/Java/Java/TemplateModels/ServiceClientTemplateModel.cs @@ -66,6 +66,7 @@ public virtual IEnumerable ImplImports } classes.AddRange(new[]{ "com.microsoft.rest.ServiceClient", + "com.microsoft.rest.AutoRestBaseUrl", "okhttp3.OkHttpClient", "retrofit2.Retrofit" }); @@ -95,6 +96,7 @@ public virtual List InterfaceImports classes.Add("java.util.List"); classes.Add("okhttp3.Interceptor"); classes.Add("okhttp3.logging.HttpLoggingInterceptor.Level"); + classes.Add("com.microsoft.rest.AutoRestBaseUrl"); classes.Add("com.microsoft.rest.serializer.JacksonMapperAdapter"); if (this.Properties.Any(p => p.Type.IsPrimaryType(KnownPrimaryType.Credentials))) { diff --git a/AutoRest/Generators/Java/Java/Templates/MethodTemplate.cshtml b/AutoRest/Generators/Java/Java/Templates/MethodTemplate.cshtml index 21586c7534..31967f7655 100644 --- a/AutoRest/Generators/Java/Java/Templates/MethodTemplate.cshtml +++ b/AutoRest/Generators/Java/Java/Templates/MethodTemplate.cshtml @@ -81,6 +81,13 @@ foreach (var transformation in Model.InputParameterTransformation.Where(t => t.P @: @outType @outProp = @(inParam).get@(inProp.ToPascalCase())(); } } +} +@if (Model.ServiceClient.Extensions.ContainsKey(Microsoft.Rest.Generator.Extensions.ParameterizedHostExtension)) +{ +foreach (var param in Model.Parameters.Where(p => p.Extensions.ContainsKey("hostParameter"))) +{ +@: @(Model.ClientReference).getBaseUrl().set("{@(param.SerializedName)}", @param.Name); +} } Call<@Model.CallType> call = service.@(Model.Name)(@Model.MethodParameterApiInvocation); @Model.ResponseGeneration @@ -155,6 +162,13 @@ foreach (var transformation in Model.InputParameterTransformation.Where(t => t.P @: @outType @outProp = @(inParam).get@(inProp.ToPascalCase())(); } } +} +@if (Model.ServiceClient.Extensions.ContainsKey(Microsoft.Rest.Generator.Extensions.ParameterizedHostExtension)) +{ +foreach (var param in Model.Parameters.Where(p => p.Extensions.ContainsKey("hostParameter"))) +{ +@: @(Model.ClientReference).getBaseUrl().set("{@(param.SerializedName)}", @param.Name); +} } Call<@Model.CallType> call = service.@(Model.Name)(@Model.MethodParameterApiInvocation); call.enqueue(new @Model.InternalCallback<@(JavaCodeNamer.WrapPrimitiveType(Model.ReturnType.Body).Name)>(serviceCallback) { diff --git a/AutoRest/Generators/Java/Java/Templates/ServiceClientInterfaceTemplate.cshtml b/AutoRest/Generators/Java/Java/Templates/ServiceClientInterfaceTemplate.cshtml index e3fab674cb..ee97d46ee8 100644 --- a/AutoRest/Generators/Java/Java/Templates/ServiceClientInterfaceTemplate.cshtml +++ b/AutoRest/Generators/Java/Java/Templates/ServiceClientInterfaceTemplate.cshtml @@ -23,11 +23,11 @@ package @(Settings.Namespace.ToLower()); */ public interface @Model.Name { /** - * Gets the URI used as the base for all cloud service requests. + * Gets the URL used as the base for all cloud service requests. * - * @@return the BaseUri value. + * @@return the BaseUrl object. */ - String getBaseUri(); + AutoRestBaseUrl getBaseUrl(); @EmptyLine /** * Gets the list of interceptors the OkHttp client will execute. diff --git a/AutoRest/Generators/Java/Java/Templates/ServiceClientTemplate.cshtml b/AutoRest/Generators/Java/Java/Templates/ServiceClientTemplate.cshtml index 0f509dc8f6..17302da278 100644 --- a/AutoRest/Generators/Java/Java/Templates/ServiceClientTemplate.cshtml +++ b/AutoRest/Generators/Java/Java/Templates/ServiceClientTemplate.cshtml @@ -31,16 +31,17 @@ public final class @(Model.Name)Impl extends ServiceClient implements @Model.Nam @: private @Model.ServiceClientServiceType service; } /** - * The URI used as the base for all cloud service requests. + * The URL used as the base for all cloud service requests. */ - private final String baseUri; + private final AutoRestBaseUrl baseUrl; @EmptyLine /** - * Gets the URI used as the base for all cloud service requests. - * @@return The BaseUri value. + * Gets the URL used as the base for all cloud service requests. + * + * @@return The BaseUrl value. */ - public String getBaseUri() { - return this.baseUri; + public AutoRestBaseUrl getBaseUrl() { + return this.baseUrl; } @foreach (var property in Model.Properties) { @@ -92,11 +93,11 @@ if(!property.IsReadOnly) /** * Initializes an instance of @(Model.Name) client. * - * @@param baseUri the base URI of the host + * @@param baseUrl the base URL of the host */ - @(Model.IsCustomBaseUri ? "private" : "public") @(Model.Name)Impl(String baseUri) { + @(Model.IsCustomBaseUri ? "private" : "public") @(Model.Name)Impl(String baseUrl) { super(); - this.baseUri = baseUri; + this.baseUrl = new AutoRestBaseUrl(baseUrl); initialize(); } @@ -104,20 +105,20 @@ if(!property.IsReadOnly) /** * Initializes an instance of @(Model.Name) client. * - @(Model.IsCustomBaseUri ? "" : "* @param baseUri the base URI of the host") + @(Model.IsCustomBaseUri ? "" : "* @param baseUrl the base URL of the host") * @@param clientBuilder the builder for building up an {@@link OkHttpClient} * @@param retrofitBuilder the builder for building up a {@@link Retrofit} */ - public @(Model.Name)Impl(@(Model.IsCustomBaseUri ? "" : "String baseUri, ")OkHttpClient.Builder clientBuilder, Retrofit.Builder retrofitBuilder) { + public @(Model.Name)Impl(@(Model.IsCustomBaseUri ? "" : "String baseUrl, ")OkHttpClient.Builder clientBuilder, Retrofit.Builder retrofitBuilder) { super(clientBuilder, retrofitBuilder); @if (Model.IsCustomBaseUri) { - @:this.baseUri = "@(Model.BaseUrl)"; + @:this.baseUrl = new AutoRestBaseUrl("@(Model.BaseUrl)"); } else { - @:this.baseUri = baseUri; + @:this.baseUrl = new AutoRestBaseUrl(baseUrl); } initialize(); @@ -134,7 +135,7 @@ else @: } } super.initialize(); - this.retrofitBuilder.baseUrl(baseUri); + this.retrofitBuilder.baseUrl(baseUrl); @if (Model.MethodTemplateModels.Any()) { @: initializeService(); diff --git a/ClientRuntimes/Java/client-runtime/src/main/java/com/microsoft/rest/AutoRestBaseUrl.java b/ClientRuntimes/Java/client-runtime/src/main/java/com/microsoft/rest/AutoRestBaseUrl.java new file mode 100644 index 0000000000..d89aa6852f --- /dev/null +++ b/ClientRuntimes/Java/client-runtime/src/main/java/com/microsoft/rest/AutoRestBaseUrl.java @@ -0,0 +1,53 @@ +/** + * + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + * + */ + +package com.microsoft.rest; + +import java.util.HashMap; +import java.util.Map; + +import okhttp3.HttpUrl; +import retrofit2.BaseUrl; + +/** + * An instance of this class stores information of the host of a service. + */ +public class AutoRestBaseUrl implements BaseUrl { + /** A template based URL with variables wrapped in {}s. */ + private String template; + /** a mapping from {} wrapped variables in the template and their actual values. */ + private Map mappings; + + @Override + public HttpUrl url() { + String url = template; + for (Map.Entry entry : mappings.entrySet()) { + url = url.replace(entry.getKey(), entry.getValue()); + } + mappings.clear(); + return HttpUrl.parse(url); + } + + /** + * Creates an instance of a template based URL. + * + * @param url the template based URL to use. + */ + public AutoRestBaseUrl(String url) { + this.template = url; + this.mappings = new HashMap<>(); + } + + /** + * Sets the value for the {} wrapped variables in the template URL. + * @param matcher the {} wrapped variable to replace. + * @param value the value to set for the variable. + */ + public void set(CharSequence matcher, String value) { + this.mappings.put(matcher, value); + } +}