Add [Resource]Container class#1180
Conversation
|
/azp run autorest.csharp - ci |
|
Azure Pipelines successfully started running 1 pipeline(s). |
samples/Azure.ResourceManager.Sample/Generated/AvailabilitySetContainer.cs
Outdated
Show resolved
Hide resolved
samples/Azure.ResourceManager.Sample/Generated/AvailabilitySetContainer.cs
Outdated
Show resolved
Hide resolved
samples/Azure.ResourceManager.Sample/Generated/AvailabilitySetContainer.cs
Outdated
Show resolved
Hide resolved
samples/Azure.ResourceManager.Sample/Generated/AvailabilitySetContainer.cs
Outdated
Show resolved
Hide resolved
samples/Azure.ResourceManager.Sample/Generated/AvailabilitySetContainer.cs
Outdated
Show resolved
Hide resolved
samples/Azure.ResourceManager.Sample/Generated/AvailabilitySetContainer.cs
Outdated
Show resolved
Hide resolved
samples/Azure.ResourceManager.Sample/Generated/AvailabilitySetContainer.cs
Outdated
Show resolved
Hide resolved
samples/Azure.ResourceManager.Sample/Generated/AvailabilitySetContainer.cs
Outdated
Show resolved
Hide resolved
d56675b to
26e0fc7
Compare
| private BlobContainersRestOperations _restClient => new BlobContainersRestOperations(_clientDiagnostics, _pipeline, Id.SubscriptionId); | ||
|
|
||
| /// <summary> Typed Resource Identifier for the container. </summary> | ||
| public new ResourceGroupResourceIdentifier Id => base.Id as ResourceGroupResourceIdentifier; |
There was a problem hiding this comment.
Without the new, Id is just a ResourceIdentifier inherited from OperationBase. We need to cast it either here or at the level of ContainerBase
There was a problem hiding this comment.
A PR to arm.core
Though the original plan was to do the type conversion in OpeationsBase but problem is, TIdentifier has different meaning in Operation and Container.
Michael said he'll consider that later
samples/Azure.Management.Storage/Generated/BlobContainerContainer.cs
Outdated
Show resolved
Hide resolved
| /// <summary> Initializes a new instance of <see cref = "BlobContainerOperations"/> class. </summary> | ||
| /// <summary> Initializes a new instance of the <see cref="BlobContainerOperations"/> class. </summary> | ||
| /// <param name="genericOperations"> An instance of <see cref="GenericResourceOperations"/> that has an id for a {todo: availability set}. </param> | ||
| internal BlobContainerOperations(GenericResourceOperations genericOperations) : base(genericOperations, genericOperations.Id) |
There was a problem hiding this comment.
I don't think this constructor is needed
There was a problem hiding this comment.
When user lists resource with name filter, we list them as generic resource and create resource instances from the generic resources.
src/AutoRest.CSharp/Mgmt/Generation/MgmtPlaneLongRunningOperationWriter.cs
Outdated
Show resolved
Hide resolved
src/AutoRest.CSharp/Mgmt/Generation/ResourceIdentifierChooser.cs
Outdated
Show resolved
Hide resolved
| internal class RestClientMethod | ||
| { | ||
| public RestClientMethod(string name, string? description, CSharpType? returnType, Request request, Parameter[] parameters, Response[] responses, DataPlaneResponseHeaderGroupType? headerModel, bool bufferResponse, string accessibility) | ||
| public RestClientMethod(string name, string? description, CSharpType? returnType, Request request, Parameter[] parameters, Response[] responses, DataPlaneResponseHeaderGroupType? headerModel, bool bufferResponse, string accessibility, Operation? operation = null) |
There was a problem hiding this comment.
In order to get the Operation object in container writer, I keep a reference to it in every RestClientMethod.
This is safe because every RestClientMethod is built from an Operation.
My only concern is if I should touch LowLevelClientMethod which inherits RestClientMethod to also add Operation to its constructor. see https://github.com/Azure/autorest.csharp/blob/feature/v3/src/AutoRest.CSharp/LowLevel/Output/LowLevelClientMethod.cs#L11
| /// <param name="containerName"> The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number. </param> | ||
| /// <param name="blobContainer"> Properties of the blob container to create. </param> | ||
| /// <param name="cancellationToken"> A token to allow the caller to cancel the call to the service. The default value is <see cref="P:System.Threading.CancellationToken.None" />. </param> | ||
| public Operation<BlobContainer> StartCreateOrUpdate(string containerName, BlobContainerData blobContainer, CancellationToken cancellationToken = default) |
There was a problem hiding this comment.
need to change the reaponse type to be the LRO object
samples/Azure.Management.Storage/Generated/BlobContainerContainer.cs
Outdated
Show resolved
Hide resolved
| throw new ArgumentNullException(nameof(blobContainer)); | ||
| } | ||
|
|
||
| return StartCreateOrUpdate(containerName, blobContainer, cancellationToken: cancellationToken).WaitForCompletion() as Response<BlobContainer>; |
There was a problem hiding this comment.
after response type change call waitforcompletion here
samples/Azure.Management.Storage/Generated/BlobServiceContainer.cs
Outdated
Show resolved
Hide resolved
src/AutoRest.CSharp/Mgmt/Generation/MgmtPlaneLongRunningOperationWriter.cs
Outdated
Show resolved
Hide resolved
src/AutoRest.CSharp/Mgmt/Generation/MgmtPlaneLongRunningOperationWriter.cs
Outdated
Show resolved
Hide resolved
| else if (IsStringLike(parameter.Type) && IsMandatory(parameter)) | ||
| { | ||
| passThru = false; | ||
| if (string.Equals(parameter.Name, "resourceGroupName", StringComparison.InvariantCultureIgnoreCase)) |
There was a problem hiding this comment.
Why are only checking resourceGroupName here? It could be subscriptionId, location ..etc
| writer.WriteXmlDocumentationSummary($"Initializes a new instance of {resourceOperation.Type.Name} for mocking."); | ||
| using (writer.Scope($"protected {resourceOperation.Type.Name}()")) | ||
| { | ||
| var typeOfThis = resourceOperation.Type.Name; |
There was a problem hiding this comment.
We shouldn't use the name here. We should use the Type.
test/TestProjects/ExactMatchInheritance/ExactMatchInheritance.json
Outdated
Show resolved
Hide resolved
- remove outdated LRO writer
- move `IsResource` to `ResourceData`
- find Get rest method by prefix ("Get*") instead of just full match
- this made `BlobServiceContainer` inheirt `ResourceContainerBase` corrrectly
- and use the method name instead of hard code "Get"
- WaitForCompletionAsync
- empty lines at file end
Description
Now the mgmt track 2 generator generates meaningful
[Resource]Containerclasses.This will be opened as draft for some early review. At the meantime I need to resolve some todo's and refactoring.
CI is expected to fail as this is pending Azure/azure-sdk-for-net#20524
Checklist
To ensure a quick review and merge, please ensure:
Ready to Land?