-
Notifications
You must be signed in to change notification settings - Fork 2.2k
azure-core, add new AzureCloud expandable enum
#43099
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
30f2ead
azure cloud
XiaofeiCao fec71cd
remove getAzureCloud
XiaofeiCao 5f592ef
licence header
XiaofeiCao 0bc6f5b
add  in test
XiaofeiCao 5a104c5
changelog for core-management
XiaofeiCao b945167
suppress test warnings
XiaofeiCao fa424cf
spotless
XiaofeiCao 3bdeaaf
move AzureProfile to com.azure.core.models
XiaofeiCao 650d729
fix changelog
XiaofeiCao 4e3ab9d
remove deprecation
XiaofeiCao 0b7a344
nit, javadoc
XiaofeiCao 4f29704
Merge branch 'main' into azure-core-azurecloud
XiaofeiCao File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
...core/azure-core-management/src/test/java/com/azure/core/management/AzureProfileTests.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. | ||
|
|
||
| package com.azure.core.management; | ||
|
|
||
| import com.azure.core.management.profile.AzureProfile; | ||
| import com.azure.core.models.AzureCloud; | ||
| import org.junit.jupiter.api.Assertions; | ||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| import java.util.HashMap; | ||
|
|
||
| public class AzureProfileTests { | ||
| @Test | ||
| public void testFromAzureCloud() { | ||
| // normal case | ||
| AzureProfile azurePublicCloud = new AzureProfile(AzureCloud.AZURE_PUBLIC_CLOUD); | ||
| Assertions.assertEquals(AzureEnvironment.AZURE, azurePublicCloud.getEnvironment()); | ||
|
|
||
| AzureProfile azureChinaCloud = new AzureProfile(AzureCloud.AZURE_CHINA_CLOUD); | ||
| Assertions.assertEquals(AzureEnvironment.AZURE_CHINA, azureChinaCloud.getEnvironment()); | ||
|
|
||
| AzureProfile azureUSGovernment = new AzureProfile(AzureCloud.AZURE_US_GOVERNMENT); | ||
| Assertions.assertEquals(AzureEnvironment.AZURE_US_GOVERNMENT, azureUSGovernment.getEnvironment()); | ||
|
|
||
| // exception case | ||
| // exception when initializing using custom AzureCloud | ||
| AzureCloud azureCloud = AzureCloud.fromString("Custom"); | ||
| Assertions.assertNotNull(azureCloud); | ||
| Assertions.assertThrows(IllegalArgumentException.class, () -> new AzureProfile(azureCloud)); | ||
|
|
||
| AzureProfile customEnvironment = new AzureProfile(new AzureEnvironment(new HashMap<>())); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
sdk/core/azure-core/src/main/java/com/azure/core/models/AzureCloud.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. | ||
|
|
||
| package com.azure.core.models; | ||
|
|
||
| import com.azure.core.util.ExpandableStringEnum; | ||
|
|
||
| /** | ||
| * An expandable enum that describes Azure cloud environment. | ||
| */ | ||
| public final class AzureCloud extends ExpandableStringEnum<AzureCloud> { | ||
| /** | ||
| * Azure public cloud. | ||
| */ | ||
| public static final AzureCloud AZURE_PUBLIC_CLOUD = fromString("AZURE_PUBLIC_CLOUD"); | ||
| /** | ||
| * Azure China cloud. | ||
| */ | ||
| public static final AzureCloud AZURE_CHINA_CLOUD = fromString("AZURE_CHINA_CLOUD"); | ||
| /** | ||
| * Azure US government cloud. | ||
| */ | ||
| public static final AzureCloud AZURE_US_GOVERNMENT = fromString("AZURE_US_GOVERNMENT"); | ||
|
|
||
| /** | ||
| * Creates or finds an AzureCloud from its string representation. | ||
| * | ||
| * @param cloudName cloud name to look for | ||
| * @return the corresponding AzureCloud | ||
| */ | ||
| public static AzureCloud fromString(String cloudName) { | ||
| return fromString(cloudName, AzureCloud.class); | ||
| } | ||
|
|
||
| /** | ||
| * Creates a new instance of {@link AzureCloud} without a {@link #toString()} value. | ||
| * <p> | ||
| * This constructor shouldn't be called as it will produce a {@link AzureCloud} which doesn't have a | ||
| * String enum value. | ||
| * | ||
| * @deprecated Use one of the constants or the {@link #fromString(String)} factory method. | ||
| */ | ||
| @Deprecated | ||
| public AzureCloud() { | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.