-
Notifications
You must be signed in to change notification settings - Fork 60
Expand file tree
/
Copy pathAzureEnvironment.java
More file actions
288 lines (254 loc) · 10.9 KB
/
Copy pathAzureEnvironment.java
File metadata and controls
288 lines (254 loc) · 10.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
/**
* 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.azure;
import com.microsoft.rest.protocol.Environment;
import java.io.Serializable;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* An instance of this class describes an environment in Azure.
*/
public final class AzureEnvironment implements Environment, Serializable {
private static final long serialVersionUID = 2419074576693L;
/** the map of all endpoints. */
private final Map<String, String> endpoints;
/**
* Initializes an instance of AzureEnvironment class.
*
* @param endpoints a map storing all the endpoint info
*/
public AzureEnvironment(Map<String, String> endpoints) {
this.endpoints = endpoints;
}
/**
* Provides the settings for authentication with Azure.
*/
public static final AzureEnvironment AZURE = new AzureEnvironment(new HashMap<String, String>() {{
put("portalUrl", "http://go.microsoft.com/fwlink/?LinkId=254433");
put("publishingProfileUrl", "http://go.microsoft.com/fwlink/?LinkId=254432");
put("managementEndpointUrl", "https://management.core.windows.net");
put("resourceManagerEndpointUrl", "https://management.azure.com/");
put("sqlManagementEndpointUrl", "https://management.core.windows.net:8443/");
put("sqlServerHostnameSuffix", ".database.windows.net");
put("galleryEndpointUrl", "https://gallery.azure.com/");
put("activeDirectoryEndpointUrl", "https://login.microsoftonline.com/");
put("activeDirectoryResourceId", "https://management.core.windows.net/");
put("activeDirectoryGraphResourceId", "https://graph.windows.net/");
put("activeDirectoryGraphApiVersion", "2013-04-05");
put("storageEndpointSuffix", ".core.windows.net");
put("keyVaultDnsSuffix", ".vault.azure.net");
put("azureDataLakeStoreFileSystemEndpointSuffix", "azuredatalakestore.net");
put("azureDataLakeAnalyticsCatalogAndJobEndpointSuffix", "azuredatalakeanalytics.net");
}});
/**
* Provides the settings for authentication with Azure China.
*/
public static final AzureEnvironment AZURE_CHINA = new AzureEnvironment(new HashMap<String, String>() {{
put("portalUrl", "http://go.microsoft.com/fwlink/?LinkId=301902");
put("publishingProfileUrl", "http://go.microsoft.com/fwlink/?LinkID=301774");
put("managementEndpointUrl", "https://management.core.chinacloudapi.cn");
put("resourceManagerEndpointUrl", "https://management.chinacloudapi.cn");
put("sqlManagementEndpointUrl", "https://management.core.chinacloudapi.cn:8443/");
put("sqlServerHostnameSuffix", ".database.chinacloudapi.cn");
put("galleryEndpointUrl", "https://gallery.chinacloudapi.cn/");
put("activeDirectoryEndpointUrl", "https://login.chinacloudapi.cn/");
put("activeDirectoryResourceId", "https://management.core.chinacloudapi.cn/");
put("activeDirectoryGraphResourceId", "https://graph.chinacloudapi.cn/");
put("activeDirectoryGraphApiVersion", "2013-04-05");
put("storageEndpointSuffix", ".core.chinacloudapi.cn");
put("keyVaultDnsSuffix", ".vault.azure.cn");
// TODO: add dns suffixes for the china cloud for datalake store and datalake analytics once they are defined.
put("azureDataLakeStoreFileSystemEndpointSuffix", "N/A");
put("azureDataLakeAnalyticsCatalogAndJobEndpointSuffix", "N/A");
}});
/**
* Provides the settings for authentication with Azure US Government.
*/
public static final AzureEnvironment AZURE_US_GOVERNMENT = new AzureEnvironment(new HashMap<String, String>() {{
put("portalUrl", "https://manage.windowsazure.us");
put("publishingProfileUrl", "https://manage.windowsazure.us/publishsettings/index");
put("managementEndpointUrl", "https://management.core.usgovcloudapi.net");
put("resourceManagerEndpointUrl", "https://management.usgovcloudapi.net");
put("sqlManagementEndpointUrl", "https://management.core.usgovcloudapi.net:8443/");
put("sqlServerHostnameSuffix", ".database.usgovcloudapi.net");
put("galleryEndpointUrl", "https://gallery.usgovcloudapi.net/");
put("activeDirectoryEndpointUrl", "https://login-us.microsoftonline.com/");
put("activeDirectoryResourceId", "https://management.core.usgovcloudapi.net/");
put("activeDirectoryGraphResourceId", "https://graph.windows.net/");
put("activeDirectoryGraphApiVersion", "2013-04-05");
put("storageEndpointSuffix", ".core.usgovcloudapi.net");
put("keyVaultDnsSuffix", ".vault.usgovcloudapi.net");
// TODO: add dns suffixes for the US government for datalake store and datalake analytics once they are defined.
put("azureDataLakeStoreFileSystemEndpointSuffix", "N/A");
put("azureDataLakeAnalyticsCatalogAndJobEndpointSuffix", "N/A");
}});
/**
* Provides the settings for authentication with Azure Germany.
*/
public static final AzureEnvironment AZURE_GERMANY = new AzureEnvironment(new HashMap<String, String>() {{
put("portalUrl", "http://portal.microsoftazure.de/");
put("publishingProfileUrl", "https://manage.microsoftazure.de/publishsettings/index");
put("managementEndpointUrl", "https://management.core.cloudapi.de");
put("resourceManagerEndpointUrl", "https://management.microsoftazure.de");
put("sqlManagementEndpointUrl", "https://management.core.cloudapi.de:8443/");
put("sqlServerHostnameSuffix", ".database.cloudapi.de");
put("galleryEndpointUrl", "https://gallery.cloudapi.de/");
put("activeDirectoryEndpointUrl", "https://login.microsoftonline.de/");
put("activeDirectoryResourceId", "https://management.core.cloudapi.de/");
put("activeDirectoryGraphResourceId", "https://graph.cloudapi.de/");
put("activeDirectoryGraphApiVersion", "2013-04-05");
put("storageEndpointSuffix", ".core.cloudapi.de");
put("keyVaultDnsSuffix", ".vault.microsoftazure.de");
// TODO: add dns suffixes for the US government for datalake store and datalake analytics once they are defined.
put("azureDataLakeStoreFileSystemEndpointSuffix", "N/A");
put("azureDataLakeAnalyticsCatalogAndJobEndpointSuffix", "N/");
}});
/**
* @return the entirety of the endpoints associated with the current environment.
*/
public Map<String, String> endpoints() {
return endpoints;
}
/**
* @return the array of known environments to Azure SDK.
*/
public static AzureEnvironment[] knownEnvironments() {
List<AzureEnvironment> environments = Arrays.asList(AZURE, AZURE_CHINA, AZURE_GERMANY, AZURE_US_GOVERNMENT);
return environments.toArray(new AzureEnvironment[environments.size()]);
}
/**
* @return the management portal URL.
*/
public String portal() {
return endpoints.get("portalUrl");
}
/**
* @return the publish settings file URL.
*/
public String publishingProfile() {
return endpoints.get("publishingProfileUrl");
}
/**
* @return the management service endpoint.
*/
public String managementEndpoint() {
return endpoints.get("managementEndpointUrl");
}
/**
* @return the resource management endpoint.
*/
public String resourceManagerEndpoint() {
return endpoints.get("resourceManagerEndpointUrl");
}
/**
* @return the sql server management endpoint for mobile commands.
*/
public String sqlManagementEndpoint() {
return endpoints.get("sqlManagementEndpointUrl");
}
/**
* @return the dns suffix for sql servers.
*/
public String sqlServerHostnameSuffix() {
return endpoints.get("sqlServerHostnameSuffix");
}
/**
* @return the Active Directory login endpoint.
*/
public String activeDirectoryEndpoint() {
return endpoints.get("activeDirectoryEndpointUrl").replaceAll("/$", "") + "/";
}
/**
* @return The resource ID to obtain AD tokens for.
*/
public String activeDirectoryResourceId() {
return endpoints.get("activeDirectoryResourceId");
}
/**
* @return the template gallery endpoint.
*/
public String galleryEndpoint() {
return endpoints.get("galleryEndpointUrl");
}
/**
* @return the Active Directory resource ID.
*/
public String graphEndpoint() {
return endpoints.get("activeDirectoryGraphResourceId");
}
/**
* @return the Active Directory api version.
*/
public String activeDirectoryGraphApiVersion() {
return endpoints.get("activeDirectoryGraphApiVersion");
}
/**
* @return the endpoint suffix for storage accounts.
*/
public String storageEndpointSuffix() {
return endpoints.get("storageEndpointSuffix");
}
/**
* @return the keyvault service dns suffix.
*/
public String keyVaultDnsSuffix() {
return endpoints.get("keyVaultDnsSuffix");
}
/**
* @return the data lake store filesystem service dns suffix.
*/
public String azureDataLakeStoreFileSystemEndpointSuffix() {
return endpoints.get("azureDataLakeStoreFileSystemEndpointSuffix");
}
/**
* @return the data lake analytics job and catalog service dns suffix.
*/
public String azureDataLakeAnalyticsCatalogAndJobEndpointSuffix() {
return endpoints.get("azureDataLakeAnalyticsCatalogAndJobEndpointSuffix");
}
/**
* The enum representing available endpoints in an environment.
*/
public enum Endpoint implements Environment.Endpoint {
/** Azure Resource Manager endpoint. */
RESOURCE_MANAGER("resourceManagerEndpointUrl"),
/** Azure Active Directory Graph APIs endpoint. */
GRAPH("activeDirectoryGraphResourceId"),
/** Azure SQL endpoint. */
SQL("sqlManagementEndpointUrl"),
/** Azure Gallery endpoint. */
GALLERY("galleryEndpointUrl"),
/** Active Directory authentication endpoint. */
ACTIVE_DIRECTORY("activeDirectoryEndpointUrl"),
/** Azure management endpoint. */
MANAGEMENT("managementEndpointUrl"),
/** Key Vault DNS suffix. */
KEYVAULT("keyVaultDnsSuffix");
private String field;
Endpoint(String value) {
this.field = value;
}
@Override
public String identifier() {
return field;
}
@Override
public String toString() {
return field;
}
}
/**
* Get the endpoint URL for the current environment.
*
* @param endpoint the endpoint
* @return the URL
*/
public String url(Environment.Endpoint endpoint) {
return endpoints.get(endpoint.identifier());
}
}