-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Mgmt rest client #47665
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
Mgmt rest client #47665
Changes from 12 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
2c5351d
remove operations_list
live1206 9d305ae
regen mgmt test
live1206 c78439d
Merge remote-tracking branch 'origin/main' into input-transform
live1206 ca523dd
Merge remote-tracking branch 'origin/main' into input-transform
live1206 203e7d9
regen to remove empty client
live1206 860640c
update clients to internal
live1206 c86a873
Merge remote-tracking branch 'origin/main' into mgmt-rest-client
live1206 6cc79ab
update client provider to internal for AzureArm
live1206 bd478d1
Merge remote-tracking branch 'origin/main' into mgmt-rest-client
live1206 42da174
Transform subscriptionId and client
live1206 4a9abc1
refactor
live1206 1f92b65
Merge remote-tracking branch 'origin/main' into mgmt-rest-client
live1206 f031280
rename
live1206 4a91930
revert type change of subscriptionId
live1206 90c66cf
regen
live1206 5c611ba
update MGC
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 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
47 changes: 47 additions & 0 deletions
47
eng/packages/http-client-csharp/generator/Azure.Generator/src/AzureArmVisitor.cs
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,47 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. | ||
|
|
||
| using Microsoft.Generator.CSharp.ClientModel; | ||
| using Microsoft.Generator.CSharp.ClientModel.Providers; | ||
| using Microsoft.Generator.CSharp.Primitives; | ||
| using Microsoft.Generator.CSharp.Providers; | ||
| using System.IO; | ||
|
|
||
| namespace Azure.Generator | ||
| { | ||
| // only apply for MPG | ||
| internal class AzureArmVisitor : ScmLibraryVisitor | ||
| { | ||
| /// <inheritdoc/> | ||
| protected override TypeProvider? Visit(TypeProvider type) | ||
| { | ||
| if (type is ClientProvider) | ||
| { | ||
| type.Update(modifiers: TransfromModifiers(type), relativeFilePath: TransformRelativeFilePathForClient(type)); | ||
| } | ||
| //if (type is RestClientProvider) | ||
| //{ | ||
| // type.Update(modifiers: TransfromModifiers(type), relativeFilePath: TransformRelativeFilePathForRestClient(type)); | ||
| //} | ||
| return type; | ||
| } | ||
|
|
||
| private static string TransformRelativeFilePathForClient(TypeProvider type) | ||
| => Path.Combine("src", "Generated", "RestOperations", $"{type.Name}RestOperations.cs"); | ||
|
|
||
| private static string TransformRelativeFilePathForRestClient(TypeProvider type) | ||
| => Path.Combine("src", "Generated", "RestOperations", $"{type.Name}.RestClient.cs"); | ||
|
|
||
| private static TypeSignatureModifiers TransfromModifiers(TypeProvider type) | ||
live1206 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| { | ||
| var modifiers = type.DeclarationModifiers; | ||
| if (modifiers.HasFlag(TypeSignatureModifiers.Public)) | ||
| { | ||
| modifiers &= ~TypeSignatureModifiers.Public; | ||
| modifiers |= TypeSignatureModifiers.Internal; | ||
| } | ||
|
|
||
| return modifiers; | ||
| } | ||
| } | ||
| } | ||
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
44 changes: 44 additions & 0 deletions
44
...client-csharp/generator/Azure.Generator/src/InputTransformation/InputClientTransformer.cs
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,44 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. | ||
|
|
||
| using Microsoft.Generator.CSharp.Input; | ||
| using System; | ||
| using System.Collections.Generic; | ||
|
|
||
| namespace Azure.Generator.InputTransformation | ||
| { | ||
| internal static class InputClientTransformer | ||
| { | ||
| public static InputClient TransformInputClient(InputClient client) | ||
| { | ||
| var operationsToKeep = new List<InputOperation>(); | ||
| foreach (var operation in client.Operations) | ||
| { | ||
| // operations_list has been covered in Azure.ResourceManager already, we don't need to generate it in the client | ||
| if (operation.CrossLanguageDefinitionId != "Azure.ResourceManager.Operations.list") | ||
| { | ||
| var transformedOperation = new InputOperation(operation.Name, operation.ResourceName, operation.Summary, operation.Doc, operation.Deprecated, operation.Accessibility, TransformInputOperationParameters(operation), operation.Responses, operation.HttpMethod, operation.RequestBodyMediaType, operation.Uri, operation.Path, operation.ExternalDocsUrl, operation.RequestMediaTypes, operation.BufferResponse, operation.LongRunning, operation.Paging, operation.GenerateProtocolMethod, operation.GenerateConvenienceMethod, operation.CrossLanguageDefinitionId); | ||
| operationsToKeep.Add(transformedOperation); | ||
| } | ||
| } | ||
| return new InputClient(client.Name, client.Summary, client.Doc, operationsToKeep, client.Parameters, client.Parent); | ||
| } | ||
|
|
||
| private static IReadOnlyList<InputParameter> TransformInputOperationParameters(InputOperation operation) | ||
| { | ||
| var parameters = new List<InputParameter>(); | ||
| foreach (var parameter in operation.Parameters) | ||
| { | ||
| if (parameter.NameInRequest.Equals("subscriptionId", StringComparison.OrdinalIgnoreCase)) | ||
| { | ||
| parameters.Add(new InputParameter(parameter.Name, parameter.NameInRequest, parameter.Summary, parameter.Doc, InputPrimitiveType.String, parameter.Location, parameter.DefaultValue, InputOperationParameterKind.Method, parameter.IsRequired, parameter.IsApiVersion, parameter.IsResourceParameter, parameter.IsContentType, parameter.IsEndpoint, parameter.SkipUrlEncoding, parameter.Explode, parameter.ArraySerializationDelimiter, parameter.HeaderCollectionPrefix)); | ||
live1206 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| else | ||
| { | ||
| parameters.Add(parameter); | ||
| } | ||
| } | ||
| return parameters; | ||
| } | ||
| } | ||
| } | ||
16 changes: 8 additions & 8 deletions
16
...client-csharp/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/Foos.RestClient.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
8 changes: 4 additions & 4 deletions
8
...sharp/generator/TestProjects/Local/Mgmt-TypeSpec/src/Generated/PrivateLinks.RestClient.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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.