-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Implement mgmt resource #47944
Open
live1206
wants to merge
57
commits into
Azure:main
Choose a base branch
from
live1206:implement-mgmt-resource
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.
Open
Implement mgmt resource #47944
Changes from 15 commits
Commits
Show all changes
57 commits
Select commit
Hold shift + click to select a range
f041f24
wip
live1206 badf1a5
wip
live1206 69fa28a
wip
live1206 615fec1
Merge remote-tracking branch 'origin/main' into implement-mgmt-resource
live1206 d136be2
wip
live1206 a040627
wip
live1206 0296a71
Merge remote-tracking branch 'origin/main' into implement-mgmt-resource
live1206 fda752a
generate operation methods for Resource
live1206 580508a
add package back
live1206 ba12225
Merge remote-tracking branch 'origin/main' into implement-mgmt-resource
live1206 ef83882
update to latest MGC
live1206 120e164
fix test
live1206 e4bbde0
Merge branch 'main' into implement-mgmt-resource
live1206 b2842c4
Add test for ResourceProvider
live1206 5f5cee9
Merge remote-tracking branch 'origin/main' into implement-mgmt-resource
live1206 41cf53c
Add RequestPath
live1206 7bba967
remove unused property
live1206 5d3a879
address comments
live1206 2fe508f
Include custom code for convenience methods
live1206 d9fd368
add TODO
live1206 17b2a0f
merge from main
live1206 45a10a7
implement resource LRO
live1206 b06fb59
implement LRO for resource
live1206 c98e231
Implement IOperationSouce and generated MgmtTypeSpec can build now
live1206 848e6d7
update test data
live1206 0db68cb
Add test for OperationSourceProvider
live1206 2b15650
update tests
live1206 51bd7f3
cleanup
live1206 a8b2b8f
update
live1206 dc2b83d
cleanup
live1206 adbcc1c
Address comments
live1206 bb92673
Add Mgmt-TypeSpec generation to Generate.ps1
live1206 af9bd9c
Merge remote-tracking branch 'origin/main' into implement-mgmt-resource
live1206 c5ca437
Update eng/packages/http-client-csharp/generator/Azure.Generator/src/…
live1206 3ed339d
update
live1206 d800d35
Merge branch 'main' into implement-mgmt-resource
live1206 8d78f7f
fix build
live1206 8fbc8aa
update to use CanonicalView
live1206 081696d
update test
live1206 f9e8afd
Use ModelSerializationExtensions.WireOptions instead of new instance
live1206 8d7b831
update test
live1206 4dcccc7
Address comments
live1206 d00ee3a
typo
live1206 0086b11
Merge remote-tracking branch 'origin/main' into implement-mgmt-resource
live1206 e34db7b
resolve comments
live1206 417af63
fix build
live1206 965e951
update test
live1206 579dd9b
separate tests for ResourceClientProvider
live1206 682e704
Add TODO
live1206 22e08c6
fix tests
live1206 541193c
Move resource related logic to ResourceBuilder
live1206 20cdaaf
Remove clientProvider and implement client methods in Resource directly
live1206 78b5cb5
update
live1206 ff44b6b
simplify resource detection
live1206 33c30fa
Merge branch 'main' into implement-mgmt-resource
live1206 ca43fe6
replace resource detection with decorators
live1206 7ff96ba
cleanup
live1206 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 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 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 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 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
29 changes: 29 additions & 0 deletions
29
...s/http-client-csharp/generator/Azure.Generator/src/Mgmt/Models/SingletonResourceSuffix.cs
This file contains 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. | ||
|
||
using System.Collections.Generic; | ||
|
||
namespace Azure.Generator.Mgmt.Models | ||
{ | ||
internal class SingletonResourceSuffix | ||
{ | ||
public static SingletonResourceSuffix Parse(string[] segments) | ||
{ | ||
// put the segments in pairs | ||
var pairs = new List<(string Key, string Value)>(); | ||
for (int i = 0; i < segments.Length; i += 2) | ||
{ | ||
pairs.Add((segments[i], segments[i + 1])); | ||
} | ||
|
||
return new SingletonResourceSuffix(pairs); | ||
} | ||
|
||
private IReadOnlyList<(string Key, string Value)> _pairs; | ||
|
||
private SingletonResourceSuffix(IReadOnlyList<(string Key, string Value)> pairs) | ||
{ | ||
_pairs = pairs; | ||
} | ||
} | ||
} |
This file contains 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 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.
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.
Isn't your parent just a property on the client from typespec?
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.
For TypeSpec, we should be able to get the resource hierarchy directly via #48281.
The resource detection logic is mainly for swagger input.
For now, given
getArmResources
API is not ready for integration. We use it as a temporary workaround.Eventually, when we have the native way ready, we should get rid of them. And the resource detection should be part of the M4 output conversion to tspCodeModel.json in autorest.csharp.
Added TODO to remove them.
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.
As offline discussed, we need to clarify the contract of input types containing the resource hierarchy. And it should be an extensible way of holding it in Azure plugin only.
Then, we can put the temp workaround of resource detection close to the input instead of output.
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.
Isolated Resource related logic in ResourceBuilder, so we have separated the temp workaround to a central place.
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.
I think we will need to have resource related logic in MPG emitter, such as call
getArmResources
API to get the resource hierarchy. MGC doesn't need to provide any extension for this. MPG can have additional input models to hold them.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.
If this is only needed for swagger input, have we considered having this in autorest.csharp only?
We can make it part of the codemodel -> input type conversion before we serialize out to the new plugin. That way the new plugin only has 1 way to do things which is to read the information directly from the codemodel.json file and it doesn't care how the data got there.