/** * Try to extract the environment the client is authenticated to based * on the information on the rest client. * @param restClient the RestClient instance * @return the non-null AzureEnvironment */ public static AzureEnvironment extractAzureEnvironment(RestClient restClient) { AzureEnvironment environment = null; if (restClient.credentials() instanceof AzureTokenCredentials) { environment = ((AzureTokenCredentials) restClient.credentials()).environment(); } else { String baseUrl = restClient.retrofit().baseUrl().toString(); for (AzureEnvironment env : AzureEnvironment.knownEnvironments()) { if (env.resourceManagerEndpoint().toLowerCase().contains(baseUrl.toLowerCase())) { environment = env; break; } } if (environment == null) { throw new IllegalArgumentException("Unknown resource manager endpoint " + baseUrl); } } return environment; }
/** * Try to extract the environment the client is authenticated to based * on the information on the rest client. * @param restClient the RestClient instance * @return the non-null AzureEnvironment */ public static AzureEnvironment extractAzureEnvironment(RestClient restClient) { AzureEnvironment environment = null; if (restClient.credentials() instanceof AzureTokenCredentials) { environment = ((AzureTokenCredentials) restClient.credentials()).environment(); } else { String baseUrl = restClient.retrofit().baseUrl().toString(); for (AzureEnvironment env : AzureEnvironment.knownEnvironments()) { if (env.resourceManagerEndpoint().toLowerCase().contains(baseUrl.toLowerCase())) { environment = env; break; } } if (environment == null) { throw new IllegalArgumentException("Unknown resource manager endpoint " + baseUrl); } } return environment; }
AzureEnvironment environment() { RestClient restClient = this.manager().inner().restClient(); AzureEnvironment environment = null; if (restClient.credentials() instanceof AzureTokenCredentials) { environment = ((AzureTokenCredentials) restClient.credentials()).environment(); } String baseUrl = restClient.retrofit().baseUrl().toString(); for (AzureEnvironment env : AzureEnvironment.knownEnvironments()) { if (env.resourceManagerEndpoint().toLowerCase().contains(baseUrl.toLowerCase())) { environment = env; break; } } if (environment != null) { return environment; } throw new IllegalArgumentException("Unknown environment"); }
AzureEnvironment environment() { RestClient restClient = this.manager().inner().restClient(); AzureEnvironment environment = null; if (restClient.credentials() instanceof AzureTokenCredentials) { environment = ((AzureTokenCredentials) restClient.credentials()).environment(); } String baseUrl = restClient.retrofit().baseUrl().toString(); for (AzureEnvironment env : AzureEnvironment.knownEnvironments()) { if (env.resourceManagerEndpoint().toLowerCase().contains(baseUrl.toLowerCase())) { environment = env; break; } } if (environment != null) { return environment; } throw new IllegalArgumentException("Unknown environment"); }