1
2
3
4 package com.azure.core;
5
6 import java.util.Arrays;
7 import java.util.HashMap;
8 import java.util.List;
9 import java.util.Map;
10
11
12
13
14 public final class AzureEnvironment {
15
16 private final Map<String, String> endpoints;
17
18
19
20
21
22
23 public AzureEnvironment(Map<String, String> endpoints) {
24 this.endpoints = endpoints;
25 }
26
27
28
29
30 public static final AzureEnvironmentreEnvironment">AzureEnvironment AZURE = new AzureEnvironment(new HashMap<String, String>() {{
31 put("portalUrl", "http://go.microsoft.com/fwlink/?LinkId=254433");
32 put("publishingProfileUrl", "http://go.microsoft.com/fwlink/?LinkId=254432");
33 put("managementEndpointUrl", "https://management.core.windows.net/");
34 put("resourceManagerEndpointUrl", "https://management.azure.com/");
35 put("sqlManagementEndpointUrl", "https://management.core.windows.net:8443/");
36 put("sqlServerHostnameSuffix", ".database.windows.net");
37 put("galleryEndpointUrl", "https://gallery.azure.com/");
38 put("activeDirectoryEndpointUrl", "https://login.microsoftonline.com/");
39 put("activeDirectoryResourceId", "https://management.core.windows.net/");
40 put("activeDirectoryGraphResourceId", "https://graph.windows.net/");
41 put("dataLakeEndpointResourceId", "https://datalake.azure.net/");
42 put("activeDirectoryGraphApiVersion", "2013-04-05");
43 put("storageEndpointSuffix", ".core.windows.net");
44 put("keyVaultDnsSuffix", ".vault.azure.net");
45 put("azureDataLakeStoreFileSystemEndpointSuffix", "azuredatalakestore.net");
46 put("azureDataLakeAnalyticsCatalogAndJobEndpointSuffix", "azuredatalakeanalytics.net");
47 put("azureLogAnalyticsResourceId", "https://api.loganalytics.io/");
48 put("azureApplicationInsightsResourceId", "https://api.applicationinsights.io/");
49 }});
50
51
52
53
54 public static final AzureEnvironmentronment">AzureEnvironment AZURE_CHINA = new AzureEnvironment(new HashMap<String, String>() {{
55 put("portalUrl", "http://go.microsoft.com/fwlink/?LinkId=301902");
56 put("publishingProfileUrl", "http://go.microsoft.com/fwlink/?LinkID=301774");
57 put("managementEndpointUrl", "https://management.core.chinacloudapi.cn/");
58 put("resourceManagerEndpointUrl", "https://management.chinacloudapi.cn/");
59 put("sqlManagementEndpointUrl", "https://management.core.chinacloudapi.cn:8443/");
60 put("sqlServerHostnameSuffix", ".database.chinacloudapi.cn");
61 put("galleryEndpointUrl", "https://gallery.chinacloudapi.cn/");
62 put("activeDirectoryEndpointUrl", "https://login.chinacloudapi.cn/");
63 put("activeDirectoryResourceId", "https://management.core.chinacloudapi.cn/");
64 put("activeDirectoryGraphResourceId", "https://graph.chinacloudapi.cn/");
65
66 put("dataLakeEndpointResourceId", "N/A");
67 put("activeDirectoryGraphApiVersion", "2013-04-05");
68 put("storageEndpointSuffix", ".core.chinacloudapi.cn");
69 put("keyVaultDnsSuffix", ".vault.azure.cn");
70
71 put("azureDataLakeStoreFileSystemEndpointSuffix", "N/A");
72 put("azureDataLakeAnalyticsCatalogAndJobEndpointSuffix", "N/A");
73 put("azureLogAnalyticsResourceId", "N/A");
74 put("azureApplicationInsightsResourceId", "N/A");
75 }});
76
77
78
79
80 public static final AzureEnvironment>AzureEnvironment AZURE_US_GOVERNMENT = new AzureEnvironment(new HashMap<String, String>() {{
81 put("portalUrl", "https://manage.windowsazure.us");
82 put("publishingProfileUrl", "https://manage.windowsazure.us/publishsettings/index");
83 put("managementEndpointUrl", "https://management.core.usgovcloudapi.net/");
84 put("resourceManagerEndpointUrl", "https://management.usgovcloudapi.net/");
85 put("sqlManagementEndpointUrl", "https://management.core.usgovcloudapi.net:8443/");
86 put("sqlServerHostnameSuffix", ".database.usgovcloudapi.net");
87 put("galleryEndpointUrl", "https://gallery.usgovcloudapi.net/");
88 put("activeDirectoryEndpointUrl", "https://login.microsoftonline.us/");
89 put("activeDirectoryResourceId", "https://management.core.usgovcloudapi.net/");
90 put("activeDirectoryGraphResourceId", "https://graph.windows.net/");
91
92 put("dataLakeEndpointResourceId", "N/A");
93 put("activeDirectoryGraphApiVersion", "2013-04-05");
94 put("storageEndpointSuffix", ".core.usgovcloudapi.net");
95 put("keyVaultDnsSuffix", ".vault.usgovcloudapi.net");
96
97 put("azureDataLakeStoreFileSystemEndpointSuffix", "N/A");
98 put("azureDataLakeAnalyticsCatalogAndJobEndpointSuffix", "N/A");
99 put("azureLogAnalyticsResourceId", "https://api.loganalytics.us/");
100 put("azureApplicationInsightsResourceId", "N/A");
101 }});
102
103
104
105
106 public static final AzureEnvironmentnment">AzureEnvironment AZURE_GERMANY = new AzureEnvironment(new HashMap<String, String>() {{
107 put("portalUrl", "http://portal.microsoftazure.de/");
108 put("publishingProfileUrl", "https://manage.microsoftazure.de/publishsettings/index");
109 put("managementEndpointUrl", "https://management.core.cloudapi.de/");
110 put("resourceManagerEndpointUrl", "https://management.microsoftazure.de/");
111 put("sqlManagementEndpointUrl", "https://management.core.cloudapi.de:8443/");
112 put("sqlServerHostnameSuffix", ".database.cloudapi.de");
113 put("galleryEndpointUrl", "https://gallery.cloudapi.de/");
114 put("activeDirectoryEndpointUrl", "https://login.microsoftonline.de/");
115 put("activeDirectoryResourceId", "https://management.core.cloudapi.de/");
116 put("activeDirectoryGraphResourceId", "https://graph.cloudapi.de/");
117
118 put("dataLakeEndpointResourceId", "N/A");
119 put("activeDirectoryGraphApiVersion", "2013-04-05");
120 put("storageEndpointSuffix", ".core.cloudapi.de");
121 put("keyVaultDnsSuffix", ".vault.microsoftazure.de");
122
123 put("azureDataLakeStoreFileSystemEndpointSuffix", "N/A");
124 put("azureDataLakeAnalyticsCatalogAndJobEndpointSuffix", "N/A");
125 put("azureLogAnalyticsResourceId", "N/A");
126 put("azureApplicationInsightsResourceId", "N/A");
127 }});
128
129
130
131
132 public Map<String, String> endpoints() {
133 return endpoints;
134 }
135
136
137
138
139 public static AzureEnvironment[] knownEnvironments() {
140 List<AzureEnvironment> environments = Arrays.asList(AZURE, AZURE_CHINA, AZURE_GERMANY, AZURE_US_GOVERNMENT);
141 return environments.toArray(new AzureEnvironment[environments.size()]);
142 }
143
144
145
146
147 public String portal() {
148 return endpoints.get("portalUrl");
149 }
150
151
152
153
154 public String publishingProfile() {
155 return endpoints.get("publishingProfileUrl");
156 }
157
158
159
160
161 public String managementEndpoint() {
162 return endpoints.get("managementEndpointUrl");
163 }
164
165
166
167
168 public String resourceManagerEndpoint() {
169 return endpoints.get("resourceManagerEndpointUrl");
170 }
171
172
173
174
175 public String sqlManagementEndpoint() {
176 return endpoints.get("sqlManagementEndpointUrl");
177 }
178
179
180
181
182 public String sqlServerHostnameSuffix() {
183 return endpoints.get("sqlServerHostnameSuffix");
184 }
185
186
187
188
189 public String activeDirectoryEndpoint() {
190 return endpoints.get("activeDirectoryEndpointUrl").replaceAll("/$", "") + "/";
191 }
192
193
194
195
196 public String activeDirectoryResourceId() {
197 return endpoints.get("activeDirectoryResourceId");
198 }
199
200
201
202
203 public String galleryEndpoint() {
204 return endpoints.get("galleryEndpointUrl");
205 }
206
207
208
209
210 public String graphEndpoint() {
211 return endpoints.get("activeDirectoryGraphResourceId");
212 }
213
214
215
216
217 public String dataLakeEndpointResourceId() {
218 return endpoints.get("dataLakeEndpointResourceId");
219 }
220
221
222
223
224 public String activeDirectoryGraphApiVersion() {
225 return endpoints.get("activeDirectoryGraphApiVersion");
226 }
227
228
229
230
231 public String storageEndpointSuffix() {
232 return endpoints.get("storageEndpointSuffix");
233 }
234
235
236
237
238 public String keyVaultDnsSuffix() {
239 return endpoints.get("keyVaultDnsSuffix");
240 }
241
242
243
244
245 public String azureDataLakeStoreFileSystemEndpointSuffix() {
246 return endpoints.get("azureDataLakeStoreFileSystemEndpointSuffix");
247 }
248
249
250
251
252 public String azureDataLakeAnalyticsCatalogAndJobEndpointSuffix() {
253 return endpoints.get("azureDataLakeAnalyticsCatalogAndJobEndpointSuffix");
254 }
255
256
257
258
259 public String logAnalyticsEndpoint() {
260 return endpoints.get("azureLogAnalyticsResourceId");
261 }
262
263
264
265
266 public String applicationInsightsEndpoint() {
267 return endpoints.get("azureApplicationInsightsResourceId");
268 }
269
270
271
272
273
274 public enum Endpoint {
275
276 MANAGEMENT("managementEndpointUrl"),
277
278 RESOURCE_MANAGER("resourceManagerEndpointUrl"),
279
280 SQL("sqlManagementEndpointUrl"),
281
282 GALLERY("galleryEndpointUrl"),
283
284 ACTIVE_DIRECTORY("activeDirectoryEndpointUrl"),
285
286 GRAPH("activeDirectoryGraphResourceId"),
287
288 KEYVAULT("keyVaultDnsSuffix"),
289
290 DATA_LAKE_STORE("azureDataLakeStoreFileSystemEndpointSuffix"),
291
292 DATA_LAKE_ANALYTICS("azureDataLakeAnalyticsCatalogAndJobEndpointSuffix"),
293
294 LOG_ANALYTICS("azureLogAnalyticsResourceId"),
295
296 APPLICATION_INSIGHTS("azureApplicationInsightsResourceId");
297
298 private String field;
299
300 Endpoint(String value) {
301 this.field = value;
302 }
303
304
305
306
307 public String identifier() {
308 return field;
309 }
310
311 @Override
312 public String toString() {
313 return field;
314 }
315 }
316
317
318
319
320
321
322
323 public String url(Endpoint endpoint) {
324 return endpoints.get(endpoint.identifier());
325 }
326 }