-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Migrate resource manager resources generation to TypeSpec #50111
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
Open
Weidong Xu (weidongxu-microsoft)
wants to merge
38
commits into
Azure:main
Choose a base branch
from
weidongxu-microsoft:issue-49803-resources-typespec
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+21,355
−22,315
Open
Changes from all commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
a512472
Regenerate resources Swagger clients
weidongxu-microsoft 1f4b041
Remove stale resources generated samples
weidongxu-microsoft 33cbbb2
Preserve resources Swagger generated files
weidongxu-microsoft f5573c3
Generate resources data boundaries from TypeSpec
weidongxu-microsoft 9c21b3c
Document resources TypeSpec migration milestones
weidongxu-microsoft 7a08602
Generate resources deployment stacks from TypeSpec
weidongxu-microsoft ca94cc2
Preserve deployment stack property flattening
weidongxu-microsoft a5103cb
Generate resources policy from TypeSpec
weidongxu-microsoft f7e0298
Customize resources policy exemption access
weidongxu-microsoft 2350275
Fix policy interface customization
weidongxu-microsoft fa60d91
Restore policy exemption client access
weidongxu-microsoft 74ccf04
Add generated resources policy samples
weidongxu-microsoft 0d83329
Generate resources subscriptions from TypeSpec
weidongxu-microsoft 1ce90d5
Add generated resources subscription samples
weidongxu-microsoft 8cf2661
Customize deployment resource references
weidongxu-microsoft cfcbb3f
Generate resources deployments from TypeSpec
weidongxu-microsoft bb3a027
Add generated resources deployment samples
weidongxu-microsoft 52477b5
Generate core resources from TypeSpec
weidongxu-microsoft 6538252
Add generated core resources samples
weidongxu-microsoft 91379fc
Fix resources sample client accessors
weidongxu-microsoft c6d1936
Update resources test recordings
weidongxu-microsoft 370ad15
Open resources implementation models to azure-core
weidongxu-microsoft 45a0908
Preserve deployment stack delete enum compatibility
weidongxu-microsoft 91b2047
Preserve combined resources package during generation
weidongxu-microsoft 97ea520
Remove redundant policy client modifier
weidongxu-microsoft 98e8c93
Point resources generation to canonical TypeSpec source
weidongxu-microsoft d62691e
Avoid duplicate policy exemptions customization
weidongxu-microsoft d6c74b4
Merge remote-tracking branch 'upstream/main' into issue-49803-resourc…
weidongxu-microsoft c9deac1
Keep migration notes local
weidongxu-microsoft e52d53a
Use management exceptions for subscription APIs
weidongxu-microsoft 02889fa
Disable VM delete-option playback test
weidongxu-microsoft 9cd9361
Disable generic resources playback test
weidongxu-microsoft d4450cb
Restore premium management library versions
weidongxu-microsoft 704a011
Disable tagged deployment playback test
weidongxu-microsoft 7442073
Pin policy generation to stable API
weidongxu-microsoft 7fa454e
Fix generated policy sample client access
weidongxu-microsoft 1f2022e
Regenerate resources models from TypeSpec
weidongxu-microsoft 3268ce0
Use full TypeSpec specification commit
weidongxu-microsoft File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
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
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
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
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
17 changes: 17 additions & 0 deletions
17
sdk/resources/azure-resourcemanager-resources/customization/pom.xml
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,17 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <project xmlns="http://maven.apache.org/POM/4.0.0" | ||
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
|
|
||
| <parent> | ||
| <groupId>com.azure</groupId> | ||
| <artifactId>azure-code-customization-parent</artifactId> | ||
| <version>1.0.0-beta.1</version> | ||
| <relativePath>../../../parents/azure-code-customization-parent</relativePath> | ||
| </parent> | ||
|
|
||
| <groupId>com.azure.resourcemanager</groupId> | ||
| <artifactId>azure-resourcemanager-resources-customization</artifactId> | ||
| <version>1.0.0-beta.1</version> | ||
| <modelVersion>4.0.0</modelVersion> | ||
| </project> |
29 changes: 29 additions & 0 deletions
29
...azure-resourcemanager-resources/customization/src/main/java/DeploymentsCustomization.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,29 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. | ||
|
|
||
| import com.azure.autorest.customization.ClassCustomization; | ||
| import com.azure.autorest.customization.Customization; | ||
| import com.azure.autorest.customization.LibraryCustomization; | ||
| import com.github.javaparser.ast.Modifier; | ||
| import org.slf4j.Logger; | ||
|
|
||
| /** | ||
| * Code customization after deployments code generation. | ||
| */ | ||
| public class DeploymentsCustomization extends Customization { | ||
| @Override | ||
| public void customize(LibraryCustomization customization, Logger logger) { | ||
| customizeResourceReference( | ||
| customization.getPackage("com.azure.resourcemanager.resources.models").getClass("ResourceReference")); | ||
| } | ||
|
|
||
| private static void customizeResourceReference(ClassCustomization customization) { | ||
| customization.customizeAst(ast -> ast.getClassByName(customization.getClassName()).ifPresent(clazz -> { | ||
| clazz.removeModifier(Modifier.Keyword.FINAL); | ||
| clazz.getConstructors() | ||
| .stream() | ||
| .filter(constructor -> constructor.getParameters().isEmpty()) | ||
| .forEach(constructor -> constructor.setModifiers(Modifier.Keyword.PROTECTED)); | ||
| })); | ||
| } | ||
| } |
58 changes: 58 additions & 0 deletions
58
...rces/azure-resourcemanager-resources/customization/src/main/java/PolicyCustomization.java
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is to handle the mistake we made a long time ago -- we release GA on a tag that includes PolicyExemptions that still is preview. The client/model class was converted as handwritten. The MangementClient would need a customizatoin. |
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,58 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. | ||
|
|
||
| import com.azure.autorest.customization.ClassCustomization; | ||
| import com.azure.autorest.customization.Customization; | ||
| import com.azure.autorest.customization.LibraryCustomization; | ||
| import com.azure.autorest.customization.PackageCustomization; | ||
| import com.github.javaparser.StaticJavaParser; | ||
| import com.github.javaparser.ast.Modifier; | ||
| import com.github.javaparser.ast.body.MethodDeclaration; | ||
| import org.slf4j.Logger; | ||
|
|
||
| /** | ||
| * Code customization after code generation. | ||
| */ | ||
| public class PolicyCustomization extends Customization { | ||
| @Override | ||
| public void customize(LibraryCustomization customization, Logger logger) { | ||
| customizePolicyClient( | ||
| customization.getPackage("com.azure.resourcemanager.resources.fluent").getClass("PolicyClient")); | ||
| customizePolicyClientImpl( | ||
| customization.getPackage("com.azure.resourcemanager.resources.implementation") | ||
| .getClass("PolicyClientImpl")); | ||
| } | ||
|
|
||
| private static void customizePolicyClient(ClassCustomization customization) { | ||
| customization.customizeAst(ast -> ast.getInterfaceByName(customization.getClassName()).ifPresent(clazz -> { | ||
| if (clazz.getMethodsByName("getPolicyExemptions").isEmpty()) { | ||
| MethodDeclaration method = clazz.addMethod("getPolicyExemptions"); | ||
| method.setType("PolicyExemptionsClient"); | ||
| method.removeBody(); | ||
| method.setJavadocComment("Gets the PolicyExemptionsClient object to access its operations.\n\n" | ||
| + "@return the PolicyExemptionsClient object."); | ||
| } | ||
| })); | ||
| } | ||
|
|
||
| private static void customizePolicyClientImpl(ClassCustomization customization) { | ||
| customization.customizeAst(ast -> ast.getClassByName(customization.getClassName()).ifPresent(clazz -> { | ||
| if (clazz.getMethodsByName("getPolicyExemptions").isEmpty()) { | ||
| ast.addImport("com.azure.resourcemanager.resources.fluent.PolicyExemptionsClient"); | ||
| clazz.addField("PolicyExemptionsClient", "policyExemptions", Modifier.Keyword.PRIVATE, | ||
| Modifier.Keyword.FINAL); | ||
|
|
||
| MethodDeclaration method = clazz.addMethod("getPolicyExemptions", Modifier.Keyword.PUBLIC); | ||
| method.addMarkerAnnotation("Override"); | ||
| method.setType("PolicyExemptionsClient"); | ||
| method.setBody(StaticJavaParser.parseBlock("{ return this.policyExemptions; }")); | ||
| method.setJavadocComment("Gets the PolicyExemptionsClient object to access its operations.\n\n" | ||
| + "@return the PolicyExemptionsClient object."); | ||
|
|
||
| clazz.getConstructors() | ||
| .forEach(constructor -> constructor.getBody() | ||
| .addStatement("this.policyExemptions = new PolicyExemptionsClientImpl(this);")); | ||
| } | ||
| })); | ||
| } | ||
| } |
2 changes: 1 addition & 1 deletion
2
...c/main/java/com/azure/resourcemanager/resources/fluent/AuthorizationOperationsClient.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
2 changes: 1 addition & 1 deletion
2
...ger-resources/src/main/java/com/azure/resourcemanager/resources/fluent/ChangesClient.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
2 changes: 1 addition & 1 deletion
2
...ces/src/main/java/com/azure/resourcemanager/resources/fluent/ChangesManagementClient.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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
policy just removed them as "bug fix" https://github.com/Azure/azure-rest-api-specs/pull/43353/changes#diff-c1419a1c98902586e334cf8112deb57a3f3771898cb89038b038a76ea2853b14