-
Notifications
You must be signed in to change notification settings - Fork 5.1k
[ContainerRegistry] SDK validation for TypeSpec #53318
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
HarveyLink
wants to merge
13
commits into
Azure:main
Choose a base branch
from
HarveyLink:v-minghc-containerregistry
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
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
c592fec
regen
HarveyLink aa85845
Fix tests
HarveyLink 3f5bc96
Export API
HarveyLink d80fec7
Update ContainerRegistryResource.cs
HarveyLink 3ade6aa
Add rehydrationToken
HarveyLink aa14806
Apply suggestion from @Copilot
ArcturusZhang ef6e0de
Apply suggestion from @Copilot
ArcturusZhang dc6325f
Fix comment
HarveyLink dc208fa
Merge branch 'v-minghc-containerregistry' of https://github.com/Harve…
HarveyLink 9587fc1
Fix comment -2
HarveyLink 7c40230
Update NextLinkOperationImplementation.cs
HarveyLink 54a1b4e
Fix typo
HarveyLink 1495516
Fix for comments
HarveyLink 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
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
95 changes: 90 additions & 5 deletions
95
...e.ResourceManager.ContainerRegistry/api/Azure.ResourceManager.ContainerRegistry.net8.0.cs
Large diffs are not rendered by default.
Oops, something went wrong.
95 changes: 90 additions & 5 deletions
95
...ceManager.ContainerRegistry/api/Azure.ResourceManager.ContainerRegistry.netstandard2.0.cs
Large diffs are not rendered by default.
Oops, something went wrong.
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
19 changes: 19 additions & 0 deletions
19
....ResourceManager.ContainerRegistry/src/Custom/ContainerRegistryPrivateLinkResourceData.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,19 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
#nullable disable | ||
|
||
using System.Collections.Generic; | ||
using System.ComponentModel; | ||
|
||
namespace Azure.ResourceManager.ContainerRegistry | ||
{ | ||
public partial class ContainerRegistryPrivateLinkResourceData | ||
{ | ||
// This is a usage change in api version 2025-11-01, add this property back for compatibility reason. | ||
/// <summary> The private link resource Private link DNS zone name. </summary> | ||
[WirePath("properties.requiredZoneNames")] | ||
[EditorBrowsable(EditorBrowsableState.Never)] | ||
public IReadOnlyList<string> RequiredZoneNames { get => (IReadOnlyList<string>)RequiredPrivateLinkZoneNames; } | ||
} | ||
} |
108 changes: 108 additions & 0 deletions
108
...rregistry/Azure.ResourceManager.ContainerRegistry/src/Custom/ContainerRegistryResource.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,108 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
#nullable disable | ||
|
||
using System; | ||
using System.ComponentModel; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Azure.Core; | ||
using Azure.ResourceManager.ContainerRegistry.Models; | ||
|
||
namespace Azure.ResourceManager.ContainerRegistry | ||
{ | ||
// The `ScheduleRun` operation is no longer LRO, add these methods back for compatibility reasons. | ||
public partial class ContainerRegistryResource | ||
{ | ||
/// <summary> | ||
/// Schedules a new run based on the request parameters and add it to the run queue. | ||
/// <list type="bullet"> | ||
/// <item> | ||
/// <term>Request Path</term> | ||
/// <description>/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scheduleRun</description> | ||
/// </item> | ||
/// <item> | ||
/// <term>Operation Id</term> | ||
/// <description>Schedules_ScheduleRun</description> | ||
/// </item> | ||
/// <item> | ||
/// <term>Default Api Version</term> | ||
/// <description>2019-06-01-preview</description> | ||
/// </item> | ||
/// </list> | ||
/// </summary> | ||
/// <param name="waitUntil"> <see cref="WaitUntil.Completed"/> if the method should wait to return until the long-running operation has completed on the service; <see cref="WaitUntil.Started"/> if it should return after starting the operation. For more information on long-running operations, please see <see href="https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/samples/LongRunningOperations.md"> Azure.Core Long-Running Operation samples</see>. </param> | ||
/// <param name="content"> The parameters of a run that needs to scheduled. </param> | ||
/// <param name="cancellationToken"> The cancellation token to use. </param> | ||
/// <exception cref="ArgumentNullException"> <paramref name="content"/> is null. </exception> | ||
[EditorBrowsable(EditorBrowsableState.Never)] | ||
public virtual async Task<ArmOperation<ContainerRegistryRunResource>> ScheduleRunAsync(WaitUntil waitUntil, ContainerRegistryRunContent content, CancellationToken cancellationToken = default) | ||
{ | ||
Argument.AssertNotNull(content, nameof(content)); | ||
|
||
using var scope = _schedulesClientDiagnostics.CreateScope("ContainerRegistryResource.ScheduleRun"); | ||
scope.Start(); | ||
try | ||
{ | ||
var response = await _schedulesRestClient.ScheduleRunAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, content, cancellationToken).ConfigureAwait(false); | ||
var uri = _schedulesRestClient.CreateScheduleRunRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, content); | ||
var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Post, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); | ||
var operation = new ContainerRegistryArmOperation<ContainerRegistryRunResource>(Response.FromValue(new ContainerRegistryRunResource(Client, response), response.GetRawResponse()), rehydrationToken); | ||
if (waitUntil == WaitUntil.Completed) | ||
await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); | ||
return operation; | ||
} | ||
catch (Exception e) | ||
{ | ||
scope.Failed(e); | ||
throw; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Schedules a new run based on the request parameters and add it to the run queue. | ||
/// <list type="bullet"> | ||
/// <item> | ||
/// <term>Request Path</term> | ||
/// <description>/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/scheduleRun</description> | ||
/// </item> | ||
/// <item> | ||
/// <term>Operation Id</term> | ||
/// <description>Schedules_ScheduleRun</description> | ||
/// </item> | ||
/// <item> | ||
/// <term>Default Api Version</term> | ||
/// <description>2019-06-01-preview</description> | ||
/// </item> | ||
/// </list> | ||
/// </summary> | ||
/// <param name="waitUntil"> <see cref="WaitUntil.Completed"/> if the method should wait to return until the long-running operation has completed on the service; <see cref="WaitUntil.Started"/> if it should return after starting the operation. For more information on long-running operations, please see <see href="https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/samples/LongRunningOperations.md"> Azure.Core Long-Running Operation samples</see>. </param> | ||
/// <param name="content"> The parameters of a run that needs to scheduled. </param> | ||
/// <param name="cancellationToken"> The cancellation token to use. </param> | ||
/// <exception cref="ArgumentNullException"> <paramref name="content"/> is null. </exception> | ||
[EditorBrowsable(EditorBrowsableState.Never)] | ||
public virtual ArmOperation<ContainerRegistryRunResource> ScheduleRun(WaitUntil waitUntil, ContainerRegistryRunContent content, CancellationToken cancellationToken = default) | ||
{ | ||
Argument.AssertNotNull(content, nameof(content)); | ||
|
||
using var scope = _schedulesClientDiagnostics.CreateScope("ContainerRegistryResource.ScheduleRun"); | ||
scope.Start(); | ||
try | ||
{ | ||
var response = _schedulesRestClient.ScheduleRun(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, content, cancellationToken); | ||
var uri = _schedulesRestClient.CreateScheduleRunRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, content); | ||
var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Post, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); | ||
var operation = new ContainerRegistryArmOperation<ContainerRegistryRunResource>(Response.FromValue(new ContainerRegistryRunResource(Client, response), response.GetRawResponse()), rehydrationToken); | ||
if (waitUntil == WaitUntil.Completed) | ||
operation.WaitForCompletion(cancellationToken); | ||
return operation; | ||
} | ||
catch (Exception e) | ||
{ | ||
scope.Failed(e); | ||
throw; | ||
} | ||
} | ||
} | ||
} |
206 changes: 206 additions & 0 deletions
206
...gistry/Azure.ResourceManager.ContainerRegistry/src/Custom/ContainerRegistryRunResource.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,206 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
#nullable disable | ||
|
||
using System; | ||
using System.ComponentModel; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Azure.Core; | ||
using Azure.ResourceManager.ContainerRegistry.Models; | ||
|
||
namespace Azure.ResourceManager.ContainerRegistry | ||
{ | ||
// The `Cancel` and `Update` operations are no longer LRO, add these methods back for compatibility reasons. | ||
public partial class ContainerRegistryRunResource | ||
{ | ||
/// <summary> | ||
/// Cancel an existing run. | ||
/// <list type="bullet"> | ||
/// <item> | ||
/// <term>Request Path</term> | ||
/// <description>/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}/cancel</description> | ||
/// </item> | ||
/// <item> | ||
/// <term>Operation Id</term> | ||
/// <description>Runs_Cancel</description> | ||
/// </item> | ||
/// <item> | ||
/// <term>Default Api Version</term> | ||
/// <description>2019-06-01-preview</description> | ||
/// </item> | ||
/// <item> | ||
/// <term>Resource</term> | ||
/// <description><see cref="ContainerRegistryRunResource"/></description> | ||
/// </item> | ||
/// </list> | ||
/// </summary> | ||
/// <param name="waitUntil"> <see cref="WaitUntil.Completed"/> if the method should wait to return until the long-running operation has completed on the service; <see cref="WaitUntil.Started"/> if it should return after starting the operation. For more information on long-running operations, please see <see href="https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/samples/LongRunningOperations.md"> Azure.Core Long-Running Operation samples</see>. </param> | ||
/// <param name="cancellationToken"> The cancellation token to use. </param> | ||
[EditorBrowsable(EditorBrowsableState.Never)] | ||
public virtual async Task<ArmOperation> CancelAsync(WaitUntil waitUntil, CancellationToken cancellationToken = default) | ||
{ | ||
using var scope = _containerRegistryRunRunsClientDiagnostics.CreateScope("ContainerRegistryRunResource.Cancel"); | ||
scope.Start(); | ||
try | ||
{ | ||
var response = await _containerRegistryRunRunsRestClient.CancelAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken).ConfigureAwait(false); | ||
var uri = _containerRegistryRunRunsRestClient.CreateCancelRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name); | ||
var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Post, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); | ||
var operation = new ContainerRegistryArmOperation(response, rehydrationToken); | ||
if (waitUntil == WaitUntil.Completed) | ||
await operation.WaitForCompletionResponseAsync(cancellationToken).ConfigureAwait(false); | ||
return operation; | ||
} | ||
catch (Exception e) | ||
{ | ||
scope.Failed(e); | ||
throw; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Cancel an existing run. | ||
/// <list type="bullet"> | ||
/// <item> | ||
/// <term>Request Path</term> | ||
/// <description>/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}/cancel</description> | ||
/// </item> | ||
/// <item> | ||
/// <term>Operation Id</term> | ||
/// <description>Runs_Cancel</description> | ||
/// </item> | ||
/// <item> | ||
/// <term>Default Api Version</term> | ||
/// <description>2019-06-01-preview</description> | ||
/// </item> | ||
/// <item> | ||
/// <term>Resource</term> | ||
/// <description><see cref="ContainerRegistryRunResource"/></description> | ||
/// </item> | ||
/// </list> | ||
/// </summary> | ||
/// <param name="waitUntil"> <see cref="WaitUntil.Completed"/> if the method should wait to return until the long-running operation has completed on the service; <see cref="WaitUntil.Started"/> if it should return after starting the operation. For more information on long-running operations, please see <see href="https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/samples/LongRunningOperations.md"> Azure.Core Long-Running Operation samples</see>. </param> | ||
/// <param name="cancellationToken"> The cancellation token to use. </param> | ||
[EditorBrowsable(EditorBrowsableState.Never)] | ||
public virtual ArmOperation Cancel(WaitUntil waitUntil, CancellationToken cancellationToken = default) | ||
{ | ||
using var scope = _containerRegistryRunRunsClientDiagnostics.CreateScope("ContainerRegistryRunResource.Cancel"); | ||
scope.Start(); | ||
try | ||
{ | ||
var response = _containerRegistryRunRunsRestClient.Cancel(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, cancellationToken); | ||
var uri = _containerRegistryRunRunsRestClient.CreateCancelRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name); | ||
var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Post, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); | ||
var operation = new ContainerRegistryArmOperation(response, rehydrationToken); | ||
if (waitUntil == WaitUntil.Completed) | ||
operation.WaitForCompletionResponse(cancellationToken); | ||
return operation; | ||
} | ||
catch (Exception e) | ||
{ | ||
scope.Failed(e); | ||
throw; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Patch the run properties. | ||
/// <list type="bullet"> | ||
/// <item> | ||
/// <term>Request Path</term> | ||
/// <description>/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}</description> | ||
/// </item> | ||
/// <item> | ||
/// <term>Operation Id</term> | ||
/// <description>Runs_Update</description> | ||
/// </item> | ||
/// <item> | ||
/// <term>Default Api Version</term> | ||
/// <description>2019-06-01-preview</description> | ||
/// </item> | ||
/// <item> | ||
/// <term>Resource</term> | ||
/// <description><see cref="ContainerRegistryRunResource"/></description> | ||
/// </item> | ||
/// </list> | ||
/// </summary> | ||
/// <param name="waitUntil"> <see cref="WaitUntil.Completed"/> if the method should wait to return until the long-running operation has completed on the service; <see cref="WaitUntil.Started"/> if it should return after starting the operation. For more information on long-running operations, please see <see href="https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/samples/LongRunningOperations.md"> Azure.Core Long-Running Operation samples</see>. </param> | ||
/// <param name="patch"> The run update properties. </param> | ||
/// <param name="cancellationToken"> The cancellation token to use. </param> | ||
/// <exception cref="ArgumentNullException"> <paramref name="patch"/> is null. </exception> | ||
[EditorBrowsable(EditorBrowsableState.Never)] | ||
public virtual async Task<ArmOperation<ContainerRegistryRunResource>> UpdateAsync(WaitUntil waitUntil, ContainerRegistryRunPatch patch, CancellationToken cancellationToken = default) | ||
{ | ||
Argument.AssertNotNull(patch, nameof(patch)); | ||
|
||
using var scope = _containerRegistryRunRunsClientDiagnostics.CreateScope("ContainerRegistryRunResource.Update"); | ||
scope.Start(); | ||
try | ||
{ | ||
var response = await _containerRegistryRunRunsRestClient.UpdateAsync(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, patch, cancellationToken).ConfigureAwait(false); | ||
var uri = _containerRegistryRunRunsRestClient.CreateUpdateRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, patch); | ||
var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Patch, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); | ||
var operation = new ContainerRegistryArmOperation<ContainerRegistryRunResource>(Response.FromValue(new ContainerRegistryRunResource(Client, response), response.GetRawResponse()), rehydrationToken); | ||
if (waitUntil == WaitUntil.Completed) | ||
await operation.WaitForCompletionAsync(cancellationToken).ConfigureAwait(false); | ||
return operation; | ||
} | ||
catch (Exception e) | ||
{ | ||
scope.Failed(e); | ||
throw; | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Patch the run properties. | ||
/// <list type="bullet"> | ||
/// <item> | ||
/// <term>Request Path</term> | ||
/// <description>/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/runs/{runId}</description> | ||
/// </item> | ||
/// <item> | ||
/// <term>Operation Id</term> | ||
/// <description>Runs_Update</description> | ||
/// </item> | ||
/// <item> | ||
/// <term>Default Api Version</term> | ||
/// <description>2019-06-01-preview</description> | ||
/// </item> | ||
/// <item> | ||
/// <term>Resource</term> | ||
/// <description><see cref="ContainerRegistryRunResource"/></description> | ||
/// </item> | ||
/// </list> | ||
/// </summary> | ||
/// <param name="waitUntil"> <see cref="WaitUntil.Completed"/> if the method should wait to return until the long-running operation has completed on the service; <see cref="WaitUntil.Started"/> if it should return after starting the operation. For more information on long-running operations, please see <see href="https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/core/Azure.Core/samples/LongRunningOperations.md"> Azure.Core Long-Running Operation samples</see>. </param> | ||
/// <param name="patch"> The run update properties. </param> | ||
/// <param name="cancellationToken"> The cancellation token to use. </param> | ||
/// <exception cref="ArgumentNullException"> <paramref name="patch"/> is null. </exception> | ||
[EditorBrowsable(EditorBrowsableState.Never)] | ||
public virtual ArmOperation<ContainerRegistryRunResource> Update(WaitUntil waitUntil, ContainerRegistryRunPatch patch, CancellationToken cancellationToken = default) | ||
{ | ||
Argument.AssertNotNull(patch, nameof(patch)); | ||
|
||
using var scope = _containerRegistryRunRunsClientDiagnostics.CreateScope("ContainerRegistryRunResource.Update"); | ||
scope.Start(); | ||
try | ||
{ | ||
var response = _containerRegistryRunRunsRestClient.Update(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, patch, cancellationToken); | ||
var uri = _containerRegistryRunRunsRestClient.CreateUpdateRequestUri(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, patch); | ||
var rehydrationToken = NextLinkOperationImplementation.GetRehydrationToken(RequestMethod.Patch, uri.ToUri(), uri.ToString(), "None", null, OperationFinalStateVia.OriginalUri.ToString()); | ||
HarveyLink marked this conversation as resolved.
Show resolved
Hide resolved
|
||
var operation = new ContainerRegistryArmOperation<ContainerRegistryRunResource>(Response.FromValue(new ContainerRegistryRunResource(Client, response), response.GetRawResponse()), rehydrationToken); | ||
if (waitUntil == WaitUntil.Completed) | ||
operation.WaitForCompletion(cancellationToken); | ||
return operation; | ||
} | ||
catch (Exception e) | ||
{ | ||
scope.Failed(e); | ||
throw; | ||
} | ||
} | ||
} | ||
} |
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.